]> git.donarmstrong.com Git - mothur.git/blobdiff - chimerabellerophoncommand.cpp
fixed bug with phylo.diversity. not calculating as intended.
[mothur.git] / chimerabellerophoncommand.cpp
index d7f60e7901322b44d3548db5200bce9d723407e9..91999094d68f247d3857f129e4d7428ce6f8f5ef 100644 (file)
@@ -27,7 +27,7 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.bellerophon");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -63,7 +63,17 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                                if (pid == 0) {
                                        #endif
 
-                                       ableToOpen = openInputFile(fastaFileNames[i], in);
+                                       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();
                                        
                                        #ifdef USE_MPI  
@@ -78,7 +88,7 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                        #endif
 
                                        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--;
@@ -164,7 +174,6 @@ int ChimeraBellerophonCommand::execute(){
                                        
                        string outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[i])) +  "bellerophon.chimeras";
                        string accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "bellerophon.accnos";
-                       bool hasAccnos = true;
                        
                        chimera->getChimeras();
                        
@@ -206,13 +215,10 @@ int ChimeraBellerophonCommand::execute(){
                        
                        if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } delete chimera;       return 0;       }
                        
-                       //delete accnos file if its blank 
-                       if (isBlank(accnosFileName)) {  remove(accnosFileName.c_str());  hasAccnos = false; }
-                       
                        m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
                        
                        outputNames.push_back(outputFileName);
-                       if (hasAccnos) {  outputNames.push_back(accnosFileName);  }
+                       outputNames.push_back(accnosFileName);
                        
                        delete chimera;
                }