]> git.donarmstrong.com Git - mothur.git/blob - errorchecking.cpp
altered venn command to make use of sharedchao for any number of groups, fixed window...
[mothur.git] / errorchecking.cpp
1 /*
2  *  errorchecking.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 "errorchecking.h"
11
12 /*******************************************************/
13
14 /******************************************************/
15
16 ErrorCheck::ErrorCheck() {
17         globaldata = GlobalData::getInstance();
18         validCommand = new ValidCommands();
19         validParameter = new ValidParameters();
20 }
21 /*******************************************************/
22
23 /******************************************************/
24
25 void ErrorCheck::refresh() {
26
27         //columnfile = globaldata->getColumnFile();
28         //phylipfile = globaldata->getPhylipFile();
29         //listfile = globaldata->getListFile();
30         //rabundfile = globaldata->getRabundFile();
31         //sabundfile = globaldata->getSabundFile();
32         //namefile = globaldata->getNameFile();
33         //groupfile = globaldata->getGroupFile();
34         //orderfile = globaldata->getOrderFile();
35         //fastafile = globaldata->getFastaFile();
36         //treefile = globaldata->getTreeFile();
37         //cutoff = globaldata->getCutOff();
38         //format = globaldata->getFormat();
39         //method = globaldata->getMethod();
40         //randomtree = globaldata->getRandomTree();
41         //sharedfile = globaldata->getSharedFile();
42
43 }
44
45 /*******************************************************/
46
47 /******************************************************/
48
49 ErrorCheck::~ErrorCheck() {
50         delete validCommand;
51         delete validParameter;
52 }
53
54 /*******************************************************/
55
56 /******************************************************/
57
58 bool ErrorCheck::checkInput(string input) {
59                 errorFree = true;
60                 clear();
61                 
62                 //refresh variable
63                 refresh();
64                 
65                 //get command name and parameters
66                 int openParen = input.find_first_of('(');
67                 int closeParen = input.find_last_of(')');
68
69                 if(openParen != -1 && closeParen != -1){                        
70                         commandName = input.substr(0, openParen);   //commandName contains everything before "("
71                         optionText = input.substr(openParen+1, closeParen-openParen-1); //optionString contains everything between "(" and ")".
72                 }else if (openParen == -1) { //there is no parenthesis
73                         cout << input << " is not a valid command. You are missing the ()." << endl;
74                         return false;
75                 }
76                 
77                 //is it a valid command
78                 if (validCommand->isValidCommand(commandName) != true) { return false; }
79                 string parameter, value;
80                 
81                 //reads in parameters and values
82                 if((optionText != "") && (commandName != "help")){
83                         while((optionText.find_first_of(',') != -1) && (errorFree)) {  //while there are parameters
84                                 splitAtComma(value, optionText);
85                                 splitAtEquals(parameter, value);
86                                 
87                                 //is it a valid parameter
88                                 if (validParameter->isValidParameter(parameter, commandName, value) != true) { return false; }
89                                 
90                                 if (parameter == "phylip" )             { phylipfile = value; }
91                                 if (parameter == "column" )             { columnfile = value; }
92                                 if (parameter == "list" )               { listfile = value; }
93                                 if (parameter == "rabund" )             { rabundfile = value; }
94                                 if (parameter == "sabund" )             { sabundfile = value; }
95                                 if (parameter == "name" )               { namefile = value; }
96                                 if (parameter == "order" )              { orderfile = value; }
97                                 if (parameter == "fasta" )              { fastafile = value; }
98                                 if (parameter == "nexus" )              { nexusfile = value; }
99                                 if (parameter == "clustal" )    { clustalfile = value; }
100                                 if (parameter == "tree" )               { treefile = value; }
101                                 if (parameter == "group" )                      { groupfile = value; }
102                                 if (parameter == "shared" )                     { sharedfile = value; }
103                                 if (parameter == "cutoff" )                     { cutoff = value; }
104                                 if (parameter == "precision" )          { precision = value; }
105                                 if (parameter == "iters" )                      { iters = value; }
106                                 if (parameter == "jumble" )                     { jumble = value; }
107                                 if (parameter == "freq" )                       { freq = value; }
108                                 if (parameter == "method" )                     { method = value; }
109                                 if (parameter == "fileroot" )           { fileroot = value; }
110                                 if (parameter == "line" )                       { line = value; }
111                                 if (parameter == "label" )                      { label = value; }
112                                 if (parameter == "abund" )          { abund = value; }
113                                 if (parameter == "random" )                     { randomtree = value; }
114                                 if (parameter == "sorted" )                     { sorted = value; }
115                                 if (parameter == "trump" )          { trump = value; }
116                                 if (parameter == "soft" )                       { soft = value; }
117                                 if (parameter == "filter" )         { filter = value; }
118                                 if (parameter == "scale" )                      { scale = value;        }
119                                 if (parameter == "ends" )                       { ends = value; }
120                                 if (parameter == "processors" )         { processors = value;   }
121
122                         }
123                         
124                         //gets the last parameter and value
125                         if (errorFree)  { //gets the last parameter and value
126                                 value = optionText;
127                                 splitAtEquals(parameter, value);
128                                 //is it a valid parameter
129                                 if (validParameter->isValidParameter(parameter, commandName, value) != true) { return false; }
130         
131                                 
132                                 if (parameter == "phylip" )             { phylipfile = value; }
133                                 if (parameter == "column" )             { columnfile = value; }                         
134                                 if (parameter == "list" )               { listfile = value; }
135                                 if (parameter == "rabund" )             { rabundfile = value; }
136                                 if (parameter == "sabund" )             { sabundfile = value; }
137                                 if (parameter == "name" )               { namefile = value; }
138                                 if (parameter == "order" )              { orderfile = value; }
139                                 if (parameter == "group" )              { groupfile = value; }
140                                 if (parameter == "shared" )             { sharedfile = value; }
141                                 if (parameter == "fasta" )              { fastafile = value; }
142                                 if (parameter == "nexus" )              { nexusfile = value; }
143                                 if (parameter == "clustal" )    { clustalfile = value; }
144                                 if (parameter == "tree" )               { treefile = value; }
145                                 if (parameter == "cutoff" )                     { cutoff = value; }
146                                 if (parameter == "precision" )          { precision = value; }
147                                 if (parameter == "iters" )                      { iters = value; }
148                                 if (parameter == "jumble" )                     { jumble = value; }
149                                 if (parameter == "freq" )                       { freq = value; }
150                                 if (parameter == "method" )                     { method = value; }
151                                 if (parameter == "fileroot" )           { fileroot = value; }
152                                 if (parameter == "line" )                       { line = value; }
153                                 if (parameter == "label" )                      { label = value; }
154                                 if (parameter == "random" )                     { randomtree = value;   }
155                                 if (parameter == "abund" )          { abund = value; }
156                                 if (parameter == "sorted" )                     { sorted = value;       }
157                                 if (parameter == "trump" )          { trump = value; }
158                                 if (parameter == "soft" )                       { soft = value; }
159                                 if (parameter == "filter" )         { filter = value; }
160                                 if (parameter == "scale" )                      { scale = value;        }
161                                 if (parameter == "ends" )                       { ends = value; }
162                                 if (parameter == "processors" )         { processors = value;   }
163
164                         }
165                 }
166                 
167                 //make sure the user does not use both the line and label parameters
168                 if ((line != "") && (label != "")) { cout << "You may use either the line or label parameters, but not both." << endl; return false; }
169                 
170                 //check for valid files 
171                 if (commandName == "read.dist") { 
172                         validateReadFiles();
173                         validateReadDist();
174                 }else if (commandName == "read.otu") { 
175                         //you want to do shared commands
176                         if ((listfile != "") && (groupfile != ""))      {
177                                 validateParseFiles(); //checks the listfile and groupfile parameters
178                         //you want to do single commands
179                         }else if ((listfile != "") || (rabundfile != "") || (sabundfile != "")){ 
180                                 validateReadFiles();
181                                 validateReadPhil();
182                         //you have not given a file
183                         }else if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "")) {
184                                 cout << "You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. " << endl; return false; 
185                         //you want to do shared commands with a shared file
186                         }else if (sharedfile != "") {//you are reading a shared file
187                                 validateReadFiles();
188                         }
189                 }else if (commandName == "read.tree") { 
190                         validateTreeFiles(); //checks the treefile and groupfile parameters
191                 }else if (commandName == "read.seqs") {
192                         if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) { cout << "You must enter a fastafile, nexusfile, or clustalfile with the read.seqs() command." << endl; return false; }
193                 }else if (commandName == "deconvolute") {
194                         if (fastafile == "") { cout << "You must enter a fastafile with the deconvolute() command." << endl; return false; }
195                         validateReadFiles();
196                 }
197                 
198                 //are you trying to cluster before you have read something      
199                 if (((commandName == "cluster") && (globaldata->gSparseMatrix == NULL)) ||
200                         ((commandName == "cluster") && (globaldata->gListVector == NULL))) {
201                                 cout << "Before you use the cluster command, you first need to read in a distance matrix." << endl; 
202                                 errorFree = false;
203                 } 
204                 
205                 if ((commandName == "libshuff") && ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL))) {
206                          cout << "You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. " << endl; return false; 
207                 }
208                 
209                 if (commandName == "parsimony") {
210                         //are you trying to use parsimony without reading a tree or saying you want random distribution
211                         if (randomtree == "")  {
212                                 if (globaldata->gTree.size() == 0) {
213                                         cout << "You must read a treefile and a groupfile or set the randomtree parameter to the output filename you wish, before you may execute the parsimony command." << endl; return false;  }
214                         }
215                 }
216                 
217                 if ((commandName == "unifrac.weighted") || (commandName == "unifrac.unweighted") || (commandName == "concensus")) {
218                         if (globaldata->gTree.size() == 0) {//no trees were read
219                                 cout << "You must execute the read.tree command, before you may execute the unifrac.weighted, unifrac.unweighted or concensus command." << endl; return false;  }
220                 }
221                 
222                 //check for valid method
223                 if(commandName == "get.group") {
224                         if ((globaldata->getGroupFile() == "")) { cout << "You must read a group before you can use the get.group command." << endl; return false; }
225                 }
226                 if (commandName == "get.label" || commandName == "get.line") {
227                         if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the get.label or get.line command." << endl; return false; }
228                 }
229                 if (commandName == "cluster") {
230                         if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
231                         else {cout << "Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average." << endl; return false; }
232                 }
233                 
234                 if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single") ){ 
235                         if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single, rarefaction.single or summary.single commands." << endl; return false; }
236                 }
237                 
238                 if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.shared") || (commandName == "bootstrap.shared")){ 
239                         if (globaldata->getSharedFile() == "") {
240                                 if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
241                                 else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
242                         }
243                 }
244                 
245                 if ((commandName == "heatmap") || (commandName == "venn")) { 
246                         if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
247                                  cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap or venn commands." << endl; return false; 
248                         }
249                 }
250                 
251                 if (commandName == "filter.seqs"){ 
252                         if ((globaldata->getFastaFile() == "") && (globaldata->getNexusFile() == "") && (globaldata->getClustalFile() == "") && (globaldata->getPhylipFile() == "")) {
253                                  cout << "You must read either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs command." << endl; return false; 
254                         }
255                 }
256                 
257                 if ((commandName == "bin.seqs")) { 
258                         if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the bin.seqs command." << endl; return false; }
259                         validateBinFiles();
260                 }
261                 
262                 if ((commandName == "get.oturep")) { 
263                         if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
264                                 cout << "Before you use the get.oturep command, you first need to read in a distance matrix." << endl; 
265                                 errorFree = false;
266                         }
267                         if (listfile == "") { cout << "list is a required parameter for the get.oturep command." << endl; errorFree = false; }
268                         validateBinFiles();
269                 } 
270
271
272                 return errorFree;
273 }
274
275 /*******************************************************/
276
277 /******************************************************/
278 //This function checks to make sure the user entered a file to 
279 // read and that the file exists and can be opened.
280 void ErrorCheck::validateReadFiles() {
281         try {
282                 //Validating files for read
283                 ifstream filehandle;
284                 int ableToOpen;
285         
286                 //are we reading a phylipfile
287                 if (phylipfile != "") {
288                         ableToOpen = openInputFile(phylipfile, filehandle);
289                         filehandle.close();
290                         //unable to open
291                         if (ableToOpen == 1) { errorFree = false; }
292                         else { globaldata->inputFileName = phylipfile; }
293                 //are we reading a columnfile
294                 }else if (columnfile != "") {
295                         ableToOpen = openInputFile(columnfile, filehandle);
296                         filehandle.close();
297                         //unable to open
298                         if (ableToOpen == 1) { errorFree = false; }
299                         else { globaldata->inputFileName = columnfile; }
300                 //are we reading a listfile
301                 }else if (listfile!= "") {
302                         ableToOpen = openInputFile(listfile, filehandle);
303                         filehandle.close();
304                         //unable to open
305                         if (ableToOpen == 1) {  errorFree = false; }
306                         else { globaldata->inputFileName = listfile; }
307                 //are we reading a rabundfile
308                 }else if (rabundfile != "") {
309                         ableToOpen = openInputFile(rabundfile, filehandle);
310                         filehandle.close();
311                         //unable to open
312                         if (ableToOpen == 1) {  errorFree = false; }
313                         else { globaldata->inputFileName = rabundfile; }
314                 //are we reading a sabundfile
315                 }else if (sabundfile != "") {
316                         ableToOpen = openInputFile(sabundfile, filehandle);
317                         filehandle.close();
318                         //unable to open
319                         if (ableToOpen == 1) {  errorFree = false; }
320                         else { globaldata->inputFileName = sabundfile; }
321                 }else if (fastafile != "") {
322                         ableToOpen = openInputFile(fastafile, filehandle);
323                         filehandle.close();
324                         //unable to open
325                         if (ableToOpen == 1) {  errorFree = false; }
326                         else { globaldata->inputFileName = fastafile; }
327                 }else if (sharedfile != "") {
328                         ableToOpen = openInputFile(sharedfile, filehandle);
329                         filehandle.close();
330                         //unable to open
331                         if (ableToOpen == 1) {  errorFree = false; }
332                         else { globaldata->inputFileName = sharedfile; }
333                 }else{ //no file given
334                         errorFree = false;
335                 }
336         }
337         catch(exception& e) {
338                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateReadFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
339                 exit(1);
340         }
341         catch(...) {
342                 cout << "An unknown error has occurred in the ErrorCheck class function validateReadFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
343                 exit(1);
344         }
345         
346 }
347 /*******************************************************/
348
349 /******************************************************/
350 //This function checks to make sure the user entered appropriate
351 // format parameters on a distfile read
352 void ErrorCheck::validateReadDist() {
353         try {
354                 ifstream filehandle;
355                 int ableToOpen;
356                 
357                 if (groupfile != "") {
358                         ableToOpen = openInputFile(groupfile, filehandle);
359                         filehandle.close();
360                         //unable to open
361                         if (ableToOpen == 1) {  errorFree = false; }
362                 }
363                 
364                 if ((phylipfile == "") && (columnfile == "")) { cout << "When executing a read.dist you must enter a phylip or a column." << endl; errorFree = false; }
365                 else if ((phylipfile != "") && (columnfile != "")) { cout << "When executing a read.dist you must enter ONLY ONE of the following: phylip or column." << endl; errorFree = false; }
366                 
367                 if (columnfile != "") {
368                         if (namefile == "") {
369                                 cout << "You need to provide a namefile if you are going to use the column format." << endl;
370                                 errorFree = false; 
371                         }else {
372                                 ableToOpen = openInputFile(namefile, filehandle);
373                                 filehandle.close();
374                                 //unable to open
375                                 if (ableToOpen == 1) { errorFree = false; }
376                         }
377                 }
378         }
379         catch(exception& e) {
380                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateReadDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
381                 exit(1);
382         }
383         catch(...) {
384                 cout << "An unknown error has occurred in the ErrorCheck class function validateReadDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
385                 exit(1);
386         }
387 }
388 /*******************************************************/
389
390 /******************************************************/
391 //This function checks to make sure the user entered appropriate
392 // format parameters on a parselistcommand
393 void ErrorCheck::validateParseFiles() {
394         try {
395                 ifstream filehandle;
396                 int ableToOpen;
397                 
398                 //checks for valid files
399         
400                 if (listfile == "") { cout << "When executing a read.otu for groups you must enter a list and a group." << endl; errorFree = false; }
401                 else if (groupfile == "") { cout << "When executing a read.otu for groups you must enter a list and a group." << endl; errorFree = false; }
402         
403                 //checks parameters on the read command
404                 if (listfile != "") {
405                         ableToOpen = openInputFile(listfile, filehandle);
406                         filehandle.close();
407                         if (ableToOpen == 1) { //unable to open
408                                 errorFree = false;
409                         }
410                         if (groupfile != "") {
411                                 ableToOpen = openInputFile(groupfile, filehandle);
412                                 filehandle.close();
413                                 if (ableToOpen == 1) { //unable to open
414                                         errorFree = false;;
415                                 }
416                         }
417                 }
418         }
419         catch(exception& e) {
420                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateReadPhil. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
421                 exit(1);
422         }
423         catch(...) {
424                 cout << "An unknown error has occurred in the ErrorCheck class function validateReadPhil. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
425                 exit(1);
426         }
427 }
428 /*******************************************************/
429
430 /******************************************************/
431 //This function checks to make sure the user entered appropriate
432 // format parameters on a parselistcommand
433 void ErrorCheck::validateTreeFiles() {
434         try {
435                 ifstream filehandle;
436                 int ableToOpen;
437                 
438                 //checks for valid files
439         
440                 if (treefile == "") { cout << "When executing a read.tree you must enter a treefile and a groupfile." << endl; errorFree = false; }
441                 else if (groupfile == "") { cout << "When executing a read.tree you must enter a treefile and a groupfile." << endl; errorFree = false; }
442         
443                 //checks parameters on the read command
444                 if (treefile != "") {
445                         ableToOpen = openInputFile(treefile, filehandle);
446                         filehandle.close();
447                         if (ableToOpen == 1) { //unable to open
448                                 errorFree = false;
449                         }
450                         if (groupfile != "") {
451                                 ableToOpen = openInputFile(groupfile, filehandle);
452                                 filehandle.close();
453                                 if (ableToOpen == 1) { //unable to open
454                                         errorFree = false;;
455                                 }
456                         }
457                 }
458         }
459         catch(exception& e) {
460                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateTreeFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
461                 exit(1);
462         }
463         catch(...) {
464                 cout << "An unknown error has occurred in the ErrorCheck class function validateTreeFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
465                 exit(1);
466         }
467 }
468
469 /*******************************************************/
470
471 /******************************************************/
472 //This function checks to make sure the user entered appropriate
473 // format parameters on a distfile read
474 void ErrorCheck::validateReadPhil() {
475         try {
476                 ifstream filehandle;
477                 int ableToOpen;
478                 
479                 //checks to make sure only one file type is given
480                 if (listfile != "") { 
481                         if ((rabundfile != "") || (sabundfile != "")) { 
482                                 cout << "When executing a read.otu you must enter ONLY ONE of the following: list, rabund or sabund." << endl; errorFree = false; }
483                 }else if (rabundfile != "") { 
484                         if ((listfile != "") || (sabundfile != "")) { 
485                                 cout << "When executing a read.otu you must enter ONLY ONE of the following: list, rabund or sabund." << endl; errorFree = false; }
486                 }else if (sabundfile != "") { 
487                         if ((listfile != "") || (rabundfile != "")) { 
488                                 cout << "When executing a read.otu you must enter ONLY ONE of the following: list, rabund or sabund." << endl; errorFree = false; }
489                 }else if ((listfile == "") && (rabundfile == "") && (sabundfile == "") && (sharedfile == "")) {
490                             cout << "When executing a read.otu you must enter one of the following: list, rabund or sabund." << endl; errorFree = false; 
491                 }
492                 
493                 //checks parameters on the read command
494                 if (orderfile != "") {
495                         ableToOpen = openInputFile(orderfile, filehandle);
496                         filehandle.close();
497                         if (ableToOpen == 1) { //unable to open
498                                 errorFree = false;
499                         }
500                 }       
501         }
502         catch(exception& e) {
503                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateReadPhil. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
504                 exit(1);
505         }
506         catch(...) {
507                 cout << "An unknown error has occurred in the ErrorCheck class function validateReadPhil. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
508                 exit(1);
509         }
510 }
511 /*******************************************************/
512
513 /******************************************************/
514 //This function checks to make sure the user entered appropriate
515 // format parameters on a bin.seq command
516 void ErrorCheck::validateBinFiles() {
517         try {
518                 ifstream filehandle;
519                 int ableToOpen;
520                 
521                 if (fastafile == "") {
522                                 cout << "fasta is a required parameter for bin.seqs and get.oturep commands." << endl; errorFree = false; 
523                 }else if (fastafile != "") {
524                         //is it a valid filename'
525                         ableToOpen = openInputFile(fastafile, filehandle);
526                         filehandle.close();
527                         //unable to open
528                         if (ableToOpen == 1) {  errorFree = false; }
529                 }else if (listfile != "") {
530                         //is it a valid filename'
531                         ableToOpen = openInputFile(listfile, filehandle);
532                         filehandle.close();
533                         //unable to open
534                         if (ableToOpen == 1) {  errorFree = false; }
535                 }else if (globaldata->getNameFile() != "") {
536                         //is it a valid filename'
537                         ifstream filehandle;
538                         int ableToOpen = openInputFile(globaldata->getNameFile(), filehandle);
539                         filehandle.close();
540                         //unable to open
541                         if (ableToOpen == 1) {  errorFree = false; }
542                 }else if (namefile != "") {
543                         //is it a valid filename'
544                         ifstream filehandle;
545                         int ableToOpen = openInputFile(namefile, filehandle);
546                         filehandle.close();
547                         //unable to open
548                         if (ableToOpen == 1) {  errorFree = false; }
549                 }
550
551
552         }
553         catch(exception& e) {
554                 cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateBinFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
555                 exit(1);
556         }
557         catch(...) {
558                 cout << "An unknown error has occurred in the ErrorCheck class function validateBinFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
559                 exit(1);
560         }
561 }
562
563 /*******************************************************/
564
565 /******************************************************/
566
567 void ErrorCheck::clear() {
568         //option definitions should go here...
569         phylipfile              =       "";
570         columnfile              =       "";
571         listfile                =       "";
572         rabundfile              =       "";
573         sabundfile              =       "";
574         namefile                =       "";
575         groupfile               =       ""; 
576         orderfile               =       "";
577         sharedfile              =       "";
578         fastafile       =   "";
579         nexusfile       =   "";
580         clustalfile     =   "";
581         line                    =       "";
582         label                   =       "";
583         method                  =   "furthest";
584 }
585 /*******************************************************/
586
587 /******************************************************/
588