]> git.donarmstrong.com Git - mothur.git/blobdiff - parsimony.cpp
changed unifrac.weighted()
[mothur.git] / parsimony.cpp
index 6c184701e2a4d3054ddd8bb74e6d586afee4ccd4..da8412ce71d590fe57366fb453126db00ff0f715 100644 (file)
 /**************************************************************************************************/
 EstOutput Parsimony::getValues(Tree* t) {
        try {
+               globaldata = GlobalData::getInstance();
+               
                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();
                        
-                        if(t->tree[i].pGroups.size() > t->tree[rc].pGroups.size() || t->tree[i].pGroups.size() > t->tree[lc].pGroups.size()){
+                       int iSize = t->tree[i].pGroups.size();
+                       int rcSize = t->tree[rc].pGroups.size();
+                       int lcSize = t->tree[lc].pGroups.size();
+               
+                       //if isize are 0 then that branch is to be ignored
+                       if (iSize == 0) { }
+                       else if ((rcSize == 0) || (lcSize == 0)) { }
+                       //if you have more groups than either of your kids then theres been a change.
+                       else if(iSize > rcSize || iSize > lcSize){
                                score++;
                        }
+                       cout << i << ' ' << score << ": ";
+                       t->tree[i].printNode();
                } 
                
+               //string hold;
+               //cin >> hold;
+               
                data[0] = score;
                
                return data;
@@ -39,4 +59,6 @@ EstOutput Parsimony::getValues(Tree* t) {
        }
 
 }
+
 /**************************************************************************************************/
+