D[count] += weightedSum;
}
-
+
//adding the wieghted sums from group l
for (int j = 0; j < t->groupNodeInfo[groupB].size(); j++) { //the leaf nodes that have seqs from group l
map<string, int>::iterator it = t->tree[t->groupNodeInfo[groupB][j]].pcount.find(groupB);
D[count] += weightedSum;
}
-
count++;
}
-
+
//calculate u for the group comb
-
for (int h = start; h < (start+num); h++) {
//report progress
- m->mothurOut("Processing combo: " + toString(h)); m->mothurOutEndLine();
+ //m->mothurOut("Processing combo: " + toString(h)); m->mothurOutEndLine();
string groupA = namesOfGroupCombos[h][0];
string groupB = namesOfGroupCombos[h][1];
//does this node have descendants from group l
it = t->tree[i].pcount.find(groupB);
+
//if it does subtract their percentage from u
if (it != t->tree[i].pcount.end()) {
u -= (double) t->tree[i].pcount[groupB] / (double) tmap->seqsPerGroup[groupB];
//if this is not the root then add it
if (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0) {
- u = abs(u * t->tree[i].getBranchLength());
- WScore[(groupA+groupB)] += u;
+ if (t->tree[i].getBranchLength() != -1) {
+ u = abs(u * t->tree[i].getBranchLength());
+ WScore[(groupA+groupB)] += u;
+ }
}
-
}
+
}
/********************************************************/
count = 0;
for (int h = start; h < (start+num); h++) {
UN = (WScore[namesOfGroupCombos[h][0]+namesOfGroupCombos[h][1]] / D[count]);
-
if (isnan(UN) || isinf(UN)) { UN = 0; }
results.push_back(UN);
count++;
D += weightedSum;
}
-
- int numLeaves = t->getNumLeaves();
-
+
//calculate u for the group comb
for(int i=0;i<t->getNumNodes();i++){
//if this is not the root then add it
if (rootForGrouping[groups].count(i) == 0) {
- u = abs(u * t->tree[i].getBranchLength());
- WScore[(groupA+groupB)] += u;
+ if (t->tree[i].getBranchLength() != -1) {
+ u = abs(u * t->tree[i].getBranchLength());
+ WScore[(groupA+groupB)] += u;
+ }
}
}
/********************************************************/
-
+
//calculate weighted score for the group combination
double UN;
UN = (WScore[(groupA+groupB)] / D);
int sib = lc;
if (lc == index) { sib = rc; }
-
+
map<string, int>::iterator itGroup;
int pcountSize = 0;
itGroup = t->tree[sib].pcount.find(groupA);
//get all nodes above the root to add so we don't add their u values above
index = *(rootForGrouping[grouping].begin());
+
while(t->tree[index].getParent() != -1){
int parent = t->tree[index].getParent();
rootForGrouping[grouping].insert(parent);
index = parent;
}
-
return sum;
}
catch(exception& e) {