/**************************************************************************************************/
-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";
}
/**************************************************************************************************/
-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 == "") {
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";
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;
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;
}
}
/**************************************************************************************************/
+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);
+ }
+}
+/**************************************************************************************************/
/**************************************************************************************************/