+}
+
+/**************************************************************************************************/
+EstOutput Weighted::getValues(Tree* t, string groupA, string groupB) {
+ try {
+ globaldata = GlobalData::getInstance();
+
+ data.clear(); //clear out old values
+
+ //initialize weighted score
+ WScore[(groupA+groupB)] = 0.0;
+ float D = 0.0;
+
+ vector<string> groups; groups.push_back(groupA); groups.push_back(groupB);
+
+ /********************************************************/
+ //calculate a D value for the group combo
+ for(int v=0;v<t->getNumLeaves();v++){
+ if (m->control_pressed) { return data; }
+
+ int index = v;
+ double sum = 0.0000;
+
+ //while you aren't at root
+ while(t->tree[index].getParent() != -1){
+
+ //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());
+ }
+
+ if (inUsersGroups(t->tree[v].getGroup(), groups)) {
+ int numSeqsInGroupI, numSeqsInGroupL;
+
+ map<string, int>::iterator it;
+ it = t->tree[v].pcount.find(groups[0]);
+ if (it != t->tree[v].pcount.end()) { //this leaf node contains seqs from group i
+ numSeqsInGroupI = it->second;
+ }else{ numSeqsInGroupI = 0; }
+
+ it = t->tree[v].pcount.find(groups[1]);
+ if (it != t->tree[v].pcount.end()) { //this leaf node contains seqs from group l
+ numSeqsInGroupL = it->second;
+ }else{ numSeqsInGroupL = 0; }
+
+ double weightedSum = ((numSeqsInGroupI * sum) / (double)tmap->seqsPerGroup[groups[0]]) + ((numSeqsInGroupL * sum) / (double)tmap->seqsPerGroup[groups[1]]);
+
+ //sum /= (double)tmap->seqsPerGroup[t->tree[v].getGroup()];
+
+ D += weightedSum;
+ }
+ }
+ /********************************************************/
+
+ //calculate u for the group comb
+ for(int i=0;i<t->getNumNodes();i++){
+
+ if (m->control_pressed) { return data; }
+
+ double u;
+ //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) tmap->seqsPerGroup[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) tmap->seqsPerGroup[groupB];
+ }
+
+ u = abs(u * t->tree[i].getBranchLength());
+
+ //save groupcombs u value
+ 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");