From: westcott Date: Mon, 8 Nov 2010 13:55:38 +0000 (+0000) Subject: fixed cluster.split bug X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=cdf9083dc32543cc640e72e9ca3aee0323cbad45 fixed cluster.split bug --- diff --git a/distancecommand.cpp b/distancecommand.cpp index edb6314..70c0a78 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -540,7 +540,7 @@ void DistanceCommand::createProcesses(string filename) { int pid = fork(); if (pid > 0) { - processIDS[lines[process]->end] = pid; //create map from line number to pid so you can append files in correct order later + 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){ if (output != "square") { driver(lines[process]->start, lines[process]->end, filename + toString(getpid()) + ".temp", cutoff); } @@ -548,7 +548,8 @@ void DistanceCommand::createProcesses(string filename) { 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); } + perror(" : "); + for (int i=0;i::iterator it = processIDS.begin(); it != processIDS.end(); it++) { - int temp = it->second; + for (int i=0;i::iterator it = processIDS.begin(); it != processIDS.end(); it++) { - m->appendFiles((filename + toString(it->second) + ".temp"), filename); - remove((filename + toString(it->second) + ".temp").c_str()); + for (int i=0;iappendFiles((filename + toString(processIDS[i]) + ".temp"), filename); + remove((filename + toString(processIDS[i]) + ".temp").c_str()); } #endif } diff --git a/distancecommand.h b/distancecommand.h index 3b2d345..3e3dc70 100644 --- a/distancecommand.h +++ b/distancecommand.h @@ -43,7 +43,7 @@ private: int processors, numNewFasta; float cutoff; - map processIDS; //end line, processid + vector processIDS; //end line, processid vector lines; bool abort; diff --git a/mothur b/mothur index 5b2897b..607932c 100755 Binary files a/mothur and b/mothur differ diff --git a/mothurout.cpp b/mothurout.cpp index de6da8c..9ec847c 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -658,6 +658,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){ fileHandle.open(completeFileName.c_str()); if(!fileHandle) { + mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine(); return 1; }else { //check for blank file @@ -801,6 +802,7 @@ void MothurOut::appendFiles(string temp, string filename) { //open output file in append mode openOutputFileAppend(filename, output); int ableToOpen = openInputFile(temp, input, "no error"); + //int ableToOpen = openInputFile(temp, input); if (ableToOpen == 0) { //you opened it while(char c = input.get()){ @@ -1038,7 +1040,7 @@ vector MothurOut::divideFile(string filename, int& proc) { //sanity check filePos for (int i = 0; i < (filePos.size()-1); i++) { - if (filePos[(i+1)] <= filePos[i]) { cout << "erasing " << (i+1) << endl; filePos.erase(filePos.begin()+(i+1)); i--; } + if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; } } proc = (filePos.size() - 1); diff --git a/splitmatrix.cpp b/splitmatrix.cpp index 13b4bd4..1f23ec3 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -10,6 +10,7 @@ #include "splitmatrix.h" #include "phylotree.h" #include "distancecommand.h" +#include "seqsummarycommand.h" /***********************************************************************/ @@ -185,6 +186,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); Command* command = new DistanceCommand(options); + command->execute(); delete command; @@ -193,7 +195,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG //remove old names files just in case remove((namefile + "." + toString(i) + ".temp").c_str()); } - + singleton = namefile + ".extra.temp"; ofstream remainingNames; m->openOutputFile(singleton, remainingNames);