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