]> git.donarmstrong.com Git - mothur.git/blobdiff - phylotree.cpp
added picrust and ref taxonomy parameters to make.biom
[mothur.git] / phylotree.cpp
index b9bab4ec2934a4121305f87111cf2d238f5ec4d5..2e3136e1f42e1a93d15fcab921b2e612f55f3997 100644 (file)
@@ -233,6 +233,48 @@ string PhyloTree::getNextTaxon(string& heirarchy, string seqname){
                exit(1);
        }
 }
                exit(1);
        }
 }
+/**************************************************************************************************/
+
+vector<string> PhyloTree::getSeqs(string seqTaxonomy){
+       try {
+        string taxCopy = seqTaxonomy;
+        vector<string> names;
+        map<string, int>::iterator childPointer;
+               
+               int currentNode = 0;
+
+        m->removeConfidences(seqTaxonomy);
+        
+        string taxon;
+        while(seqTaxonomy != ""){
+                       
+                       if (m->control_pressed) { return names; }
+                       
+                       taxon = getNextTaxon(seqTaxonomy, "");
+            
+            if (m->debug) { m->mothurOut(taxon +'\n'); }
+                       
+                       if (taxon == "") {  m->mothurOut(taxCopy + " has an error in the taxonomy.  This may be due to a ;;"); m->mothurOutEndLine(); break;  }
+                       
+                       childPointer = tree[currentNode].children.find(taxon);
+                       
+                       if(childPointer != tree[currentNode].children.end()){   //if the node already exists, move on
+                               currentNode = childPointer->second;
+                       }
+                       else{                                                                                   //otherwise, error this taxonomy is not in tree
+                               m->mothurOut("[ERROR]: " + taxCopy + " is not in taxonomy tree, please correct."); m->mothurOutEndLine(); m->control_pressed = true; return names;
+                       }
+            
+                       if (seqTaxonomy == "") {   names = tree[currentNode].accessions;        }
+               }
+        
+        return names;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloTree", "getSeqs");
+               exit(1);
+       }
+}
 
 /**************************************************************************************************/
 
 
 /**************************************************************************************************/