]> git.donarmstrong.com Git - mothur.git/blobdiff - screenseqscommand.cpp
removed some couts from qualityscores.cpp
[mothur.git] / screenseqscommand.cpp
index 8a7a108eb322978377a9d09ffb880a2745c54caf..150a27e54273dfcf7c61d8c1582efe794e0362ba 100644 (file)
@@ -26,8 +26,7 @@ vector<string> ScreenSeqsCommand::getValidParameters(){
 //**********************************************************************************************************************
 ScreenSeqsCommand::ScreenSeqsCommand(){        
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["name"] = tempOutNames;
@@ -67,10 +66,10 @@ vector<string> ScreenSeqsCommand::getRequiredFiles(){
 
 ScreenSeqsCommand::ScreenSeqsCommand(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
@@ -247,7 +246,7 @@ ScreenSeqsCommand::~ScreenSeqsCommand(){    /*      do nothing      */      }
 int ScreenSeqsCommand::execute(){
        try{
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //if the user want to optimize we need to no the 90% mark
                vector<unsigned long int> positions;
@@ -267,7 +266,7 @@ int ScreenSeqsCommand::execute(){
                int start = time(NULL);
                
 #ifdef USE_MPI 
-                       int pid, end, numSeqsPerProcessor; 
+                       int pid, numSeqsPerProcessor; 
                        int tag = 2001;
                        vector<unsigned long int> MPIPos;
                        
@@ -507,13 +506,13 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                outputNames.push_back(goodNameFile);  outputTypes["name"].push_back(goodNameFile);
                
                ofstream goodNameOut;   m->openOutputFile(goodNameFile, goodNameOut);
-       
+               
                while(!inputNames.eof()){
                        if (m->control_pressed) { goodNameOut.close();  inputNames.close(); remove(goodNameFile.c_str());  return 0; }
 
                        inputNames >> seqName >> seqList;
                        it = badSeqNames.find(seqName);
-                       
+                               
                        if(it != badSeqNames.end()){
                                badSeqNames.erase(it);
                                
@@ -558,7 +557,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                                if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodNameFile.c_str());  remove(goodGroupFile.c_str()); return 0; }
 
                                inputGroups >> seqName >> group;
-
+                               
                                it = badSeqGroups.find(seqName);
                                
                                if(it != badSeqGroups.end()){
@@ -580,7 +579,8 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                                }
                        }
                }
-                       
+               
+               
                return 0;
        
        }
@@ -721,7 +721,11 @@ int ScreenSeqsCommand::createProcessesCreateSummary(vector<int>& startPosition,
                                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);
+                       }
                }
                
                num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
@@ -1007,6 +1011,9 @@ int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File&
                                        delete buf3;
                                }
                        }
+                       
+                       //report progress
+                       if((i) % 100 == 0){     m->mothurOut("Processing sequence: " + toString(i)); m->mothurOutEndLine();             }
                }
                                
                return 1;
@@ -1043,7 +1050,11 @@ int ScreenSeqsCommand::createProcesses(string goodFileName, string badAccnos, st
                                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