X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=removegroupscommand.cpp;h=64f9ab6822301310e975e6bbe58736e953eed4f2;hp=1e5fe11de39f34b30f59249895bcf393506e32f9;hb=d1c97b8c04bb75faca1e76ffad60b37a4d789d3d;hpb=af0a94ea8f02421b2b73e77e68753a2b4c37768e diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 1e5fe11..64f9ab6 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -355,11 +355,19 @@ int RemoveGroupsCommand::execute(){ //make sure groups are valid //takes care of user setting groupNames that are invalid or setting groups=all - SharedUtil* util = new SharedUtil(); vector namesGroups = groupMap->getNamesOfGroups(); - util->setGroups(Groups, namesGroups); - delete util; - + vector checkedGroups; + for (int i = 0; i < Groups.size(); i++) { + if (m->inUsersGroups(Groups[i], namesGroups)) { checkedGroups.push_back(Groups[i]); } + else { m->mothurOut("[WARNING]: " + Groups[i] + " is not a valid group in your groupfile, ignoring.\n"); } + } + + if (checkedGroups.size() == 0) { m->mothurOut("[ERROR]: no valid groups, aborting.\n"); delete groupMap; return 0; } + else { + Groups = checkedGroups; + m->setGroups(Groups); + } + //fill names with names of sequences that are from the groups we want to remove fillNames();