X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=filterseqscommand.cpp;h=6041c95d59952fbaf1c856055181d4e145c3a9c0;hb=fefd5ee1517abd3bc38b469cb2dffc85a1571c7e;hp=f6ca47988809f623b940f2ae04703d276ad90fa8;hpb=deba0af0ccdcb6005ed5b2b82649b137c63fbdf7;p=mothur.git diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index f6ca479..6041c95 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -558,7 +558,7 @@ int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_Fil } - if((i+1) % 100 == 0){ cout << (i+1) << endl; m->mothurOutJustToLog(toString(i+1) + "\n"); } + if((i+1) % 100 == 0){ cout << (i+1) << endl; } } if(outputString != ""){ //output to file @@ -572,7 +572,7 @@ int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_Fil delete buf; } - if((num) % 100 != 0){ cout << (num) << endl; m->mothurOutJustToLog(toString(num) + "\n"); } + if((num) % 100 != 0){ cout << (num) << endl; } return 0; } @@ -623,10 +623,10 @@ int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string i #endif //report progress - if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } + if((count) % 100 == 0){ m->mothurOutJustToScreen(toString(count)+"\n"); } } //report progress - if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } + if((count) % 100 != 0){ m->mothurOutJustToScreen(toString(count)+"\n"); } out.close(); @@ -653,18 +653,18 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename, strin //loop through and create all the processes you want while (process != processors) { - int pid = fork(); + pid_t pid = fork(); if (pid > 0) { processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later process++; }else if (pid == 0){ - string filteredFasta = filename + toString(getpid()) + ".temp"; + string filteredFasta = filename + m->mothurGetpid(process) + ".temp"; num = driverRunFilter(F, filteredFasta, filename, lines[process]); //pass numSeqs to parent ofstream out; - string tempFile = filename + toString(getpid()) + ".num.temp"; + string tempFile = filename + m->mothurGetpid(process) + ".num.temp"; m->openOutputFile(tempFile, out); out << num << endl; out.close(); @@ -729,6 +729,9 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename, strin //Close all thread handles and free memory allocations. for(int i=0; i < pDataArray.size(); i++){ num += pDataArray[i]->count; + if (pDataArray[i]->count != pDataArray[i]->end) { + m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->end) + " sequences assigned to it, quitting. \n"); m->control_pressed = true; + } CloseHandle(hThreadArray[i]); delete pDataArray[i]; } @@ -987,7 +990,8 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair* Sequence seq(in); m->gobble(in); if (seq.getName() != "") { - if (seq.getAligned().length() != alignmentLength) { m->mothurOut("Sequences are not all the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } + if (m->debug) { m->mothurOut("[DEBUG]: " + seq.getName() + " length = " + toString(seq.getAligned().length())); m->mothurOutEndLine();} + if (seq.getAligned().length() != alignmentLength) { m->mothurOut("[ERROR]: Sequences are not all the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } if(trump != '*') { F.doTrump(seq); } if(m->isTrue(vertical) || soft != 0) { F.getFreqs(seq); } @@ -1003,10 +1007,10 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair* #endif //report progress - if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } + if((count) % 100 == 0){ m->mothurOutJustToScreen(toString(count)+"\n"); } } //report progress - if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } + if((count) % 100 != 0){ m->mothurOutJustToScreen(toString(count)+"\n"); } in.close(); return count; @@ -1049,11 +1053,11 @@ int FilterSeqsCommand::MPICreateFilter(int start, int num, Filters& F, MPI_File& cout.flush(); //report progress - if((i+1) % 100 == 0){ cout << (i+1) << endl; m->mothurOutJustToLog(toString(i+1) + "\n"); } + if((i+1) % 100 == 0){ cout << (i+1) << endl; } } //report progress - if((num) % 100 != 0){ cout << num << endl; m->mothurOutJustToLog(toString(num) + "\n"); } + if((num) % 100 != 0){ cout << num << endl; } return 0; } @@ -1075,7 +1079,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) //loop through and create all the processes you want while (process != processors) { - int pid = fork(); + pid_t pid = fork(); if (pid > 0) { processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later @@ -1091,7 +1095,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) num = driverCreateFilter(F, filename, lines[process]); //write out filter counts to file - filename += toString(getpid()) + "filterValues.temp"; + filename += m->mothurGetpid(process) + "filterValues.temp"; ofstream out; m->openOutputFile(filename, out); @@ -1176,6 +1180,9 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) //Close all thread handles and free memory allocations. for(int i=0; i < pDataArray.size(); i++){ num += pDataArray[i]->count; + if (pDataArray[i]->count != pDataArray[i]->end) { + m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->end) + " sequences assigned to it, quitting. \n"); m->control_pressed = true; + } F.mergeFilter(pDataArray[i]->F.getFilter()); for (int k = 0; k < alignmentLength; k++) { F.a[k] += pDataArray[i]->F.a[k]; }