+}
+/**************************************************************************************************/
+EstOutput Weighted::getValues(Tree* t, string groupA, string groupB) {
+ try {
+
+ data.clear(); //clear out old values
+
+ CountTable* ct = t->getCountTable();
+
+ if (m->control_pressed) { return data; }
+
+ //initialize weighted score
+ WScore[(groupA+groupB)] = 0.0;
+ double D = 0.0;
+ set<int> validBranches;
+
+ vector<string> groups; groups.push_back(groupA); groups.push_back(groupB);
+
+ //adding the wieghted sums from group i
+ for (int j = 0; j < t->groupNodeInfo[groups[0]].size(); j++) { //the leaf nodes that have seqs from group i
+ map<string, int>::iterator it = t->tree[t->groupNodeInfo[groups[0]][j]].pcount.find(groups[0]);
+ int numSeqsInGroupI = it->second;
+
+ double sum = getLengthToRoot(t, t->groupNodeInfo[groups[0]][j], groups[0], groups[1]);
+ double weightedSum = ((numSeqsInGroupI * sum) / (double)ct->getGroupCount(groups[0]));
+
+ D += weightedSum;
+ }
+
+ //adding the wieghted sums from group l
+ for (int j = 0; j < t->groupNodeInfo[groups[1]].size(); j++) { //the leaf nodes that have seqs from group l
+ map<string, int>::iterator it = t->tree[t->groupNodeInfo[groups[1]][j]].pcount.find(groups[1]);
+ int numSeqsInGroupL = it->second;
+
+ double sum = getLengthToRoot(t, t->groupNodeInfo[groups[1]][j], groups[0], groups[1]);
+ double weightedSum = ((numSeqsInGroupL * sum) / (double)ct->getGroupCount(groups[1]));
+
+ D += weightedSum;
+ }
+
+ //calculate u for the group comb
+ for(int i=0;i<t->getNumNodes();i++){
+
+ if (m->control_pressed) { return data; }
+
+ double u;
+ //int pcountSize = 0;
+ //does this node have descendants from groupA
+ it = t->tree[i].pcount.find(groupA);
+ //if it does u = # of its descendants with a certain group / total number in tree with a certain group
+ if (it != t->tree[i].pcount.end()) {
+ u = (double) t->tree[i].pcount[groupA] / (double) ct->getGroupCount(groupA);
+ }else { u = 0.00; }
+
+
+ //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) ct->getGroupCount(groupB);
+ }
+
+ if (includeRoot) {
+ if (t->tree[i].getBranchLength() != -1) {
+ u = abs(u * t->tree[i].getBranchLength());
+ WScore[(groupA+groupB)] += u;
+ }
+ }else{
+ //if this is not the root then add it
+ if (rootForGrouping[groups].count(i) == 0) {
+ 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);
+
+ if (isnan(UN) || isinf(UN)) { UN = 0; }
+ data.push_back(UN);
+
+ return data;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Weighted", "getValues");