]> git.donarmstrong.com Git - mothur.git/blobdiff - degapseqscommand.cpp
added compile time default path
[mothur.git] / degapseqscommand.cpp
index c6c4b5521fe35fa1984ecb56229a33c6c58c8163..8f8a5c3901d845b27cdbeb5a3f0c34df0b587ce2 100644 (file)
@@ -54,11 +54,21 @@ DegapSeqsCommand::DegapSeqsCommand(string option)  {
                                        }
        
                                        ifstream in;
-                                       int 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--;