]> git.donarmstrong.com Git - mothur.git/blob - removegroupscommand.cpp
rewrote metastats command in c++, added mothurRemove function to handle ~ error....
[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                         else { m->setAccnosFile(accnosfile); }
170                         
171                         fastafile = validParameter.validFile(parameters, "fasta", true);
172                         if (fastafile == "not open") { abort = true; }
173                         else if (fastafile == "not found") {  fastafile = "";  }        
174                         else { m->setFastaFile(fastafile); }
175                         
176                         namefile = validParameter.validFile(parameters, "name", true);
177                         if (namefile == "not open") { abort = true; }
178                         else if (namefile == "not found") {  namefile = "";  }  
179                         else { m->setNameFile(namefile); }
180                         
181                         groupfile = validParameter.validFile(parameters, "group", true);
182                         if (groupfile == "not open") { abort = true; }
183                         else if (groupfile == "not found") {            
184                                 //if there is a current group file, use it
185                                 groupfile = m->getGroupFile(); 
186                                 if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
187                                 else {  m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
188                         }else { m->setGroupFile(groupfile); }   
189                         
190                         listfile = validParameter.validFile(parameters, "list", true);
191                         if (listfile == "not open") { abort = true; }
192                         else if (listfile == "not found") {  listfile = "";  }
193                         else { m->setListFile(listfile); }
194                         
195                         taxfile = validParameter.validFile(parameters, "taxonomy", true);
196                         if (taxfile == "not open") { abort = true; }
197                         else if (taxfile == "not found") {  taxfile = "";  }
198                         else { m->setTaxonomyFile(taxfile); }
199                         
200                         groups = validParameter.validFile(parameters, "groups", false);                 
201                         if (groups == "not found") { groups = ""; }
202                         else { 
203                                 m->splitAtDash(groups, Groups);
204                         }
205                         
206                         if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
207                         
208                         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; }
209                 }
210                 
211         }
212         catch(exception& e) {
213                 m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
214                 exit(1);
215         }
216 }
217 //**********************************************************************************************************************
218
219 int RemoveGroupsCommand::execute(){
220         try {
221                 
222                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
223                 
224                 groupMap = new GroupMap(groupfile);
225                 groupMap->readMap();
226                 
227                 //get groups you want to remove
228                 if (accnosfile != "") { readAccnos(); }
229                 
230                 //make sure groups are valid
231                 //takes care of user setting groupNames that are invalid or setting groups=all
232                 SharedUtil* util = new SharedUtil();
233                 util->setGroups(Groups, groupMap->namesOfGroups);
234                 delete util;
235                 
236                 //fill names with names of sequences that are from the groups we want to remove 
237                 fillNames();
238                 
239                 if (m->control_pressed) { delete groupMap; return 0; }
240                 
241                 //read through the correct file and output lines you want to keep
242                 if (namefile != "")                     {               readName();             }
243                 if (fastafile != "")            {               readFasta();    }
244                 if (groupfile != "")            {               readGroup();    }
245                 if (listfile != "")                     {               readList();             }
246                 if (taxfile != "")                      {               readTax();              }
247                 
248                 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
249                 
250                 m->mothurOut("Removed " + toString(names.size()) + " sequences. From the groups: "); m->mothurOutEndLine();
251                 for (int i = 0; i < Groups.size(); i++) {       m->mothurOut(Groups[i]); m->mothurOut("\t" + toString(groupMap->getNumSeqs(Groups[i]))); m->mothurOutEndLine(); }
252                 m->mothurOutEndLine();
253                 
254                 if (outputNames.size() != 0) {
255                         m->mothurOutEndLine();
256                         m->mothurOut("Output File names: "); m->mothurOutEndLine();
257                         for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
258                         m->mothurOutEndLine();
259                         
260                         //set fasta file as new current fastafile
261                         string current = "";
262                         itTypes = outputTypes.find("fasta");
263                         if (itTypes != outputTypes.end()) {
264                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
265                         }
266                         
267                         itTypes = outputTypes.find("name");
268                         if (itTypes != outputTypes.end()) {
269                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
270                         }
271                         
272                         itTypes = outputTypes.find("group");
273                         if (itTypes != outputTypes.end()) {
274                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
275                         }
276                         
277                         itTypes = outputTypes.find("list");
278                         if (itTypes != outputTypes.end()) {
279                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
280                         }
281                         
282                         itTypes = outputTypes.find("taxonomy");
283                         if (itTypes != outputTypes.end()) {
284                                 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
285                         }
286                 }
287                 
288                 return 0;               
289         }
290         
291         catch(exception& e) {
292                 m->errorOut(e, "RemoveGroupsCommand", "execute");
293                 exit(1);
294         }
295 }
296
297 //**********************************************************************************************************************
298 int RemoveGroupsCommand::readFasta(){
299         try {
300                 string thisOutputDir = outputDir;
301                 if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
302                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
303                 
304                 ofstream out;
305                 m->openOutputFile(outputFileName, out);
306                 
307                 ifstream in;
308                 m->openInputFile(fastafile, in);
309                 string name;
310                 
311                 bool wroteSomething = false;
312                 
313                 while(!in.eof()){
314                         if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
315                         
316                         Sequence currSeq(in);
317                         name = currSeq.getName();
318                         
319                         if (name != "") {
320                                 //if this name is in the accnos file
321                                 if (names.count(name) == 0) {
322                                         wroteSomething = true;
323                                         
324                                         currSeq.printSequence(out);
325                                 }
326                         }
327                         m->gobble(in);
328                 }
329                 in.close();     
330                 out.close();
331                 
332                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
333                 outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
334                 
335                 return 0;
336                 
337         }
338         catch(exception& e) {
339                 m->errorOut(e, "RemoveGroupsCommand", "readFasta");
340                 exit(1);
341         }
342 }
343
344 //**********************************************************************************************************************
345 int RemoveGroupsCommand::readList(){
346         try {
347                 string thisOutputDir = outputDir;
348                 if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
349                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
350                 
351                 ofstream out;
352                 m->openOutputFile(outputFileName, out);
353                 
354                 ifstream in;
355                 m->openInputFile(listfile, in);
356                 
357                 bool wroteSomething = false;
358                 
359                 while(!in.eof()){
360                         //read in list vector
361                         ListVector list(in);
362                         
363                         //make a new list vector
364                         ListVector newList;
365                         newList.setLabel(list.getLabel());
366                         
367                         //for each bin
368                         for (int i = 0; i < list.getNumBins(); i++) {
369                                 if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
370                                 
371                                 //parse out names that are in accnos file
372                                 string binnames = list.get(i);
373                                 
374                                 string newNames = "";
375                                 while (binnames.find_first_of(',') != -1) { 
376                                         string name = binnames.substr(0,binnames.find_first_of(','));
377                                         binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
378                                         
379                                         //if that name is in the .accnos file, add it
380                                         if (names.count(name) == 0) {  newNames += name + ",";  }
381                                 }
382                                 
383                                 //get last name
384                                 if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
385                                 
386                                 //if there are names in this bin add to new list
387                                 if (newNames != "") {  
388                                         newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
389                                         newList.push_back(newNames);    
390                                 }
391                         }
392                         
393                         //print new listvector
394                         if (newList.getNumBins() != 0) {
395                                 wroteSomething = true;
396                                 newList.print(out);
397                         }
398                         
399                         m->gobble(in);
400                 }
401                 in.close();     
402                 out.close();
403                 
404                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
405                 outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
406                 
407                 return 0;
408                 
409         }
410         catch(exception& e) {
411                 m->errorOut(e, "RemoveGroupsCommand", "readList");
412                 exit(1);
413         }
414 }
415 //**********************************************************************************************************************
416 int RemoveGroupsCommand::readName(){
417         try {
418                 string thisOutputDir = outputDir;
419                 if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
420                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
421                 
422                 ofstream out;
423                 m->openOutputFile(outputFileName, out);
424                 
425                 ifstream in;
426                 m->openInputFile(namefile, in);
427                 string name, firstCol, secondCol;
428                 
429                 bool wroteSomething = false;
430                 
431                 while(!in.eof()){
432                         if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
433                         
434                         in >> firstCol;         m->gobble(in);          
435                         in >> secondCol;                        
436                         
437                         vector<string> parsedNames;
438                         m->splitAtComma(secondCol, parsedNames);
439                                                 
440                         vector<string> validSecond;  validSecond.clear();
441                         for (int i = 0; i < parsedNames.size(); i++) {
442                                 if (names.count(parsedNames[i]) == 0) {
443                                         validSecond.push_back(parsedNames[i]);
444                                 }
445                         }
446                         
447                         
448                         //if the name in the first column is in the set then print it and any other names in second column also in set
449                         if (names.count(firstCol) == 0) {
450                                 
451                                 wroteSomething = true;
452                                 
453                                 out << firstCol << '\t';
454                                 
455                                 //you know you have at least one valid second since first column is valid
456                                 for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
457                                 out << validSecond[validSecond.size()-1] << endl;
458                                 
459                                 //make first name in set you come to first column and then add the remaining names to second column
460                         }else {
461                                 
462                                 //you want part of this row
463                                 if (validSecond.size() != 0) {
464                                         
465                                         wroteSomething = true;
466                                         
467                                         out << validSecond[0] << '\t';
468                                         
469                                         //you know you have at least one valid second since first column is valid
470                                         for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
471                                         out << validSecond[validSecond.size()-1] << endl;
472                                 }
473                         }
474                         
475                         m->gobble(in);
476                 }
477                 in.close();
478                 out.close();
479                 
480                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
481                 outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
482                 
483                 return 0;
484         }
485         catch(exception& e) {
486                 m->errorOut(e, "RemoveGroupsCommand", "readName");
487                 exit(1);
488         }
489 }
490
491 //**********************************************************************************************************************
492 int RemoveGroupsCommand::readGroup(){
493         try {
494                 string thisOutputDir = outputDir;
495                 if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
496                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
497                 
498                 ofstream out;
499                 m->openOutputFile(outputFileName, out);
500                 
501                 ifstream in;
502                 m->openInputFile(groupfile, in);
503                 string name, group;
504                 
505                 bool wroteSomething = false;
506                 
507                 while(!in.eof()){
508                         if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
509                         
510                         in >> name;                             //read from first column
511                         in >> group;                    //read from second column
512                         
513                         //if this name is in the accnos file
514                         if (names.count(name) == 0) {
515                                 wroteSomething = true;
516                                 out << name << '\t' << group << endl;
517                         }
518                         
519                         m->gobble(in);
520                 }
521                 in.close();
522                 out.close();
523                 
524                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
525                 outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
526                 
527                 return 0;
528         }
529         catch(exception& e) {
530                 m->errorOut(e, "RemoveGroupsCommand", "readGroup");
531                 exit(1);
532         }
533 }
534 //**********************************************************************************************************************
535 int RemoveGroupsCommand::readTax(){
536         try {
537                 string thisOutputDir = outputDir;
538                 if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
539                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
540                 ofstream out;
541                 m->openOutputFile(outputFileName, out);
542                 
543                 ifstream in;
544                 m->openInputFile(taxfile, in);
545                 string name, tax;
546                 
547                 bool wroteSomething = false;
548                 
549                 while(!in.eof()){
550                         if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
551                         
552                         in >> name;                             //read from first column
553                         in >> tax;                      //read from second column
554                         
555                         //if this name is in the accnos file
556                         if (names.count(name) == 0) {
557                                 wroteSomething = true;
558                                 out << name << '\t' << tax << endl;
559                         }
560                         
561                         m->gobble(in);
562                 }
563                 in.close();
564                 out.close();
565                 
566                 if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
567                 outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
568                 
569                 return 0;
570         }
571         catch(exception& e) {
572                 m->errorOut(e, "RemoveGroupsCommand", "readTax");
573                 exit(1);
574         }
575 }
576 //**********************************************************************************************************************
577 void RemoveGroupsCommand::readAccnos(){
578         try {
579                 Groups.clear();
580                 
581                 ifstream in;
582                 m->openInputFile(accnosfile, in);
583                 string name;
584                 
585                 while(!in.eof()){
586                         in >> name;
587                         
588                         Groups.push_back(name);
589                         
590                         m->gobble(in);
591                 }
592                 in.close();             
593                 
594         }
595         catch(exception& e) {
596                 m->errorOut(e, "RemoveGroupsCommand", "readAccnos");
597                 exit(1);
598         }
599 }
600 //**********************************************************************************************************************
601 int RemoveGroupsCommand::fillNames(){
602         try {
603                 vector<string> seqs = groupMap->getNamesSeqs();
604                 
605                 for (int i = 0; i < seqs.size(); i++) {
606                         
607                         if (m->control_pressed) { return 0; }
608                         
609                         string group = groupMap->getGroup(seqs[i]);
610                         
611                         if (m->inUsersGroups(group, Groups)) {
612                                 names.insert(seqs[i]);
613                         }
614                 }
615                 
616                 return 0;
617         }
618         catch(exception& e) {
619                 m->errorOut(e, "RemoveGroupsCommand", "fillNames");
620                 exit(1);
621         }
622 }
623
624 //**********************************************************************************************************************
625
626
627