From dbc9352256135d7b3e2b17dddc5c506770e2df92 Mon Sep 17 00:00:00 2001 From: pschloss Date: Fri, 6 Mar 2009 14:58:27 +0000 Subject: [PATCH] fixed parsimony bug --- ace.cpp | 2 -- parsimony.cpp | 16 +++++++++++++++- tree.cpp | 10 +++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ace.cpp b/ace.cpp index d074310..17049bd 100644 --- a/ace.cpp +++ b/ace.cpp @@ -13,9 +13,7 @@ EstOutput Ace::getValues(SAbundVector* rank) { try { - cout << "abund = " << abund << "\n"; data.resize(3,0); - // vector aceData(3,0); double ace, acelci, acehci; int nrare = 0; diff --git a/parsimony.cpp b/parsimony.cpp index 0dea64e..fc1a8b6 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -89,9 +89,12 @@ EstOutput Parsimony::getValues(Tree* t) { //create pgroups that reflect the groups the user want to use for(int i=copyTree->getNumLeaves();igetNumNodes();i++){ +// cout << i << "..." << endl; copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups)); } +// map::iterator it; + for(int i=copyTree->getNumLeaves();igetNumNodes();i++){ int lc = copyTree->tree[i].getLChild(); int rc = copyTree->tree[i].getRChild(); @@ -99,7 +102,15 @@ EstOutput Parsimony::getValues(Tree* t) { int iSize = copyTree->tree[i].pGroups.size(); int rcSize = copyTree->tree[rc].pGroups.size(); int lcSize = copyTree->tree[lc].pGroups.size(); - + +// cout << i+1 << '\t' << lc+1 << '\t' << rc+1 << ":\t"; + +// for(it=copyTree->tree[i].pGroups.begin();it!=copyTree->tree[i].pGroups.end();it++){ +// cout << it->first << '\t'; +// } + +// cout << " : " << iSize << '\t' << rcSize << '\t' << lcSize << '\t'; + //if isize are 0 then that branch is to be ignored if (iSize == 0) { } else if ((rcSize == 0) || (lcSize == 0)) { } @@ -107,9 +118,12 @@ EstOutput Parsimony::getValues(Tree* t) { else if(iSize > rcSize || iSize > lcSize){ score++; } +// cout << score << endl; } data[count] = score; + string hold; +// cin >> hold; } return data; diff --git a/tree.cpp b/tree.cpp index 2cd9cba..1e115bd 100644 --- a/tree.cpp +++ b/tree.cpp @@ -178,7 +178,7 @@ map Tree::mergeGroups(int i) { for(it=parsimony.begin();it!=parsimony.end();it++){ if(it->second == 1){ parsimony.erase(it->first); - it--; +// it--; } } //set one remaining groups to 1 @@ -240,24 +240,20 @@ map Tree::mergeUserGroups(int i, vector g) { 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) { -- 2.39.2