]> git.donarmstrong.com Git - mothur.git/blobdiff - makegroupcommand.cpp
added compile time default path
[mothur.git] / makegroupcommand.cpp
index 57028c957397f8ead2e38cd326020391a61ef7a2..455826a3a8ab61ec1cf7a5af44e91ba791907583 100644 (file)
@@ -60,18 +60,26 @@ MakeGroupCommand::MakeGroupCommand(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("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
                                                //erase from file list
                                                fastaFileNames.erase(fastaFileNames.begin()+i);
                                                i--;
                                        }else{  filename += getRootName(getSimpleName(fastaFileNames[i]));  }
-                                       
                                }
                                
                                filename += "groups";