+
+ //sanity check
+ if (nodeBelonging == -1) {
+ m->mothurOut("[WARNING]: cannot find a nodes in the tree from grouping ");
+ for (int g = 0; g < namesOfGroupCombos[h].size()-1; g++) { m->mothurOut(namesOfGroupCombos[h][g] + "-"); }
+ m->mothurOut(namesOfGroupCombos[h][namesOfGroupCombos[h].size()-1]);
+ m->mothurOut(", skipping."); m->mothurOutEndLine(); results[count] = UW;
+ }else{
+ //cout << "trying to get root" << endl;
+ //if including the root this clears rootForGrouping[namesOfGroupCombos[h]]
+ getRoot(t, nodeBelonging, namesOfGroupCombos[h]);
+ //cout << "here" << endl;
+ for(int i=0;i<t->getNumNodes();i++){
+
+ if (m->control_pressed) { return data; }
+ //cout << i << endl;
+ //pcountSize = 0, they are from a branch that is entirely from a group the user doesn't want
+ //pcountSize = 2, not unique to one group
+ //pcountSize = 1, unique to one group
+
+ int pcountSize = 0;
+ for (int j = 0; j < namesOfGroupCombos[h].size(); j++) {
+ map<string, int>::iterator itGroup = t->tree[i].pcount.find(namesOfGroupCombos[h][j]);
+ if (itGroup != t->tree[i].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } }
+ }
+
+
+ //unique calc
+ if (pcountSize == 0) { }
+ else if ((t->tree[i].getBranchLength() != -1) && (pcountSize == 1) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a unique branch length and you are not the root
+ UniqueBL += abs(t->tree[i].getBranchLength());
+ }
+
+ //total calc
+ if (pcountSize == 0) { }
+ else if ((t->tree[i].getBranchLength() != -1) && (pcountSize != 0) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a branch length and you are not the root
+ totalBL += abs(t->tree[i].getBranchLength());
+ }
+ }
+ //cout << UniqueBL << '\t' << totalBL << endl;
+ UW = (UniqueBL / totalBL);
+
+ if (isnan(UW) || isinf(UW)) { UW = 0; }
+
+ results[count] = UW;
+ }
+ count++;
+
+ //report progress
+ //if((count % twentyPercent) == 0) { float tempOut = (count / (float)total); if (isnan(tempOut) || isinf(tempOut)) { tempOut = 0.0; } m->mothurOut("Percentage complete: " + toString((int(tempOut) * 100.0))); m->mothurOutEndLine(); }
+ }
+
+ //report progress
+ //if((count % twentyPercent) != 0) { float tempOut = (count / (float)total); if (isnan(tempOut) || isinf(tempOut)) { tempOut = 0.0; } m->mothurOut("Percentage complete: " + toString((int(tempOut) * 100.0))); m->mothurOutEndLine(); }
+
+ return results;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Unweighted", "driver");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+
+EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, string o) {
+ try {
+ processors = p;
+ outputDir = o;
+
+ CountTable* ct = t->getCountTable();
+
+ //if the users enters no groups then give them the score of all groups
+ int numGroups = m->getNumGroups();
+
+ //calculate number of comparsions
+ int numComp = 0;
+ vector< vector<string> > namesOfGroupCombos;
+ for (int r=0; r<numGroups; r++) {
+ for (int l = 0; l < r; l++) {
+ numComp++;
+ vector<string> groups; groups.push_back((m->getGroups())[r]); groups.push_back((m->getGroups())[l]);
+ namesOfGroupCombos.push_back(groups);
+ }
+ }
+
+ if (numComp != 1) {
+ vector<string> groups;
+ if (numGroups == 0) {
+ //get score for all users groups
+ for (int i = 0; i < (ct->getNamesOfGroups()).size(); i++) {
+ if ((ct->getNamesOfGroups())[i] != "xxx") {
+ groups.push_back((ct->getNamesOfGroups())[i]);
+ }
+ }
+ namesOfGroupCombos.push_back(groups);
+ }else {
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ groups.push_back((m->getGroups())[i]);
+ }
+ namesOfGroupCombos.push_back(groups);
+ }
+ }