]> git.donarmstrong.com Git - mothur.git/blob - rarefactcommand.cpp
added [ERROR] flag if command aborts
[mothur.git] / rarefactcommand.cpp
1 /*
2  *  rarefactcommand.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/2/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "rarefactcommand.h"
11 #include "ace.h"
12 #include "sobs.h"
13 #include "nseqs.h"
14 #include "chao1.h"
15 #include "bootstrap.h"
16 #include "simpson.h"
17 #include "simpsoneven.h"
18 #include "heip.h"
19 #include "smithwilson.h"
20 #include "invsimpson.h"
21 #include "npshannon.h"
22 #include "shannoneven.h"
23 #include "shannon.h"
24 #include "jackknife.h"
25 #include "coverage.h"
26
27 //**********************************************************************************************************************
28 vector<string> RareFactCommand::getValidParameters(){   
29         try {
30                 string Array[] =  {"iters","freq","label","calc","abund","processors","outputdir","inputdir"};
31                 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
32                 return myArray;
33         }
34         catch(exception& e) {
35                 m->errorOut(e, "RareFactCommand", "getValidParameters");
36                 exit(1);
37         }
38 }
39 //**********************************************************************************************************************
40 vector<string> RareFactCommand::getRequiredParameters(){        
41         try {
42                 vector<string> myArray;
43                 return myArray;
44         }
45         catch(exception& e) {
46                 m->errorOut(e, "RareFactCommand", "getRequiredParameters");
47                 exit(1);
48         }
49 }
50 //**********************************************************************************************************************
51 vector<string> RareFactCommand::getRequiredFiles(){     
52         try {
53                 string AlignArray[] =  {"shared","list","rabund","sabund","or"};
54                 vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
55                 return myArray;
56         }
57         catch(exception& e) {
58                 m->errorOut(e, "RareFactCommand", "getRequiredFiles");
59                 exit(1);
60         }
61 }
62 //**********************************************************************************************************************
63 RareFactCommand::RareFactCommand(){     
64         try {
65                 abort = true; calledHelp = true; 
66                 vector<string> tempOutNames;
67                 outputTypes["rarefaction"] = tempOutNames;
68                 outputTypes["r_chao"] = tempOutNames;
69                 outputTypes["r_ace"] = tempOutNames;
70                 outputTypes["r_jack"] = tempOutNames;
71                 outputTypes["r_shannon"] = tempOutNames;
72                 outputTypes["r_shannoneven"] = tempOutNames;
73                 outputTypes["r_heip"] = tempOutNames;
74                 outputTypes["r_smithwilson"] = tempOutNames;
75                 outputTypes["r_npshannon"] = tempOutNames;
76                 outputTypes["r_simpson"] = tempOutNames;
77                 outputTypes["r_simpsoneven"] = tempOutNames;
78                 outputTypes["r_invsimpson"] = tempOutNames;
79                 outputTypes["r_bootstrap"] = tempOutNames;
80                 outputTypes["r_coverage"] = tempOutNames;
81                 outputTypes["r_nseqs"] = tempOutNames;
82         }
83         catch(exception& e) {
84                 m->errorOut(e, "RareFactCommand", "RareFactCommand");
85                 exit(1);
86         }
87 }
88 //**********************************************************************************************************************
89 RareFactCommand::RareFactCommand(string option)  {
90         try {
91                 globaldata = GlobalData::getInstance();
92                 abort = false; calledHelp = false;   
93                 allLines = 1;
94                 labels.clear();
95                 Estimators.clear();
96                                 
97                 //allow user to run help
98                 if(option == "help") { validCalculator = new ValidCalculators(); help(); delete validCalculator; abort = true; calledHelp = true; }
99                 
100                 else {
101                         //valid paramters for this command
102                         string Array[] =  {"iters","freq","label","calc","abund","processors","outputdir","inputdir"};
103                         vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
104                         
105                         OptionParser parser(option);
106                         map<string,string> parameters = parser.getParameters();
107                         
108                         ValidParameters validParameter;
109                 
110                         //check to make sure all parameters are valid for command
111                         for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
112                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
113                         }
114                         
115                         //initialize outputTypes
116                         vector<string> tempOutNames;
117                         outputTypes["rarefaction"] = tempOutNames;
118                         outputTypes["r_chao"] = tempOutNames;
119                         outputTypes["r_ace"] = tempOutNames;
120                         outputTypes["r_jack"] = tempOutNames;
121                         outputTypes["r_shannon"] = tempOutNames;
122                         outputTypes["r_shannoneven"] = tempOutNames;
123                         outputTypes["r_heip"] = tempOutNames;
124                         outputTypes["r_smithwilson"] = tempOutNames;
125                         outputTypes["r_npshannon"] = tempOutNames;
126                         outputTypes["r_simpson"] = tempOutNames;
127                         outputTypes["r_simpsoneven"] = tempOutNames;
128                         outputTypes["r_invsimpson"] = tempOutNames;
129                         outputTypes["r_bootstrap"] = tempOutNames;
130                         outputTypes["r_coverage"] = tempOutNames;
131                         outputTypes["r_nseqs"] = tempOutNames;
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);           if (outputDir == "not found"){  
135                                 outputDir = ""; 
136                                 outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it       
137                         }
138
139                         //make sure the user has already run the read.otu command
140                         if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund, rabund or shared file before you can use the rarefact.single command."); m->mothurOutEndLine(); abort = true; }
141                         
142                         //check for optional parameter and set defaults
143                         // ...at some point should added some additional type checking...
144                         label = validParameter.validFile(parameters, "label", false);                   
145                         if (label == "not found") { label = ""; }
146                         else { 
147                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
148                                 else { allLines = 1;  }
149                         }
150                         
151                         //if the user has not specified any labels use the ones from read.otu
152                         if(label == "") {  
153                                 allLines = globaldata->allLines; 
154                                 labels = globaldata->labels; 
155                         }
156                                 
157                         calc = validParameter.validFile(parameters, "calc", false);                     
158                         if (calc == "not found") { calc = "sobs";  }
159                         else { 
160                                  if (calc == "default")  {  calc = "sobs";  }
161                         }
162                         m->splitAtDash(calc, Estimators);
163
164                         string temp;
165                         temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
166                         convert(temp, freq); 
167                         
168                         temp = validParameter.validFile(parameters, "abund", false);                    if (temp == "not found") { temp = "10"; }
169                         convert(temp, abund); 
170                         
171                         temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
172                         convert(temp, nIters); 
173                         
174                         temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = "1";                             }
175                         convert(temp, processors);
176                 }
177                 
178         }
179         catch(exception& e) {
180                 m->errorOut(e, "RareFactCommand", "RareFactCommand");
181                 exit(1);
182         }
183 }
184 //**********************************************************************************************************************
185
186 void RareFactCommand::help(){
187         try {
188                 m->mothurOut("The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n");
189                 m->mothurOut("The rarefaction.single command can be executed after a successful cluster command.  It will use the .list file from the output of the cluster.\n");
190                 m->mothurOut("The rarefaction.single command parameters are label, iters, freq, calc, processors and abund.  No parameters are required. \n");
191                 m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n");
192                 m->mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n");
193                 m->mothurOut("The rarefaction.single command should be in the following format: \n");
194                 m->mothurOut("rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n");
195                 m->mothurOut("Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n");
196                 m->mothurOut("The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness.\n");
197                 validCalculator->printCalc("rarefaction", cout);
198                 m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
199                 m->mothurOut("Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n\n");
200         }
201         catch(exception& e) {
202                 m->errorOut(e, "RareFactCommand", "help");
203                 exit(1);
204         }
205 }
206
207 //**********************************************************************************************************************
208
209 RareFactCommand::~RareFactCommand(){}
210
211 //**********************************************************************************************************************
212
213 int RareFactCommand::execute(){
214         try {
215         
216                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
217                 
218                 string hadShared = "";
219                 if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
220                 else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
221                                 
222                 if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
223                 
224                 for (int p = 0; p < inputFileNames.size(); p++) {
225                         
226                         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
227                         globaldata->inputFileName = inputFileNames[p];
228                         
229                         if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
230                         
231                         if (inputFileNames.size() > 1) {
232                                 m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
233                         }
234                         int i;
235                         validCalculator = new ValidCalculators();
236                         
237                         
238                         for (i=0; i<Estimators.size(); i++) {
239                                 if (validCalculator->isValidCalculator("rarefaction", Estimators[i]) == true) { 
240                                         if (Estimators[i] == "sobs") { 
241                                                 rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
242                                                 outputNames.push_back(fileNameRoot+"rarefaction"); outputTypes["rarefaction"].push_back(fileNameRoot+"rarefaction");
243                                         }else if (Estimators[i] == "chao") { 
244                                                 rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
245                                                 outputNames.push_back(fileNameRoot+"r_chao"); outputTypes["r_chao"].push_back(fileNameRoot+"r_chao");
246                                         }else if (Estimators[i] == "ace") { 
247                                                 if(abund < 5)
248                                                         abund = 10;
249                                                 rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
250                                                 outputNames.push_back(fileNameRoot+"r_ace"); outputTypes["r_ace"].push_back(fileNameRoot+"r_ace");
251                                         }else if (Estimators[i] == "jack") { 
252                                                 rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
253                                                 outputNames.push_back(fileNameRoot+"r_jack"); outputTypes["r_jack"].push_back(fileNameRoot+"r_jack");
254                                         }else if (Estimators[i] == "shannon") { 
255                                                 rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
256                                                 outputNames.push_back(fileNameRoot+"r_shannon"); outputTypes["r_shannon"].push_back(fileNameRoot+"r_shannon");
257                                         }else if (Estimators[i] == "shannoneven") { 
258                                                 rDisplays.push_back(new RareDisplay(new ShannonEven(), new ThreeColumnFile(fileNameRoot+"r_shannoneven")));
259                                                 outputNames.push_back(fileNameRoot+"r_shannoneven"); outputTypes["r_shannoneven"].push_back(fileNameRoot+"r_shannoneven");
260                                         }else if (Estimators[i] == "heip") { 
261                                                 rDisplays.push_back(new RareDisplay(new Heip(), new ThreeColumnFile(fileNameRoot+"r_heip")));
262                                                 outputNames.push_back(fileNameRoot+"r_heip"); outputTypes["r_heip"].push_back(fileNameRoot+"r_heip");
263                                         }else if (Estimators[i] == "smithwilson") { 
264                                                 rDisplays.push_back(new RareDisplay(new SmithWilson(), new ThreeColumnFile(fileNameRoot+"r_smithwilson")));
265                                                 outputNames.push_back(fileNameRoot+"r_smithwilson"); outputTypes["r_smithwilson"].push_back(fileNameRoot+"r_smithwilson");
266                                         }else if (Estimators[i] == "npshannon") { 
267                                                 rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
268                                                 outputNames.push_back(fileNameRoot+"r_npshannon"); outputTypes["r_npshannon"].push_back(fileNameRoot+"r_npshannon");
269                                         }else if (Estimators[i] == "simpson") { 
270                                                 rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
271                                                 outputNames.push_back(fileNameRoot+"r_simpson"); outputTypes["r_simpson"].push_back(fileNameRoot+"r_simpson");
272                                         }else if (Estimators[i] == "simpsoneven") { 
273                                                 rDisplays.push_back(new RareDisplay(new SimpsonEven(), new ThreeColumnFile(fileNameRoot+"r_simpsoneven")));
274                                                 outputNames.push_back(fileNameRoot+"r_simpsoneven"); outputTypes["r_simpsoneven"].push_back(fileNameRoot+"r_simpsoneven");
275                                         }else if (Estimators[i] == "invsimpson") { 
276                                                 rDisplays.push_back(new RareDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"r_invsimpson")));
277                                                 outputNames.push_back(fileNameRoot+"r_invsimpson"); outputTypes["r_invsimpson"].push_back(fileNameRoot+"r_invsimpson");
278                                         }else if (Estimators[i] == "bootstrap") { 
279                                                 rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
280                                                 outputNames.push_back(fileNameRoot+"r_bootstrap"); outputTypes["r_bootstrap"].push_back(fileNameRoot+"r_bootstrap");
281                                         }else if (Estimators[i] == "coverage") { 
282                                                 rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
283                                                 outputNames.push_back(fileNameRoot+"r_coverage"); outputTypes["r_coverage"].push_back(fileNameRoot+"r_coverage");
284                                         }else if (Estimators[i] == "nseqs") { 
285                                                 rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
286                                                 outputNames.push_back(fileNameRoot+"r_nseqs"); outputTypes["r_nseqs"].push_back(fileNameRoot+"r_nseqs");
287                                         }
288                                 }
289                         }
290                         
291                         
292                         //if the users entered no valid calculators don't execute command
293                         if (rDisplays.size() == 0) { for(int i=0;i<rDisplays.size();i++){       delete rDisplays[i];    } delete validCalculator; return 0; }
294                         
295                         read = new ReadOTUFile(globaldata->inputFileName);      
296                         read->read(&*globaldata); 
297                         
298                         order = globaldata->gorder;
299                         string lastLabel = order->getLabel();
300                         input = globaldata->ginput;
301                         
302                         //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
303                         set<string> processedLabels;
304                         set<string> userLabels = labels;
305                         
306                         if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
307                         
308                         //as long as you are not at the end of the file or done wih the lines you want
309                         while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
310                                 
311                                 if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
312
313                                 
314                                 if(allLines == 1 || labels.count(order->getLabel()) == 1){
315                                         
316                                         m->mothurOut(order->getLabel()); m->mothurOutEndLine();
317                                         rCurve = new Rarefact(order, rDisplays, processors);
318                                         rCurve->getCurve(freq, nIters);
319                                         delete rCurve;
320                                         
321                                         processedLabels.insert(order->getLabel());
322                                         userLabels.erase(order->getLabel());
323                                 }
324                                 
325                                 if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
326                                         string saveLabel = order->getLabel();
327                                         
328                                         delete order;
329                                         order = (input->getOrderVector(lastLabel));
330                                         
331                                         m->mothurOut(order->getLabel()); m->mothurOutEndLine();
332                                         rCurve = new Rarefact(order, rDisplays, processors);
333                                         rCurve->getCurve(freq, nIters);
334                                         delete rCurve;
335                                         
336                                         processedLabels.insert(order->getLabel());
337                                         userLabels.erase(order->getLabel());
338                                         
339                                         //restore real lastlabel to save below
340                                         order->setLabel(saveLabel);
341                                 }
342                                 
343                                 lastLabel = order->getLabel();          
344                                 
345                                 delete order;
346                                 order = (input->getOrderVector());
347                         }
348                         
349                         if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }  return 0; }
350
351                         //output error messages about any remaining user labels
352                         set<string>::iterator it;
353                         bool needToRun = false;
354                         for (it = userLabels.begin(); it != userLabels.end(); it++) {  
355                                 m->mothurOut("Your file does not include the label " + *it);
356                                 if (processedLabels.count(lastLabel) != 1) {
357                                         m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
358                                         needToRun = true;
359                                 }else {
360                                         m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
361                                 }
362                         }
363                         
364                         if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
365
366                         //run last label if you need to
367                         if (needToRun == true)  {
368                                 if (order != NULL) {    delete order;   }
369                                 order = (input->getOrderVector(lastLabel));
370                                 
371                                 m->mothurOut(order->getLabel()); m->mothurOutEndLine();
372                                 rCurve = new Rarefact(order, rDisplays, processors);
373                                 rCurve->getCurve(freq, nIters);
374                                 delete rCurve;
375                                 
376                                 delete order;
377                         }
378                         
379                         
380                         for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
381                         rDisplays.clear();
382                         globaldata->gorder = NULL;
383                         delete input;  globaldata->ginput = NULL;
384                         delete read;
385                         delete validCalculator;
386                         
387                 }
388                 
389                 if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
390                 
391                 if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } return 0; }
392
393                 m->mothurOutEndLine();
394                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
395                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
396                 m->mothurOutEndLine();
397
398                 return 0;
399         }
400         catch(exception& e) {
401                 m->errorOut(e, "RareFactCommand", "execute");
402                 exit(1);
403         }
404 }
405 //**********************************************************************************************************************
406 vector<string> RareFactCommand::parseSharedFile(string filename) {
407         try {
408                 vector<string> filenames;
409                 
410                 map<string, ofstream*> filehandles;
411                 map<string, ofstream*>::iterator it3;
412                 
413                                 
414                 //read first line
415                 read = new ReadOTUFile(filename);       
416                 read->read(&*globaldata); 
417                         
418                 input = globaldata->ginput;
419                 vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
420                 
421                 string sharedFileRoot = m->getRootName(filename);
422                 
423                 //clears file before we start to write to it below
424                 for (int i=0; i<lookup.size(); i++) {
425                         remove((sharedFileRoot + lookup[i]->getGroup() + ".rabund").c_str());
426                         filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
427                 }
428                 
429                 ofstream* temp;
430                 for (int i=0; i<lookup.size(); i++) {
431                         temp = new ofstream;
432                         filehandles[lookup[i]->getGroup()] = temp;
433                         groups.push_back(lookup[i]->getGroup());
434                 }
435
436                 while(lookup[0] != NULL) {
437                 
438                         for (int i = 0; i < lookup.size(); i++) {
439                                 RAbundVector rav = lookup[i]->getRAbundVector();
440                                 m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
441                                 rav.print(*(filehandles[lookup[i]->getGroup()]));
442                                 (*(filehandles[lookup[i]->getGroup()])).close();
443                         }
444                 
445                         for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
446                         lookup = input->getSharedRAbundVectors();
447                 }
448                 
449                 //free memory
450                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
451                         delete it3->second;
452                 }
453                 delete read;
454                 delete input;
455                 globaldata->ginput = NULL;
456
457                 return filenames;
458         }
459         catch(exception& e) {
460                 m->errorOut(e, "RareFactCommand", "parseSharedFile");
461                 exit(1);
462         }
463 }
464 //**********************************************************************************************************************
465
466
467