]> git.donarmstrong.com Git - mothur.git/blob - treenode.cpp
changed random forest output filename
[mothur.git] / treenode.cpp
1 /*
2  *  treenode.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/23/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "treenode.h"
11
12
13 /****************************************************************/      
14 Node::Node() {
15         m = MothurOut::getInstance();
16         //initialize node
17         name = "";
18         branchLength = -1;
19         parent = -1;
20         lchild = -1;
21         rchild = -1;
22         length2leaf = 0.0;
23         label = -1;
24         
25 }
26 /****************************************************************/
27 void Node::setName(string Name) {  name = Name; }
28 /****************************************************************/
29 void Node::setGroup(vector<string> groups)  { group =groups; }
30 /****************************************************************/
31 void Node::setBranchLength(float l) { branchLength = l; }
32 /****************************************************************/
33 void Node::setLabel(float l) { label = l; }
34 /****************************************************************/
35 void Node::setLengthToLeaves(float l) { length2leaf = l; }
36 /****************************************************************/
37 void Node::setParent(int p)  { parent = p; }
38 /****************************************************************/
39 void Node::setIndex(int i)  { vectorIndex = i; }
40 /****************************************************************/
41 void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; }    //leftchild, rightchild
42 /****************************************************************/
43 string Node::getName() { return name; }
44 /****************************************************************/
45 vector<string> Node::getGroup() { return group; }
46 /****************************************************************/
47 float Node::getBranchLength() { return branchLength; }
48 /****************************************************************/
49 float Node::getLabel() { return label; }
50 /****************************************************************/
51 float Node::getLengthToLeaves() { return length2leaf; }
52 /****************************************************************/
53 int Node::getParent() { return parent; }
54 /****************************************************************/
55 int Node::getLChild() { return lchild; }
56 /****************************************************************/
57 int Node::getRChild() { return rchild; }
58 /****************************************************************/
59 int Node::getIndex() { return vectorIndex; }
60 /****************************************************************/
61 //to be used by printTree in the Tree class to print the leaf info                      
62 void Node::printNode() {
63         try{
64                 m->mothurOut(name + " " + toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
65                 
66                 /*for (int i = 0; i < group.size(); i++) {  m->mothurOut( group[i] + " "); }
67                 
68                 //there is a branch length
69                 if (branchLength != -1) { 
70                         m->mothurOut(" " + toString(branchLength)); 
71                 }
72                 m->mothurOut(" |");
73                 
74                 map<string, int>::iterator it;
75                 for(it=pGroups.begin();it!=pGroups.end();it++){
76                         m->mothurOut(" " + it->first + ":" + toString(it->second));
77                 }
78                 m->mothurOut(" |");
79                 for(it=pcount.begin();it!=pcount.end();it++){
80                         m->mothurOut(" " + it->first + ":" + toString(it->second));
81                 }*/
82                 m->mothurOutEndLine();
83                 
84                 
85         }
86         catch(exception& e) {
87                 m->errorOut(e, "Node", "printNode");
88                 exit(1);
89         }
90 }
91 /****************************************************************/