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