]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
added current as option is lists of file names, processors now outputted with current...
[mothur.git] / filterseqscommand.cpp
index a677eef9729ef5f1035db03f0a5daff9f7280e36..613dfda1dbbfcc74bea7e218fff53850c366fd7c 100644 (file)
@@ -132,51 +132,66 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                                
                                //go through files and make sure they are good, if not, then disregard them
                                for (int i = 0; i < fastafileNames.size(); i++) {
-                                       if (inputDir != "") {
-                                               string path = m->hasPath(fastafileNames[i]);
-                                               //if the user has not given a path then, add inputdir. else leave path alone.
-                                               if (path == "") {       fastafileNames[i] = inputDir + fastafileNames[i];               }
-                                       }
-
-                                       ifstream in;
-                                       int ableToOpen = m->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() + m->getSimpleName(fastafileNames[i]);
-                                                       m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       fastafileNames[i] = tryPath;
-                                               }
-                                       }
                                        
-                                       //if you can't open it, try default location
-                                       if (ableToOpen == 1) {
-                                               if (m->getOutputDir() != "") { //default path is set
-                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]);
-                                                       m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       fastafileNames[i] = tryPath;
+                                       bool ignore = false;
+                                       if (fastafileNames[i] == "current") { 
+                                               fastafileNames[i] = m->getFastaFile(); 
+                                               if (fastafileNames[i] != "") {  m->mothurOut("Using " + fastafileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
+                                               else {  
+                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
+                                                       //erase from file list
+                                                       fastafileNames.erase(fastafileNames.begin()+i);
+                                                       i--;
                                                }
                                        }
                                        
-                                       in.close();
+                                       if (!ignore) {
+                                               if (inputDir != "") {
+                                                       string path = m->hasPath(fastafileNames[i]);
+                                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                                       if (path == "") {       fastafileNames[i] = inputDir + fastafileNames[i];               }
+                                               }
+
+                                               ifstream in;
+                                               int ableToOpen = m->openInputFile(fastafileNames[i], in, "noerror");
                                        
-                                       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{  
-                                               string simpleName = m->getSimpleName(fastafileNames[i]);
-                                               filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
+                                               //if you can't open it, try default location
+                                               if (ableToOpen == 1) {
+                                                       if (m->getDefaultPath() != "") { //default path is set
+                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastafileNames[i]);
+                                                               m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                               ifstream in2;
+                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                               in2.close();
+                                                               fastafileNames[i] = tryPath;
+                                                       }
+                                               }
+                                               
+                                               //if you can't open it, try default location
+                                               if (ableToOpen == 1) {
+                                                       if (m->getOutputDir() != "") { //default path is set
+                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]);
+                                                               m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                               ifstream in2;
+                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                               in2.close();
+                                                               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{  
+                                                       string simpleName = m->getSimpleName(fastafileNames[i]);
+                                                       filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
+                                               }
+                                               in.close();
                                        }
-                                       in.close();
                                }
                                
                                //make sure there is at least one valid file left