1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void findParsimony(string s, std::map <string, Node>& tr,int len){
if(tr[s].getChild(0)=="NA"){cout<< s <<"\n\n";}//base case is when function reaches a leaf
else{
findParsimony(tr[s].getChild(0),tr,len); //pass left branch
findParsimony(tr[s].getChild(1),tr,len); //pass right branch
cout << "got here for " << s << endl;
for(int i=0;i<len;i++){
if(tr[tr[s].getChild(0)].getSeqAt(i)==tr[tr[s].getChild(1)].getSeqAt(i)){
tr[s].setTrace(i,'L');
tr[s].setSeq(i, tr[tr[s].getChild(0)].getSeqAt(i) );
tr[s].setScore(i, min( tr[tr[s].getChild(0)].getScoreAt(i), tr[tr[s].getChild(1)].getScoreAt(i) ) );
}
else{
if(tr[tr[s].getChild(0)].getScoreAt(i)+1 < tr[tr[s].getChild(1)].getScoreAt(i)+1){
tr[s].setTrace(i,'L');
tr[s].setSeq(i, tr[tr[s].getChild(0)].getSeqAt(i) );
tr[s].setScore(i, tr[tr[s].getChild(0)].getScoreAt(i)+1 );
}
else{
tr[s].setTrace(i,'R');
tr[s].setSeq(i, tr[tr[s].getChild(1)].getSeqAt(i) );
tr[s].setScore(i, tr[tr[s].getChild(1)].getScoreAt(i)+1 );
}
}
}
}
}
|