X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classifyseqscommand.cpp;h=158069e7ae596e3eebd6a9d2da5834ec3529dcdc;hb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;hp=0504e6635802c3f6e3e186e4568675906774b3ff;hpb=91a27e0483827c06c21c4fe89558923bbfe86573;p=mothur.git diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 0504e66..158069e 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -465,9 +465,7 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { } } } - - } - + } } catch(exception& e) { m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand"); @@ -486,7 +484,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 { @@ -504,11 +502,17 @@ int ClassifySeqsCommand::execute(){ string baseTName = taxonomyFileName; if (taxonomyFileName == "saved") {baseTName = rdb->getSavedTaxonomy(); } - 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 += "."; - + //set rippedTaxName to + string RippedTaxName = ""; + bool foundDot = false; + for (int i = baseTName.length()-1; i >= 0; i--) { + cout << baseTName[i] << endl; + if (foundDot && (baseTName[i] != '.')) { RippedTaxName = baseTName[i] + RippedTaxName; } + else if (foundDot && (baseTName[i] == '.')) { break; } + else if (!foundDot && (baseTName[i] == '.')) { foundDot = true; } + } + 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"; @@ -915,8 +919,8 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, else { m->mothurRemove(accnos); } //remove so other files can be renamed to it for(int i=0;iappendFiles((taxFileName + toString(processIDS[i]) + ".temp"), taxFileName); + m->appendFiles((tempTaxFile + toString(processIDS[i]) + ".temp"), tempTaxFile); if (!(m->isBlank(accnos + toString(processIDS[i]) + ".temp"))) { nonBlankAccnosFiles.push_back(accnos + toString(processIDS[i]) + ".temp"); }else { m->mothurRemove((accnos + toString(processIDS[i]) + ".temp")); } @@ -930,7 +934,7 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, rename(nonBlankAccnosFiles[0].c_str(), accnos.c_str()); for (int h=1; h < nonBlankAccnosFiles.size(); h++) { - appendTaxFiles(nonBlankAccnosFiles[h], accnos); + m->appendFiles(nonBlankAccnosFiles[h], accnos); m->mothurRemove(nonBlankAccnosFiles[h]); } }else { //recreate the accnosfile if needed @@ -947,30 +951,6 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, exit(1); } } -/**************************************************************************************************/ - -void ClassifySeqsCommand::appendTaxFiles(string temp, string filename) { - try{ - - ofstream output; - ifstream input; - m->openOutputFileAppend(filename, output); - m->openInputFile(temp, input); - - while(char c = input.get()){ - if(input.eof()) { break; } - else { output << c; } - } - - input.close(); - output.close(); - } - catch(exception& e) { - m->errorOut(e, "ClassifySeqsCommand", "appendTaxFiles"); - exit(1); - } -} - //********************************************************************************************************************** int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempTFName, string accnos, string filename){