8 * Created by Sarah Westcott on 1/22/09.
9 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
14 #include "globaldata.hpp"
17 /* This class represents the treefile. */
23 Tree(); //to generate a tree from a file
26 void getCopy(Tree*); //makes tree a copy of the one passed in.
27 void getSubTree(Tree*, vector<string>); //makes tree a that contains only the names passed in.
28 void assembleRandomTree();
29 void assembleRandomUnifracTree(vector<string>);
30 void assembleRandomUnifracTree(string, string);
31 void createNewickFile(string);
33 void setIndex(string, int);
34 int getNumNodes() { return numNodes; }
35 int getNumLeaves(){ return numLeaves; }
36 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
39 void print(ostream&, string);
40 int findRoot(); //return index of root node
42 //this function takes the leaf info and populates the non leaf nodes
44 int assembleTree(string);
46 vector<Node> tree; //the first n nodes are the leaves, where n is the number of sequences.
47 map< string, vector<int> > groupNodeInfo; //maps group to indexes of leaf nodes with that group, different groups may contain same node because of names file.
50 GlobalData* globaldata;
51 int numNodes, numLeaves;
55 map<string, int>::iterator it, it2;
56 map<string, int> mergeGroups(int); //returns a map with a groupname and the number of times that group was seen in the children
57 map<string,int> mergeGcounts(int);
59 void addNamesToCounts();
60 void randomTopology();
61 void randomBlengths();
62 void randomLabels(vector<string>);
63 //void randomLabels(string, string);
64 void printBranch(int, ostream&, string); //recursively print out tree
65 void parseTreeFile(); //parses through tree file to find names of nodes and number of them
66 //this is required in case user has sequences in the names file that are
67 //not included in the tree.
68 //only takes names from the first tree in the tree file and assumes that all trees use the same names.
69 int readTreeString(ifstream&);
70 int populateNewTree(vector<Node>&, int, int&);
71 void printBranch(int, ostream&, string, vector<Node>&);