]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
fixed unifrac bug with multiple processors if numComps was less than processors....
[mothur.git] / unweighted.cpp
index 0ac7147d7d8b0b288789267c18c43e1867b43e93..ea66294a5354c7cab7c265c3213a967a4a5a01f9 100644 (file)
@@ -66,7 +66,6 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                
                                        lines.push_back(linePair(startPos, numPairsPerProcessor));
                                }
-
                                data = createProcesses(t, namesOfGroupCombos);
                                lines.clear();
                        }
@@ -87,7 +86,6 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfG
        try {
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                int process = 1;
-               int num = 0;
                vector<int> processIDS;
                
                EstOutput results;
@@ -116,7 +114,11 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > 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);
@@ -314,7 +316,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
                                        }
                                        lines.push_back(linePair(startPos, numPairsPerProcessor));
                                }
-
+                                       
                                data = createProcesses(t, namesOfGroupCombos, true);
                                
                                lines.clear();
@@ -336,7 +338,6 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfG
        try {
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                int process = 1;
-               int num = 0;
                vector<int> processIDS;
                
                EstOutput results;
@@ -363,7 +364,11 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > 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);
@@ -386,12 +391,13 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfG
                        if (!in.eof()) {
                                int num;
                                in >> num; m->gobble(in);
-                               
+                                       
                                if (m->control_pressed) { break; }
                                
                                double w; 
                                for (int j = 0; j < num; j++) {
                                        in >> w;
+                                       
                                        results.push_back(w);
                                }
                                m->gobble(in);
@@ -415,8 +421,6 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                EstOutput results; results.resize(num);
                
                int count = 0;
-               int total = num;
-               int twentyPercent = (total * 0.20);
                int numLeaves = t->getNumLeaves();
                
                Tree* copyTree = new Tree;