X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classifyseqscommand.cpp;h=0a1ef8823e35f687529c70de5ef29e7d33eb91fe;hb=dfa69e4bbb18b2313495822f36b80cb475b7fb08;hp=9f05eda2704c179ca3eb4f120d83862aeb4eb6e4;hpb=8bc3e5b38c2317a1715f53be22fa96455868c281;p=mothur.git diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 9f05eda..0a1ef88 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -30,6 +30,7 @@ vector ClassifySeqsCommand::getValidParameters(){ //********************************************************************************************************************** ClassifySeqsCommand::ClassifySeqsCommand(){ try { + abort = true; //initialize outputTypes vector tempOutNames; outputTypes["taxonomy"] = tempOutNames; @@ -161,7 +162,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(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; } } @@ -170,7 +173,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(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; } } @@ -223,7 +228,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { if (m->getDefaultPath() != "") { //default path is set string tryPath = m->getDefaultPath() + m->getSimpleName(namefileNames[i]); m->mothurOut("Unable to open " + namefileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); namefileNames[i] = tryPath; } } @@ -232,7 +239,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { if (m->getOutputDir() != "") { //default path is set string tryPath = m->getOutputDir() + m->getSimpleName(namefileNames[i]); m->mothurOut("Unable to open " + namefileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); namefileNames[i] = tryPath; } } @@ -274,7 +283,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { if (m->getDefaultPath() != "") { //default path is set string tryPath = m->getDefaultPath() + m->getSimpleName(groupfileNames[i]); m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); groupfileNames[i] = tryPath; } } @@ -283,7 +294,9 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { if (m->getOutputDir() != "") { //default path is set string tryPath = m->getOutputDir() + m->getSimpleName(groupfileNames[i]); m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); groupfileNames[i] = tryPath; } } @@ -448,7 +461,7 @@ int ClassifySeqsCommand::execute(){ for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); #ifdef USE_MPI - int pid, end, numSeqsPerProcessor; + int pid, numSeqsPerProcessor; int tag = 2001; vector MPIPos; @@ -546,16 +559,6 @@ int ClassifySeqsCommand::execute(){ numFastaSeqs = createProcesses(newTaxonomyFile, tempTaxonomyFile, fastaFileNames[s]); - rename((newTaxonomyFile + toString(processIDS[0]) + ".temp").c_str(), newTaxonomyFile.c_str()); - rename((tempTaxonomyFile + toString(processIDS[0]) + ".temp").c_str(), tempTaxonomyFile.c_str()); - - for(int i=1;imothurOut("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 does its part + num = driver(lines[0], taxFileName, tempTaxFile, filename); + //force parent to wait until all the processes are done - for (int i=0;icontrol_pressed) { return 0; } Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA); - + if (candidateSeq->getName() != "") { + taxonomy = classify->getTaxonomy(candidateSeq); if (m->control_pressed) { delete candidateSeq; return 0; } @@ -846,10 +864,11 @@ int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempT //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } + } //report progress if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } - + inFASTA.close(); outTax.close(); outTaxSimple.close();