]> git.donarmstrong.com Git - mothur.git/commitdiff
sped up the remove.seqs and remove.lineage and get.seqs and get.lineage. fixed bug...
authorwestcott <westcott>
Mon, 4 Apr 2011 14:36:21 +0000 (14:36 +0000)
committerwestcott <westcott>
Mon, 4 Apr 2011 14:36:21 +0000 (14:36 +0000)
chimeraslayercommand.cpp
getlineagecommand.cpp
getseqscommand.cpp
nast.cpp
removelineagecommand.cpp
removeseqscommand.cpp

index e7b02b8937d74c8cabd382ea9dcc1c56c11af071..9b4a87b6a45124d5e472952626207e82e1ebbb67 100644 (file)
@@ -684,7 +684,7 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f
                                        
                                        
                                }
-                       count++;
+                               count++;
                        }
                        delete candidateSeq;
                        
index 2a5505f149241c88b0591f1622a50d6a2fc89577..7950680c7e394ebbcf88f8108c4f7eb72029b3cd 100644 (file)
@@ -442,15 +442,7 @@ int GetLineageCommand::readName(){
                        if (dups) { hold = secondCol; }
                        
                        vector<string> parsedNames;
-                       //parse second column saving each name
-                       while (secondCol.find_first_of(',') != -1) { 
-                               name = secondCol.substr(0,secondCol.find_first_of(','));
-                               secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
-                               parsedNames.push_back(name);
-                       }
-                       
-                       //get name after last ,
-                       parsedNames.push_back(secondCol);
+                       m->splitAtComma(secondCol, parsedNames);
                        
                        vector<string> validSecond;
                        for (int i = 0; i < parsedNames.size(); i++) {
index 6d4bff2c38cf495a843b9c57ff7eff802a7ee72f..ce820fea0da0bfecc47db0126c9c5c70425c74e6 100644 (file)
@@ -539,15 +539,7 @@ int GetSeqsCommand::readName(){
                        if (dups) { hold = secondCol; }
                        
                        vector<string> parsedNames;
-                       //parse second column saving each name
-                       while (secondCol.find_first_of(',') != -1) { 
-                               name = secondCol.substr(0,secondCol.find_first_of(','));
-                               secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
-                               parsedNames.push_back(name);
-                       }
-                       
-                       //get name after last ,
-                       parsedNames.push_back(secondCol);
+                       m->splitAtComma(secondCol, parsedNames);
                        
                        vector<string> validSecond;
                        for (int i = 0; i < parsedNames.size(); i++) {
index bf65fa2b46ea319bf54ab74a9696bb9e7b22fafe..647e0e4f1e17e205c183c78615a966b7a98545cc 100644 (file)
--- a/nast.cpp
+++ b/nast.cpp
@@ -139,24 +139,22 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                                        string leftCandidateString = candAln.substr(0,(leftIndex-insertLength+1));
                                                        string rightCandidateString = candAln.substr((leftIndex+1));
                                                        candAln = leftCandidateString + rightCandidateString;
-               
-                                               }
-                                               else{                                                                   //      not enough room to the left, have to steal some space to
+                                                       
+                                               }else{                                                                  //      not enough room to the left, have to steal some space to the right
                                                
                        //cout << "in else lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << insertLength << endl;
-                                                       string leftTemplateString = newTemplateAlign.substr(0,i);       //      the right
+                                                       string leftTemplateString = newTemplateAlign.substr(0,i);       
                                                        string rightTemplateString = newTemplateAlign.substr((i+insertLength));
                                                        newTemplateAlign = leftTemplateString + rightTemplateString;
                                                        longAlignmentLength = newTemplateAlign.length();
-                       //cout << " in else lr candAln = " << candAln.length() << '\t' << " leftIndex = " << leftIndex << " leftroom = " << leftRoom << " rightIndex = " << rightIndex << '\t' << endl;                                 
+                       //cout << " in else lr candAln = " << candAln.length() << '\t' << " leftIndex = " << leftIndex << " leftroom = " << leftRoom << " rightIndex = " << rightIndex << '\t' << " rightroom = " << rightRoom << '\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)));
                                                        candAln = leftCandidateString + insertString + rightCandidateString;
                                
                                                }
-                                       }
-                                       else{                                                                           //      the right gap is closer - > move stuff right there's
+                                       }else{                                                                          //      the right gap is closer - > move stuff right there's
                                                if(rightRoom >= insertLength){                  //      enough room to the right to move
                        //cout << "rr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << i+insertLength << endl;
                                                        string leftTemplateString = newTemplateAlign.substr(0,i);
@@ -184,7 +182,9 @@ void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAl
                                                                        
                                                }
                                        }
-                                       i -= insertLength;
+                                       
+                                       if ((i - insertLength) < 0) {  i = 0; }
+                                       else { i -= insertLength; }
 
                                }
                                else{
@@ -207,7 +207,7 @@ 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; }
+                               if (i < 0) { m->mothurOut("i is negative"); m->mothurOutEndLine(); } 
                        } 
                }
        }
index ef1e77e01755f57acbaa4581c36a3e66d376c198..ebd06084e23d481fe6eb1a18b8498807d688ca57 100644 (file)
@@ -434,16 +434,8 @@ int RemoveLineageCommand::readName(){
                        in >> secondCol;                        
 
                        vector<string> parsedNames;
-                       //parse second column saving each name
-                       while (secondCol.find_first_of(',') != -1) { 
-                               name = secondCol.substr(0,secondCol.find_first_of(','));
-                               secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
-                               parsedNames.push_back(name);
-                       }
+                       m->splitAtComma(secondCol, parsedNames);
                        
-                       //get name after last ,
-                       parsedNames.push_back(secondCol);
-
                        vector<string> validSecond;  validSecond.clear();
                        for (int i = 0; i < parsedNames.size(); i++) {
                                if (names.count(parsedNames[i]) == 0) {
index 1990e9c364d6bdedb257f2801abe55f566de8e29..02cb5d94c2f286f3456f073ccd30db753f4743d3 100644 (file)
@@ -513,24 +513,17 @@ int RemoveSeqsCommand::readName(){
                string name, firstCol, secondCol;
                
                bool wroteSomething = false;
+                               
                
                while(!in.eof()){
                        if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
-
+                       
                        in >> firstCol;         m->gobble(in);          
                        in >> secondCol;                        
-
+                       
                        vector<string> parsedNames;
-                       //parse second column saving each name
-                       while (secondCol.find_first_of(',') != -1) { 
-                               name = secondCol.substr(0,secondCol.find_first_of(','));
-                               secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
-                               parsedNames.push_back(name);
-                       }
+                       m->splitAtComma(secondCol, parsedNames);
                        
-                       //get name after last ,
-                       parsedNames.push_back(secondCol);
-
                        vector<string> validSecond;  validSecond.clear();
                        for (int i = 0; i < parsedNames.size(); i++) {
                                if (names.count(parsedNames[i]) == 0) {
@@ -541,7 +534,7 @@ int RemoveSeqsCommand::readName(){
                        if ((dups) && (validSecond.size() != parsedNames.size())) {  //if dups is true and we want to get rid of anyone, get rid of everyone
                                for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
                        }else {
-                                       //if the name in the first column is in the set then print it and any other names in second column also in set
+                               //if the name in the first column is in the set then print it and any other names in second column also in set
                                if (names.count(firstCol) == 0) {
                                        
                                        wroteSomething = true;
@@ -572,10 +565,10 @@ int RemoveSeqsCommand::readName(){
                }
                in.close();
                out.close();
-
+               
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
                outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
-                               
+               
                return 0;
        }
        catch(exception& e) {