-void PhyloDiversity::setTotalGroupBranchLengths(Tree* t) {
- try {
-
- groupTotals.clear();
-
- //initialize group totals
- for (int i=0; i<globaldata->Groups.size(); i++) { groupTotals[globaldata->Groups[i]] = 0.0; }
-
-
- /********************************************************/
- //calculate a D value for each group
- for(int v=0;v<t->getNumLeaves();v++){
-
- //is this node from a sequence which is in one of the users groups
- if (inUsersGroups(t->tree[v].getGroup(), globaldata->Groups) == true) {
-
- //calc the branch length
- int index = v;
- float sum = 0.0;
-
- while(t->tree[index].getParent() != -1){ //while you aren't at root
-
- //if you have a BL
- if(t->tree[index].getBranchLength() != -1){
- sum += abs(t->tree[index].getBranchLength());
- }
- index = t->tree[index].getParent();
- }
-
- //get last breanch length added
- if(t->tree[index].getBranchLength() != -1){
- sum += abs(t->tree[index].getBranchLength());
- }
-
- //account for the names file
- vector<string> groups = t->tree[v].getGroup();
- for (int j = 0; j < groups.size(); j++) {
- int numSeqsInGroupJ = 0;
- map<string, int>::iterator it;
- it = t->tree[v].pcount.find(groups[j]);
- if (it != t->tree[v].pcount.end()) { //this leaf node contains seqs from group j
- numSeqsInGroupJ = it->second;
- }