]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
bugs fixes while testing for 1.5 release
[mothur.git] / unweighted.cpp
index 3694d263fb1039ea5208926301b7bd18a38875a3..c39e6629df1c2749928833fe24af65d48e853d64 100644 (file)
@@ -57,8 +57,10 @@ EstOutput Unweighted::getValues(Tree* t) {
                                        //This section adds in all lengths that are non leaf
                        
                                        copyIpcount = t->tree[i].pcount;
-                                       for (it = copyIpcount.begin(); it != copyIpcount.end(); it++) {
-                                               if (inUsersGroups(it->first, groups) != true) { copyIpcount.erase(it->first);   }
+                                       for (it = copyIpcount.begin(); it != copyIpcount.end();) {
+                                               if (inUsersGroups(it->first, groups) != true) { 
+                                                       copyIpcount.erase(it++);        
+                                               }else { it++;  }
                                        }
                        
                                        //if i's children are from the same group then i's pcount size will be 1 
@@ -109,7 +111,9 @@ EstOutput Unweighted::getValues(Tree* t) {
                        if (numGroups == 0) {
                                //get score for all users groups
                                for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
-                                       groups.push_back(tmap->namesOfGroups[i]);
+                                       if (tmap->namesOfGroups[i] != "xxx") {
+                                               groups.push_back(tmap->namesOfGroups[i]);
+                                       }
                                }
                        }else {
                                for (int i = 0; i < globaldata->Groups.size(); i++) {
@@ -131,8 +135,10 @@ EstOutput Unweighted::getValues(Tree* t) {
                                //This section adds in all lengths that are non leaf
                        
                                copyIpcount = t->tree[i].pcount;
-                               for (it = copyIpcount.begin(); it != copyIpcount.end(); it++) {
-                                       if (inUsersGroups(it->first, groups) != true) { copyIpcount.erase(it->first);   }
+                               for (it = copyIpcount.begin(); it != copyIpcount.end();) {
+                                       if (inUsersGroups(it->first, groups) != true) { 
+                                               copyIpcount.erase(it++);        
+                                       }else {  it++;  }
                                }
                        
                                //if i's children are from the same group then i's pcount size will be 1 
@@ -179,14 +185,9 @@ EstOutput Unweighted::getValues(Tree* t) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Unweighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Unweighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Unweighted", "getValues");
                exit(1);
        }
-
 }
 
 /**************************************************************************************************/
@@ -243,10 +244,11 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                        
                                        /**********************************************************************/
                                        //This section adds in all lengths that are non leaf
-                       
                                        copyIpcount = copyTree->tree[i].pcount;
-                                       for (it = copyIpcount.begin(); it != copyIpcount.end(); it++) {
-                                               if (inUsersGroups(it->first, groups) != true) { copyIpcount.erase(it->first);   }
+                                       for (it = copyIpcount.begin(); it != copyIpcount.end();) {
+                                               if (inUsersGroups(it->first, groups) != true) { 
+                                                       copyIpcount.erase(it++);        
+                                               }else { it++;  }
                                        }
                        
                                        //if i's children are from the same group then i's pcount size will be 1 
@@ -297,7 +299,9 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                        if (numGroups == 0) {
                                //get score for all users groups
                                for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
-                                       groups.push_back(tmap->namesOfGroups[i]);
+                                       if (tmap->namesOfGroups[i] != "xxx") {
+                                               groups.push_back(tmap->namesOfGroups[i]);
+                                       }
                                }
                        }else {
                                for (int i = 0; i < globaldata->Groups.size(); i++) {
@@ -325,8 +329,10 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
                                //This section adds in all lengths that are non leaf
                        
                                copyIpcount = copyTree->tree[i].pcount;
-                               for (it = copyIpcount.begin(); it != copyIpcount.end(); it++) {
-                                       if (inUsersGroups(it->first, groups) != true) { copyIpcount.erase(it->first);   }
+                               for (it = copyIpcount.begin(); it != copyIpcount.end();) {
+                                               if (inUsersGroups(it->first, groups) != true) { 
+                                                       copyIpcount.erase(it++);        
+                                               }else { it++;  }
                                }
                        
                                //if i's children are from the same group then i's pcount size will be 1 
@@ -375,11 +381,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB) {
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Unweighted class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Unweighted class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Unweighted", "getValues");
                exit(1);
        }
 }