]> git.donarmstrong.com Git - mothur.git/blob - tree.h
broke up globaldata and moved error checking and help into commands
[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 #include "treenode.h"
14 #include "globaldata.hpp"
15
16 /* This class represents the treefile. */
17
18 class Tree {
19 public: 
20         Tree();         //to generate a tree from a file
21         ~Tree();
22         
23         void getCopy(Tree*);  //makes tree a copy of the one passed in.
24         void assembleRandomTree();
25         void assembleRandomUnifracTree(vector<string>);
26         void assembleRandomUnifracTree(string, string);
27         void createNewickFile(string);
28         int getIndex(string);
29         void setIndex(string, int);
30         int getNumNodes() { return numNodes; }
31         int getNumLeaves(){     return numLeaves; }
32         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
33         void printTree();
34         void print(ostream&);
35         void printForBoot(ostream&);
36         int findRoot();  //return index of root node
37         
38         //this function takes the leaf info and populates the non leaf nodes
39         void assembleTree();            
40         
41         vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
42 private:
43         GlobalData* globaldata;
44         int numNodes, numLeaves;
45         ofstream out;
46         string filename;
47         
48         map<string, int>::iterator it, it2;
49         map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
50         
51         map<string,int> mergeGcounts(int);
52         void randomTopology();
53         void randomBlengths();
54         void randomLabels(vector<string>);
55         void randomLabels(string, string);
56         void printBranch(int, ostream&, string);  //recursively print out tree
57         void parseTreeFile();   //parses through tree file to find names of nodes and number of them
58                                                         //this is required in case user has sequences in the names file that are
59                                                         //not included in the tree. 
60                                                         //only takes names from the first tree in the tree file and assumes that all trees use the same names.
61         void readTreeString(ifstream&);
62 };
63
64 #endif