]> git.donarmstrong.com Git - mothur.git/commitdiff
print tree debugger
authorpschloss <pschloss>
Tue, 24 Feb 2009 13:04:56 +0000 (13:04 +0000)
committerpschloss <pschloss>
Tue, 24 Feb 2009 13:04:56 +0000 (13:04 +0000)
Mothur.xcodeproj/project.pbxproj
parsimony.cpp
tree.cpp
tree.h
treenode.cpp
treenode.h

index ac5bd2d2929620357dbc507c49c1d227573b9dfd..62d929a1ba847330373bd88396c2904869525f37 100644 (file)
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_OPTIMIZATION_LEVEL = 3;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "_GLIBCXX_DEBUG=1",
                                        "_GLIBCXX_DEBUG_PEDANTIC=1",
                        buildSettings = {
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                GCC_MODEL_TUNING = G5;
+                               GCC_OPTIMIZATION_LEVEL = 3;
                                INSTALL_PATH = /usr/local/bin;
                                PRODUCT_NAME = mothur;
                        };
index 8c7e3e4aa8fb206d8794a63d8bd190659953ac2c..e76a7b039c4e91afec85c27f375b22f120185f7b 100644 (file)
@@ -38,8 +38,13 @@ EstOutput Parsimony::getValues(Tree* t) {
                        else if(iSize > rcSize || iSize > lcSize){
                                score++;
                        }
+                       cout << i << ' ' << score << ": ";
+                       t->tree[i].printNode();
                } 
                
+               string hold;
+               cin >> hold;
+               
                data[0] = score;
                
                return data;
index d332f4771ba0b3f890b407b8f5a0ca31834b46ad..eea3af4dea1f5db04cb689b052fb0177ef03e7f3 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -493,7 +493,7 @@ void Tree::printBranch(int node) {
                        printBranch(tree[node].getRChild());
                        out << ")";
                }else { //you are a leaf
-                       tree[node].printNode(out);  //prints out name and branch length
+                       tree[node].printNode();  //prints out name and branch length
                }
                
        }
@@ -508,6 +508,7 @@ void Tree::printBranch(int node) {
 }
 
 /*****************************************************************/
+
 void Tree::setGroups() {
        try {
                //if the user has not entered specific groups to analyze then do them all
@@ -546,3 +547,17 @@ void Tree::setGroups() {
 
 }
 
+/*****************************************************************/
+
+void Tree::printTree() {
+       
+       for(int i=0;i<numNodes;i++){
+               cout << i << '\t';
+               tree[i].printNode();
+       }
+       
+}
+
+/*****************************************************************/
+
+
diff --git a/tree.h b/tree.h
index 55d3c92aabca1083fd300896a813f41374eca860..6404db784eec791783e609dfc8ff8d8a971c61aa 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -18,42 +18,42 @@ using namespace std;
 /* This class represents the treefile. */
 
 class Tree {
-       public: 
-               Tree();         //to generate a tree from a file
-               ~Tree() {};
-               
-               
-               void getCopy(Tree*);  //makes tree a copy of the one passed in.
-               void assembleRandomTree();
-               void assembleRandomUnifracTree();
-               void createNewickFile();
-               int getIndex(string);
-               void setIndex(string, int);
-               int getNumNodes() { return numNodes; }
-               int getNumLeaves(){     return numLeaves; }
-               map<string, int> mergeUserGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
-               
-               //this function takes the leaf info and populates the non leaf nodes
-               void assembleTree();            
-               
-               vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
-               
-       private:
-               GlobalData* globaldata;
-               int numNodes, numLeaves;
-               ofstream out;
-               string filename;
-               
-               map<string, int>::iterator it, it2;
-               map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
-               
-               map<string,int> Tree::mergeGcounts(int);
-               void randomTopology();
-               void randomBlengths();
-               void randomLabels();
-               int findRoot();  //return index of root node
-               void printBranch(int);  //recursively print out tree
-               void setGroups();
+public: 
+       Tree();         //to generate a tree from a file
+       ~Tree() {};
+       
+       
+       void getCopy(Tree*);  //makes tree a copy of the one passed in.
+       void assembleRandomTree();
+       void assembleRandomUnifracTree();
+       void createNewickFile();
+       int getIndex(string);
+       void setIndex(string, int);
+       int getNumNodes() { return numNodes; }
+       int getNumLeaves(){     return numLeaves; }
+       map<string, int> mergeUserGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
+       void printTree();
+       
+       //this function takes the leaf info and populates the non leaf nodes
+       void assembleTree();            
+       
+       vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
+private:
+       GlobalData* globaldata;
+       int numNodes, numLeaves;
+       ofstream out;
+       string filename;
+       
+       map<string, int>::iterator it, it2;
+       map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
+       
+       map<string,int> Tree::mergeGcounts(int);
+       void randomTopology();
+       void randomBlengths();
+       void randomLabels();
+       int findRoot();  //return index of root node
+       void printBranch(int);  //recursively print out tree
+       void setGroups();
 };
 
 #endif
index ae7d0e4ec6731a78967a46004aed02e61ceaf984..7fff2c1deae9d687bba9f87229a4d7078cdc861d 100644 (file)
@@ -48,14 +48,23 @@ int Node::getRChild() { return rchild; }
 int Node::getIndex() { return vectorIndex; }
 /****************************************************************/
 //to be used by printTree in the Tree class to print the leaf info                     
-void Node::printNode(ostream& out) {
+void Node::printNode() {
        try{
-               out << name;
-               
+               cout << parent << ' ' << lchild << ' ' << rchild << ' ' << group;
                //there is a branch length
                if (branchLength != -1) { 
-                       out << ":" << setprecision(4) << branchLength; 
+                       cout << ' ' << setprecision(4) << branchLength; 
+               }
+               cout << " |";
+               map<string, int>::iterator it;
+               for(it=pGroups.begin();it!=pGroups.end();it++){
+                       cout << ' ' << it->first << ':' << it->second;
+               }
+               cout << " |";
+               for(it=pcount.begin();it!=pcount.end();it++){
+                       cout << ' ' << it->first << ':' << it->second;
                }
+               cout << endl;
                
        }
        catch(exception& e) {
index 73532483e96a0e8ea495b983c595435dc9e04ea8..a5c39167ca6bda64c8058e99b16a02ca4e07c748 100644 (file)
@@ -36,7 +36,7 @@ class Node  {
                int getLChild();
                int getRChild();
                int getIndex();
-               void printNode(ostream&);   //prints out the name and the branch length
+               void printNode();   //prints out the name and the branch length
                
                
                //pGroup is the parsimony group info.  i.e. for a leaf node it would contain 1 enter pGroup["groupname"] = 1;