X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getsharedotucommand.cpp;h=9beca6aa96f75a58891b5326b5cbd94209701656;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=02d8413675bade0cf79f8781987cc45078b74db2;hpb=91a27e0483827c06c21c4fe89558923bbfe86573;p=mothur.git diff --git a/getsharedotucommand.cpp b/getsharedotucommand.cpp index 02d8413..9beca6a 100644 --- a/getsharedotucommand.cpp +++ b/getsharedotucommand.cpp @@ -58,6 +58,29 @@ string GetSharedOTUCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** +string GetSharedOTUCommand::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 = "shared.fasta"; } + else if (type == "accnos") { outputFileName = "accnos"; } + else if (type == "sharedseqs") { outputFileName = "shared.seqs"; } + 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, "GetSharedOTUCommand", "getOutputFileNameTag"); + exit(1); + } +} + //********************************************************************************************************************** GetSharedOTUCommand::GetSharedOTUCommand(){ try { @@ -372,9 +395,9 @@ int GetSharedOTUCommand::process(ListVector* shared) { if (outputDir == "") { outputDir += m->hasPath(listfile); } if (output != "accnos") { - outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".shared.seqs"; + outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("sharedseqs"); }else { - outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".accnos"; + outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("accnos"); } m->openOutputFile(outputFileNames, outNames); @@ -481,7 +504,7 @@ int GetSharedOTUCommand::process(ListVector* shared) { //if fasta file provided output new fasta file if ((fastafile != "") && wroteSomething) { if (outputDir == "") { outputDir += m->hasPath(fastafile); } - string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta"; + string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("fasta"); ofstream outFasta; m->openOutputFile(outputFileFasta, outFasta); outputNames.push_back(outputFileFasta); outputTypes["fasta"].push_back(outputFileFasta);