]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed cluster.split bug
authorwestcott <westcott>
Mon, 8 Nov 2010 13:55:38 +0000 (13:55 +0000)
committerwestcott <westcott>
Mon, 8 Nov 2010 13:55:38 +0000 (13:55 +0000)
distancecommand.cpp
distancecommand.h
mothur
mothurout.cpp
splitmatrix.cpp

index edb6314427a423f216ab5ab6576305d8c0b51687..70c0a7806c2902b73f20601ff1fda5b330aa8c10 100644 (file)
@@ -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<int, int>::iterator it = processIDS.begin(); it != processIDS.end(); it++) { int temp = it->second; kill (temp, SIGINT); }
+                               perror(" : ");
+                               for (int i=0;i<processIDS.size();i++) {  int temp = processIDS[i]; kill (temp, SIGINT); }
                                exit(0);
                        }
                }
@@ -559,15 +560,15 @@ void DistanceCommand::createProcesses(string filename) {
                
                
                //force parent to wait until all the processes are done
-               for (map<int, int>::iterator it = processIDS.begin(); it != processIDS.end(); it++) { 
-                       int temp = it->second;
+               for (int i=0;i<processIDS.size();i++) { 
+                       int temp = processIDS[i];
                        wait(&temp);
                }
                
                //append and remove temp files
-               for (map<int, int>::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;i<processIDS.size();i++) { 
+                       m->appendFiles((filename + toString(processIDS[i]) + ".temp"), filename);
+                       remove((filename + toString(processIDS[i]) + ".temp").c_str());
                }
 #endif
        }
index 3b2d345d73fc46244446cd136366869f92a6e6d6..3e3dc7098a768461c67dc1d45751e50891ccc9c2 100644 (file)
@@ -43,7 +43,7 @@ private:
 
        int processors, numNewFasta;
        float cutoff;
-       map<int, int> processIDS;   //end line, processid
+       vector<int> processIDS;   //end line, processid
        vector<linePair*> lines;
        
        bool abort;
diff --git a/mothur b/mothur
index 5b2897bf929025c213710269df8eb49372369223..607932c98a801c4a3a026780c00eb011c9471e1e 100755 (executable)
Binary files a/mothur and b/mothur differ
index de6da8c217a36a17368be48c21a7116d36a43108..9ec847c81152b3ee0b33742c0d369acb74a4f98a 100644 (file)
@@ -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<unsigned long int> 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);
index 13b4bd46b6cb487f91344a678fa94bbc8552fbea..1f23ec3aa48202d6516208d643c09b6928da6f47 100644 (file)
@@ -10,6 +10,7 @@
 #include "splitmatrix.h"
 #include "phylotree.h"
 #include "distancecommand.h"
+#include "seqsummarycommand.h"
 
 /***********************************************************************/
 
@@ -185,6 +186,7 @@ int SplitMatrix::createDistanceFilesFromTax(map<string, int>& 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<string, int>& 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);