X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedutilities.cpp;h=4339a254efbfd9af51796e5c1d473fffa9ffaefa;hb=b8f3e71c8a0310e25261464d27e6fcfe891483b0;hp=de627c643c9ff277854a1d8b8ffcb595004d0a85;hpb=753dc84cf289b1d5dc0ca5b0c043640927aa951a;p=mothur.git diff --git a/sharedutilities.cpp b/sharedutilities.cpp index de627c6..4339a25 100644 --- a/sharedutilities.cpp +++ b/sharedutilities.cpp @@ -49,11 +49,7 @@ void SharedUtil::getSharedVectors(vector Groups, vectorerrorOut(e, "SharedUtil", "getSharedVectors"); exit(1); } } @@ -97,11 +93,7 @@ void SharedUtil::getSharedVectorswithReplacement(vector Groups, vectorerrorOut(e, "SharedUtil", "getSharedVectorswithReplacement"); exit(1); } } @@ -115,7 +107,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //check that groups are valid for (int i = 0; i < userGroups.size(); i++) { if (isValidGroup(userGroups[i], allGroups) != true) { - cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl; + m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine(); // erase the invalid group from userGroups userGroups.erase(userGroups.begin()+i); i--; @@ -124,7 +116,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //if the user only entered invalid groups if (userGroups.size() == 0) { - cout << "You provided no valid groups. I will run the command using all the groups in your groupfile." << endl; + m->mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); for (int i = 0; i < allGroups.size(); i++) { userGroups.push_back(allGroups[i]); } @@ -144,14 +136,9 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "setGroups"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } /**************************************************************************************************/ //need to have mode because different commands require different number of valid groups @@ -162,7 +149,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //check that groups are valid for (int i = 0; i < userGroups.size(); i++) { if (isValidGroup(userGroups[i], allGroups) != true) { - cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl; + m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine(); // erase the invalid group from userGroups userGroups.erase(userGroups.begin()+i); i--; @@ -184,7 +171,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) { //if the user only entered invalid groups if ((userGroups.size() == 0) || (userGroups.size() == 1)) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); for (int i = 0; i < allGroups.size(); i++) { userGroups.push_back(allGroups[i]); } @@ -193,14 +180,9 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "setGroups"); exit(1); } - } @@ -217,7 +199,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups //check that groups are valid for (int i = 0; i < userGroups.size(); i++) { if (isValidGroup(userGroups[i], allGroups) != true) { - cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl; + m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine(); // erase the invalid group from globaldata->Groups userGroups.erase(userGroups.begin()+i); i--; @@ -254,9 +236,9 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups userGroups.push_back(allGroups[i]); } } - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); }else if (userGroups.size() == 1) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); userGroups.clear(); for (int i=0; i < allGroups.size(); i++) { if (allGroups[i] != "xxx") { @@ -269,7 +251,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups }else if ((mode == "unweighted") || (mode == "parsimony")) { //if the user only entered invalid groups if ((userGroups.size() == 0) && (numGroups == 0)) { - cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; + m->mothurOut("When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine(); for (int i = 0; i < allGroups.size(); i++) { if (allGroups[i] != "xxx") { userGroups.push_back(allGroups[i]); @@ -281,11 +263,7 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "setGroups"); exit(1); } } @@ -303,11 +281,7 @@ void SharedUtil::getCombos(vector& groupComb, vector userGroups, } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "getCombos"); exit(1); } } @@ -321,11 +295,7 @@ bool SharedUtil::isValidGroup(string groupname, vector groups) { return false; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "isValidGroup"); exit(1); } } @@ -339,11 +309,7 @@ void SharedUtil::updateGroupIndex(vector& userGroups, map& } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedUtil class function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedUtil", "updateGroupIndex"); exit(1); } }