]> git.donarmstrong.com Git - mothur.git/blob - treenode.cpp
print tree debugger
[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         //initialize node
16         name = "";
17         branchLength = -1;
18         parent = -1;
19         lchild = -1;
20         rchild = -1;
21         
22 }
23 /****************************************************************/
24 void Node::setName(string Name) {  name = Name; }
25 /****************************************************************/
26 void Node::setGroup(string groups)  { group =groups; }
27 /****************************************************************/
28 void Node::setBranchLength(float l) { branchLength = l; }
29 /****************************************************************/
30 void Node::setParent(int p)  { parent = p; }
31 /****************************************************************/
32 void Node::setIndex(int i)  { vectorIndex = i; }
33 /****************************************************************/
34 void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; }    //leftchild, rightchild
35 /****************************************************************/
36 string Node::getName() { return name; }
37 /****************************************************************/
38 string Node::getGroup() { return group; }
39 /****************************************************************/
40 float Node::getBranchLength() { return branchLength; }
41 /****************************************************************/
42 int Node::getParent() { return parent; }
43 /****************************************************************/
44 int Node::getLChild() { return lchild; }
45 /****************************************************************/
46 int Node::getRChild() { return rchild; }
47 /****************************************************************/
48 int Node::getIndex() { return vectorIndex; }
49 /****************************************************************/
50 //to be used by printTree in the Tree class to print the leaf info                      
51 void Node::printNode() {
52         try{
53                 cout << parent << ' ' << lchild << ' ' << rchild << ' ' << group;
54                 //there is a branch length
55                 if (branchLength != -1) { 
56                         cout << ' ' << setprecision(4) << branchLength; 
57                 }
58                 cout << " |";
59                 map<string, int>::iterator it;
60                 for(it=pGroups.begin();it!=pGroups.end();it++){
61                         cout << ' ' << it->first << ':' << it->second;
62                 }
63                 cout << " |";
64                 for(it=pcount.begin();it!=pcount.end();it++){
65                         cout << ' ' << it->first << ':' << it->second;
66                 }
67                 cout << endl;
68                 
69         }
70         catch(exception& e) {
71                 cout << "Standard Error: " << e.what() << " has occurred in the Node class Function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
72                 exit(1);
73         }
74         catch(...) {
75                 cout << "An unknown error has occurred in the Node class function printNode. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
76                 exit(1);
77         }               
78 }
79 /****************************************************************/