]> git.donarmstrong.com Git - mothur.git/blobdiff - chimerabellerophoncommand.cpp
added [ERROR] flag if command aborts
[mothur.git] / chimerabellerophoncommand.cpp
index 6d0a116ac4d0d5d1bb2b8cf97f1ea5a1b5126fef..22e4fe2956e18100b1e6a4920c25b9237a8d5504 100644 (file)
@@ -48,10 +48,11 @@ vector<string> ChimeraBellerophonCommand::getRequiredFiles(){
 //**********************************************************************************************************************
 ChimeraBellerophonCommand::ChimeraBellerophonCommand(){        
        try {
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["chimera"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand");
@@ -61,10 +62,10 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(){
 //***************************************************************************************************************
 ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -86,6 +87,7 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                        vector<string> tempOutNames;
                        outputTypes["chimera"] = tempOutNames;
                        outputTypes["accnos"] = tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
                
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
@@ -114,7 +116,9 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                                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();
-                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       ifstream in2;
+                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                       in2.close();
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
@@ -124,7 +128,9 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                                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();
-                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       ifstream in2;
+                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                       in2.close();
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
@@ -203,7 +209,7 @@ ChimeraBellerophonCommand::~ChimeraBellerophonCommand(){    /*      do nothing      */      }
 int ChimeraBellerophonCommand::execute(){
        try{
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                for (int i = 0; i < fastaFileNames.size(); i++) {
                        
@@ -236,7 +242,7 @@ int ChimeraBellerophonCommand::execute(){
                        MPI_File_open(MPI_COMM_WORLD, FileName, outMode, MPI_INFO_NULL, &outMPI);  //comm, filename, mode, info, filepointer
                        MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
        
-                       numSeqs = chimera->print(outMPI, outMPIAccnos);
+                       numSeqs = chimera->print(outMPI, outMPIAccnos, "");
                        
                        MPI_File_close(&outMPI);
                        MPI_File_close(&outMPIAccnos);
@@ -249,7 +255,7 @@ int ChimeraBellerophonCommand::execute(){
                        ofstream out2;
                        m->openOutputFile(accnosFileName, out2);
                        
-                       numSeqs = chimera->print(out, out2);
+                       numSeqs = chimera->print(out, out2, "");
                        out.close();
                        out2.close();