X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=filterseqscommand.cpp;h=cb0b131f58e039f5eea76b784334715e1e7481e3;hb=348de0f8b17d84ede77081dcf67bd6ef43496677;hp=c463cd294d04dcdc31e1a6891db1659db45dc05e;hpb=8bc3e5b38c2317a1715f53be22fa96455868c281;p=mothur.git diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index c463cd2..cb0b131 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -25,7 +25,7 @@ vector FilterSeqsCommand::getValidParameters(){ //********************************************************************************************************************** FilterSeqsCommand::FilterSeqsCommand(){ try { - //initialize outputTypes + abort = true; calledHelp = true; vector tempOutNames; outputTypes["fasta"] = tempOutNames; outputTypes["filter"] = tempOutNames; @@ -61,11 +61,11 @@ vector FilterSeqsCommand::getRequiredFiles(){ /**************************************************************************************/ FilterSeqsCommand::FilterSeqsCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; filterFileName = ""; //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 @@ -132,7 +132,9 @@ FilterSeqsCommand::FilterSeqsCommand(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; } } @@ -142,7 +144,9 @@ FilterSeqsCommand::FilterSeqsCommand(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; } } @@ -235,7 +239,7 @@ void FilterSeqsCommand::help(){ int FilterSeqsCommand::execute() { try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } ifstream inFASTA; m->openInputFile(fastafileNames[0], inFASTA); @@ -298,6 +302,12 @@ int FilterSeqsCommand::execute() { m->mothurOut("Length of the original alignment: " + toString(alignmentLength)); m->mothurOutEndLine(); m->mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); m->mothurOutEndLine(); + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -324,7 +334,7 @@ int FilterSeqsCommand::filterSequences() { string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + "filter.fasta"; #ifdef USE_MPI - int pid, start, end, numSeqsPerProcessor, num; + int pid, numSeqsPerProcessor, num; int tag = 2001; vectorMPIPos; @@ -333,7 +343,6 @@ int FilterSeqsCommand::filterSequences() { MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are MPI_File outMPI; - MPI_File tempMPI; MPI_File inMPI; int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; @@ -605,7 +614,11 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename) { 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 @@ -969,7 +982,11 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) 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); + } } //parent do your part