X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classifyseqscommand.cpp;h=4e244905ff6b755fd064617368506b9160770048;hb=ffc44592ff7ae94f14f9e21f87198e33d323cd1d;hp=794b961dcc29ecdc79bf063d116887b4cf8c30ac;hpb=d6c0a11d1cecfac18b323285e7ffadb7f58e848f;p=mothur.git diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 794b961..4e24490 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -457,13 +457,16 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { search = "kmer"; } - if (namefileNames.size() == 0){ - vector files; files.push_back(fastaFileNames[fastaFileNames.size()-1]); - parser.getNameFile(files); - } + if (!abort) { + if (namefileNames.size() == 0){ + if (fastaFileNames.size() != 0) { + vector files; files.push_back(fastaFileNames[fastaFileNames.size()-1]); + parser.getNameFile(files); + } + } + } } - } catch(exception& e) { m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand"); @@ -482,7 +485,7 @@ ClassifySeqsCommand::~ClassifySeqsCommand(){ int ClassifySeqsCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } - + if(method == "bayesian"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand(), flip); } else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, rand()); } else { @@ -503,8 +506,8 @@ int ClassifySeqsCommand::execute(){ string RippedTaxName = m->getRootName(m->getSimpleName(baseTName)); RippedTaxName = m->getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1)); if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); } - RippedTaxName += "."; - + if (RippedTaxName != "") { RippedTaxName += "."; } + if (outputDir == "") { outputDir += m->hasPath(fastaFileNames[s]); } string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy"; string newaccnosFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "flip.accnos"; @@ -615,7 +618,7 @@ int ClassifySeqsCommand::execute(){ #else vector positions; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastaFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); } #else @@ -623,6 +626,7 @@ int ClassifySeqsCommand::execute(){ lines.push_back(new linePair(0, 1000)); }else { positions = m->setFilePosFasta(fastaFileNames[s], numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; @@ -821,7 +825,7 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; //loop through and create all the processes you want @@ -905,16 +909,35 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, } #endif - + vector nonBlankAccnosFiles; + if (!(m->isBlank(accnos))) { nonBlankAccnosFiles.push_back(accnos); } + else { m->mothurRemove(accnos); } //remove so other files can be renamed to it + for(int i=0;iisBlank(accnos + toString(processIDS[i]) + ".temp"))) { + nonBlankAccnosFiles.push_back(accnos + toString(processIDS[i]) + ".temp"); + }else { m->mothurRemove((accnos + toString(processIDS[i]) + ".temp")); } + m->mothurRemove((m->getFullPathName(taxFileName) + toString(processIDS[i]) + ".temp")); m->mothurRemove((m->getFullPathName(tempTaxFile) + toString(processIDS[i]) + ".temp")); - m->mothurRemove((m->getFullPathName(accnos) + toString(processIDS[i]) + ".temp")); } + //append accnos files + if (nonBlankAccnosFiles.size() != 0) { + rename(nonBlankAccnosFiles[0].c_str(), accnos.c_str()); + + for (int h=1; h < nonBlankAccnosFiles.size(); h++) { + appendTaxFiles(nonBlankAccnosFiles[h], accnos); + m->mothurRemove(nonBlankAccnosFiles[h]); + } + }else { //recreate the accnosfile if needed + ofstream out; + m->openOutputFile(accnos, out); + out.close(); + } + return num; } @@ -1002,7 +1025,7 @@ int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempT } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else