map<string, int> priority;
int setUpForSelfReference(SequenceParser*&, map<string, string>&, map<string, map<string, int> >&, int);
int setUpForSelfReference(SequenceCountParser*&, map<string, string>&, map<string, map<string, int> >&, int);
- int driverGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
- int createProcessesGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
- int MPIExecuteGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
+ int driverGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&, string);
+ int createProcessesGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&, string, string);
+ int MPIExecuteGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&, string, string);
#ifdef USE_MPI
- int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&, string, map<string, int>&, bool);
+ int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, set<string>&, vector<unsigned long long>&, string, map<string, int>&, bool);
#endif
bool abort, realign, trim, trimera, save, hasName, hasCount, dups;
int processors, window, iters, increment, numwanted, ksize, match, mismatch, parents, minSimilarity, minCoverage, minBS, minSNP, numSeqs, templateSeqsLength;
float divR;
+ map<string, map<string, string> > group2NameMap;
vector<string> outputNames;
vector<string> fastaFileNames;
vector<string> nameFileNames;
string outputFName;
string fasta;
string accnos;
- string filename;
+ string filename, countlist;
string templatefile;
string search;
string blastlocation;
bool trimera;
- bool trim, realign;
+ bool trim, realign, dups, hasCount;
unsigned long long start;
unsigned long long end;
int ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted;
int threadId;
map<string, map<string, int> > fileToPriority;
map<string, string> fileGroup;
+ map<string, map<string, string> > group2NameMap;
slayerData(){}
slayerData(string o, string fa, string ac, string f, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, unsigned long long st, unsigned long long en, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
count = 0;
numNoParents = 0;
}
- slayerData(string o, string fa, string ac, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, map<string, map<string, int> >& fPriority, map<string, string>& fileG, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
+ slayerData(map<string, map<string, string> > g2n, bool hc, bool dps, string cl, string o, string fa, string ac, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, map<string, map<string, int> >& fPriority, map<string, string>& fileG, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
outputFName = o;
fasta = fa;
accnos = ac;
templatefile = te;
search = se;
blastlocation = bl;
+ countlist = cl;
+ dups = dps;
+ hasCount = hc;
+ group2NameMap = g2n;
trimera = tri;
trim = trm;
realign = re;
inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA);
}
- pDataArray->count = pDataArray->end;
-
if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 0; }
if (chimera->getUnaligned()) {
if (pDataArray->start == 0) { chimera->printHeader(out); }
- int count = 0;
+ pDataArray->count = 0;
for(int i = 0; i < pDataArray->end; i++){
if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 1; }
}
- count++;
+ pDataArray->count++;
}
delete candidateSeq;
//report progress
- if((count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+ if((pDataArray->count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(pDataArray->count)); pDataArray->m->mothurOutEndLine(); }
}
//report progress
- if((count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+ if((pDataArray->count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(pDataArray->count)); pDataArray->m->mothurOutEndLine(); }
pDataArray->numNoParents = chimera->getNumNoParents();
- if (pDataArray->numNoParents == count) { pDataArray->m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors.\n"); }
+ if (pDataArray->numNoParents == pDataArray->count) { pDataArray->m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors.\n"); }
out.close();
out2.close();
pDataArray = (slayerData*)lpParam;
try {
-
+ ofstream outCountList;
+ if (pDataArray->hasCount && pDataArray->dups) { pDataArray->m->openOutputFile(pDataArray->countlist, outCountList); }
+
int totalSeqs = 0;
+ pDataArray->end = 0;
for (map<string, map<string, int> >::iterator itFile = pDataArray->fileToPriority.begin(); itFile != pDataArray->fileToPriority.end(); itFile++) {
if (pDataArray->trim) { out3.close(); }
inFASTA.close();
delete chimera;
-
+ pDataArray->end++;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //if we provided a count file with group info and set dereplicate=t, then we want to create a *.pick.count_table
+ //This table will zero out group counts for seqs determined to be chimeric by that group.
+ if (pDataArray->dups) {
+ if (!pDataArray->m->isBlank(thisaccnosFileName)) {
+ ifstream in;
+ pDataArray->m->openInputFile(thisaccnosFileName, in);
+ string name;
+ if (pDataArray->hasCount) {
+ while (!in.eof()) {
+ in >> name; pDataArray->m->gobble(in);
+ outCountList << name << '\t' << pDataArray->fileGroup[thisFastaName] << endl;
+ }
+ in.close();
+ }else {
+ map<string, map<string, string> >::iterator itGroupNameMap = pDataArray->group2NameMap.find(pDataArray->fileGroup[thisFastaName]);
+ if (itGroupNameMap != pDataArray->group2NameMap.end()) {
+ map<string, string> thisnamemap = itGroupNameMap->second;
+ map<string, string>::iterator itN;
+ ofstream out;
+ pDataArray->m->openOutputFile(thisaccnosFileName+".temp", out);
+ while (!in.eof()) {
+ in >> name; pDataArray->m->gobble(in);
+ //pDataArray->m->mothurOut("here = " + name + '\t');
+ itN = thisnamemap.find(name);
+ if (itN != thisnamemap.end()) {
+ vector<string> tempNames; pDataArray->m->splitAtComma(itN->second, tempNames);
+ for (int j = 0; j < tempNames.size(); j++) { out << tempNames[j] << endl; }
+ //pDataArray->m->mothurOut(itN->second + '\n');
+
+ }else { pDataArray->m->mothurOut("[ERROR]: parsing cannot find " + name + ".\n"); pDataArray->m->control_pressed = true; }
+ }
+ out.close();
+ in.close();
+ pDataArray->m->renameFile(thisaccnosFileName+".temp", thisaccnosFileName);
+ }else { pDataArray->m->mothurOut("[ERROR]: parsing cannot find " + pDataArray->fileGroup[thisFastaName] + ".\n"); pDataArray->m->control_pressed = true; }
+ }
+
+ }
+ }
+
+
//append files
pDataArray->m->appendFiles(thisoutputFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(thisoutputFileName);
pDataArray->m->appendFiles(thisaccnosFileName, pDataArray->accnos); pDataArray->m->mothurRemove(thisaccnosFileName);
}
pDataArray->count = totalSeqs;
+ if (pDataArray->hasCount && pDataArray->dups) { outCountList.close(); }
return 0;