X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unweighted.cpp;h=ef9e52188ed32bcea6bf009231bf6c9a0c26ee4a;hb=cbb336d5650cfe1f83a398a837794dcfbbbd3756;hp=edd628d82b72a871b6595aed0d1e644a7fd89af9;hpb=672cc1adbb2f8dac82757653cd579c093fe886c2;p=mothur.git diff --git a/unweighted.cpp b/unweighted.cpp index edd628d..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); @@ -177,7 +181,7 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo for (int h = start; h < (start+num); h++) { - + //cout << namesOfGroupCombos[h][0] << '\t' << namesOfGroupCombos[h][1] << endl; if (m->control_pressed) { return results; } double UniqueBL=0.0000; //a branch length is unique if it's chidren are from the same group @@ -203,12 +207,14 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo nodePcountSize[i] = pcountSize; - if (pcountSize == 0) { ; } + //cout << i << '\t' << t->tree[i].getName() << " br = " << abs(t->tree[i].getBranchLength()) << '\t'; + if (pcountSize == 0) { } else if ((t->tree[i].getBranchLength() != -1) && (pcountSize == 1)) { UniqueBL += abs(t->tree[i].getBranchLength()); } - + //if you are a leaf from a users group add to total if (i < numLeaves) { - if ((t->tree[i].getBranchLength() != -1) && pcountSize != 0) { + if ((t->tree[i].getBranchLength() != -1) && pcountSize != 0) { + //cout << "added to total" << endl; totalBL += abs(t->tree[i].getBranchLength()); } tempTotals[i] = 0.0; //we don't care about you, or we have already added you @@ -220,17 +226,21 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo //if yes, add your childrens tempTotals if ((nodePcountSize[lc] != 0) && (nodePcountSize[rc] != 0)) { totalBL += tempTotals[lc] + tempTotals[rc]; + //cout << "added to total " << tempTotals[lc] << '\t' << tempTotals[rc] << endl; if (t->tree[i].getBranchLength() != -1) { tempTotals[i] = abs(t->tree[i].getBranchLength()); }else { tempTotals[i] = 0.0; } + }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()); } + //cout << "temptotal = "<< tempTotals[i] << endl; } + } - cout << UniqueBL << '\t' << totalBL << endl; + //cout << UniqueBL << '\t' << totalBL << endl; UW = (UniqueBL / totalBL); if (isnan(UW) || isinf(UW)) { UW = 0; } @@ -357,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); @@ -446,13 +460,13 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo } nodePcountSize[i] = pcountSize; - + if (pcountSize == 0) { } - else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize == 1)) { UniqueBL += abs(copyTree->tree[i].getBranchLength()); } + else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize == 1)) { UniqueBL += abs(copyTree->tree[i].getBranchLength()); } //if you are a leaf from a users group add to total if (i < numLeaves) { - if ((copyTree->tree[i].getBranchLength() != -1) && pcountSize != 0) { + if ((copyTree->tree[i].getBranchLength() != -1) && pcountSize != 0) { totalBL += abs(copyTree->tree[i].getBranchLength()); } tempTotals[i] = 0.0; //we don't care about you, or we have already added you @@ -464,14 +478,17 @@ EstOutput Unweighted::driver(Tree* t, vector< vector > namesOfGroupCombo //if yes, add your childrens tempTotals if ((nodePcountSize[lc] != 0) && (nodePcountSize[rc] != 0)) { totalBL += tempTotals[lc] + tempTotals[rc]; + if (copyTree->tree[i].getBranchLength() != -1) { tempTotals[i] = abs(copyTree->tree[i].getBranchLength()); }else { tempTotals[i] = 0.0; } + }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()); } + } }