]> git.donarmstrong.com Git - mothur.git/blob - treenode.h
fixed concensus command and modified tree class so you can print labels on trees
[mothur.git] / treenode.h
1 #ifndef TREENODE_H
2 #define TREENODE_H
3
4 /*
5  *  treenode.h
6  *  Mothur
7  *
8  *  Created by Sarah Westcott on 1/23/09.
9  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10  *
11  */
12
13 using namespace std;
14
15 #include "mothur.h"
16
17 /* This class represents a node on a tree. */
18
19
20 class Node  {
21         public:
22                 Node();  //pass it the sequence name
23                 ~Node() { pGroups.clear(); pcount.clear(); };
24                 
25                 void setName(string);
26                 void setGroup(string);  
27                 void setBranchLength(float);
28                 void setLabel(float);
29                 void setParent(int);
30                 void setChildren(int, int);             //leftchild, rightchild
31                 void setIndex(int);
32                 void setLengthToLeaves(float);
33                 
34                 string getName();
35                 string getGroup();  
36                 float getBranchLength();
37                 float getLengthToLeaves();
38                 float getLabel();
39                 int getParent();
40                 int getLChild();
41                 int getRChild();
42                 int getIndex();
43                 void printNode();   //prints out the name and the branch length
44                 
45                 
46                 //pGroup is the parsimony group info.  i.e. for a leaf node it would contain 1 enter pGroup["groupname"] = 1;
47                 //but for a branch node it may contain several entries so if the nodes children are from different groups it
48                 //would have at least two entries pgroup["groupnameOfLeftChild"] = 1, pgroup["groupnameOfRightChild"] = 1.
49                 //pCount is the nodes descendant group infomation.  i.e. pCount["black"] = 20 would mean that 20 of the nodes 
50                 //descendant are from group black.
51
52                 map<string, int> pGroups; //leaf nodes will only have 1 group, but branch nodes may have multiple groups.
53                 map<string, int> pcount;        
54                         
55         private:
56                 string                  name;
57                 string                  group;
58                 float                   branchLength, length2leaf, label;
59                 int                             parent;
60                 int                             lchild;
61                 int                             rchild;
62                 int                             vectorIndex;
63 };              
64
65 #endif