8 * Created by Sarah Westcott on 1/22/09.
9 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
15 /* This class represents the treefile. */
19 Tree(string); //do not use tree generated by this constructor its just to extract the treenames, its a chicken before the egg thing that needs to be revisited.
21 Tree(TreeMap*); //to generate a tree from a file
24 void getCopy(Tree*); //makes tree a copy of the one passed in.
25 void getSubTree(Tree*, vector<string>); //makes tree a that contains only the names passed in.
26 void assembleRandomTree();
27 void assembleRandomUnifracTree(vector<string>);
28 void assembleRandomUnifracTree(string, string);
29 void createNewickFile(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
37 void print(ostream&, string);
38 int findRoot(); //return index of root node
40 //this function takes the leaf info and populates the non leaf nodes
42 int assembleTree(string);
44 vector<Node> tree; //the first n nodes are the leaves, where n is the number of sequences.
45 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.
49 int numNodes, numLeaves;
53 map<string, int>::iterator it, it2;
54 map<string, int> mergeGroups(int); //returns a map with a groupname and the number of times that group was seen in the children
55 map<string,int> mergeGcounts(int);
57 void addNamesToCounts();
58 void randomTopology();
59 void randomBlengths();
60 void randomLabels(vector<string>);
61 //void randomLabels(string, string);
62 void printBranch(int, ostream&, string); //recursively print out tree
63 void parseTreeFile(); //parses through tree file to find names of nodes and number of them
64 //this is required in case user has sequences in the names file that are
65 //not included in the tree.
66 //only takes names from the first tree in the tree file and assumes that all trees use the same names.
67 int readTreeString(ifstream&);
68 int populateNewTree(vector<Node>&, int, int&);
69 void printBranch(int, ostream&, string, vector<Node>&);