]> git.donarmstrong.com Git - mothur.git/blob - catchallcommand.cpp
8e29d6294c942369b178eea7b3cf6a0c3e7ba272
[mothur.git] / catchallcommand.cpp
1 /*
2  *  catchallcommand.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 5/11/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "catchallcommand.h"
11 #include "globaldata.hpp"
12
13 //**********************************************************************************************************************
14 vector<string> CatchAllCommand::getValidParameters(){   
15         try {
16                 string AlignArray[] =  {"sabund","shared","label","inputdir","outputdir"};
17                 vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
18                 return myArray;
19         }
20         catch(exception& e) {
21                 m->errorOut(e, "CatchAllCommand", "getValidParameters");
22                 exit(1);
23         }
24 }
25 //**********************************************************************************************************************
26 CatchAllCommand::CatchAllCommand(){     
27         try {
28                 //initialize outputTypes
29                 vector<string> tempOutNames;
30                 outputTypes["csv"] = tempOutNames;
31                 outputTypes["summary"] = tempOutNames;
32         }
33         catch(exception& e) {
34                 m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
35                 exit(1);
36         }
37 }
38 //**********************************************************************************************************************
39 vector<string> CatchAllCommand::getRequiredParameters(){        
40         try {
41                 string AlignArray[] =  {"sabund","shared","or"};
42                 vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
43                 return myArray;
44         }
45         catch(exception& e) {
46                 m->errorOut(e, "CatchAllCommand", "getRequiredParameters");
47                 exit(1);
48         }
49 }
50 //**********************************************************************************************************************
51 vector<string> CatchAllCommand::getRequiredFiles(){     
52         try {
53                 vector<string> myArray;
54                 return myArray;
55         }
56         catch(exception& e) {
57                 m->errorOut(e, "CatchAllCommand", "getRequiredFiles");
58                 exit(1);
59         }
60 }
61 /**************************************************************************************/
62 CatchAllCommand::CatchAllCommand(string option)  {      
63         try {
64                 globaldata = GlobalData::getInstance();
65                 abort = false;
66                 allLines = 1;
67                 
68                 //allow user to run help
69                 if(option == "help") { help(); abort = true; }
70                 
71                 else {
72                         //valid paramters for this command
73                         string Array[] =  {"shared","sabund","label","inputdir","outputdir"};
74                         vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
75                         
76                         OptionParser parser(option);
77                         map<string,string> parameters = parser.getParameters();
78                         
79                         ValidParameters validParameter;
80                         map<string, string>::iterator it;
81                 
82                         //check to make sure all parameters are valid for command
83                         for (it = parameters.begin(); it != parameters.end(); it++) { 
84                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
85                         }
86                         
87                         //initialize outputTypes
88                         vector<string> tempOutNames;
89                         outputTypes["csv"] = tempOutNames;
90                         outputTypes["summary"] = tempOutNames;
91                         
92                         //if the user changes the input directory command factory will send this info to us in the output parameter 
93                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
94                         if (inputDir == "not found"){   inputDir = "";          }
95                         else {
96                                 string path;
97                                 it = parameters.find("sabund");
98                                 //user has given a template file
99                                 if(it != parameters.end()){ 
100                                         path = m->hasPath(it->second);
101                                         //if the user has not given a path then, add inputdir. else leave path alone.
102                                         if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
103                                 }
104                                 
105                                 it = parameters.find("shared");
106                                 //user has given a template file
107                                 if(it != parameters.end()){ 
108                                         path = m->hasPath(it->second);
109                                         //if the user has not given a path then, add inputdir. else leave path alone.
110                                         if (path == "") {       parameters["shared"] = inputDir + it->second;           }
111                                 }
112                         }
113
114                         //check for required parameters
115                         sabundfile = validParameter.validFile(parameters, "sabund", true);
116                         if (sabundfile == "not open") { sabundfile = ""; abort = true; }
117                         else if (sabundfile == "not found") { sabundfile = "";  }
118                         else { globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
119                         
120                         sharedfile = validParameter.validFile(parameters, "shared", true);
121                         if (sharedfile == "not open") { sharedfile = ""; abort = true; }
122                         else if (sharedfile == "not found") { sharedfile = "";   }
123                         
124                         string label = validParameter.validFile(parameters, "label", false);                    
125                         if (label == "not found") { label = ""; }
126                         else { 
127                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
128                                 else { allLines = 1;  }
129                         }
130                 
131                         if ((sharedfile == "") && (sabundfile == "")) { m->mothurOut("You must provide a sabund or shared file for the catchall command."); m->mothurOutEndLine(); abort=true; }
132
133                         //if the user changes the output directory command factory will send this info to us in the output parameter 
134                         outputDir = validParameter.validFile(parameters, "outputdir", false);           
135                         if (outputDir == "not found"){  
136                                 if (sabundfile != "") {  outputDir = m->hasPath(sabundfile); }
137                                 else { outputDir = m->hasPath(sharedfile); }
138                         }
139                 }
140
141         }
142         catch(exception& e) {
143                 m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
144                 exit(1);
145         }
146 }
147 //**********************************************************************************************************************
148
149 void CatchAllCommand::help(){
150         try {
151                 m->mothurOut("The catchall command interfaces mothur with the catchall program written by Linda Woodard, Sean Connolly and John Bunge.\n");
152                 m->mothurOut("For more information about catchall refer to http://www.northeastern.edu/catchall/index.html \n");
153                 m->mothurOut("The catchall executable must be in the same folder as your mothur executable. \n");
154                 m->mothurOut("If you are a MAC or Linux user you must also have installed mono, a link to mono is on the webpage. \n");
155                 m->mothurOut("The catchall command parameters are shared, sabund and label.  shared or sabund is required. \n");
156                 m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
157                 m->mothurOut("The catchall command should be in the following format: \n");
158                 m->mothurOut("catchall(sabund=yourSabundFile) \n");
159                 m->mothurOut("Example: catchall(sabund=abrecovery.fn.sabund) \n");      
160         }
161         catch(exception& e) {
162                 m->errorOut(e, "CatchAllCommand", "help");
163                 exit(1);
164         }
165 }
166
167 /**************************************************************************************/
168 int CatchAllCommand::execute() {        
169         try {
170                 
171                 if (abort == true) { return 0; }
172                 
173                 //prepare full output directory
174                 outputDir = m->getFullPathName(outputDir);
175                 
176                 //get location of catchall
177                 GlobalData* globaldata = GlobalData::getInstance();
178                 path = globaldata->argv;
179                 path = path.substr(0, (path.find_last_of('m')));
180                 path = m->getFullPathName(path);
181
182                 string catchAllCommandExe = ""; 
183                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
184                         catchAllCommandExe += "mono " + path + "CatchAllcmdL.exe ";
185                 #else
186                         catchAllCommandExe += "\"" + path + "CatchAllcmdW.exe\"" + " ";
187                 #endif
188                 
189                 vector<string> inputFileNames;
190                 if (sharedfile != "") { inputFileNames = parseSharedFile(sharedfile);  globaldata->setFormat("sabund");  }
191                 else {  inputFileNames.push_back(sabundfile);  }                
192                 
193                 for (int p = 0; p < inputFileNames.size(); p++) {
194                         if (inputFileNames.size() > 1) {
195                                 m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
196                         }
197                         
198                         InputData* input = new InputData(inputFileNames[p], "sabund");
199                         SAbundVector* sabund = input->getSAbundVector();
200                         string lastLabel = sabund->getLabel();
201                                                         
202                         set<string> processedLabels;
203                         set<string> userLabels = labels;
204                         
205                         string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "catchall.summary";
206                         summaryfilename = m->getFullPathName(summaryfilename);
207                         
208                         ofstream out;
209                         m->openOutputFile(summaryfilename, out);        
210                         
211                         out << "label\tmodel\testimate\tlci\tuci" << endl;
212                         
213                         //for each label the user selected
214                         while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
215
216                                                 
217                                 if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
218                                                 m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
219                                                 
220                                                 //create catchall input file from mothur's inputfile
221                                                 string filename = process(sabund, inputFileNames[p]);
222                                                 string outputPath = m->getPathName(filename);
223                                         
224                                                 //create system command
225                                                 string catchAllCommand = "";
226                                                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
227                                                         catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
228                                                 #else
229                                                         if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
230                                                         catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
231                                                         //wrap entire string in ""
232                                                         catchAllCommand = "\"" + catchAllCommand + "\"";
233                                                 #endif
234                                                                                 //run catchall
235                                                 system(catchAllCommand.c_str());
236                                         
237                                                 remove(filename.c_str());
238                                         
239                                                 filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
240                                         
241                                                 outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
242                                                 outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
243                                                 outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
244                                                 outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
245                                         
246                                                 createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
247                                                                                         
248                                                 if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str());    }  delete input;  delete sabund;  return 0; }
249
250                                                 processedLabels.insert(sabund->getLabel());
251                                                 userLabels.erase(sabund->getLabel());
252                                 }
253                                 
254                                 if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
255                                                 string saveLabel = sabund->getLabel();
256                                                 
257                                                 delete sabund;          
258                                                 sabund = (input->getSAbundVector(lastLabel));
259                                                 
260                                                 m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
261                                                 
262
263                                                 //create catchall input file from mothur's inputfile
264                                                 string filename = process(sabund, inputFileNames[p]);
265                                                 string outputPath = m->getPathName(filename);
266                                                 
267                                                 //create system command
268                                                 string catchAllCommand = "";
269                                                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
270                                                         catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
271                                                 #else
272                                                         if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
273                                                         catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
274                                                         catchAllCommand = "\"" + catchAllCommand + "\"";
275                                                 #endif
276
277                                                 //run catchall
278                                                 system(catchAllCommand.c_str());
279                                         
280                                                 remove(filename.c_str());
281                                         
282                                                 filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
283                                         
284                                                 outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
285                                                 outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
286                                                 outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
287                                                 outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
288                                         
289                                                 createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
290                                         
291                                                 if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str());    }  delete input;  delete sabund;  return 0; }
292
293                                                 processedLabels.insert(sabund->getLabel());
294                                                 userLabels.erase(sabund->getLabel());
295                                                 
296                                                 //restore real lastlabel to save below
297                                                 sabund->setLabel(saveLabel);
298                                 }
299                                 
300                                 
301                                 lastLabel = sabund->getLabel(); 
302                                 
303                                 delete sabund;          
304                                 sabund = (input->getSAbundVector());
305                         }
306                         
307                         //output error messages about any remaining user labels
308                         set<string>::iterator it;
309                         bool needToRun = false;
310                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
311                                 m->mothurOut("Your file does not include the label " + *it); 
312                                 if (processedLabels.count(lastLabel) != 1) {
313                                         m->mothurOut(". I will use " + lastLabel + ".");  m->mothurOutEndLine();
314                                         needToRun = true;
315                                 }else {
316                                         m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
317                                 }
318                         }
319                         
320                         //run last label if you need to
321                         if (needToRun == true)  {
322                                 if (sabund != NULL) {   delete sabund;  }
323                                 sabund = (input->getSAbundVector(lastLabel));
324                                 
325                                 m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
326                                 
327                                 //create catchall input file from mothur's inputfile
328                                 string filename = process(sabund, inputFileNames[p]);
329                                 string outputPath = m->getPathName(filename);
330                                 
331                                 //create system command
332                                 string catchAllCommand = "";
333                                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
334                                         catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
335                                 #else
336                                         if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
337                                         catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
338                                         catchAllCommand = "\"" + catchAllCommand + "\"";
339                                 #endif
340                                 
341                                 //run catchall
342                                 system(catchAllCommand.c_str());
343                                 
344                                 remove(filename.c_str());
345                                 
346                                 filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
347                                 
348                                 outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
349                                 outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
350                                 outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
351                                 outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");        
352                                 
353                                 createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
354                                 
355                                 delete sabund;
356                         }
357                         
358                         out.close();
359                         delete input; 
360                         
361                         if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } return 0; }
362                                 
363                 }
364                 
365                 if (sharedfile == "") {  
366                         string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[0])) + "catchall.summary";
367                         summaryfilename = m->getFullPathName(summaryfilename);
368                         outputNames.push_back(summaryfilename); outputTypes["summary"].push_back(summaryfilename);
369                 }else { //combine summaries
370                         vector<string> sumNames;
371                         for (int i = 0; i < inputFileNames.size(); i++) {
372                                 sumNames.push_back(m->getFullPathName(outputDir + m->getRootName(m->getSimpleName(inputFileNames[i])) + "catchall.summary"));
373                         }
374                         string summaryfilename = combineSummmary(sumNames);
375                         outputNames.push_back(summaryfilename); outputTypes["summary"].push_back(summaryfilename);
376                 }
377                 
378                 m->mothurOutEndLine();
379                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
380                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
381                 m->mothurOutEndLine();
382                 
383
384                 return 0;
385         }
386         catch(exception& e) {
387                 m->errorOut(e, "CatchAllCommand", "execute");
388                 exit(1);
389         }
390 }
391 //**********************************************************************************************************************
392 string CatchAllCommand::process(SAbundVector* sabund, string file1) {
393         try {
394                 string filename = outputDir + m->getRootName(m->getSimpleName(file1)) + sabund->getLabel() + ".csv";
395                 filename = m->getFullPathName(filename);
396         
397                 ofstream out;
398                 m->openOutputFile(filename, out);
399                 
400                 for (int i = 1; i <= sabund->getMaxRank(); i++) {
401                         int temp = sabund->get(i);
402                         
403                         if (temp != 0) {
404                                 out << i << "," << temp << endl;
405                         }
406                 }
407                 out.close();
408                 
409                 return filename;
410         
411         }
412         catch(exception& e) {
413                 m->errorOut(e, "CatchAllCommand", "process");
414                 exit(1);
415         }
416 }
417 //*********************************************************************************************************************
418 string CatchAllCommand::combineSummmary(vector<string>& outputNames) {
419         try {
420                 
421                 ofstream out;
422                 string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "catchall.summary";
423                 
424                 //open combined file
425                 m->openOutputFile(combineFileName, out);
426                 
427                 out << "label\tgroup\tmodel\testimate\tlci\tuci" << endl;
428                 
429                 //open each groups summary file
430                 string newLabel = "";
431                 int numLines = 0;
432                 map<string, vector<string> > files;
433                 for (int i=0; i<outputNames.size(); i++) {
434                         vector<string> thisFilesLines;
435                         
436                         ifstream temp;
437                         m->openInputFile(outputNames[i], temp);
438                         
439                         //read through first line - labels
440                         m->getline(temp);                       
441                         m->gobble(temp);
442                         
443                         //for each label
444                         while (!temp.eof()) {
445                                 
446                                 string thisLine = "";
447                                 string tempLabel;
448                                 
449                                 for (int j = 0; j < 5; j++) {  
450                                         temp >> tempLabel; 
451                                         
452                                         //save for later
453                                         if (j == 1) { thisLine += groups[i] + "\t" + tempLabel + "\t";  }
454                                         else{  thisLine += tempLabel + "\t";    }
455                                 }
456                                 
457                                 thisLine += "\n";
458                                 
459                                 thisFilesLines.push_back(thisLine);
460                                 
461                                 m->gobble(temp);
462                         }
463                         
464                         files[outputNames[i]] = thisFilesLines;
465                         
466                         numLines = thisFilesLines.size();
467                         
468                         temp.close();
469                         remove(outputNames[i].c_str());
470                 }
471                 
472                 //for each label
473                 for (int k = 0; k < numLines; k++) {
474                         
475                         //grab summary data for each group
476                         for (int i=0; i<outputNames.size(); i++) {
477                                 out << files[outputNames[i]][k];
478                         }
479                 }       
480                 
481                 
482                 out.close();
483                 
484                 //return combine file name
485                 return combineFileName;
486                 
487         }
488         catch(exception& e) {
489                 m->errorOut(e, "CatchAllCommand", "combineSummmary");
490                 exit(1);
491         }
492 }
493 //**********************************************************************************************************************
494 int CatchAllCommand::createSummaryFile(string file1, string label, ofstream& out) {
495         try {
496                 
497                 ifstream in;
498                 m->openInputFile(file1, in);
499                 
500                 if (!in.eof()) {
501                         
502                         string header = m->getline(in); m->gobble(in);
503                         
504                         int pos = header.find("Total Number of Observed Species =");
505                         string numString = "";
506                         
507                         
508                         if (pos == string::npos) { m->mothurOut("[ERROR]: cannot parse " + file1); m->mothurOutEndLine(); }
509                         else {
510                                 //pos will be the position of the T in total, so we want to count to the position of =
511                                 pos += 34;
512                                 char c=header[pos];
513                                 while (c != ','){
514                                         if (c != ' ') {
515                                                 numString += c;
516                                         }
517                                         pos++;
518                                         c=header[pos];
519                                         
520                                         //sanity check
521                                         if (pos > header.length()) { m->mothurOut("Cannot find number of OTUs in " + file1); m->mothurOutEndLine(); in.close(); return 0; }
522                                 }
523                         }
524                                                                                                                           
525                         string firstline = m->getline(in); m->gobble(in);
526                         vector<string> values;
527                         m->splitAtComma(firstline, values);
528                         
529                         values.pop_back(); //last value is always a blank string since the last character in the line is always a ','
530                         
531                         if (values.size() == 1) { //grab next line if firstline didn't have what you wanted
532                                 string secondline = m->getline(in); m->gobble(in);
533                                 values.clear();
534                                 m->splitAtComma(secondline, values);
535                                 
536                                 values.pop_back(); //last value is always a blank string since the last character in the line is always a ','
537                         }
538                         
539                         if (values.size() == 1) { //still not what we wanted fill values with numOTUs
540                                 values.resize(8, "");
541                                 values[1] = "Sobs";
542                                 values[4] = numString;
543                                 values[6] = numString;
544                                 values[7] = numString;
545                         }
546                         
547                         if (values.size() < 8) { values.resize(8, ""); }
548                         
549                         out << label << '\t' << values[1] << '\t' << values[4] << '\t' << values[6] << '\t' << values[7] << endl;
550                 }
551                 
552                 in.close();
553                 
554                 return 0;
555                 
556         }
557         catch(exception& e) {
558                 m->errorOut(e, "CatchAllCommand", "createSummaryFile");
559                 exit(1);
560         }
561 }
562 //**********************************************************************************************************************
563 vector<string> CatchAllCommand::parseSharedFile(string filename) {
564         try {
565                 vector<string> filenames;
566                 
567                 //read first line
568                 InputData* input = new InputData(filename, "sharedfile");
569                 vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
570                 
571                 string sharedFileRoot = outputDir + m->getRootName(m->getSimpleName(filename));
572                 
573                 //clears file before we start to write to it below
574                 for (int i=0; i<lookup.size(); i++) {
575                         remove((sharedFileRoot + lookup[i]->getGroup() + ".sabund").c_str());
576                         filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
577                         groups.push_back(lookup[i]->getGroup());
578                 }
579                 
580                 while(lookup[0] != NULL) {
581                         
582                         for (int i = 0; i < lookup.size(); i++) {
583                                 SAbundVector sav = lookup[i]->getSAbundVector();
584                                 ofstream out;
585                                 m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".sabund", out);
586                                 sav.print(out);
587                                 out.close();
588                         }
589                         
590                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
591                         lookup = input->getSharedRAbundVectors();
592                 }
593                 
594                 delete input;
595                 
596                 return filenames;
597         }
598         catch(exception& e) {
599                 m->errorOut(e, "CatchAllCommand", "parseSharedFile");
600                 exit(1);
601         }
602 }
603 /**************************************************************************************/