]> git.donarmstrong.com Git - mothur.git/blobdiff - nast.cpp
working on testing
[mothur.git] / nast.cpp
index 8ed69fa6820cca9003dd8af1a0cb148c85899753..b2887523532c6b6bcaef1ca61b2c748a9ad77d14 100644 (file)
--- a/nast.cpp
+++ b/nast.cpp
@@ -99,7 +99,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
        
                for(int i=0; i<longAlignmentLength; i++){                               //      use the long alignment as the standard
                        int rightIndex, rightRoom, leftIndex, leftRoom;
-                       
+       
                        //      Part C of Fig. 2 from DeSantis et al.
                        if((isalpha(newTemplateAlign[i]) != isalpha(tempAln[i]))){      //if there is a discrepancy between the regapped
                                
@@ -132,12 +132,12 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                        if((i-leftIndex) <= (rightIndex-i)){            //      the left gap is closer - > move stuff left there's
        
                                                if(leftRoom >= insertLength){                   //      enough room to the left to move
-                       //cout << "lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << i+insertLength << endl;
+                       //cout << "lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << insertLength << endl;
                                                        string leftTemplateString = newTemplateAlign.substr(0,i);
                                                        string rightTemplateString = newTemplateAlign.substr((i+insertLength));
                                                        newTemplateAlign = leftTemplateString + rightTemplateString;
                                                        longAlignmentLength = newTemplateAlign.length();
-                       //cout << "lr candAln = " << candAln.length() << '\t' << leftIndex-insertLength+1 << '\t' << leftIndex+1 << endl;                               
+                       //cout << "lr candAln = " << candAln.length() << '\t' << leftIndex << '\t'  << endl;                            
                                                        string leftCandidateString = candAln.substr(0,(leftIndex-insertLength+1));
                                                        string rightCandidateString = candAln.substr((leftIndex+1));
                                                        candAln = leftCandidateString + rightCandidateString;
@@ -145,12 +145,12 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                                }
                                                else{                                                                   //      not enough room to the left, have to steal some space to
                                                
-                       //cout << "in else lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << i+insertLength << endl;
+                       //cout << "in else lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << insertLength << endl;
                                                        string leftTemplateString = newTemplateAlign.substr(0,i);       //      the right
                                                        string rightTemplateString = newTemplateAlign.substr((i+insertLength));
                                                        newTemplateAlign = leftTemplateString + rightTemplateString;
                                                        longAlignmentLength = newTemplateAlign.length();
-                       //cout << " in else lr candAln = " << candAln.length() << '\t' << leftIndex-leftRoom+1 << '\t' << rightIndex-leftIndex-1 << '\t' << rightIndex+(insertLength-leftRoom) << endl;                                 
+                       //cout << " in else lr candAln = " << candAln.length() << '\t' << " leftIndex = " << leftIndex << " leftroom = " << leftRoom << " rightIndex = " << rightIndex << '\t' << endl;                                 
                                                        string leftCandidateString = candAln.substr(0,(leftIndex-leftRoom+1));
                                                        string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
                                                        string rightCandidateString = candAln.substr((rightIndex+(insertLength-leftRoom)));
@@ -207,6 +207,9 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                }
                        
 //                             i -= insertLength;
+                               
+                               //if i is negative, we want to remove the extra gaps to the right
+                               if (i < 0) { cout << "i is negative" << endl; }
                        } 
                }
        }
@@ -220,7 +223,7 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
 
 void Nast::regapSequences(){   //This is essentially part B in Fig 2. of DeSantis et al.
        try { 
-       
+       //cout << candidateSeq->getName() << endl;
                string candPair = candidateSeq->getPairwise();
                string candAln = "";
                
@@ -249,6 +252,7 @@ void Nast::regapSequences(){        //This is essentially part B in Fig 2. of DeSantis
                string lastLoop = "";
                
                while(pairwiseAlignIndex<pairwiseLength){
+       //cout << pairwiseAlignIndex << '\t' << fullAlignIndex << '\t' << pairwiseLength << endl;
                        if(isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
                           && isalpha(candPair[pairwiseAlignIndex])){
                                //  the template and candidate pairwise and template aligned have characters
@@ -355,6 +359,7 @@ void Nast::regapSequences(){        //This is essentially part B in Fig 2. of DeSantis
                }                                                                                               //      2 of Desantis et al.
 
                candidateSeq->setAligned(candAln);
+       //cout << "here" << endl;
        }
        catch(exception& e) {
                m->errorOut(e, "Nast", "regapSequences");