From: westcott Date: Fri, 5 Nov 2010 19:26:09 +0000 (+0000) Subject: cluster.split fix X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=cbb336d5650cfe1f83a398a837794dcfbbbd3756 cluster.split fix --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 855dad8..1c282d9 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -1124,6 +1124,7 @@ }; buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "Mothur" */; compatibilityVersion = "Xcode 3.0"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, diff --git a/aligncommand.cpp b/aligncommand.cpp index 624aab4..87ca6cb 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -850,7 +850,11 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s 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 diff --git a/bellerophon.cpp b/bellerophon.cpp index 4f48d9c..761d291 100644 --- a/bellerophon.cpp +++ b/bellerophon.cpp @@ -373,7 +373,11 @@ int Bellerophon::createProcesses(vector mid) { string tempOut = outputDir + toString(getpid()) + ".temp"; writePrefs(tempOut, lines[process]); 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 diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index 5f90a08..286681a 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -597,7 +597,11 @@ int ChimeraCcodeCommand::createProcesses(string outputFileName, 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 diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index b3f49a4..abf6b90 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -572,7 +572,11 @@ int ChimeraCheckCommand::createProcesses(string outputFileName, 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 diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index b355f6d..abab7a3 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -678,7 +678,11 @@ int ChimeraPintailCommand::createProcesses(string outputFileName, string filenam 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 diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index dbdd4a9..cd84bdc 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -610,7 +610,11 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, 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 diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index b8d5b8e..3876c6c 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -757,7 +757,11 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, 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 diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index 6b5012a..85a183a 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -885,7 +885,11 @@ int ClusterSplitCommand::createProcesses(vector < vector < map > outLabels.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 diff --git a/distancecommand.cpp b/distancecommand.cpp index 07d7f0f..edb6314 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -423,6 +423,21 @@ int DistanceCommand::execute(){ else { driver(0, numSeqs, outputFile, "square"); } }else{ //you have multiple processors + unsigned long int numDists = 0; + + if (output == "square") { + numDists = numSeqs * numSeqs; + }else { + for(int i=0;i processors) { break; } + } + } + } + + if (numDists < processors) { processors = numDists; } + for (int i = 0; i < processors; i++) { lines.push_back(new linePair()); if (output != "square") { @@ -432,19 +447,10 @@ int DistanceCommand::execute(){ lines[i]->start = int ((float(i)/float(processors)) * numSeqs); lines[i]->end = int ((float(i+1)/float(processors)) * numSeqs); } + //cout << i << '\t' << lines[i]->start << '\t' << lines[i]->end << endl; } createProcesses(outputFile); - - map::iterator it = processIDS.begin(); - rename((outputFile + toString(it->second) + ".temp").c_str(), outputFile.c_str()); - it++; - - //append and remove temp files - for (; it != processIDS.end(); it++) { - m->appendFiles((outputFile + toString(it->second) + ".temp"), outputFile); - remove((outputFile + toString(it->second) + ".temp").c_str()); - } } #else //ifstream inFASTA; @@ -526,7 +532,7 @@ int DistanceCommand::execute(){ void DistanceCommand::createProcesses(string filename) { try { #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - int process = 0; + int process = 1; processIDS.clear(); //loop through and create all the processes you want @@ -540,14 +546,29 @@ void DistanceCommand::createProcesses(string filename) { if (output != "square") { driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", cutoff); } else { driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", "square"); } 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. Error code: " + toString(pid)); m->mothurOutEndLine(); + for (map::iterator it = processIDS.begin(); it != processIDS.end(); it++) { int temp = it->second; kill (temp, SIGINT); } + exit(0); + } } - + + //parent does its part + if (output != "square") { driver(lines[0]->start, lines[0]->end, filename, cutoff); } + else { driver(lines[0]->start, lines[0]->end, filename, "square"); } + + //force parent to wait until all the processes are done for (map::iterator it = processIDS.begin(); it != processIDS.end(); it++) { int temp = it->second; wait(&temp); } + + //append and remove temp files + for (map::iterator it = processIDS.begin(); it != processIDS.end(); it++) { + m->appendFiles((filename + toString(it->second) + ".temp"), filename); + remove((filename + toString(it->second) + ".temp").c_str()); + } #endif } catch(exception& e) { diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index c4a3a95..b9436f8 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -610,7 +610,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 @@ -974,7 +978,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 diff --git a/metastatscommand.cpp b/metastatscommand.cpp index 2078584..a734ce3 100644 --- a/metastatscommand.cpp +++ b/metastatscommand.cpp @@ -366,7 +366,11 @@ int MetaStatsCommand::process(vector& thisLookUp){ }else if (pid == 0){ driver(lines[process].start, lines[process].num, thisLookUp); 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); + } } //do my part diff --git a/mothur b/mothur index b0584ed..6d82146 100755 Binary files a/mothur and b/mothur differ diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index aed03cd..18412fd 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -536,7 +536,11 @@ void PairwiseSeqsCommand::createProcesses(string filename) { if (output != "square") { driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", cutoff); } else { driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", "square"); } 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 (map::iterator it = processIDS.begin(); it != processIDS.end(); it++) { int temp = it->second; kill (temp, SIGINT); } + exit(0); + } } //force parent to wait until all the processes are done diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp index efa14cd..a97e095 100644 --- a/phylodiversitycommand.cpp +++ b/phylodiversitycommand.cpp @@ -322,7 +322,11 @@ int PhyloDiversityCommand::createProcesses(vector& procIters, Tree* t, map< 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); + } } driver(t, div, sumDiv, procIters[0], increment, randomLeaf, numSampledList, outCollect, outSum, true); diff --git a/pintail.cpp b/pintail.cpp index c0ea904..2fa1ca7 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -560,7 +560,11 @@ void Pintail::createProcessesQuan() { 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 does its part diff --git a/rarefact.cpp b/rarefact.cpp index d04885f..ec77dd5 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -137,7 +137,11 @@ int Rarefact::createProcesses(vector& procIters, RarefactionCurveData* rcd, displays[i]->outputTempFiles(tempFile); } 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); + } } driver(rcd, increment, procIters[0]); diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 30dda1f..98b6681 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -721,7 +721,11 @@ int ScreenSeqsCommand::createProcessesCreateSummary(vector& 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]); @@ -1046,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 diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 5776b97..7edb717 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -505,7 +505,11 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& 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); + } } //force parent to wait until all the processes are done diff --git a/splitmatrix.cpp b/splitmatrix.cpp index dcc5b50..ec71e5b 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -77,7 +77,7 @@ int SplitMatrix::splitDistance(){ int SplitMatrix::splitClassify(){ try { cutoff = int(cutoff); - + map seqGroup; map::iterator it; map::iterator it2; @@ -182,7 +182,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG //process each distance file for (int i = 0; i < numGroups; i++) { - string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); + string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(1) + ", cutoff=" + toString(distCutoff); Command* command = new DistanceCommand(options); command->execute(); diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 32a9f7c..956e080 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -508,7 +508,11 @@ int SummarySharedCommand::process(vector thisLookup, string } 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 diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 4e7a129..8aacd9d 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -714,7 +714,11 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName }else if (pid == 0){ driverCreateTrim(filename, qFileName, (trimFile + toString(getpid()) + ".temp"), (scrapFile + toString(getpid()) + ".temp"), (trimQFile + toString(getpid()) + ".temp"), (scrapQFile + toString(getpid()) + ".temp"), (groupFile + toString(getpid()) + ".temp"), fastaNames, qualNames, lines[process], qLines[process]); 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 diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 33a0e6d..df73c93 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -349,7 +349,11 @@ int UnifracWeightedCommand::createProcesses(Tree* t, vector< vector > na 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); + } } driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, scores); diff --git a/unweighted.cpp b/unweighted.cpp index 0ac7147..ef9e521 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -116,7 +116,11 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfG 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); + } } results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num); @@ -363,7 +367,11 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfG 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); + } } results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, usingGroups); diff --git a/weighted.cpp b/weighted.cpp index 6cbeae8..1ac2746 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -104,7 +104,11 @@ EstOutput Weighted::createProcesses(Tree* t, vector< vector > namesOfGro 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); + } } results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num);