]> git.donarmstrong.com Git - mothur.git/blobdiff - chimerapintailcommand.cpp
some more mods to shh.seqs
[mothur.git] / chimerapintailcommand.cpp
index 2dccd498f6dd2e5fdf82a9b12665aaf7a523ad90..a8d2d65c6c3752fcc7ca9737e505c32850d62f7b 100644 (file)
@@ -25,6 +25,7 @@ vector<string> ChimeraPintailCommand::getValidParameters(){
 //**********************************************************************************************************************
 ChimeraPintailCommand::ChimeraPintailCommand(){        
        try {
+               abort = true; calledHelp = true;
                vector<string> tempOutNames;
                outputTypes["chimera"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
@@ -60,10 +61,10 @@ vector<string> ChimeraPintailCommand::getRequiredFiles(){
 //***************************************************************************************************************
 ChimeraPintailCommand::ChimeraPintailCommand(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
@@ -140,7 +141,9 @@ ChimeraPintailCommand::ChimeraPintailCommand(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;
                                                }
                                        }
@@ -149,7 +152,9 @@ ChimeraPintailCommand::ChimeraPintailCommand(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;
                                                }
                                        }
@@ -196,7 +201,9 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                                        if (m->getDefaultPath() != "") { //default path is set
                                                        string tryPath = m->getDefaultPath() + m->getSimpleName(maskfile);
                                                        m->mothurOut("Unable to open " + maskfile + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       ifstream in2;
+                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                       in2.close();
                                                        maskfile = tryPath;
                                        }
                                }
@@ -205,7 +212,9 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                                                if (m->getOutputDir() != "") { //default path is set
                                                        string tryPath = m->getOutputDir() + m->getSimpleName(maskfile);
                                                        m->mothurOut("Unable to open " + maskfile + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       ifstream in2;
+                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                       in2.close();
                                                        maskfile = tryPath;
                                                }
                                }
@@ -301,7 +310,7 @@ ChimeraPintailCommand::~ChimeraPintailCommand(){    /*      do nothing      */      }
 int ChimeraPintailCommand::execute(){
        try{
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                for (int s = 0; s < fastaFileNames.size(); s++) {
                                
@@ -374,7 +383,7 @@ int ChimeraPintailCommand::execute(){
                        templateSeqsLength = chimera->getLength();
                
                #ifdef USE_MPI
-                       int pid, end, numSeqsPerProcessor; 
+                       int pid, numSeqsPerProcessor; 
                                int tag = 2001;
                                vector<unsigned long int> MPIPos;
                                
@@ -623,7 +632,7 @@ int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fi
                                        if (m->control_pressed) {       delete candidateSeq; return 1;  }
                
                                        //print results
-                                       bool isChimeric = chimera->print(outMPI, outAccMPI);
+                                       chimera->print(outMPI, outAccMPI);
                                }
                        }
                        delete candidateSeq;
@@ -670,7 +679,11 @@ int ChimeraPintailCommand::createProcesses(string outputFileName, string filenam
                                out.close();
 
                                exit(0);
-                       }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
+                       }else { 
+                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
+                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
+                               exit(0);
+                       }
                }
                
                //force parent to wait until all the processes are done