- if (mode == "venn") {
- //if the user only entered invalid groups
- if (userGroups.size() == 0) {
- if (allGroups.size() > 4) {
- cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first four groups in your groupfile." << endl;
- for (int i = 0; i < 4; i++) {
- userGroups.push_back(allGroups[i]);
- }
- }else {
- 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;
- for (int i = 0; i < allGroups.size(); i++) {
- userGroups.push_back(allGroups[i]);
- }
- }
- }
-
- //check to make sure their are only 4 groups
- if (userGroups.size() > 4) {
- cout << "You may only use up to 4 groups at a time with this command. I will choose the first four and disregard the rest." << endl;
- for (int i = 4; i < userGroups.size(); i++) {
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedUtil", "setGroups");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+//need to have mode because different commands require different number of valid groups
+void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string mode) {
+ try {
+
+ sort(userGroups.begin(), userGroups.end());
+ sort(allGroups.begin(), allGroups.end());
+
+ if (userGroups.size() != 0) {
+ if (userGroups[0] != "all") {
+ //check that groups are valid
+ for (int i = 0; i < userGroups.size(); i++) {
+ if (isValidGroup(userGroups[i], allGroups) != true) {
+ m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
+ // erase the invalid group from userGroups