5 * Created by Sarah Westcott on 1/26/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "parsimony.h"
12 /**************************************************************************************************/
14 EstOutput Parsimony::getValues(Tree* t) {
16 globaldata = GlobalData::getInstance();
18 copyTree = new Tree();
20 //if the users enters no groups then give them the score of all groups
21 int numGroups = globaldata->Groups.size();
24 for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
25 globaldata->Groups.push_back(tmap->namesOfGroups[i]);
29 //calculate number of comparsions
31 for (int r=0; r<numGroups; r++) {
32 for (int l = r+1; l < numGroups; l++) {
37 //numComp+1 for AB, AC, BC, ABC
38 data.resize(numComp+1,0);
39 vector<string> groups;
42 for (int a=0; a<numGroups; a++) {
43 for (int l = a+1; l < numGroups; l++) {
46 //groups in this combo
47 groups.push_back(globaldata->Groups[a]); groups.push_back(globaldata->Groups[l]);
49 //copy users tree so that you can redo pgroups
52 //create pgroups that reflect the groups the user want to use
53 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
54 copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
57 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
58 int lc = copyTree->tree[i].getLChild();
59 int rc = copyTree->tree[i].getRChild();
61 int iSize = copyTree->tree[i].pGroups.size();
62 int rcSize = copyTree->tree[rc].pGroups.size();
63 int lcSize = copyTree->tree[lc].pGroups.size();
65 //if isize are 0 then that branch is to be ignored
67 else if ((rcSize == 0) || (lcSize == 0)) { }
68 //if you have more groups than either of your kids then theres been a change.
69 else if(iSize > rcSize || iSize > lcSize){
80 //get score for all users groups
82 //copy users tree so that you can redo pgroups
86 //create pgroups that reflect the groups the user want to use
87 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
88 copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, globaldata->Groups));
91 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
92 int lc = copyTree->tree[i].getLChild();
93 int rc = copyTree->tree[i].getRChild();
95 int iSize = copyTree->tree[i].pGroups.size();
96 int rcSize = copyTree->tree[rc].pGroups.size();
97 int lcSize = copyTree->tree[lc].pGroups.size();
99 //if isize are 0 then that branch is to be ignored
101 else if ((rcSize == 0) || (lcSize == 0)) { }
102 //if you have more groups than either of your kids then theres been a change.
103 else if(iSize > rcSize || iSize > lcSize){
112 catch(exception& e) {
113 cout << "Standard Error: " << e.what() << " has occurred in the Parsimony class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
117 cout << "An unknown error has occurred in the Parsimony class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
123 /**************************************************************************************************/