5 * Created by Sarah Westcott on 1/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "sharedcommand.h"
11 //********************************************************************************************************************
12 //sorts lowest to highest
13 inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* right){
14 return (left->getGroup() < right->getGroup());
16 //**********************************************************************************************************************
17 vector<string> SharedCommand::setParameters(){
19 CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
20 CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
21 //CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
22 CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
23 CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
24 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
25 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
27 vector<string> myArray;
28 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
32 m->errorOut(e, "SharedCommand", "setParameters");
36 //**********************************************************************************************************************
37 string SharedCommand::getHelpString(){
39 string helpString = "";
40 helpString += "The make.shared command reads a list and group file and creates a shared file, as well as a rabund file for each group.\n";
41 helpString += "The make.shared command parameters are list, group, ordergroup, groups and label. list and group are required unless a current file is available.\n";
42 helpString += "The groups parameter allows you to indicate which groups you want to include, group names should be separated by dashes. ex. groups=A-B-C. Default is all groups in your groupfile.\n";
43 helpString += "The label parameter allows you to indicate which labels you want to include, label names should be separated by dashes. Default is all labels in your list file.\n";
44 //helpString += "The ordergroup parameter allows you to indicate the order of the groups in the sharedfile, by default the groups are listed alphabetically.\n";
48 m->errorOut(e, "SharedCommand", "getHelpString");
52 //**********************************************************************************************************************
53 SharedCommand::SharedCommand(){
55 abort = true; calledHelp = true;
57 //initialize outputTypes
58 vector<string> tempOutNames;
59 outputTypes["rabund"] = tempOutNames;
60 outputTypes["shared"] = tempOutNames;
61 outputTypes["group"] = tempOutNames;
64 m->errorOut(e, "SharedCommand", "SharedCommand");
68 //**********************************************************************************************************************
69 SharedCommand::SharedCommand(string option) {
71 abort = false; calledHelp = false;
74 //allow user to run help
75 if(option == "help") { help(); abort = true; calledHelp = true; }
76 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
80 vector<string> myArray = setParameters();
82 OptionParser parser(option);
83 map<string, string> parameters = parser.getParameters();
85 ValidParameters validParameter;
86 map<string, string>::iterator it;
88 //check to make sure all parameters are valid for command
89 for (it = parameters.begin(); it != parameters.end(); it++) {
90 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
93 //if the user changes the input directory command factory will send this info to us in the output parameter
94 string inputDir = validParameter.validFile(parameters, "inputdir", false);
95 if (inputDir == "not found"){ inputDir = ""; }
98 it = parameters.find("list");
99 //user has given a template file
100 if(it != parameters.end()){
101 path = m->hasPath(it->second);
102 //if the user has not given a path then, add inputdir. else leave path alone.
103 if (path == "") { parameters["list"] = inputDir + it->second; }
106 it = parameters.find("group");
107 //user has given a template file
108 if(it != parameters.end()){
109 path = m->hasPath(it->second);
110 //if the user has not given a path then, add inputdir. else leave path alone.
111 if (path == "") { parameters["group"] = inputDir + it->second; }
114 it = parameters.find("ordergroup");
115 //user has given a template file
116 if(it != parameters.end()){
117 path = m->hasPath(it->second);
118 //if the user has not given a path then, add inputdir. else leave path alone.
119 if (path == "") { parameters["ordergroup"] = inputDir + it->second; }
124 //if the user changes the output directory command factory will send this info to us in the output parameter
125 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
127 //check for required parameters
128 listfile = validParameter.validFile(parameters, "list", true);
129 if (listfile == "not open") { listfile = ""; abort = true; }
130 else if (listfile == "not found") {
131 listfile = m->getListFile();
132 if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
133 else { m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
134 }else { m->setListFile(listfile); }
136 ordergroupfile = validParameter.validFile(parameters, "ordergroup", true);
137 if (ordergroupfile == "not open") { abort = true; }
138 else if (ordergroupfile == "not found") { ordergroupfile = ""; }
140 groupfile = validParameter.validFile(parameters, "group", true);
141 if (groupfile == "not open") { groupfile = ""; abort = true; }
142 else if (groupfile == "not found") {
143 groupfile = m->getGroupFile();
144 if (groupfile != "") {
145 m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine();
146 groupMap = new GroupMap(groupfile);
148 int error = groupMap->readMap();
149 if (error == 1) { abort = true; }
150 vector<string> allGroups = groupMap->getNamesOfGroups();
151 m->setAllGroups(allGroups);
153 else { m->mothurOut("You have no current group file and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
155 groupMap = new GroupMap(groupfile);
157 int error = groupMap->readMap();
158 if (error == 1) { abort = true; }
159 vector<string> allGroups = groupMap->getNamesOfGroups();
160 m->setAllGroups(allGroups);
161 m->setGroupFile(groupfile);
164 string groups = validParameter.validFile(parameters, "groups", false);
165 if (groups == "not found") { groups = ""; }
167 m->splitAtDash(groups, Groups);
168 m->setGroups(Groups);
171 //check for optional parameter and set defaults
172 // ...at some point should added some additional type checking...
173 string label = validParameter.validFile(parameters, "label", false);
174 if (label == "not found") { label = ""; }
176 if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
177 else { allLines = 1; }
182 catch(exception& e) {
183 m->errorOut(e, "SharedCommand", "SharedCommand");
187 //**********************************************************************************************************************
189 int SharedCommand::execute(){
192 if (abort == true) { if (calledHelp) { return 0; } return 2; }
194 //getting output filename
197 if (outputDir == "") { outputDir += m->hasPath(filename); }
199 filename = outputDir + m->getRootName(m->getSimpleName(filename));
200 filename = filename + "shared";
201 outputTypes["shared"].push_back(filename);
203 m->openOutputFile(filename, out);
204 pickedGroups = false;
206 //if hte user has not specified any groups then use them all
207 if (Groups.size() == 0) {
208 Groups = groupMap->getNamesOfGroups(); m->setGroups(Groups);
209 }else { pickedGroups = true; }
211 //fill filehandles with neccessary ofstreams
214 for (i=0; i<Groups.size(); i++) {
216 filehandles[Groups[i]] = temp;
220 fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
222 //clears file before we start to write to it below
223 for (int i=0; i<Groups.size(); i++) {
224 m->mothurRemove((fileroot + Groups[i] + ".rabund"));
225 outputNames.push_back((fileroot + Groups[i] + ".rabund"));
226 outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
230 string errorOff = "no error";
233 //if user provided an order file containing the order the shared file should be in read it
234 if (ordergroupfile != "") { readOrderFile(); }
236 input = new InputData(listfile, "shared");
237 SharedList = input->getSharedListVector();
238 string lastLabel = SharedList->getLabel();
239 vector<SharedRAbundVector*> lookup;
241 if (m->control_pressed) {
242 delete input; delete SharedList; delete groupMap;
243 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
244 out.close(); m->mothurRemove(filename);
245 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
250 int error = ListGroupSameSeqs();
252 if ((!pickedGroups) && (SharedList->getNumSeqs() != groupMap->getNumSeqs())) { //if the user has not specified any groups and their files don't match exit with error
253 m->mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine();
256 m->mothurRemove(filename); //remove blank shared file you made
258 createMisMatchFile();
261 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
265 delete input; delete SharedList; delete groupMap;
270 if (error == 1) { m->control_pressed = true; }
272 //if user has specified groups make new groupfile for them
273 if (pickedGroups) { //make new group file
275 if (m->getNumGroups() < 4) {
276 for (int i = 0; i < m->getNumGroups(); i++) {
277 groups += (m->getGroups())[i] + ".";
279 }else { groups = "merge"; }
281 string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + "groups";
282 outputTypes["group"].push_back(newGroupFile);
283 outputNames.push_back(newGroupFile);
285 m->openOutputFile(newGroupFile, outGroups);
287 vector<string> names = groupMap->getNamesSeqs();
289 for (int i = 0; i < names.size(); i++) {
290 groupName = groupMap->getGroup(names[i]);
291 if (isValidGroup(groupName, m->getGroups())) {
292 outGroups << names[i] << '\t' << groupName << endl;
298 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
299 set<string> processedLabels;
300 set<string> userLabels = labels;
302 while((SharedList != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
303 if (m->control_pressed) {
304 delete input; delete SharedList; delete groupMap;
305 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
306 out.close(); m->mothurRemove(filename);
307 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
311 if(allLines == 1 || labels.count(SharedList->getLabel()) == 1){
313 lookup = SharedList->getSharedRAbundVector();
315 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
316 if (pickedGroups) { //check for otus with no seqs in them
317 eliminateZeroOTUS(lookup);
320 if (m->control_pressed) {
321 delete input; delete SharedList; delete groupMap;
322 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
323 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
324 out.close(); m->mothurRemove(filename);
325 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
329 if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
330 printSharedData(lookup); //prints info to the .shared file
331 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
333 processedLabels.insert(SharedList->getLabel());
334 userLabels.erase(SharedList->getLabel());
337 if ((m->anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) {
338 string saveLabel = SharedList->getLabel();
341 SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
343 lookup = SharedList->getSharedRAbundVector();
344 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
345 if (pickedGroups) { //check for otus with no seqs in them
346 eliminateZeroOTUS(lookup);
350 if (m->control_pressed) {
351 delete input; delete SharedList; delete groupMap;
352 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
353 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
354 out.close(); m->mothurRemove(filename);
355 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
359 if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
360 printSharedData(lookup); //prints info to the .shared file
361 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
363 processedLabels.insert(SharedList->getLabel());
364 userLabels.erase(SharedList->getLabel());
366 //restore real lastlabel to save below
367 SharedList->setLabel(saveLabel);
371 lastLabel = SharedList->getLabel();
374 SharedList = input->getSharedListVector(); //get new list vector to process
377 //output error messages about any remaining user labels
378 set<string>::iterator it;
379 bool needToRun = false;
380 for (it = userLabels.begin(); it != userLabels.end(); it++) {
381 if (processedLabels.count(lastLabel) != 1) {
386 //run last label if you need to
387 if (needToRun == true) {
388 if (SharedList != NULL) { delete SharedList; }
389 SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
391 lookup = SharedList->getSharedRAbundVector();
392 m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
393 if (pickedGroups) { //check for otus with no seqs in them
394 eliminateZeroOTUS(lookup);
397 if (m->control_pressed) {
398 delete input; delete groupMap;
399 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; }
400 out.close(); m->mothurRemove(filename);
401 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
405 if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
406 printSharedData(lookup); //prints info to the .shared file
407 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
413 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
417 delete input; delete groupMap;
419 if (m->control_pressed) {
420 m->mothurRemove(filename);
421 for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
425 //set rabund file as new current rabundfile
427 itTypes = outputTypes.find("rabund");
428 if (itTypes != outputTypes.end()) {
429 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
432 itTypes = outputTypes.find("shared");
433 if (itTypes != outputTypes.end()) {
434 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
437 itTypes = outputTypes.find("group");
438 if (itTypes != outputTypes.end()) {
439 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
442 m->mothurOutEndLine();
443 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
444 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
445 m->mothurOut(filename); m->mothurOutEndLine();
446 m->mothurOutEndLine();
450 catch(exception& e) {
451 m->errorOut(e, "SharedCommand", "execute");
455 //**********************************************************************************************************************
456 void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup) {
459 if (order.size() == 0) { //user has not specified an order so do aplabetically
460 sort(thislookup.begin(), thislookup.end(), compareSharedRabunds);
463 vector<string> Groups;
465 //initialize bin values
466 for (int i = 0; i < thislookup.size(); i++) {
467 out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
468 thislookup[i]->print(out);
470 Groups.push_back(thislookup[i]->getGroup());
472 RAbundVector rav = thislookup[i]->getRAbundVector();
473 m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
474 rav.print(*(filehandles[thislookup[i]->getGroup()]));
475 (*(filehandles[thislookup[i]->getGroup()])).close();
477 m->setGroups(Groups);
479 //create a map from groupName to each sharedrabund
480 map<string, SharedRAbundVector*> myMap;
481 map<string, SharedRAbundVector*>::iterator myIt;
483 for (int i = 0; i < thislookup.size(); i++) {
484 myMap[thislookup[i]->getGroup()] = thislookup[i];
488 vector<string> Groups;
490 //loop through ordered list and print the rabund
491 for (int i = 0; i < order.size(); i++) {
492 myIt = myMap.find(order[i]);
494 if(myIt != myMap.end()) { //we found it
495 out << (myIt->second)->getLabel() << '\t' << (myIt->second)->getGroup() << '\t';
496 (myIt->second)->print(out);
498 Groups.push_back((myIt->second)->getGroup());
500 RAbundVector rav = (myIt->second)->getRAbundVector();
501 m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
502 rav.print(*(filehandles[(myIt->second)->getGroup()]));
503 (*(filehandles[(myIt->second)->getGroup()])).close();
505 m->mothurOut("Can't find shared info for " + order[i] + ", skipping."); m->mothurOutEndLine();
509 m->setGroups(Groups);
514 catch(exception& e) {
515 m->errorOut(e, "SharedCommand", "printSharedData");
519 //**********************************************************************************************************************
520 int SharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
523 vector<SharedRAbundVector*> newLookup;
524 for (int i = 0; i < thislookup.size(); i++) {
525 SharedRAbundVector* temp = new SharedRAbundVector();
526 temp->setLabel(thislookup[i]->getLabel());
527 temp->setGroup(thislookup[i]->getGroup());
528 newLookup.push_back(temp);
532 for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
533 if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } return 0; }
535 //look at each sharedRabund and make sure they are not all zero
537 for (int j = 0; j < thislookup.size(); j++) {
538 if (thislookup[j]->getAbundance(i) != 0) { allZero = false; break; }
541 //if they are not all zero add this bin
543 for (int j = 0; j < thislookup.size(); j++) {
544 newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
546 //if there is a bin label use it otherwise make one
548 //else{ cout << "bin # " << i << " is all zeros" << endl; }
551 for (int j = 0; j < thislookup.size(); j++) { delete thislookup[j]; }
552 thislookup = newLookup;
557 catch(exception& e) {
558 m->errorOut(e, "SharedCommand", "eliminateZeroOTUS");
562 //**********************************************************************************************************************
563 int SharedCommand::createMisMatchFile() {
565 ofstream outMisMatch;
566 string outputMisMatchName = outputDir + m->getRootName(m->getSimpleName(listfile));
568 //you have sequences in your list file that are not in your group file
569 if (SharedList->getNumSeqs() > groupMap->getNumSeqs()) {
570 outputMisMatchName += "missing.group";
571 m->mothurOut("For a list of names that are in your list file and not in your group file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
573 m->openOutputFile(outputMisMatchName, outMisMatch);
575 set<string> listNames;
576 set<string>::iterator itList;
578 //go through list and if group returns "not found" output it
579 for (int i = 0; i < SharedList->getNumBins(); i++) {
580 if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; }
582 string names = SharedList->get(i);
584 vector<string> binNames;
585 m->splitAtComma(names, binNames);
587 for (int j = 0; j < binNames.size(); j++) {
588 string name = binNames[j];
589 string group = groupMap->getGroup(name);
591 if(group == "not found") { outMisMatch << name << endl; }
593 itList = listNames.find(name);
594 if (itList != listNames.end()) { m->mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
595 else { listNames.insert(name); }
602 }else {//you have sequences in your group file that are not in you list file
604 outputMisMatchName += "missing.name";
605 m->mothurOut("For a list of names that are in your group file and not in your list file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
607 map<string, string> namesInList;
608 map<string, string>::iterator itList;
610 //go through listfile and get names
611 for (int i = 0; i < SharedList->getNumBins(); i++) {
612 if (m->control_pressed) { return 0; }
615 string names = SharedList->get(i);
617 vector<string> binNames;
618 m->splitAtComma(names, binNames);
620 for (int j = 0; j < binNames.size(); j++) {
622 string name = binNames[j];
624 itList = namesInList.find(name);
625 if (itList != namesInList.end()) { m->mothurOut(name + " is in your list file more than once. Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
627 namesInList[name] = name;
632 //get names of sequences in groupfile
633 vector<string> seqNames = groupMap->getNamesSeqs();
635 map<string, string>::iterator itMatch;
637 m->openOutputFile(outputMisMatchName, outMisMatch);
639 //loop through names in seqNames and if they aren't in namesIn list output them
640 for (int i = 0; i < seqNames.size(); i++) {
641 if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; }
643 itMatch = namesInList.find(seqNames[i]);
645 if (itMatch == namesInList.end()) {
647 outMisMatch << seqNames[i] << endl;
655 catch(exception& e) {
656 m->errorOut(e, "SharedCommand", "createMisMatchFile");
660 //**********************************************************************************************************************
661 int SharedCommand::ListGroupSameSeqs() {
666 vector<string> groupMapsSeqs = groupMap->getNamesSeqs();
668 set<string> groupNamesSeqs;
669 for(int i = 0; i < groupMapsSeqs.size(); i++) {
670 groupNamesSeqs.insert(groupMapsSeqs[i]);
673 //go through list and if group returns "not found" output it
674 for (int i = 0; i < SharedList->getNumBins(); i++) {
675 if (m->control_pressed) { return 0; }
677 string names = SharedList->get(i);
679 vector<string> listNames;
680 m->splitAtComma(names, listNames);
682 for (int j = 0; j < listNames.size(); j++) {
683 int num = groupNamesSeqs.count(listNames[j]);
685 if (num == 0) { error = 1; m->mothurOut("[ERROR]: " + listNames[j] + " is in your listfile and not in your groupfile. Please correct."); m->mothurOutEndLine(); }
686 else { groupNamesSeqs.erase(listNames[j]); }
690 for (set<string>::iterator itGroupSet = groupNamesSeqs.begin(); itGroupSet != groupNamesSeqs.end(); itGroupSet++) {
692 m->mothurOut("[ERROR]: " + (*itGroupSet) + " is in your groupfile and not your listfile. Please correct."); m->mothurOutEndLine();
697 catch(exception& e) {
698 m->errorOut(e, "SharedCommand", "ListGroupSameSeqs");
702 //**********************************************************************************************************************
704 SharedCommand::~SharedCommand(){
709 //**********************************************************************************************************************
710 int SharedCommand::readOrderFile() {
716 m->openInputFile(ordergroupfile, in);
720 in >> thisGroup; m->gobble(in);
722 order.push_back(thisGroup);
724 if (m->control_pressed) { order.clear(); break; }
730 catch(exception& e) {
731 m->errorOut(e, "SharedCommand", "readOrderFile");
735 //**********************************************************************************************************************
737 bool SharedCommand::isValidGroup(string groupname, vector<string> groups) {
739 for (int i = 0; i < groups.size(); i++) {
740 if (groupname == groups[i]) { return true; }
745 catch(exception& e) {
746 m->errorOut(e, "SharedCommand", "isValidGroup");
750 /************************************************************/