]> git.donarmstrong.com Git - mothur.git/blobdiff - phylotree.cpp
modified mpi code to save ram by writing out every 10 seqs.
[mothur.git] / phylotree.cpp
index 8d03607820955f6f4474a78f0505fad9de93ad81..1001542ea36548742a2c92b809875fd4e7ec4f89 100644 (file)
 
 PhyloTree::PhyloTree(){
        try {
+               m = MothurOut::getInstance();
                numNodes = 1;
                numSeqs = 0;
                tree.push_back(TaxNode("Root"));
                tree[0].heirarchyID = "0";
+               maxLevel = 0;
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "PhyloTree");
+               m->errorOut(e, "PhyloTree", "PhyloTree");
                exit(1);
        }
 }
@@ -48,7 +50,7 @@ PhyloTree::PhyloTree(string tfile){
                assignHeirarchyIDs(0);
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "PhyloTree");
+               m->errorOut(e, "PhyloTree", "PhyloTree");
                exit(1);
        }
 }
@@ -65,7 +67,7 @@ string PhyloTree::getNextTaxon(string& heirarchy){
                return currentLevel;
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "getNextTaxon");
+               m->errorOut(e, "PhyloTree", "getNextTaxon");
                exit(1);
        }
 }
@@ -122,7 +124,7 @@ void PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){
 
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "addSeqToTree");
+               m->errorOut(e, "PhyloTree", "addSeqToTree");
                exit(1);
        }
 }
@@ -137,7 +139,7 @@ vector<int> PhyloTree::getGenusNodes()      {
                return genusIndex;
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "getGenusNodes");
+               m->errorOut(e, "PhyloTree", "getGenusNodes");
                exit(1);
        }
 }
@@ -160,7 +162,7 @@ void PhyloTree::assignHeirarchyIDs(int index){
                }
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "assignHeirarchyIDs");
+               m->errorOut(e, "PhyloTree", "assignHeirarchyIDs");
                exit(1);
        }
 }
@@ -214,7 +216,26 @@ void PhyloTree::binUnclassified(){
                
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "binUnclassified");
+               m->errorOut(e, "PhyloTree", "binUnclassified");
+               exit(1);
+       }
+}
+/**************************************************************************************************/
+string PhyloTree::getFullTaxonomy(string seqName) {
+       try {
+               string tax = "";
+               
+               int currentNode = name2Taxonomy[seqName];
+               
+               while (tree[currentNode].parent != -1) {
+                       tax = tree[currentNode].name + ";" + tax;
+                       currentNode = tree[currentNode].parent;
+               }
+               
+               return tax;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloTree", "getFullTaxonomy");
                exit(1);
        }
 }
@@ -226,7 +247,7 @@ void PhyloTree::print(ofstream& out){
                print(0, out);
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "print");
+               m->errorOut(e, "PhyloTree", "print");
                exit(1);
        }
 }
@@ -244,7 +265,7 @@ void PhyloTree::print(int i, ofstream& out){
                
        }
        catch(exception& e) {
-               errorOut(e, "PhyloTree", "print");
+               m->errorOut(e, "PhyloTree", "print");
                exit(1);
        }
 }