- string group = tmap->getGroup(Groups[i]);
- vector<string> tempGroups; tempGroups.push_back(group);
- tree[i].setGroup(tempGroups);
- groupNodeInfo[group].push_back(i);
-
- //set pcount and pGroup for groupname to 1.
- tree[i].pcount[group] = 1;
- tree[i].pGroups[group] = 1;
-
- //Treemap knows name, group and index to speed up search
- tmap->setIndex(Groups[i], i);
-
- //intialize non leaf nodes
+ int maxPars = 1;
+ vector<string> group;
+ vector<int> counts = ct->getGroupCounts(Groups[i]);
+ for (int j = 0; j < namesOfGroups.size(); j++) {
+ if (counts[j] != 0) { //you have seqs from this group
+ groupNodeInfo[namesOfGroups[j]].push_back(i);
+ group.push_back(namesOfGroups[j]);
+ tree[i].pGroups[namesOfGroups[j]] = counts[j];
+ tree[i].pcount[namesOfGroups[j]] = counts[j];
+ //keep highest group
+ if(counts[j] > maxPars){ maxPars = counts[j]; }
+ }
+ }
+ tree[i].setGroup(group);
+ setIndex(Groups[i], i);
+
+ if (maxPars > 1) { //then we have some more dominant groups
+ //erase all the groups that are less than maxPars because you found a more dominant group.
+ for(it=tree[i].pGroups.begin();it!=tree[i].pGroups.end();){
+ if(it->second < maxPars){
+ tree[i].pGroups.erase(it++);
+ }else { it++; }
+ }
+ //set one remaining groups to 1
+ for(it=tree[i].pGroups.begin();it!=tree[i].pGroups.end();it++){
+ tree[i].pGroups[it->first] = 1;
+ }
+ }//end if
+
+ //intialize non leaf nodes