]> git.donarmstrong.com Git - mothur.git/blobdiff - treenode.cpp
changing command name classify.shared to classifyrf.shared
[mothur.git] / treenode.cpp
index 7fff2c1deae9d687bba9f87229a4d7078cdc861d..0131f59c340ef30eeeeb56ed2a96fc2dc258b808 100644 (file)
 
 /****************************************************************/     
 Node::Node() {
+       m = MothurOut::getInstance();
        //initialize node
        name = "";
        branchLength = -1;
        parent = -1;
        lchild = -1;
        rchild = -1;
+       length2leaf = 0.0;
+       label = -1;
        
 }
 /****************************************************************/
 void Node::setName(string Name) {  name = Name; }
 /****************************************************************/
-void Node::setGroup(string groups)  { group =groups; }
+void Node::setGroup(vector<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; }
@@ -35,10 +42,14 @@ void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; }        //leftchild
 /****************************************************************/
 string Node::getName() { return name; }
 /****************************************************************/
-string Node::getGroup() { return group; }
+vector<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; }
@@ -50,30 +61,31 @@ int Node::getIndex() { return vectorIndex; }
 //to be used by printTree in the Tree class to print the leaf info                     
 void Node::printNode() {
        try{
-               cout << parent << ' ' << lchild << ' ' << rchild << ' ' << group;
+               m->mothurOut(name + " " + toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
+               
+               /*for (int i = 0; i < group.size(); i++) {  m->mothurOut( group[i] + " "); }
+               
                //there is a branch length
                if (branchLength != -1) { 
-                       cout << ' ' << setprecision(4) << branchLength
+                       m->mothurOut(" " + toString(branchLength))
                }
-               cout << " |";
+               m->mothurOut(" |");
+               
                map<string, int>::iterator it;
                for(it=pGroups.begin();it!=pGroups.end();it++){
-                       cout << ' ' << it->first << ':' << it->second;
+                       m->mothurOut(" " + it->first + ":" + toString(it->second));
                }
-               cout << " |";
+               m->mothurOut(" |");
                for(it=pcount.begin();it!=pcount.end();it++){
-                       cout << ' ' << it->first << ':' << it->second;
-               }
-               cout << endl;
+                       m->mothurOut(" " + it->first + ":" + toString(it->second));
+               }*/
+               m->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";
+               m->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);
-       }               
 }
 /****************************************************************/