X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=unifracweightedcommand.h;h=a5507cdb6cc2d95152eec0241f386acd66de1aab;hp=fead41b0e8cb5dae95eed551ff76427b8c8d85f3;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=90708fe9701e3827e477c82fb3652539c3bf2a0d diff --git a/unifracweightedcommand.h b/unifracweightedcommand.h index fead41b..a5507cd 100644 --- a/unifracweightedcommand.h +++ b/unifracweightedcommand.h @@ -28,8 +28,9 @@ class UnifracWeightedCommand : public Command { vector setParameters(); string getCommandName() { return "unifrac.weighted"; } string getCommandCategory() { return "Hypothesis Testing"; } - string getOutputFileNameTag(string, string); + string getHelpString(); + string getOutputPattern(string); string getCitation() { return "Lozupone CA, Hamady M, Kelley ST, Knight R (2007). Quantitative and qualitative beta diversity measures lead to different insights into factors that structure microbial communities. Appl Environ Microbiol 73: 1576-85. \nhttp://www.mothur.org/wiki/Unifrac.weighted"; } string getDescription() { return "generic tests that describes whether two or more communities have the same structure"; } @@ -53,9 +54,9 @@ class UnifracWeightedCommand : public Command { int iters, numGroups, numComp, counter; vector< vector > rScores; //vector each group comb has an entry vector< vector > uScores; //vector each group comb has an entry - vector< map > rScoreFreq; //map -vector entry for each combination. - vector< map > rCumul; //map -vector entry for each c - map validScores; //map contains scores from random + vector< map > rScoreFreq; //map -vector entry for each combination. + vector< map > rCumul; //map -vector entry for each c + map validScores; //map contains scores from random bool abort, phylip, random, includeRoot, subsample, consensus; string groups, itersString, outputForm, treefile, groupfile, namefile, countfile; @@ -79,6 +80,77 @@ class UnifracWeightedCommand : public Command { }; +/***********************************************************************/ +struct weightedRandomData { + int start; + int num; + MothurOut* m; + vector< vector > scores; + vector< vector > namesOfGroupCombos; + Tree* t; + CountTable* ct; + bool includeRoot; + + weightedRandomData(){} + weightedRandomData(MothurOut* mout, int st, int en, vector< vector > ngc, Tree* tree, CountTable* count, bool ir, vector< vector > sc) { + m = mout; + start = st; + num = en; + namesOfGroupCombos = ngc; + t = tree; + ct = count; + includeRoot = ir; + scores = sc; + } +}; + +/**************************************************************************************************/ +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) +#else +static DWORD WINAPI MyWeightedRandomThreadFunction(LPVOID lpParam){ + weightedRandomData* pDataArray; + pDataArray = (weightedRandomData*)lpParam; + try { + + Tree* randT = new Tree(pDataArray->ct); + + Weighted weighted(pDataArray->includeRoot); + + for (int h = pDataArray->start; h < (pDataArray->start+pDataArray->num); h++) { + + if (pDataArray->m->control_pressed) { return 0; } + + //initialize weighted score + string groupA = pDataArray->namesOfGroupCombos[h][0]; + string groupB = pDataArray->namesOfGroupCombos[h][1]; + + //copy T[i]'s info. + randT->getCopy(pDataArray->t); + + //create a random tree with same topology as T[i], but different labels + randT->assembleRandomUnifracTree(groupA, groupB); + + if (pDataArray->m->control_pressed) { delete randT; return 0; } + + //get wscore of random tree + EstOutput randomData = weighted.getValues(randT, groupA, groupB); + + if (pDataArray->m->control_pressed) { delete randT; return 0; } + + //save scores + pDataArray->scores[h].push_back(randomData[0]); + } + + delete randT; + + return 0; + } + catch(exception& e) { + pDataArray->m->errorOut(e, "Weighted", "MyWeightedRandomThreadFunction"); + exit(1); + } +} +#endif #endif