]> git.donarmstrong.com Git - mothur.git/blobdiff - needlemanoverlap.cpp
working on make.contigs. fixed trim.seqs filename issue
[mothur.git] / needlemanoverlap.cpp
index b14d8e3d10e42ee9c7a21f5595315b29ad172ff5..1239beb1a2a9f61d3f8c2cec178161fb36a7b865 100644 (file)
@@ -24,8 +24,8 @@
 
 /**************************************************************************************************/
 
-NeedlemanOverlap::NeedlemanOverlap(float gO, float m, float mm, int r) ://     note that we don't have a gap extend
-gap(gO), match(m), mismatch(mm), Alignment(r) {                                                        //      the gap openning penalty is assessed for
+NeedlemanOverlap::NeedlemanOverlap(float gO, float f, float mm, int r) ://     note that we don't have a gap extend
+gap(gO), match(f), mismatch(mm), Alignment(r) {                                                        //      the gap openning penalty is assessed for
        try {                                                                                                                                   //      every gapped position
                for(int i=1;i<nCols;i++){
                        alignment[0][i].prevCell = 'l';                                 //      initialize first row by pointing all poiters to the left
@@ -39,11 +39,9 @@ gap(gO), match(m), mismatch(mm), Alignment(r) {                                                      //      the gap openning penalt
        
        }
        catch(exception& e) {
-               errorOut(e, "NeedlemanOverlap", "NeedlemanOverlap");
+               m->errorOut(e, "NeedlemanOverlap", "NeedlemanOverlap");
                exit(1);
        }
-                                                                                                                               
-                                                                                                                                               
 }
 /**************************************************************************************************/
 
@@ -53,18 +51,21 @@ NeedlemanOverlap::~NeedlemanOverlap(){      /*      do nothing      */      }
 
 void NeedlemanOverlap::align(string A, string B){
        try {
+       
                seqA = ' ' + A; lA = seqA.length();             //      algorithm requires a dummy space at the beginning of each string
                seqB = ' ' + B; lB = seqB.length();             //      algorithm requires a dummy space at the beginning of each string
 
-               if (lA > nRows) { mothurOut("Your one of your candidate sequences is longer than you longest template sequence."); mothurOutEndLine();  }
+               if (lA > nRows) { m->mothurOut("One of your candidate sequences is longer than you longest template sequence. Your longest template sequence is " + toString(nRows) + ". Your candidate is " + toString(lA) + "."); m->mothurOutEndLine();  }
                
                for(int i=1;i<lB;i++){                                  //      This code was largely translated from Perl code provided in Ex 3.1 
+               
                        for(int j=1;j<lA;j++){                          //      of the O'Reilly BLAST book.  I found that the example output had a
+       
                                //      number of errors
                                float diagonal;
                                if(seqB[i] == seqA[j])  {       diagonal = alignment[i-1][j-1].cValue + match;          }
                                else                                    {       diagonal = alignment[i-1][j-1].cValue + mismatch;       }
-                               
+                       
                                float up        = alignment[i-1][j].cValue + gap;
                                float left      = alignment[i][j-1].cValue + gap;
                                
@@ -90,13 +91,14 @@ void NeedlemanOverlap::align(string A, string B){
                                }
                        }
                }
+
                Overlap over;                                           
                over.setOverlap(alignment, lA, lB, 0);          //      Fix gaps at the beginning and end of the sequences
                traceBack();                                                            //      Traceback the alignment to populate seqAaln and seqBaln
-               
+       
        }
        catch(exception& e) {
-               errorOut(e, "NeedlemanOverlap", "align");
+               m->errorOut(e, "NeedlemanOverlap", "align");
                exit(1);
        }