]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
added compile time default path
[mothur.git] / filterseqscommand.cpp
index fada19aeba83054f7d41b42d2827147e86215414..3784c3deab49a0c4302101372247f48f5ec3e89b 100644 (file)
@@ -72,11 +72,22 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                                                if (path == "") {       fastafileNames[i] = inputDir + fastafileNames[i];               }
                                        }
 
-                                       int ableToOpen;
                                        ifstream in;
-                                       ableToOpen = openInputFile(fastafileNames[i], in);
+                                       int ableToOpen = openInputFile(fastafileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(fastafileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       fastafileNames[i] = tryPath;
+                                               }
+                                       }
+                                       in.close();
+                                       
                                        if (ableToOpen == 1) { 
-                                               m->mothurOut(fastafileNames[i] + " will be disregarded."); m->mothurOutEndLine(); 
+                                               m->mothurOut("Unable to open " + fastafileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
                                                //erase from file list
                                                fastafileNames.erase(fastafileNames.begin()+i);
                                                i--;