]> git.donarmstrong.com Git - mothur.git/blobdiff - tree.cpp
fixed parsimony bug
[mothur.git] / tree.cpp
index e34253d8cf90fc17b5ca72b0465a6d16a502da4b..1e115bddad1a451c181c4c26b90b758788df1155 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -49,43 +49,6 @@ Tree::Tree() {
        }               
 }
 
-/*****************************************************************/
-void Tree::resetTree(){
-try {
-               numLeaves = globaldata->gTreemap->getNumSeqs();
-               numNodes = 2*numLeaves - 1;
-               
-               tree.resize(numNodes);
-
-               //initialize tree with correct number of nodes, name and group info.
-               for (int i = 0; i < numNodes; i++) {
-                       //initialize leaf nodes
-                       if (i <= (numLeaves-1)) {
-                               tree[i].setName(globaldata->gTreemap->namesOfSeqs[i]);
-                               tree[i].setGroup(globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i]));
-                               //set pcount and pGroup for groupname to 1.
-                               tree[i].pcount[globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i])] = 1;
-                               tree[i].pGroups[globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i])] = 1;
-                               //Treemap knows name, group and index to speed up search
-                               globaldata->gTreemap->setIndex(globaldata->gTreemap->namesOfSeqs[i], i);
-       
-                       //intialize non leaf nodes
-                       }else if (i > (numLeaves-1)) {
-                               tree[i].setName("");
-                               tree[i].setGroup("");
-                       }
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function resetTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Tree class function resetTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
-
-}
 /*****************************************************************/
 int Tree::getIndex(string searchName) {
        try {
@@ -189,7 +152,7 @@ map<string, int> Tree::mergeGroups(int i) {
        try {
                int lc = tree[i].getLChild();
                int rc = tree[i].getRChild();
-cout << i << lc << rc << endl;
+
                //set parsimony groups to left child
                map<string,int> parsimony = tree[lc].pGroups;
                
@@ -215,7 +178,7 @@ cout << i << lc << rc << endl;
                        for(it=parsimony.begin();it!=parsimony.end();it++){
                                if(it->second == 1){
                                        parsimony.erase(it->first);
-                                       it--;
+//                                     it--;
                                }
                        }
                        //set one remaining groups to 1
@@ -277,24 +240,20 @@ map<string, int> Tree::mergeUserGroups(int i, vector<string> g) {
                                maxPars = parsimony[it->first];
                        }
                }
-       
+                       
                // this is true if right child had a greater parsimony for a certain group
                if(maxPars > 1){
                        //erase all the groups that are only 1 because you found something with 2.
                        for(it=parsimony.begin();it!=parsimony.end();it++){
                                if(it->second == 1){
                                        parsimony.erase(it->first);
-                                       it--;
                                }
                        }
-                       //set one remaining groups to 1
-                       //so with our above example p[white] = 2 would be left and it would become p[white] = 1
                        for(it=parsimony.begin();it!=parsimony.end();it++){
                                parsimony[it->first] = 1;
                        }
+               }               
                
-               }
-       
                return parsimony;
        }
        catch(exception& e) {