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