X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=blastdb.cpp;h=bc646dfaa498750448ba741f5649450a185415dd;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=af157203630c68bc8e8cfd0e09a2bcf846e4d33c;hpb=4e4d3cb3315fe25b40383c6f65cd6be23f58903d;p=mothur.git diff --git a/blastdb.cpp b/blastdb.cpp index af15720..bc646df 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -14,19 +14,23 @@ /**************************************************************************************************/ -BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b) : Database(), +BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b, int tid) : Database(), gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { try { count = 0; path = b; + threadID = tid; int randNumber = rand(); //int randNumber = 12345; string pid = ""; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - pid += toString(getpid()); + pid += getpid(); +#else + pid += toString(threadID); #endif + dbFileName = tag + pid + toString(randNumber) + ".template.unaligned.fasta"; queryFileName = tag + pid + toString(randNumber) + ".candidate.unaligned.fasta"; blastFileName = tag + pid + toString(randNumber) + ".blast"; @@ -96,11 +100,12 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { } /**************************************************************************************************/ -BlastDB::BlastDB(string b) : Database() { +BlastDB::BlastDB(string b, int tid) : Database() { try { count = 0; path = b; + threadID = tid; //make sure blast exists in the write place if (path == "") { @@ -119,7 +124,9 @@ BlastDB::BlastDB(string b) : Database() { int randNumber = rand(); string pid = ""; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - pid += toString(getpid()); + pid += getpid(); +#else + pid += toString(threadID); #endif dbFileName = pid + toString(randNumber) + ".template.unaligned.fasta"; @@ -206,10 +213,7 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { ofstream queryFile; int randNumber = rand(); - string pid = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - pid += toString(getpid()); -#endif + string pid = scrubName(seq->getName()); m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile); queryFile << '>' << seq->getName() << endl; @@ -273,10 +277,7 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { ofstream queryFile; int randNumber = rand(); - string pid = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - pid += toString(getpid()); -#endif + string pid = scrubName(seq->getName()); m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile); queryFile << '>' << seq->getName() << endl; @@ -382,6 +383,24 @@ void BlastDB::generateDB() { } } /**************************************************************************************************/ +string BlastDB::scrubName(string seqName) { + try { + + string cleanName = ""; + + for (int i = 0; i < seqName.length(); i++) { + if (isalnum(seqName[i])) { cleanName += seqName[i]; } + else { cleanName += "_"; } + } + + return cleanName; + } + catch(exception& e) { + m->errorOut(e, "BlastDB", "scrubName"); + exit(1); + } +} +/**************************************************************************************************/ /**************************************************************************************************/