]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
fixed bug in unifrac commands with unrooted trees
[mothur.git] / unweighted.cpp
index 24b41a1d03317e343e05c65c7516e94778cd557c..fb2f0b22afa3cc2143ad95afe6c45e4e093db222 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();
                        }
@@ -233,7 +232,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > 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;
                                }
@@ -317,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();
@@ -392,12 +395,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);
@@ -482,7 +486,11 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > 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];
+                                               }
                                        }
                                        
                                }