X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deconvolutecommand.cpp;fp=deconvolutecommand.cpp;h=bab5a634cd101507957dabc22e34e429c5ec5b1b;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=3d0c0d51acaac8844b71a3efa40c7925674ad4c5;hpb=ee8403d4eb5760187d62b42a9cf4272de8fc0ec4;p=mothur.git diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 3d0c0d5..bab5a63 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -45,6 +45,27 @@ string DeconvoluteCommand::getHelpString(){ } } //********************************************************************************************************************** +string DeconvoluteCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //is this a type this command creates + it = outputTypes.find(type); + if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } + else { + if (type == "fasta") { outputFileName = "unique" + m->getExtension(inputName); } + else if (type == "name") { outputFileName = "names"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } + } + return outputFileName; + } + catch(exception& e) { + m->errorOut(e, "DeconvoluteCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** DeconvoluteCommand::DeconvoluteCommand(){ try { abort = true; calledHelp = true; @@ -149,14 +170,14 @@ int DeconvoluteCommand::execute() { if (abort == true) { if (calledHelp) { return 0; } return 2; } //prepare filenames and open files - string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names"; - string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName); + string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("name"); + string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("fasta", inFastaName); map nameMap; map::iterator itNames; if (oldNameMapFName != "") { m->readNames(oldNameMapFName, nameMap); - if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique.names"; } + if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("name"); } } if (m->control_pressed) { return 0; }