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();
17 vector<string> groups;
19 copyTree = new Tree();
21 //if the users enters no groups then give them the score of all groups
22 int numGroups = globaldata->Groups.size();
24 //calculate number of comparsions
26 for (int r=0; r<numGroups; r++) {
27 for (int l = r+1; l < numGroups; l++) {
32 //numComp+1 for AB, AC, BC, ABC
33 data.resize(numComp+1,0);
36 for (int a=0; a<numGroups; a++) {
37 for (int l = a+1; l < numGroups; l++) {
40 //groups in this combo
41 groups.push_back(globaldata->Groups[a]); groups.push_back(globaldata->Groups[l]);
43 //copy users tree so that you can redo pgroups
46 //create pgroups that reflect the groups the user want to use
47 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
48 copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
51 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
52 int lc = copyTree->tree[i].getLChild();
53 int rc = copyTree->tree[i].getRChild();
55 int iSize = copyTree->tree[i].pGroups.size();
56 int rcSize = copyTree->tree[rc].pGroups.size();
57 int lcSize = copyTree->tree[lc].pGroups.size();
59 //if isize are 0 then that branch is to be ignored
61 else if ((rcSize == 0) || (lcSize == 0)) { }
62 //if you have more groups than either of your kids then theres been a change.
63 else if(iSize > rcSize || iSize > lcSize){
76 //get score for all users groups
77 for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
78 if (tmap->namesOfGroups[i] != "xxx") {
79 groups.push_back(tmap->namesOfGroups[i]);
83 for (int i = 0; i < globaldata->Groups.size(); i++) {
84 groups.push_back(globaldata->Groups[i]);
88 //copy users tree so that you can redo pgroups
92 //create pgroups that reflect the groups the user want to use
93 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
94 copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
97 // map<string,int>::iterator it;
99 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
100 int lc = copyTree->tree[i].getLChild();
101 int rc = copyTree->tree[i].getRChild();
103 int iSize = copyTree->tree[i].pGroups.size();
104 int rcSize = copyTree->tree[rc].pGroups.size();
105 int lcSize = copyTree->tree[lc].pGroups.size();
108 //if isize are 0 then that branch is to be ignored
110 else if ((rcSize == 0) || (lcSize == 0)) { }
111 //if you have more groups than either of your kids then theres been a change.
112 else if(iSize > rcSize || iSize > lcSize){
125 catch(exception& e) {
126 errorOut(e, "Parsimony", "getValues");
131 /**************************************************************************************************/