X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deconvolutecommand.cpp;h=bab5a634cd101507957dabc22e34e429c5ec5b1b;hb=ccae9eef0b44f2d63fdf4a707d0d40243aa1b990;hp=3fa622f01ff2fc334f5cbb9d79851a9ca7f8b30c;hpb=ae57e166b2ed7b475ec3f466106bd76fabadd063;p=mothur.git diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 3fa622f..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; @@ -125,9 +146,15 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { } oldNameMapFName = validParameter.validFile(parameters, "name", true); - if (oldNameMapFName == "not open") { abort = true; } + if (oldNameMapFName == "not open") { oldNameMapFName = ""; abort = true; } else if (oldNameMapFName == "not found"){ oldNameMapFName = ""; } else { m->setNameFile(oldNameMapFName); } + + if (oldNameMapFName == "") { + vector files; files.push_back(inFastaName); + parser.getNameFile(files); + } + } } @@ -143,12 +170,15 @@ 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 != "") { + m->readNames(oldNameMapFName, nameMap); + if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("name"); } + } if (m->control_pressed) { return 0; }