- //does this node have descendants from group l
- it = t->tree[i].pcount.find(tmap->namesOfGroups[l]);
- //if it does subtract their percentage from u
- if (it != t->tree[i].pcount.end()) {
- u -= (double) t->tree[i].pcount[tmap->namesOfGroups[l]] / (double) tmap->seqsPerGroup[tmap->namesOfGroups[l]];
+ //while you aren't at root
+ while(t->tree[index].getParent() != -1){
+
+ //if you have a BL
+ if(t->tree[index].getBranchLength() != -1){
+ sum += t->tree[index].getBranchLength();
+ }
+
+ index = t->tree[index].getParent();
+ }
+
+ //get last breanch length added
+ if(t->tree[index].getBranchLength() != -1){
+ sum += t->tree[index].getBranchLength();
+ }
+
+ if (globaldata->Groups.size() == 0) {
+ //is this sum from a sequence which is in one of the users groups
+ if (inUsersGroups(t->tree[v].getGroup(), tmap->namesOfGroups) == true) {
+ //is this sum from a sequence which is in this groupCombo
+ if ((t->tree[v].getGroup() == tmap->namesOfGroups[b-1]) || (t->tree[v].getGroup() == tmap->namesOfGroups[l])) {
+ sum /= (double)tmap->seqsPerGroup[t->tree[v].getGroup()];
+ D[n-1] += sum;
+ }
+ }
+ }else {
+ //is this sum from a sequence which is in one of the users groups
+ if (inUsersGroups(t->tree[v].getGroup(), globaldata->Groups) == true) {
+ //is this sum from a sequence which is in this groupCombo
+ if ((t->tree[v].getGroup() == globaldata->Groups[b-1]) || (t->tree[v].getGroup() == globaldata->Groups[l])) {
+ sum /= (double)tmap->seqsPerGroup[t->tree[v].getGroup()];
+ D[n-1] += sum;
+ }
+ }
+ }