X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=chimeraslayercommand.cpp;h=636e17536a024f04476fc04ce431bb6524e29839;hb=cd7040a22ae19c86a13c2c10ed90a64b77a0c482;hp=097664efc2640af01a0b10cfa3bcd9efcc46d5e3;hpb=e150b0b0664caec517485ee6d69dcdade6dcae77;p=mothur.git diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 097664e..636e175 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -205,6 +205,8 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { //erase from file list fastaFileNames.erase(fastaFileNames.begin()+i); i--; + }else { + m->setFastaFile(fastaFileNames[i]); } } } @@ -279,6 +281,8 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { //erase from file list nameFileNames.erase(nameFileNames.begin()+i); i--; + }else { + m->setNameFile(nameFileNames[i]); } } } @@ -305,9 +309,10 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { templatefile = validParameter.validFile(parameters, "reference", true); if (templatefile == "not open") { abort = true; } - else if (templatefile == "not found") { templatefile = ""; m->mothurOut("reference is a required parameter for the chimera.slayer command."); m->mothurOutEndLine(); abort = true; } + else if (templatefile == "not found") { templatefile = ""; m->mothurOut("reference is a required parameter for the chimera.slayer command, unless and namefile is given."); m->mothurOutEndLine(); abort = true; } } - } + }else if (hasName) { templatefile = "self"; } + else { templatefile = ""; m->mothurOut("reference is a required parameter for the chimera.slayer command."); m->mothurOutEndLine(); abort = true; } string temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); @@ -508,6 +513,16 @@ int ChimeraSlayerCommand::execute(){ //do your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, outMPIFasta, MPIPos); + int numNoParents = chimera->getNumNoParents(); + int temp; + for(int i = 1; i < processors; i++) { + MPI_Recv(&temp, 1, MPI_INT, 1, tag, MPI_COMM_WORLD, &status); + numNoParents += temp; + } + + + if (numSeqs == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } remove(outputFileName.c_str()); remove(accnosFileName.c_str()); delete chimera; return 0; } }else{ //you are a child process @@ -523,6 +538,9 @@ int ChimeraSlayerCommand::execute(){ //do your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, outMPIFasta, MPIPos); + + int numNoParents = chimera->getNumNoParents(); + MPI_Send(&numNoParents, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } @@ -555,6 +573,9 @@ int ChimeraSlayerCommand::execute(){ if(processors == 1){ numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName); + int numNoParents = chimera->getNumNoParents(); + if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } + if (m->control_pressed) { outputTypes.clear(); if (trim) { remove(trimFastaFileName.c_str()); } remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } }else{ @@ -591,6 +612,10 @@ int ChimeraSlayerCommand::execute(){ #else numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName); + int numNoParents = chimera->getNumNoParents(); + if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } + + if (m->control_pressed) { outputTypes.clear(); if (trim) { remove(trimFastaFileName.c_str()); } remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } #endif @@ -669,7 +694,6 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f string candidateAligned = candidateSeq->getAligned(); if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file - if (candidateSeq->getAligned().length() != templateSeqsLength) { m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine(); }else{ @@ -715,15 +739,15 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f data_results rightResults = chimera->getResults(); //if either piece is chimeric then report - Sequence* trimmed = chimera->print(out, out2, leftResults, rightResults); - if (trim) { trimmed->printSequence(out3); delete trimmed; } + Sequence trimmed = chimera->print(out, out2, leftResults, rightResults); + if (trim) { trimmed.printSequence(out3); } delete left; delete right; }else { //already chimeric //print results - Sequence* trimmed = chimera->print(out, out2); - if (trim) { trimmed->printSequence(out3); delete trimmed; } + Sequence trimmed = chimera->print(out, out2); + if (trim) { trimmed.printSequence(out3); } } @@ -831,10 +855,9 @@ int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fil data_results rightResults = chimera->getResults(); //if either piece is chimeric then report - Sequence* trimmed = chimera->print(outMPI, outAccMPI, leftResults, rightResults); + Sequence trimmed = chimera->print(outMPI, outAccMPI, leftResults, rightResults); if (trim) { - string outputString = ">" + trimmed->getName() + "\n" + trimmed->getAligned() + "\n"; - delete trimmed; + string outputString = ">" + trimmed.getName() + "\n" + trimmed.getAligned() + "\n"; //write to accnos file int length = outputString.length(); @@ -849,11 +872,10 @@ int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fil }else { //print results - Sequence* trimmed = chimera->print(outMPI, outAccMPI); + Sequence trimmed = chimera->print(outMPI, outAccMPI); if (trim) { - string outputString = ">" + trimmed->getName() + "\n" + trimmed->getAligned() + "\n"; - delete trimmed; + string outputString = ">" + trimmed.getName() + "\n" + trimmed.getAligned() + "\n"; //write to accnos file int length = outputString.length(); @@ -907,9 +929,8 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename ofstream out; string tempFile = outputFileName + toString(getpid()) + ".num.temp"; m->openOutputFile(tempFile, out); - out << num << endl; + out << num << '\t' << chimera->getNumNoParents() << endl; out.close(); - exit(0); }else { m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); @@ -924,14 +945,17 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename wait(&temp); } + int numNoParents = 0; for (int i = 0; i < processIDS.size(); i++) { ifstream in; string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); - if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } + if (!in.eof()) { int tempNum = 0; int tempNumParents = 0; in >> tempNum >> tempNumParents; num += tempNum; numNoParents += tempNumParents; } in.close(); remove(tempFile.c_str()); } + if (num == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } + return num; #endif }