X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=preclustercommand.h;h=e0767826ecde2fcf8056bbdebfb8d1bd8ce435c4;hb=01d5a60fc5f396339acf529151fa8186ee7c1a41;hp=0bd56c8662a5b8c622b57a4628f23cc829828f90;hpb=deba0af0ccdcb6005ed5b2b82649b137c63fbdf7;p=mothur.git diff --git a/preclustercommand.h b/preclustercommand.h index 0bd56c8..e076782 100644 --- a/preclustercommand.h +++ b/preclustercommand.h @@ -29,13 +29,21 @@ struct seqPNode { ~seqPNode() {} }; /************************************************************/ -inline bool comparePriority(seqPNode first, seqPNode second) { +inline bool comparePriorityTopDown(seqPNode first, seqPNode second) { if (first.numIdentical > second.numIdentical) { return true; } else if (first.numIdentical == second.numIdentical) { if (first.seq.getName() > second.seq.getName()) { return true; } } return false; } +/************************************************************/ +inline bool comparePriorityDownTop(seqPNode first, seqPNode second) { + if (first.numIdentical < second.numIdentical) { return true; } + else if (first.numIdentical == second.numIdentical) { + if (first.seq.getName() > second.seq.getName()) { return true; } + } + return false; +} //************************************************************/ class PreClusterCommand : public Command { @@ -71,7 +79,7 @@ private: CountTable ct; int diffs, length, processors; - bool abort, bygroup; + bool abort, bygroup, topdown; string fastafile, namefile, outputDir, groupfile, countfile; vector alignSeqs; //maps the number of identical seqs to a sequence map names; //represents the names file first column maps to second column @@ -79,7 +87,6 @@ private: map::iterator itSize; // map active; //maps sequence name to whether it has already been merged or not. vector outputNames; - map > outputTypes; int readFASTA(); void readNameFile(); @@ -104,13 +111,14 @@ struct preClusterData { string newFName, newNName, newMName; MothurOut* m; int start; - int end; + int end, count; int diffs, threadID; vector groups; vector mapFileNames; + bool topdown; preClusterData(){} - preClusterData(string f, string n, string g, string c, string nff, string nnf, string nmf, vector gr, MothurOut* mout, int st, int en, int d, int tid) { + preClusterData(string f, string n, string g, string c, string nff, string nnf, string nmf, vector gr, MothurOut* mout, int st, int en, int d, bool td, int tid) { fastafile = f; namefile = n; groupfile = g; @@ -124,6 +132,8 @@ struct preClusterData { threadID = tid; groups = gr; countfile = c; + topdown = td; + count=0; } }; @@ -155,6 +165,8 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){ //precluster each group for (int k = pDataArray->start; k < pDataArray->end; k++) { + pDataArray->count++; + int start = time(NULL); if (pDataArray->m->control_pressed) { delete parser; return 0; } @@ -236,9 +248,10 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){ pDataArray->m->openOutputFile(pDataArray->newMName+pDataArray->groups[k]+".map", out); pDataArray->mapFileNames.push_back(pDataArray->newMName+pDataArray->groups[k]+".map"); - //sort seqs by number of identical seqs - sort(alignSeqs.begin(), alignSeqs.end(), comparePriority); - + //sort seqs by number of identical seqs + if (pDataArray->topdown) { sort(alignSeqs.begin(), alignSeqs.end(), comparePriorityTopDown); } + else { sort(alignSeqs.begin(), alignSeqs.end(), comparePriorityDownTop); } + int count = 0; //think about running through twice...