]> git.donarmstrong.com Git - mothur.git/blob - tree.h
fixed multiple bugs for 1.4 release
[mothur.git] / tree.h
1 #ifndef TREE_H
2 #define TREE_H
3
4 /*
5  *  tree.h
6  *  Mothur
7  *
8  *  Created by Sarah Westcott on 1/22/09.
9  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10  *
11  */
12
13 using namespace std;
14
15 #include "treenode.h"
16 #include "globaldata.hpp"
17
18 /* This class represents the treefile. */
19
20 class Tree {
21 public: 
22         Tree();         //to generate a tree from a file
23         ~Tree();
24         
25         
26         void getCopy(Tree*);  //makes tree a copy of the one passed in.
27         void assembleRandomTree();
28         void assembleRandomUnifracTree(vector<string>);
29         void assembleRandomUnifracTree(string, string);
30         void createNewickFile(string);
31         int getIndex(string);
32         void setIndex(string, int);
33         int getNumNodes() { return numNodes; }
34         int getNumLeaves(){     return numLeaves; }
35         map<string, int> mergeUserGroups(int, vector<string>);  //returns a map with a groupname and the number of times that group was seen in the children
36         void printTree();
37         void print(ostream&);
38         void printForBoot(ostream&);
39         int findRoot();  //return index of root node
40         
41         //this function takes the leaf info and populates the non leaf nodes
42         void assembleTree();            
43         
44         vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
45 private:
46         GlobalData* globaldata;
47         int numNodes, numLeaves;
48         ofstream out;
49         string filename;
50         
51         map<string, int>::iterator it, it2;
52         map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
53         
54         map<string,int> mergeGcounts(int);
55         void randomTopology();
56         void randomBlengths();
57         void randomLabels(vector<string>);
58         void randomLabels(string, string);
59         void printBranch(int, ostream&, string);  //recursively print out tree
60 };
61
62 #endif