]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimony.cpp
fix weighted unifrac bug in findIndex and randomize labels
[mothur.git] / parsimony.cpp
index 3ef141ed8518eb4ff9a0057152484d2ef85b3968..3840514523002b545b7cf0f2fbb848b4c0ad0dd5 100644 (file)
@@ -10,6 +10,7 @@
 #include "parsimony.h"
 
 /**************************************************************************************************/
+
 EstOutput Parsimony::getValues(Tree* t) {
        try {
                globaldata = GlobalData::getInstance();
@@ -17,7 +18,12 @@ EstOutput Parsimony::getValues(Tree* t) {
                data.resize(1,0);
                        
                int score = 0;
-                                       
+               
+               //create pgroups that reflect the groups the user want to use
+               for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
+                       t->tree[i].pGroups = (t->mergeUserGroups(i));
+               }
+               
                for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
                        int lc = t->tree[i].getLChild();
                        int rc = t->tree[i].getRChild();
@@ -25,21 +31,7 @@ EstOutput Parsimony::getValues(Tree* t) {
                        int iSize = t->tree[i].pGroups.size();
                        int rcSize = t->tree[rc].pGroups.size();
                        int lcSize = t->tree[lc].pGroups.size();
-                       
-                       //add in all the groups the users wanted
-                       for (it = t->tree[i].pGroups.begin(); it != t->tree[i].pGroups.end(); it++) {
-                               if (inUsersGroups(it->first, globaldata->Groups) != true) {  iSize--;  }
-                       }
-                       //add in all the groups the users wanted
-                       for (it = t->tree[rc].pGroups.begin(); it != t->tree[rc].pGroups.end(); it++) {
-                               if (inUsersGroups(it->first, globaldata->Groups) != true) {  rcSize--;  }
-                       }
-                       
-                       //add in all the groups the users wanted
-                       for (it = t->tree[lc].pGroups.begin(); it != t->tree[lc].pGroups.end(); it++) {
-                               if (inUsersGroups(it->first, globaldata->Groups) != true) {  lcSize--;  }
-                       }
-                       
+               
                        //if isize are 0 then that branch is to be ignored
                        if (iSize == 0) { }
                        else if ((rcSize == 0) || (lcSize == 0)) { }
@@ -49,6 +41,7 @@ EstOutput Parsimony::getValues(Tree* t) {
                        }
                } 
                
+               
                data[0] = score;
                
                return data;
@@ -64,3 +57,5 @@ EstOutput Parsimony::getValues(Tree* t) {
 
 }
 
+/**************************************************************************************************/
+