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