]> git.donarmstrong.com Git - mothur.git/blob - tree.h
adding treeclimber and unifrac pieces
[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 <string>
16 #include <iostream>
17 #include <vector>
18 #include <fstream>
19 #include <iomanip>
20 #include <sstream>
21 #include <map>
22
23 #include "treenode.h"
24 #include "globaldata.hpp"
25
26 /* This class represents the treefile. */
27
28 class Tree {
29         public: 
30                 Tree();         //to generate a tree from a file
31                 ~Tree() {};
32                 
33                 
34                 void getCopy(Tree*);  //makes tree a copy of the one passed in.
35                 void assembleRandomTree();
36                 void assembleRandomUnifracTree();
37                 void createNewickFile();
38                 int getIndex(string);
39                 void setIndex(string, int);
40                 int getNumNodes() { return numNodes; }
41                 int getNumLeaves(){     return numLeaves; }
42                 
43                 //this function takes the leaf info and populates the non leaf nodes
44                 void assembleTree();            
45                 
46                 vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
47                 
48         private:
49                 GlobalData* globaldata;
50                 int numNodes, numLeaves;
51                 ofstream out;
52                 string filename;
53                 
54                 map<string, int>::iterator it;
55                 map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
56                 map<string,int> Tree::mergeGcounts(int);
57                 void randomTopology();
58                 void randomBlengths();
59                 void randomLabels();
60                 int findRoot();  //return index of root node
61                 void printBranch(int);  //recursively print out tree
62 };
63
64 #endif