]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug in make.biom with picrust that didn’t allow for unclassified OTUs. fixed...
authorSarah Westcott <mothur.westcott@gmail.com>
Tue, 25 Feb 2014 16:57:05 +0000 (11:57 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Tue, 25 Feb 2014 16:57:05 +0000 (11:57 -0500)
makebiomcommand.cpp
parsefastaqcommand.cpp

index 4c350922608489b89156c01244c170d8688d930d..36bda1580bf55c50aa122e36c023b2d112899953 100644 (file)
@@ -680,8 +680,17 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector<SharedRAbundVector*>& lookup, ma
         for (map<string, string>::iterator it = labelTaxMap.begin(); it != labelTaxMap.end(); it++) { //maps label -> consensus taxonomy
             if (m->control_pressed) { break; }
             
+            string OTUTaxonomy = it->second;
+            
+            //remove confidences
+            m->removeConfidences(OTUTaxonomy);
+            
+            //remove unclassifieds to match template
+            int thisPos = OTUTaxonomy.find("unclassified;");
+            if (thisPos != string::npos) {  OTUTaxonomy = OTUTaxonomy.substr(0, thisPos);  }
+            
             //get list of reference ids that map to this taxonomy
-            vector<string> referenceIds = phylo.getSeqs(it->second);
+            vector<string> referenceIds = phylo.getSeqs(OTUTaxonomy);
             
             if (m->control_pressed) { break; }
             
@@ -724,6 +733,7 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector<SharedRAbundVector*>& lookup, ma
         map<string, string> newLabelTaxMap;
         //loop through ggOTUID list combining mothur otus and adjusting labels
         //ggOTUIDs = 16097 -> <OTU01, OTU10, OTU22>
+        
         for (map<string, vector<string> >::iterator itMap = ggOTUIDs.begin(); itMap != ggOTUIDs.end(); itMap++) {
                        if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
             
@@ -737,14 +747,18 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector<SharedRAbundVector*>& lookup, ma
             vector<int> abunds; abunds.resize(lookup.size(), 0);
             string mergeString = "";
             vector<float> boots; boots.resize(scores.size(), 0);
+            bool scoresNULL = false;
             for (int j = 0; j < itMap->second.size(); j++) { //<OTU01, OTU10, OTU22>
-                //merge bootstrap scores
-                vector<string> scores;
-                vector<string> taxonomies = parseTax(it->second, scores);
-                for (int i = 0; i < boots.size(); i++) {
-                    float tempScore; m->mothurConvert(scores[i], tempScore);
-                    boots[i] += tempScore;
-                }
+                
+                if (scores[0] != "null") {
+                    //merge bootstrap scores
+                    vector<string> scores;
+                    vector<string> taxonomies = parseTax(it->second, scores);
+                    for (int i = 0; i < boots.size(); i++) {
+                        float tempScore; m->mothurConvert(scores[i], tempScore);
+                        boots[i] += tempScore;
+                    }
+                }else { scoresNULL = true; }
                 
                 //merge abunds
                 mergeString += (itMap->second)[j] + " ";
@@ -757,14 +771,21 @@ int MakeBiomCommand::getGreenGenesOTUIDs(vector<SharedRAbundVector*>& lookup, ma
             
             //average scores
             //add merged otu to new lookup
-            for (int j = 0; j < boots.size(); j++) { boots[j] /= (float) itMap->second.size(); }
-            
-            //assemble new taxomoy
             string newTaxString = "";
-            for (int j = 0; j < boots.size(); j++) {
-                newTaxString += taxonomies[j] + "(" + toString(boots[j]) + ");";
+            if (!scoresNULL) {
+                for (int j = 0; j < boots.size(); j++) { boots[j] /= (float) itMap->second.size(); }
+            
+                //assemble new taxomoy
+                for (int j = 0; j < boots.size(); j++) {
+                    newTaxString += taxonomies[j] + "(" + toString(boots[j]) + ");";
+                }
+            }else {
+                //assemble new taxomoy
+                for (int j = 0; j < taxonomies.size(); j++) {
+                    newTaxString += taxonomies[j] + ";";
+                }
             }
-
+            
             //set new gg otu id to taxonomy. OTU01 -> k__Bacteria becomes 16097 -> k__Bacteria
             //find taxonomy of this otu
             newLabelTaxMap[itMap->first] = newTaxString;
index c3bd3933836c3f67149a96b9dba1661978b31bc4..a509ae9ef38d985c8837fa6589bc125cca9fe4a1 100644 (file)
@@ -308,7 +308,6 @@ int ParseFastaQCommand::execute(){
                 }
                 //report progress
                 if((count+1) % 10000 == 0){    m->mothurOut(toString(count+1)); m->mothurOutEndLine();         }
-                if(count > 100000){    break;  }
                 count++;
                        }
                }