if (i <= (numLeaves-1)) {
tree[i].setName(globaldata->gTreemap->namesOfSeqs[i]);
tree[i].setGroup(globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i]));
- //the node knows its index
- tree[i].setIndex(i);
//set pcount and pGroup for groupname to 1.
tree[i].pcount[globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i])] = 1;
tree[i].pGroups[globaldata->gTreemap->getGroup(globaldata->gTreemap->namesOfSeqs[i])] = 1;
}else if (i > (numLeaves-1)) {
tree[i].setName("");
tree[i].setGroup("");
- //the node knows its index
- tree[i].setIndex(i);
}
}
}
}
/*****************************************************************/
-
int Tree::getIndex(string searchName) {
try {
//Treemap knows name, group and index to speed up search
try {
int lc = tree[i].getLChild();
int rc = tree[i].getRChild();
-
+
//set parsimony groups to left child
map<string,int> parsimony = tree[lc].pGroups;
for(it=parsimony.begin();it!=parsimony.end();it++){
if(it->second == 1){
parsimony.erase(it->first);
- it--;
+// it--;
}
}
//set one remaining groups to 1
maxPars = parsimony[it->first];
}
}
-
+
// this is true if right child had a greater parsimony for a certain group
if(maxPars > 1){
//erase all the groups that are only 1 because you found something with 2.
for(it=parsimony.begin();it!=parsimony.end();it++){
if(it->second == 1){
parsimony.erase(it->first);
- it--;
}
}
- //set one remaining groups to 1
- //so with our above example p[white] = 2 would be left and it would become p[white] = 1
for(it=parsimony.begin();it!=parsimony.end();it++){
parsimony[it->first] = 1;
}
+ }
- }
-
return parsimony;
}
catch(exception& e) {