X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unweighted.cpp;h=fb2f0b22afa3cc2143ad95afe6c45e4e093db222;hb=5334a314651228c55fd0f206dec0209bc3148b24;hp=0ac7147d7d8b0b288789267c18c43e1867b43e93;hpb=59c2827ee568dcc9293faef40e5d67499bc68bc3;p=mothur.git diff --git a/unweighted.cpp b/unweighted.cpp index 0ac7147..fb2f0b2 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -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 > namesOfG try { #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) int process = 1; - int num = 0; vector processIDS; EstOutput results; @@ -116,7 +114,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); @@ -230,7 +232,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo } }else if ((nodePcountSize[lc] == 0) && (nodePcountSize[rc] == 0)) { tempTotals[i] = 0.0; //we don't care about you }else { //if no, your tempTotal is your childrens temp totals + your branch length - tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(t->tree[i].getBranchLength()); + if (t->tree[i].getBranchLength() != -1) { + tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(t->tree[i].getBranchLength()); + }else { + tempTotals[i] = tempTotals[lc] + tempTotals[rc]; + } } //cout << "temptotal = "<< tempTotals[i] << endl; } @@ -314,7 +320,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 +342,6 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfG try { #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) int process = 1; - int num = 0; vector processIDS; EstOutput results; @@ -363,7 +368,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); @@ -386,12 +395,13 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > 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 +425,6 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > 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; @@ -478,7 +486,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo } }else if ((nodePcountSize[lc] == 0) && (nodePcountSize[rc] == 0)) { tempTotals[i] = 0.0; //we don't care about you }else { //if no, your tempTotal is your childrens temp totals + your branch length - tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength()); + if (t->tree[i].getBranchLength() != -1) { + tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength()); + }else { + tempTotals[i] = tempTotals[lc] + tempTotals[rc]; + } } }