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