]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed unweighted calculator
authorwestcott <westcott>
Mon, 23 Feb 2009 13:55:04 +0000 (13:55 +0000)
committerwestcott <westcott>
Mon, 23 Feb 2009 13:55:04 +0000 (13:55 +0000)
unweighted.cpp

index 1a2573b6d5738055ddd7d69448a321369d72bb53..b224996efe0bb9a2bbdb517502b93ca6d62e7edf 100644 (file)
@@ -18,15 +18,13 @@ EstOutput Unweighted::getValues(Tree* t) {
                //clear out old values
                data.resize(1,0); 
                
-               float UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
-               float totalBL = 0.00;   //all branch lengths
-               float UW = 0.00;                //Unweighted Value = UniqueBL / totalBL;
+               double UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
+               double totalBL = 0.00;  //all branch lengths
+               double UW = 0.00;               //Unweighted Value = UniqueBL / totalBL;
                
                map<string, int>::iterator it;  //iterator to traverse pgroups
-               map<string, int> copyLCpcount;
-               map<string, int> copyRCpcount;
                map<string, int> copyIpcount;
-       
+               
                for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
                
                        int lc = t->tree[i].getLChild();  //lc = vector index of left child
@@ -35,32 +33,15 @@ EstOutput Unweighted::getValues(Tree* t) {
                        /**********************************************************************/
                        //This section adds in all lengths that are non leaf
                        
-                       //copy left childs pGroups and remove groups that the user doesn't want
                        copyIpcount = t->tree[i].pcount;
                        for (it = copyIpcount.begin(); it != copyIpcount.end(); it++) {
                                if (inUsersGroups(it->first, globaldata->Groups) != true) {     copyIpcount.erase(it->first);   }
                        }
-
-                       //copy left childs pGroups and remove groups that the user doesn't want
-                       copyLCpcount = t->tree[lc].pcount;
-                       for (it = copyLCpcount.begin(); it != copyLCpcount.end(); it++) {
-                               if (inUsersGroups(it->first, globaldata->Groups) != true) {     copyLCpcount.erase(it->first);  }
-                       }
-
-                       //copy right childs pGroups and remove groups that the user doesn't want
-                       copyRCpcount = t->tree[rc].pcount;
-                       for (it = copyRCpcount.begin(); it != copyRCpcount.end(); it++) {
-                               if (inUsersGroups(it->first, globaldata->Groups) != true) {     copyRCpcount.erase(it->first);  }
-                       }
-       
-                       //if i's children are from the same group and i has a BL then add i's length to unique
-                       //if copyRCpcount.size() = 0 && copyLCpcount.size() = 0 they are from a branch that is entirely from a group the user doesn't want
-                       if ((copyRCpcount.size() == 0) && (copyLCpcount.size() == 0)) { }
-                       else {
-                               if ((copyRCpcount == copyLCpcount) && (t->tree[i].getBranchLength() != -1)) {  UniqueBL += t->tree[i].getBranchLength();        }
-                               //if either childs groups = 0 then all of there groups were not valid making the parent unique
-                               else if (((copyRCpcount.size() == 0) || (copyLCpcount.size() == 0)) && (t->tree[i].getBranchLength() != -1)) {  UniqueBL += t->tree[i].getBranchLength();       }
-                       }
+                       
+                       //if i's children are from the same group then i's pcount size will be 1 
+                       //if copyIpcount.size() = 0 they are from a branch that is entirely from a group the user doesn't want
+                       if (copyIpcount.size() == 0) { }
+                       else if ((t->tree[i].getBranchLength() != -1) && (copyIpcount.size() == 1)) {  UniqueBL += t->tree[i].getBranchLength();        }
                        
                        //add i's BL to total if it is from the groups the user wants
                        if ((t->tree[i].getBranchLength() != -1) && (copyIpcount.size() != 0)) {  
@@ -88,7 +69,6 @@ EstOutput Unweighted::getValues(Tree* t) {
                        }
                        
                        /**********************************************************************/
-               
                }
                
                UW = (UniqueBL / totalBL);