]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed parsimony bug
authorpschloss <pschloss>
Fri, 6 Mar 2009 14:58:27 +0000 (14:58 +0000)
committerpschloss <pschloss>
Fri, 6 Mar 2009 14:58:27 +0000 (14:58 +0000)
ace.cpp
parsimony.cpp
tree.cpp

diff --git a/ace.cpp b/ace.cpp
index d074310ab1678ca44abbb23372ee74b41321999b..17049bdc414f7e4cb0371332b3e2aef7ac2c4f41 100644 (file)
--- a/ace.cpp
+++ b/ace.cpp
@@ -13,9 +13,7 @@
 
 EstOutput Ace::getValues(SAbundVector* rank) {
        try {
-               cout << "abund = " << abund << "\n";
                data.resize(3,0);
-       //      vector<double> aceData(3,0);
                double ace, acelci, acehci;
        
                int nrare = 0;
index 0dea64e99a5f7bbe3adfe3dbd648ab8fb5365acf..fc1a8b6f48821a3d66aa1fb9c70799260c56c241 100644 (file)
@@ -89,9 +89,12 @@ EstOutput Parsimony::getValues(Tree* t) {
                
                        //create pgroups that reflect the groups the user want to use
                        for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
+//                             cout << i << "..." << endl;
                                copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
                        }
                
+//                     map<string,int>::iterator it;
+                       
                        for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
                                int lc = copyTree->tree[i].getLChild();
                                int rc = copyTree->tree[i].getRChild();
@@ -99,7 +102,15 @@ EstOutput Parsimony::getValues(Tree* t) {
                                int iSize = copyTree->tree[i].pGroups.size();
                                int rcSize = copyTree->tree[rc].pGroups.size();
                                int lcSize = copyTree->tree[lc].pGroups.size();
-               
+                               
+//                             cout << i+1 << '\t' << lc+1 << '\t' << rc+1 << ":\t";
+                               
+//                             for(it=copyTree->tree[i].pGroups.begin();it!=copyTree->tree[i].pGroups.end();it++){
+//                                     cout << it->first << '\t';
+//                             }
+                               
+//                             cout << " : " << iSize << '\t' << rcSize << '\t' << lcSize << '\t';
+                                       
                                //if isize are 0 then that branch is to be ignored
                                if (iSize == 0) { }
                                else if ((rcSize == 0) || (lcSize == 0)) { }
@@ -107,9 +118,12 @@ EstOutput Parsimony::getValues(Tree* t) {
                                else if(iSize > rcSize || iSize > lcSize){
                                        score++;
                                }
+//                             cout << score << endl;
                        } 
                
                        data[count] = score;
+                       string hold;
+//                     cin >> hold;
                }
                
                return data;
index 2cd9cbabc691d692fcb30a7fb9408da8ad22c383..1e115bddad1a451c181c4c26b90b758788df1155 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -178,7 +178,7 @@ map<string, int> Tree::mergeGroups(int i) {
                        for(it=parsimony.begin();it!=parsimony.end();it++){
                                if(it->second == 1){
                                        parsimony.erase(it->first);
-                                       it--;
+//                                     it--;
                                }
                        }
                        //set one remaining groups to 1
@@ -240,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) {