X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=chimeraperseuscommand.h;h=b6d4fc9323f659abe52cd70a1e3598a84d9db936;hp=b3d6ccf56858deb00435ace345826450f7d4cd9e;hb=d1c97b8c04bb75faca1e76ffad60b37a4d789d3d;hpb=3504e4e2feeb05aabb0c79aa42cb696522030924 diff --git a/chimeraperseuscommand.h b/chimeraperseuscommand.h index b3d6ccf..b6d4fc9 100644 --- a/chimeraperseuscommand.h +++ b/chimeraperseuscommand.h @@ -64,8 +64,8 @@ private: vector readFiles(string inputFile, CountTable* ct); vector loadSequences(string); int deconvoluteResults(map&, string, string); - int driverGroups(string, string, int, int, vector); - int createProcessesGroups(string, string, vector, string, string, string); + int driverGroups(string, string, string, int, int, vector); + int createProcessesGroups(string, string, string, vector, string, string, string); string removeNs(string); }; @@ -79,16 +79,17 @@ struct perseusData { string groupfile; string outputFName; string accnos; + string countlist; MothurOut* m; int start; int end; - bool hasName, hasCount; + bool hasName, hasCount, dups; int threadID, count, numChimeras; double alpha, beta, cutoff; vector groups; perseusData(){} - perseusData(bool hn, bool hc, double a, double b, double c, string o, string f, string n, string g, string ac, vector gr, MothurOut* mout, int st, int en, int tid) { + perseusData(bool dps, bool hn, bool hc, double a, double b, double c, string o, string f, string n, string g, string ac, string ctlist, vector gr, MothurOut* mout, int st, int en, int tid) { alpha = a; beta = b; cutoff = c; @@ -96,6 +97,7 @@ struct perseusData { namefile = n; groupfile = g; outputFName = o; + countlist = ctlist; accnos = ac; m = mout; start = st; @@ -104,6 +106,7 @@ struct perseusData { groups = gr; hasName = hn; hasCount = hc; + dups = dps; count = 0; numChimeras = 0; } @@ -127,7 +130,7 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ SequenceCountParser* cparser; if (pDataArray->hasCount) { CountTable* ct = new CountTable(); - ct->readTable(pDataArray->namefile); + ct->readTable(pDataArray->namefile, true); cparser = new SequenceCountParser(pDataArray->fastafile, *ct); delete ct; }else { @@ -137,6 +140,9 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ int totalSeqs = 0; int numChimeras = 0; + + ofstream outCountList; + if (pDataArray->hasCount && pDataArray->dups) { pDataArray->m->openOutputFile(pDataArray->countlist, outCountList); } for (int u = pDataArray->start; u < pDataArray->end; u++) { @@ -337,16 +343,49 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ chimeraFile << j << '\t' << sequences[j].seqName << "\t0\t0\tNull\t0\t0\t0\tNull\tNull\t0.0\t0.0\t0.0\t0\t0\t0\t0.0\t0.0\tgood" << endl; } //report progress - if((j+1) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(j+1) + "\n"); } + if((j+1) % 100 == 0){ pDataArray->m->mothurOutJustToScreen("Processing sequence: " + toString(j+1) + "\n"); } } - if((numSeqs) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(numSeqs) + "\n"); } + if((numSeqs) % 100 != 0){ pDataArray->m->mothurOutJustToScreen("Processing sequence: " + toString(numSeqs) + "\n"); } chimeraFile.close(); accnosFile.close(); //////////////////////////////////////////////////////////////////////////////////////// totalSeqs += numSeqs; + + if (pDataArray->dups) { + if (!pDataArray->m->isBlank(accnosFileName)) { + ifstream in; + pDataArray->m->openInputFile(accnosFileName, in); + string name; + if (pDataArray->hasCount) { + while (!in.eof()) { + in >> name; pDataArray->m->gobble(in); + outCountList << name << '\t' << pDataArray->groups[u] << endl; + } + in.close(); + }else { + map thisnamemap = parser->getNameMap(pDataArray->groups[u]); + map::iterator itN; + ofstream out; + pDataArray->m->openOutputFile(accnosFileName+".temp", out); + while (!in.eof()) { + in >> name; pDataArray->m->gobble(in); + itN = thisnamemap.find(name); + if (itN != thisnamemap.end()) { + vector tempNames; pDataArray->m->splitAtComma(itN->second, tempNames); + for (int j = 0; j < tempNames.size(); j++) { out << tempNames[j] << endl; } + + }else { pDataArray->m->mothurOut("[ERROR]: parsing cannot find " + name + ".\n"); pDataArray->m->control_pressed = true; } + } + out.close(); + in.close(); + pDataArray->m->renameFile(accnosFileName+".temp", accnosFileName); + } + + } + } //append files pDataArray->m->appendFiles(chimeraFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(chimeraFileName); @@ -356,6 +395,8 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ if (pDataArray->m->control_pressed) { if (pDataArray->hasCount) { delete cparser; } { delete parser; } pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; } } + if (pDataArray->hasCount && pDataArray->dups) { outCountList.close(); } + pDataArray->count = totalSeqs; if (pDataArray->hasCount) { delete cparser; } { delete parser; } return totalSeqs;