Permalink
Browse files

Fixes bug with shortcut files and windows parallelization

  • Loading branch information...
1 parent 7f0ffe0 commit 9d05ee48fe1791f81ba544732af5c869da498288 @mothur-westcott mothur-westcott committed Jan 24, 2017
@@ -20,7 +20,7 @@ ChimeraCheckRDP::ChimeraCheckRDP(string filename, string temp, string n, bool s,
kmerSize = k;
outputDir = o;
- templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, rand());
+ templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, rand(), true);
m->mothurOutEndLine();
kmer = new Kmer(kmerSize);
@@ -295,7 +295,7 @@ int AlignCommand::execute(){
try {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, rand());
+ templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, rand(), true);
for (int s = 0; s < candidateFileNames.size(); s++) {
if (m->control_pressed) { outputTypes.clear(); return 0; }
@@ -135,7 +135,7 @@ static DWORD WINAPI MyAlignThreadFunction(LPVOID lpParam){
inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA);
}
- AlignmentDB* templateDB = new AlignmentDB(pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->threadID);
+ AlignmentDB* templateDB = new AlignmentDB(pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->threadID, false);
//moved this into driver to avoid deep copies in windows paralellized version
Alignment* alignment;
@@ -908,7 +908,7 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile,
string extension = "";
if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
- classifyData* tempclass = new classifyData((accnos + extension), probs, method, templateFileName, taxonomyFileName, (taxFileName + extension), (tempTaxFile + extension), filename, search, kmerSize, iters, numWanted, m, lines[i]->start, lines[i]->end, match, misMatch, gapOpen, gapExtend, cutoff, i, flip, writeShortcuts);
+ classifyData* tempclass = new classifyData((accnos + extension), probs, method, templateFileName, taxonomyFileName, (taxFileName + extension), (tempTaxFile + extension), filename, search, kmerSize, iters, numWanted, m, lines[i]->start, lines[i]->end, match, misMatch, gapOpen, gapExtend, cutoff, i, flip, false);
pDataArray.push_back(tempclass);
//MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
@@ -463,13 +463,14 @@ RenameFileCommand::RenameFileCommand(string option) {
temp = validParameter.validFile(parameters, "deleteold", false); if (temp == "not found") { temp = "T"; }
deleteOld = m->isTrue(temp);
- prefix = validParameter.validFile(parameters, "prefix", false); if (prefix == "not found") { temp = ""; }
+ prefix = validParameter.validFile(parameters, "prefix", false); if (prefix == "not found") { prefix = ""; }
outputfile = validParameter.validFile(parameters, "new", false);
if (outputfile == "not found") {
if (!mothurGenerated) { m->mothurOut("[ERROR]: you must enter an output file name"); m->mothurOutEndLine(); abort=true; }
outputfile = "";
- }else if (outputDir != "") { outputfile = outputDir + m->getSimpleName(outputfile); }
+ }else { mothurGenerated=false; }
+ if (outputDir != "") { outputfile = outputDir + m->getSimpleName(outputfile); }
if ((!mothurGenerated) && (numFiles > 1)) {
m->mothurOut("[ERROR]: You cannot use more than one file parameter unless mothur is generating the output filenames for you.\n"); abort= true;
@@ -632,6 +633,7 @@ int RenameFileCommand::execute(){
string RenameFileCommand::getNewName(string name, string type){
try {
string newName = outputfile;
+ name = m->getFullPathName(name);
if (mothurGenerated) {
string extension = m->getExtension(name);
@@ -644,12 +646,15 @@ string RenameFileCommand::getNewName(string name, string type){
}else { basicName = prefix; }
if ((type == "shared") || (type == "list") || (type == "relabund") || (type == "rabund") || (type == "sabund")) {
- vector<string> tags; tags.push_back(".an."); tags.push_back(".tx."); tags.push_back(".agc."); tags.push_back(".dgc."); tags.push_back(".nn."); tags.push_back(".fn."); tags.push_back(".wn."); tags.push_back(".opti.");
- vector<string> newTags; newTags.push_back("an"); newTags.push_back("tx"); newTags.push_back("agc"); newTags.push_back("dgc"); newTags.push_back("nn"); newTags.push_back("fn"); newTags.push_back("wn"); tags.push_back(".opti.");
+ vector<string> tags; tags.push_back(".an."); tags.push_back(".tx."); tags.push_back(".agc."); tags.push_back(".dgc."); tags.push_back(".nn."); tags.push_back(".fn."); tags.push_back(".wn."); tags.push_back(".opti_");
for (int i = 0; i < tags.size(); i++) {
- int pos2 = name.find_first_of(tags[i]);
- if (pos2 != string::npos) { tag = newTags[i]; break; }
+ int pos2 = name.find(tags[i]);
+ if (pos2 != string::npos) {
+ int pos3 = name.substr(pos2+1).find_first_of('.');
+ tag = name.substr(pos2+1, pos3);
+ break;
+ }
}
}else if (type == "constaxonomy") {
extension = ".cons.taxonomy";
@@ -13,7 +13,7 @@
#include "blastdb.hpp"
/**************************************************************************************************/
-AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int tid){ // This assumes that the template database is in fasta format, may
+AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int tid, bool writeShortcut){ // This assumes that the template database is in fasta format, may
try { // need to alter this in the future?
m = MothurOut::getInstance();
longest = 0;
@@ -104,8 +104,8 @@ AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gap
if (m->control_pressed) { templateSequences.clear(); }
- search->generateDB();
-
+ if ((method != "kmer") || ((method == "kmer") && (writeShortcut))) { search->generateDB(); }
+
}else if ((method == "kmer") && (!needToGenerate)) {
ifstream kmerFileTest(kmerDBName.c_str());
search->readKmerDB(kmerFileTest);
@@ -20,7 +20,7 @@ class AlignmentDB {
public:
- AlignmentDB(string, string, int, float, float, float, float, int); //reads fastafile passed in and stores sequences
+ AlignmentDB(string, string, int, float, float, float, float, int, bool); //reads fastafile passed in and stores sequences
AlignmentDB(string);
~AlignmentDB();
@@ -123,7 +123,7 @@ vector<int> KmerDB::findClosestSequences(Sequence* candidateSeq, int num){
}
/**************************************************************************************************/
-
+//print shortcut file
void KmerDB::generateDB(){
try {

0 comments on commit 9d05ee4

Please sign in to comment.