- data.clear(); //clear out old values
-
- for(int i=0;i<t->getNumNodes();i++){
- //calculate weighted score for each of the group comb i.e. with groups A,B,C = AB, AC, BC.
- for (int b=0; b<numGroups; b++) {
- for (int l = b+1; l < numGroups; l++) {
-
- if (m->control_pressed) { return data; }
-
- //calculate a u value for each combo
- double u;
- //does this node have descendants from group b-1
- it = t->tree[i].pcount.find(globaldata->Groups[b]);
- //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[globaldata->Groups[b]] / (double) tmap->seqsPerGroup[globaldata->Groups[b]];
- }else { u = 0.00; }
-
- //does this node have descendants from group l
- it = t->tree[i].pcount.find(globaldata->Groups[l]);
- //if it does subtract their percentage from u
- if (it != t->tree[i].pcount.end()) {
- u -= (double) t->tree[i].pcount[globaldata->Groups[l]] / (double) tmap->seqsPerGroup[globaldata->Groups[l]];
- }
+ //m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine();
+
+ return results;
+#endif
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Weighted", "createProcesses");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+EstOutput Weighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, TreeMap* tmap) {
+ try {
+ EstOutput results;
+ vector<double> D;
+
+ int count = 0;
+ for (int h = start; h < (start+num); h++) {
+
+ if (m->control_pressed) { return results; }
+
+ //initialize weighted score
+ string groupA = namesOfGroupCombos[h][0];
+ string groupB = namesOfGroupCombos[h][1];
+
+ set<int> validBranches;
+ WScore[groupA+groupB] = 0.0;
+ D.push_back(0.0000); //initialize a spot in D for each combination
+
+ //adding the wieghted sums from group i
+ for (int j = 0; j < t->groupNodeInfo[groupA].size(); j++) { //the leaf nodes that have seqs from group i
+ map<string, int>::iterator it = t->tree[t->groupNodeInfo[groupA][j]].pcount.find(groupA);
+ int numSeqsInGroupI = it->second;
+
+ double sum = getLengthToRoot(t, t->groupNodeInfo[groupA][j], groupA, groupB);
+ double weightedSum = ((numSeqsInGroupI * sum) / (double)tmap->seqsPerGroup[groupA]);
+
+ 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);
+ int numSeqsInGroupL = it->second;
+
+ double sum = getLengthToRoot(t, t->groupNodeInfo[groupB][j], groupA, groupB);
+ double weightedSum = ((numSeqsInGroupL * sum) / (double)tmap->seqsPerGroup[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();