]> git.donarmstrong.com Git - mothur.git/blobdiff - treenode.cpp
added logfile feature
[mothur.git] / treenode.cpp
index ae7d0e4ec6731a78967a46004aed02e61ceaf984..54cdae4e502250229a6e70e5ce937a631a843b1e 100644 (file)
@@ -18,6 +18,8 @@ Node::Node() {
        parent = -1;
        lchild = -1;
        rchild = -1;
+       length2leaf = 0.0;
+       label = -1;
        
 }
 /****************************************************************/
@@ -27,6 +29,10 @@ void Node::setGroup(string groups)  { group =groups; }
 /****************************************************************/
 void Node::setBranchLength(float l) { branchLength = l; }
 /****************************************************************/
+void Node::setLabel(float l) { label = l; }
+/****************************************************************/
+void Node::setLengthToLeaves(float l) { length2leaf = l; }
+/****************************************************************/
 void Node::setParent(int p)  { parent = p; }
 /****************************************************************/
 void Node::setIndex(int i)  { vectorIndex = i; }
@@ -39,6 +45,10 @@ string Node::getGroup() { return group; }
 /****************************************************************/
 float Node::getBranchLength() { return branchLength; }
 /****************************************************************/
+float Node::getLabel() { return label; }
+/****************************************************************/
+float Node::getLengthToLeaves() { return length2leaf; }
+/****************************************************************/
 int Node::getParent() { return parent; }
 /****************************************************************/
 int Node::getLChild() { return lchild; }
@@ -48,23 +58,29 @@ int Node::getRChild() { return rchild; }
 int Node::getIndex() { return vectorIndex; }
 /****************************************************************/
 //to be used by printTree in the Tree class to print the leaf info                     
-void Node::printNode(ostream& out) {
+void Node::printNode() {
        try{
-               out << name;
-               
+               mothurOut(toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " " + group);
                //there is a branch length
                if (branchLength != -1) { 
-                       out << ":" << setprecision(4) << branchLength
+                       mothurOut(" " + toString(branchLength))
                }
+               mothurOut(" |");
+               map<string, int>::iterator it;
+               for(it=pGroups.begin();it!=pGroups.end();it++){
+                       mothurOut(" " + it->first + ":" + toString(it->second));
+               }
+               mothurOut(" |");
+               for(it=pcount.begin();it!=pcount.end();it++){
+                       mothurOut(" " + it->first + ":" + toString(it->second));
+               }
+               mothurOutEndLine();
+               
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Node class Function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Node", "printNode");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the Node class function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /****************************************************************/