]> git.donarmstrong.com Git - mothur.git/blob - treenode.h
working on chimeras
[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 #include "mothur.h"
14
15 /* This class represents a node on a tree. */
16
17
18 class Node  {
19         public:
20                 Node();  //pass it the sequence name
21                 ~Node() { pGroups.clear(); pcount.clear(); };
22                 
23                 void setName(string);
24                 void setGroup(vector<string>);  
25                 void setBranchLength(float);
26                 void setLabel(float);
27                 void setParent(int);
28                 void setChildren(int, int);             //leftchild, rightchild
29                 void setIndex(int);
30                 void setLengthToLeaves(float);
31                 
32                 string getName();
33                 vector<string> getGroup();  
34                 float getBranchLength();
35                 float getLengthToLeaves();
36                 float getLabel();
37                 int getParent();
38                 int getLChild();
39                 int getRChild();
40                 int getIndex();
41                 void printNode();   //prints out the name and the branch length
42                 
43                 
44                 //pGroup is the parsimony group info.  i.e. for a leaf node it would contain 1 enter pGroup["groupname"] = 1;
45                 //but for a branch node it may contain several entries so if the nodes children are from different groups it
46                 //would have at least two entries pgroup["groupnameOfLeftChild"] = 1, pgroup["groupnameOfRightChild"] = 1.
47                 //pCount is the nodes descendant group infomation.  i.e. pCount["black"] = 20 would mean that 20 of the nodes 
48                 //descendant are from group black.
49
50                 map<string, int> pGroups; //leaf nodes will only have 1 group, but branch nodes may have multiple groups.
51                 map<string, int> pcount;        
52                         
53         private:
54                 string                  name;
55                 vector<string>  group; 
56                 float                   branchLength, length2leaf, label;
57                 int                             parent;
58                 int                             lchild;
59                 int                             rchild;
60                 int                             vectorIndex;
61 };              
62
63 #endif