]> git.donarmstrong.com Git - mothur.git/blob - removegroupscommand.cpp
finished adding the names option to trim.seqs
[mothur.git] / removegroupscommand.cpp
1 /*
2  *  removegroupscommand.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 11/10/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "removegroupscommand.h"
11 #include "sequence.hpp"
12 #include "listvector.hpp"
13 #include "sharedutilities.h"
14
15 //**********************************************************************************************************************
16 vector<string> RemoveGroupsCommand::setParameters(){    
17         try {
18                 CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
19                 CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
20                 CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(pgroup);
21                 CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
22                 CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
23                 CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
24                 CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
25                 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
26                 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
27                 
28                 vector<string> myArray;
29                 for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
30                 return myArray;
31         }
32         catch(exception& e) {
33                 m->errorOut(e, "RemoveGroupsCommand", "setParameters");
34                 exit(1);
35         }
36 }
37 //**********************************************************************************************************************
38 string RemoveGroupsCommand::getHelpString(){    
39         try {
40                 string helpString = "";
41                 helpString += "The remove.groups command removes sequences from a specfic group or set of groups from the following file types: fasta, name, group, list, taxonomy.\n";
42                 helpString += "It outputs a file containing the sequences NOT in the those specified groups.\n";
43                 helpString += "The remove.groups command parameters are accnos, fasta, name, group, list, taxonomy and groups. The group parameter is required, unless you have a current group file.\n";
44                 helpString += "You must also provide an accnos containing the list of groups to remove or set the groups parameter to the groups you wish to remove.\n";
45                 helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like removed.  You can separate group names with dashes.\n";
46                 helpString += "The remove.groups command should be in the following format: remove.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n";
47                 helpString += "Example remove.groups(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n";
48                 helpString += "or remove.groups(groups=pasture, fasta=amazon.fasta, amazon.groups).\n";
49                 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
50                 return helpString;
51         }
52         catch(exception& e) {
53                 m->errorOut(e, "RemoveGroupsCommand", "getHelpString");
54                 exit(1);
55         }
56 }
57
58 //**********************************************************************************************************************
59 RemoveGroupsCommand::RemoveGroupsCommand(){     
60         try {
61                 abort = true; calledHelp = true; 
62                 setParameters();
63                 vector<string> tempOutNames;
64                 outputTypes["fasta"] = tempOutNames;
65                 outputTypes["taxonomy"] = tempOutNames;
66                 outputTypes["name"] = tempOutNames;
67                 outputTypes["group"] = tempOutNames;
68                 outputTypes["list"] = tempOutNames;
69         }
70         catch(exception& e) {
71                 m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
72                 exit(1);
73         }
74 }
75 //**********************************************************************************************************************
76 RemoveGroupsCommand::RemoveGroupsCommand(string option)  {
77         try {
78                 abort = false; calledHelp = false;   
79                 
80                 //allow user to run help
81                 if(option == "help") { help(); abort = true; calledHelp = true; }
82                 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
83                 
84                 else {
85                         vector<string> myArray = setParameters();
86                         
87                         OptionParser parser(option);
88                         map<string,string> parameters = parser.getParameters();
89                         
90                         ValidParameters validParameter;
91                         map<string,string>::iterator it;
92                         
93                         //check to make sure all parameters are valid for command
94                         for (it = parameters.begin(); it != parameters.end(); it++) { 
95                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
96                         }
97                         
98                         //initialize outputTypes
99                         vector<string> tempOutNames;
100                         outputTypes["fasta"] = tempOutNames;
101                         outputTypes["taxonomy"] = tempOutNames;
102                         outputTypes["name"] = tempOutNames;
103                         outputTypes["group"] = tempOutNames;
104                         outputTypes["list"] = tempOutNames;
105                         
106                         
107                         //if the user changes the output directory command factory will send this info to us in the output parameter 
108                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
109                         
110                         //if the user changes the input directory command factory will send this info to us in the output parameter 
111                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
112                         if (inputDir == "not found"){   inputDir = "";          }
113                         else {
114                                 string path;
115                                 it = parameters.find("fasta");
116                                 //user has given a template file
117                                 if(it != parameters.end()){ 
118                                         path = m->hasPath(it->second);
119                                         //if the user has not given a path then, add inputdir. else leave path alone.
120                                         if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
121                                 }
122                                 
123                                 it = parameters.find("accnos");
124                                 //user has given a template file
125                                 if(it != parameters.end()){ 
126                                         path = m->hasPath(it->second);
127                                         //if the user has not given a path then, add inputdir. else leave path alone.
128                                         if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
129                                 }
130                                 
131                                 it = parameters.find("list");
132                                 //user has given a template file
133                                 if(it != parameters.end()){ 
134                                         path = m->hasPath(it->second);
135                                         //if the user has not given a path then, add inputdir. else leave path alone.
136                                         if (path == "") {       parameters["list"] = inputDir + it->second;             }
137                                 }
138                                 
139                                 it = parameters.find("name");
140                                 //user has given a template file
141                                 if(it != parameters.end()){ 
142                                         path = m->hasPath(it->second);
143                                         //if the user has not given a path then, add inputdir. else leave path alone.
144                                         if (path == "") {       parameters["name"] = inputDir + it->second;             }
145                                 }
146                                 
147                                 it = parameters.find("group");
148                                 //user has given a template file
149                                 if(it != parameters.end()){ 
150                                         path = m->hasPath(it->second);
151                                         //if the user has not given a path then, add inputdir. else leave path alone.
152                                         if (path == "") {       parameters["group"] = inputDir + it->second;            }
153                                 }
154                                 
155                                 it = parameters.find("taxonomy");
156                                 //user has given a template file
157                                 if(it != parameters.end()){ 
158                                         path = m->hasPath(it->second);
159                                         //if the user has not given a path then, add inputdir. else leave path alone.
160                                         if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
161                                 }
162                         }
163                         
164                         
165                         //check for required parameters
166                         accnosfile = validParameter.validFile(parameters, "accnos", true);
167                         if (accnosfile == "not open") { abort = true; }
168                         else if (accnosfile == "not found") {  accnosfile = ""; }       
169                         
170                         fastafile = validParameter.validFile(parameters, "fasta", true);
171                         if (fastafile == "not open") { abort = true; }
172                         else if (fastafile == "not found") {  fastafile = "";  }        
173                         
174                         namefile = validParameter.validFile(parameters, "name", true);
175                         if (namefile == "not open") { abort = true; }
176                         else if (namefile == "not found") {  namefile = "";  }  
177                         
178                         groupfile = validParameter.validFile(parameters, "group", true);
179                         if (groupfile == "not open") { abort = true; }
180                         else if (groupfile == "not found") {            
181                                 //if there is a current group file, use it
182                                 groupfile = m->getGroupFile(); 
183                                 if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
184                                 else {  m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
185                         }       
186                         
187                         listfile = validParameter.validFile(parameters, "list", true);
188                         if (listfile == "not open") { abort = true; }
189                         else if (listfile == "not found") {  listfile = "";  }
190                         
191                         taxfile = validParameter.validFile(parameters, "taxonomy", true);
192                         if (taxfile == "not open") { abort = true; }
193                         else if (taxfile == "not found") {  taxfile = "";  }
194                         
195                         groups = validParameter.validFile(parameters, "groups", false);                 
196                         if (groups == "not found") { groups = ""; }
197                         else { 
198                                 m->splitAtDash(groups, Groups);
199                         }
200                         
201                         if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
202                         
203                         if ((fastafile == "") && (namefile == "") && (groupfile == "")  && (listfile == "") && (taxfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, taxonomy, group or list."); m->mothurOutEndLine(); abort = true; }
204                 }
205                 
206         }
207         catch(exception& e) {
208                 m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
209                 exit(1);
210         }
211 }
212 //**********************************************************************************************************************
213
214 int RemoveGroupsCommand::execute(){
215         try {
216                 
217                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
218                 
219                 groupMap = new GroupMap(groupfile);
220                 groupMap->readMap();
221                 
222                 //get groups you want to remove
223                 if (accnosfile != "") { readAccnos(); }
224                 
225                 //make sure groups are valid
226                 //takes care of user setting groupNames that are invalid or setting groups=all
227                 SharedUtil* util = new SharedUtil();
228                 util->setGroups(Groups, groupMap->namesOfGroups);
229                 delete util;
230                 
231                 //fill names with names of sequences that are from the groups we want to remove 
232                 fillNames();
233                 
234                 if (m->control_pressed) { delete groupMap; return 0; }
235                 
236                 //read through the correct file and output lines you want to keep
237                 if (namefile != "")                     {               readName();             }
238                 if (fastafile != "")            {               readFasta();    }
239                 if (groupfile != "")            {               readGroup();    }
240                 if (listfile != "")                     {               readList();             }
241                 if (taxfile != "")                      {               readTax();              }
242                 
243                 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0; }
244                 
245                 m->mothurOut("Removed " + toString(names.size()) + " sequences. From the groups: "); m->mothurOutEndLine();
246                 for (int i = 0; i < Groups.size(); i++) {       m->mothurOut(Groups[i]); m->mothurOut("\t" + toString(groupMap->getNumSeqs(Groups[i]))); m->mothurOutEndLine(); }
247                 m->mothurOutEndLine();
248                 
249                 if (outputNames.size() != 0) {
250                         m->mothurOutEndLine();
251                         m->mothurOut("Output File names: "); m->mothurOutEndLine();
252                         for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
253                         m->mothurOutEndLine();
254                         
255                         //set fasta file as new current fastafile
256                         string current = "";
257                         itTypes = outputTypes.find("fasta");
258                         if (itTypes != outputTypes.end()) {
259                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
260                         }
261                         
262                         itTypes = outputTypes.find("name");
263                         if (itTypes != outputTypes.end()) {
264                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
265                         }
266                         
267                         itTypes = outputTypes.find("group");
268                         if (itTypes != outputTypes.end()) {
269                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
270                         }
271                         
272                         itTypes = outputTypes.find("list");
273                         if (itTypes != outputTypes.end()) {
274                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
275                         }
276                         
277                         itTypes = outputTypes.find("taxonomy");
278                         if (itTypes != outputTypes.end()) {
279                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
280                         }
281                 }
282                 
283                 return 0;               
284         }
285         
286         catch(exception& e) {
287                 m->errorOut(e, "RemoveGroupsCommand", "execute");
288                 exit(1);
289         }
290 }
291
292 //**********************************************************************************************************************
293 int RemoveGroupsCommand::readFasta(){
294         try {
295                 string thisOutputDir = outputDir;
296                 if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
297                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
298                 
299                 ofstream out;
300                 m->openOutputFile(outputFileName, out);
301                 
302                 ifstream in;
303                 m->openInputFile(fastafile, in);
304                 string name;
305                 
306                 bool wroteSomething = false;
307                 
308                 while(!in.eof()){
309                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
310                         
311                         Sequence currSeq(in);
312                         name = currSeq.getName();
313                         
314                         if (name != "") {
315                                 //if this name is in the accnos file
316                                 if (names.count(name) == 0) {
317                                         wroteSomething = true;
318                                         
319                                         currSeq.printSequence(out);
320                                 }
321                         }
322                         m->gobble(in);
323                 }
324                 in.close();     
325                 out.close();
326                 
327                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
328                 outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
329                 
330                 return 0;
331                 
332         }
333         catch(exception& e) {
334                 m->errorOut(e, "RemoveGroupsCommand", "readFasta");
335                 exit(1);
336         }
337 }
338
339 //**********************************************************************************************************************
340 int RemoveGroupsCommand::readList(){
341         try {
342                 string thisOutputDir = outputDir;
343                 if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
344                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
345                 
346                 ofstream out;
347                 m->openOutputFile(outputFileName, out);
348                 
349                 ifstream in;
350                 m->openInputFile(listfile, in);
351                 
352                 bool wroteSomething = false;
353                 
354                 while(!in.eof()){
355                         //read in list vector
356                         ListVector list(in);
357                         
358                         //make a new list vector
359                         ListVector newList;
360                         newList.setLabel(list.getLabel());
361                         
362                         //for each bin
363                         for (int i = 0; i < list.getNumBins(); i++) {
364                                 if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
365                                 
366                                 //parse out names that are in accnos file
367                                 string binnames = list.get(i);
368                                 
369                                 string newNames = "";
370                                 while (binnames.find_first_of(',') != -1) { 
371                                         string name = binnames.substr(0,binnames.find_first_of(','));
372                                         binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
373                                         
374                                         //if that name is in the .accnos file, add it
375                                         if (names.count(name) == 0) {  newNames += name + ",";  }
376                                 }
377                                 
378                                 //get last name
379                                 if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
380                                 
381                                 //if there are names in this bin add to new list
382                                 if (newNames != "") {  
383                                         newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
384                                         newList.push_back(newNames);    
385                                 }
386                         }
387                         
388                         //print new listvector
389                         if (newList.getNumBins() != 0) {
390                                 wroteSomething = true;
391                                 newList.print(out);
392                         }
393                         
394                         m->gobble(in);
395                 }
396                 in.close();     
397                 out.close();
398                 
399                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
400                 outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
401                 
402                 return 0;
403                 
404         }
405         catch(exception& e) {
406                 m->errorOut(e, "RemoveGroupsCommand", "readList");
407                 exit(1);
408         }
409 }
410 //**********************************************************************************************************************
411 int RemoveGroupsCommand::readName(){
412         try {
413                 string thisOutputDir = outputDir;
414                 if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
415                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
416                 
417                 ofstream out;
418                 m->openOutputFile(outputFileName, out);
419                 
420                 ifstream in;
421                 m->openInputFile(namefile, in);
422                 string name, firstCol, secondCol;
423                 
424                 bool wroteSomething = false;
425                 
426                 while(!in.eof()){
427                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
428                         
429                         in >> firstCol;         m->gobble(in);          
430                         in >> secondCol;                        
431                         
432                         vector<string> parsedNames;
433                         m->splitAtComma(secondCol, parsedNames);
434                                                 
435                         vector<string> validSecond;  validSecond.clear();
436                         for (int i = 0; i < parsedNames.size(); i++) {
437                                 if (names.count(parsedNames[i]) == 0) {
438                                         validSecond.push_back(parsedNames[i]);
439                                 }
440                         }
441                         
442                         
443                         //if the name in the first column is in the set then print it and any other names in second column also in set
444                         if (names.count(firstCol) == 0) {
445                                 
446                                 wroteSomething = true;
447                                 
448                                 out << firstCol << '\t';
449                                 
450                                 //you know you have at least one valid second since first column is valid
451                                 for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
452                                 out << validSecond[validSecond.size()-1] << endl;
453                                 
454                                 //make first name in set you come to first column and then add the remaining names to second column
455                         }else {
456                                 
457                                 //you want part of this row
458                                 if (validSecond.size() != 0) {
459                                         
460                                         wroteSomething = true;
461                                         
462                                         out << validSecond[0] << '\t';
463                                         
464                                         //you know you have at least one valid second since first column is valid
465                                         for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
466                                         out << validSecond[validSecond.size()-1] << endl;
467                                 }
468                         }
469                         
470                         m->gobble(in);
471                 }
472                 in.close();
473                 out.close();
474                 
475                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
476                 outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
477                 
478                 return 0;
479         }
480         catch(exception& e) {
481                 m->errorOut(e, "RemoveGroupsCommand", "readName");
482                 exit(1);
483         }
484 }
485
486 //**********************************************************************************************************************
487 int RemoveGroupsCommand::readGroup(){
488         try {
489                 string thisOutputDir = outputDir;
490                 if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
491                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
492                 
493                 ofstream out;
494                 m->openOutputFile(outputFileName, out);
495                 
496                 ifstream in;
497                 m->openInputFile(groupfile, in);
498                 string name, group;
499                 
500                 bool wroteSomething = false;
501                 
502                 while(!in.eof()){
503                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
504                         
505                         in >> name;                             //read from first column
506                         in >> group;                    //read from second column
507                         
508                         //if this name is in the accnos file
509                         if (names.count(name) == 0) {
510                                 wroteSomething = true;
511                                 out << name << '\t' << group << endl;
512                         }
513                         
514                         m->gobble(in);
515                 }
516                 in.close();
517                 out.close();
518                 
519                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
520                 outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
521                 
522                 return 0;
523         }
524         catch(exception& e) {
525                 m->errorOut(e, "RemoveGroupsCommand", "readGroup");
526                 exit(1);
527         }
528 }
529 //**********************************************************************************************************************
530 int RemoveGroupsCommand::readTax(){
531         try {
532                 string thisOutputDir = outputDir;
533                 if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
534                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
535                 ofstream out;
536                 m->openOutputFile(outputFileName, out);
537                 
538                 ifstream in;
539                 m->openInputFile(taxfile, in);
540                 string name, tax;
541                 
542                 bool wroteSomething = false;
543                 
544                 while(!in.eof()){
545                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
546                         
547                         in >> name;                             //read from first column
548                         in >> tax;                      //read from second column
549                         
550                         //if this name is in the accnos file
551                         if (names.count(name) == 0) {
552                                 wroteSomething = true;
553                                 out << name << '\t' << tax << endl;
554                         }
555                         
556                         m->gobble(in);
557                 }
558                 in.close();
559                 out.close();
560                 
561                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
562                 outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
563                 
564                 return 0;
565         }
566         catch(exception& e) {
567                 m->errorOut(e, "RemoveGroupsCommand", "readTax");
568                 exit(1);
569         }
570 }
571 //**********************************************************************************************************************
572 void RemoveGroupsCommand::readAccnos(){
573         try {
574                 Groups.clear();
575                 
576                 ifstream in;
577                 m->openInputFile(accnosfile, in);
578                 string name;
579                 
580                 while(!in.eof()){
581                         in >> name;
582                         
583                         Groups.push_back(name);
584                         
585                         m->gobble(in);
586                 }
587                 in.close();             
588                 
589         }
590         catch(exception& e) {
591                 m->errorOut(e, "RemoveGroupsCommand", "readAccnos");
592                 exit(1);
593         }
594 }
595 //**********************************************************************************************************************
596 int RemoveGroupsCommand::fillNames(){
597         try {
598                 vector<string> seqs = groupMap->getNamesSeqs();
599                 
600                 for (int i = 0; i < seqs.size(); i++) {
601                         
602                         if (m->control_pressed) { return 0; }
603                         
604                         string group = groupMap->getGroup(seqs[i]);
605                         
606                         if (m->inUsersGroups(group, Groups)) {
607                                 names.insert(seqs[i]);
608                         }
609                 }
610                 
611                 return 0;
612         }
613         catch(exception& e) {
614                 m->errorOut(e, "RemoveGroupsCommand", "fillNames");
615                 exit(1);
616         }
617 }
618
619 //**********************************************************************************************************************
620
621
622