X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parsimony.cpp;h=54960cc516047f0f43ff8cde28f697512d9d6c91;hb=010638fc7580c18a51f5ed650e9ee7589c8fb2d4;hp=6239f75f08a59c9a5f690401e15ef93c19fe8f50;hpb=d97b619c4297b1274c754d73a64792ba656b0a79;p=mothur.git diff --git a/parsimony.cpp b/parsimony.cpp index 6239f75..54960cc 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -17,47 +17,44 @@ EstOutput Parsimony::getValues(Tree* t) { data.resize(1,0); int score = 0; - + + //create pgroups that reflect the groups the user want to use + for(int i=t->getNumLeaves();igetNumNodes();i++){ + t->tree[i].pGroups = (t->mergeUserGroups(i)); + } + for(int i=t->getNumLeaves();igetNumNodes();i++){ int lc = t->tree[i].getLChild(); int rc = t->tree[i].getRChild(); - int iSize = 0; - int rcSize = 0; - int lcSize = 0; - + int iSize = t->tree[i].pGroups.size(); + int rcSize = t->tree[rc].pGroups.size(); + int lcSize = t->tree[lc].pGroups.size(); +cout << " i groups "; //add in all the groups the users wanted for (it = t->tree[i].pGroups.begin(); it != t->tree[i].pGroups.end(); it++) { - if (inUsersGroups(it->first, globaldata->Groups) == true) { iSize++; } +cout << it->first << " "; + // if (inUsersGroups(it->first, globaldata->Groups) != true) { iSize--; } } - - //if that leaves no groups give it 1 so it will cause no change to parent - if (iSize == 0) { iSize++; } - +cout << endl << " rc groups "; //add in all the groups the users wanted for (it = t->tree[rc].pGroups.begin(); it != t->tree[rc].pGroups.end(); it++) { - - if (inUsersGroups(it->first, globaldata->Groups) == true) { rcSize++; } +cout << it->first << " "; + //if (inUsersGroups(it->first, globaldata->Groups) != true) { rcSize--; } } - - //if that leaves no groups give it 1 so it will cause no change to parent - if (rcSize == 0) { rcSize++; } - - +cout << endl << " lc groups "; //add in all the groups the users wanted for (it = t->tree[lc].pGroups.begin(); it != t->tree[lc].pGroups.end(); it++) { - - if (inUsersGroups(it->first, globaldata->Groups) == true) { lcSize++; } +cout << it->first << " "; + //if (inUsersGroups(it->first, globaldata->Groups) != true) { lcSize--; } } - - //if that leaves no groups give it 1 so it will cause no change to parent - if (lcSize == 0) { lcSize++; } - - +cout << endl; + //if isize are 0 then that branch is to be ignored + if (iSize == 0) { } + else if ((rcSize == 0) || (lcSize == 0)) { } //if you have more groups than either of your kids then theres been a change. - if(iSize > rcSize || iSize > lcSize){ + else if(iSize > rcSize || iSize > lcSize){ score++; - } }