]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
added errorchecking and help info on new unifrac and treeclimber code
[mothur.git] / unweighted.cpp
index a7cf9c9092e6b8565f538d38b2f86ae4a75b5944..4416e79afd680059b8958cab6c28e035b3633d1c 100644 (file)
@@ -13,7 +13,8 @@
 
 EstOutput Unweighted::getValues(Tree* t) {
        try {
-       
+               globaldata = GlobalData::getInstance();
+               
                //clear out old values
                data.resize(1,0); 
                penalty.resize(t->getNumLeaves(), 0);
@@ -60,7 +61,7 @@ EstOutput Unweighted::getValues(Tree* t) {
     
                map<string,double>::iterator pos;
                for(pos=unique.begin();pos!=unique.end();pos++){
-                       if(pos->first!="xxx"){      
+                       if((pos->first!="xxx") && (inUsersGroups(pos->first))){     
                                UW += unique[pos->first];
                        }
                }
@@ -85,4 +86,20 @@ EstOutput Unweighted::getValues(Tree* t) {
 
 }
 
-/**************************************************************************************************/
\ No newline at end of file
+/**************************************************************************************************/
+bool Unweighted::inUsersGroups(string groupname) {
+       try {
+               for (int i = 0; i < globaldata->Groups.size(); i++) {
+                       if (groupname == globaldata->Groups[i]) { return true; }
+               }
+               return false;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the Unweighted class Function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the Unweighted class function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
\ No newline at end of file