X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=parsimony.h;h=51c0496b1405c43793ba2c47c7557c6b0c43630f;hp=11d4cc859b2c35295a273780499485ac70e1c052;hb=cf9987b67aa49777a4c91c2d21f96e58bf17aa82;hpb=5a3592c6478d5d786ec20e4bee71854ad92fdb8c diff --git a/parsimony.h b/parsimony.h index 11d4cc8..51c0496 100644 --- a/parsimony.h +++ b/parsimony.h @@ -12,25 +12,117 @@ */ #include "treecalculator.h" -#include "treemap.h" -#include "globaldata.hpp" +#include "counttable.h" /***********************************************************************/ class Parsimony : public TreeCalculator { public: - Parsimony(TreeMap* t) : tmap(t) {}; + Parsimony() {}; ~Parsimony() {}; - EstOutput getValues(Tree*); - EstOutput getValues(Tree*, string, string) { return data; }; + EstOutput getValues(Tree*, int, string); private: - GlobalData* globaldata; + struct linePair { + int start; + int num; + linePair(int i, int j) : start(i), num(j) {} + }; + vector lines; + EstOutput data; - TreeMap* tmap; - map::iterator it; + int processors; + string outputDir; + + EstOutput driver(Tree*, vector< vector >, int, int, CountTable*); + EstOutput createProcesses(Tree*, vector< vector >, CountTable*); }; - /***********************************************************************/ -#endif \ No newline at end of file +struct parsData { + int start; + int num; + MothurOut* m; + EstOutput results; + vector< vector > namesOfGroupCombos; + Tree* t; + CountTable* ct; + + parsData(){} + parsData(MothurOut* mout, int st, int en, vector< vector > ngc, Tree* tree, CountTable* count) { + m = mout; + start = st; + num = en; + namesOfGroupCombos = ngc; + t = tree; + ct = count; + } +}; + +/**************************************************************************************************/ +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) +#else +static DWORD WINAPI MyParsimonyThreadFunction(LPVOID lpParam){ + parsData* pDataArray; + pDataArray = (parsData*)lpParam; + try { + + pDataArray->results.resize(pDataArray->num); + + Tree* copyTree = new Tree(pDataArray->ct); + int count = 0; + + for (int h = pDataArray->start; h < (pDataArray->start+pDataArray->num); h++) { + + if (pDataArray->m->control_pressed) { delete copyTree; return 0; } + + int score = 0; + + //groups in this combo + vector groups = pDataArray->namesOfGroupCombos[h]; + + //copy users tree so that you can redo pgroups + copyTree->getCopy(pDataArray->t); + + //create pgroups that reflect the groups the user want to use + for(int i=copyTree->getNumLeaves();igetNumNodes();i++){ + copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups)); + } + + for(int i=copyTree->getNumLeaves();igetNumNodes();i++){ + + if (pDataArray->m->control_pressed) { return 0; } + + int lc = copyTree->tree[i].getLChild(); + int rc = copyTree->tree[i].getRChild(); + + int iSize = copyTree->tree[i].pGroups.size(); + int rcSize = copyTree->tree[rc].pGroups.size(); + int lcSize = copyTree->tree[lc].pGroups.size(); + + //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. + else if(iSize > rcSize || iSize > lcSize){ + score++; + } + } + + pDataArray->results[count] = score; + count++; + } + + delete copyTree; + + return 0; + + } + catch(exception& e) { + pDataArray->m->errorOut(e, "Parsimony", "MyParsimonyThreadFunction"); + exit(1); + } +} +#endif + +#endif