9 * Created by Sarah Westcott on 1/26/09.
10 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
14 #include "treecalculator.h"
15 #include "counttable.h"
17 /***********************************************************************/
19 class Parsimony : public TreeCalculator {
24 EstOutput getValues(Tree*, int, string);
30 linePair(int i, int j) : start(i), num(j) {}
32 vector<linePair> lines;
38 EstOutput driver(Tree*, vector< vector<string> >, int, int, CountTable*);
39 EstOutput createProcesses(Tree*, vector< vector<string> >, CountTable*);
41 /***********************************************************************/
47 vector< vector<string> > namesOfGroupCombos;
52 parsData(MothurOut* mout, int st, int en, vector< vector<string> > ngc, Tree* tree, CountTable* count) {
56 namesOfGroupCombos = ngc;
62 /**************************************************************************************************/
63 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
65 static DWORD WINAPI MyParsimonyThreadFunction(LPVOID lpParam){
67 pDataArray = (parsData*)lpParam;
70 pDataArray->results.resize(pDataArray->num);
72 Tree* copyTree = new Tree(pDataArray->ct);
75 for (int h = pDataArray->start; h < (pDataArray->start+pDataArray->num); h++) {
77 if (pDataArray->m->control_pressed) { delete copyTree; return 0; }
81 //groups in this combo
82 vector<string> groups = pDataArray->namesOfGroupCombos[h];
84 //copy users tree so that you can redo pgroups
85 copyTree->getCopy(pDataArray->t);
87 //create pgroups that reflect the groups the user want to use
88 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
89 copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
92 for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
94 if (pDataArray->m->control_pressed) { return 0; }
96 int lc = copyTree->tree[i].getLChild();
97 int rc = copyTree->tree[i].getRChild();
99 int iSize = copyTree->tree[i].pGroups.size();
100 int rcSize = copyTree->tree[rc].pGroups.size();
101 int lcSize = copyTree->tree[lc].pGroups.size();
103 //if isize are 0 then that branch is to be ignored
105 else if ((rcSize == 0) || (lcSize == 0)) { }
106 //if you have more groups than either of your kids then theres been a change.
107 else if(iSize > rcSize || iSize > lcSize){
112 pDataArray->results[count] = score;
121 catch(exception& e) {
122 pDataArray->m->errorOut(e, "Parsimony", "MyParsimonyThreadFunction");