]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
fixed bug in unifrac commands with unrooted trees
[mothur.git] / unweighted.cpp
index ea66294a5354c7cab7c265c3213a967a4a5a01f9..fb2f0b22afa3cc2143ad95afe6c45e4e093db222 100644 (file)
@@ -232,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;
                                }
@@ -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];
+                                               }
                                        }
                                        
                                }