8 * Created by Sarah Westcott on 1/22/09.
9 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
14 #include "counttable.h"
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.
20 Tree(int, CountTable*);
21 Tree(CountTable*); //to generate a tree from a file
22 Tree(CountTable*, vector< vector<double> >&); //create tree from sim matrix
25 CountTable* getCountTable() { return ct; }
26 void getCopy(Tree*); //makes tree a copy of the one passed in.
27 void getCopy(Tree* copy, bool); //makes a copy of the tree structure passed in, (just parents, children and br). Used with the Tree(TreeMap*) constructor. Assumes the tmap already has set seqs groups you want. Used by subsample to reassign seqs you don't want included to group "doNotIncludeMe".
28 void getSubTree(Tree*, vector<string>); //makes tree a that contains only the names passed in.
29 //int getSubTree(Tree* originalToCopy, vector<string> seqToInclude, map<string, string> nameMap); //used with (int, TreeMap) constructor. SeqsToInclude contains subsample wanted - assumes these are unique seqs and size of vector=numLeaves passed into constructor. nameMap is unique -> redundantList can be empty if no namesfile was provided.
31 void assembleRandomTree();
32 void assembleRandomUnifracTree(vector<string>);
33 void assembleRandomUnifracTree(string, string);
35 void createNewickFile(string);
37 void setIndex(string, int);
38 int getNumNodes() { return numNodes; }
39 int getNumLeaves(){ return numLeaves; }
40 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
43 void print(ostream&, string);
44 void print(ostream&, map<string, string>);
45 int findRoot(); //return index of root node
47 //this function takes the leaf info and populates the non leaf nodes
50 vector<Node> tree; //the first n nodes are the leaves, where n is the number of sequences.
51 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.
55 int numNodes, numLeaves;
59 //map<string, string> names;
60 map<string, int>::iterator it, it2;
61 map<string, int> mergeGroups(int); //returns a map with a groupname and the number of times that group was seen in the children
62 map<string,int> mergeGcounts(int);
63 map<string, int> indexes; //maps seqName -> index in tree vector
65 void addNamesToCounts(map<string, string>);
66 void randomTopology();
67 void randomBlengths();
68 void randomLabels(vector<string>);
69 //void randomLabels(string, string);
70 void printBranch(int, ostream&, map<string, string>); //recursively print out tree
71 void printBranch(int, ostream&, string);
72 int parseTreeFile(); //parses through tree file to find names of nodes and number of them
73 //this is required in case user has sequences in the names file that are
74 //not included in the tree.
75 //only takes names from the first tree in the tree file and assumes that all trees use the same names.
76 int readTreeString(ifstream&);
77 int populateNewTree(vector<Node>&, int, int&);
78 void printBranch(int, ostream&, string, vector<Node>&);