]> git.donarmstrong.com Git - mothur.git/blobdiff - getseqscommand.cpp
added adjustDots function to pcr.seqs, keeps sequences aligned in case where primers...
[mothur.git] / getseqscommand.cpp
index 779ea912ebebbe58ec22e65723899c4ea566b85f..142023e7a40881c1c6397a761ba350132490b75c 100644 (file)
@@ -427,6 +427,11 @@ int GetSeqsCommand::readFasta(){
                        
                        Sequence currSeq(in);
                        name = currSeq.getName();
+            
+            if (!dups) {//adjust name if needed
+                map<string, string>::iterator it = uniqueMap.find(name);
+                if (it != uniqueMap.end()) { name = it->second; }
+            }
                        
                        if (name != "") {
                                //if this name is in the accnos file
@@ -485,13 +490,18 @@ int GetSeqsCommand::readQual(){
                        string name = "";
                        string scores = "";
                        
-                       in >> name; 
+                       in >> name;
+            
+            if (!dups) {//adjust name if needed
+                map<string, string>::iterator it = uniqueMap.find(name);
+                if (it != uniqueMap.end()) { name = it->second; }
+            }
                                
                        if (name.length() != 0) { 
                                saveName = name.substr(1);
                                while (!in.eof())       {       
                                        char c = in.get(); 
-                                       if (c == 10 || c == 13){        break;  }
+                                       if (c == 10 || c == 13 || c == -1){     break;  }
                                        else { name += c; }     
                                } 
                                m->gobble(in);
@@ -577,7 +587,7 @@ int GetSeqsCommand::readCount(){
         //check for groups that have been eliminated
         CountTable ct;
         if (ct.testGroups(outputFileName)) {
-            ct.readTable(outputFileName);
+            ct.readTable(outputFileName, true);
             ct.printTable(outputFileName);
         }
                
@@ -748,6 +758,8 @@ int GetSeqsCommand::readName(){
                                                wroteSomething = true;
                                                
                                                out << validSecond[0] << '\t';
+                        //we are changing the unique name in the fasta file
+                        uniqueMap[firstCol] = validSecond[0];
                                        
                                                //you know you have at least one valid second since first column is valid
                                                for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
@@ -805,6 +817,7 @@ int GetSeqsCommand::readGroup(){
 
                        in >> name;                             //read from first column
                        in >> group;                    //read from second column
+            
                        
                        //if this name is in the accnos file
                        if (names.count(name) != 0) {
@@ -862,6 +875,11 @@ int GetSeqsCommand::readTax(){
 
                        in >> name;                             //read from first column
                        in >> tax;                      //read from second column
+            
+            if (!dups) {//adjust name if needed
+                map<string, string>::iterator it = uniqueMap.find(name);
+                if (it != uniqueMap.end()) { name = it->second; }
+            }
                        
                        //if this name is in the accnos file
                        if (names.count(name) != 0) {
@@ -924,6 +942,11 @@ int GetSeqsCommand::readAlign(){
 
 
                        in >> name;                             //read from first column
+            
+            if (!dups) {//adjust name if needed
+                map<string, string>::iterator it = uniqueMap.find(name);
+                if (it != uniqueMap.end()) { name = it->second; }
+            }
                        
                        //if this name is in the accnos file
                        if (names.count(name) != 0) {