X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=chopseqscommand.cpp;h=05037f6817a5a554a029a7d635460d048bf73203;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=4e06201cd352104b5ee9c9d1c41764d16473003e;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp index 4e06201..05037f6 100644 --- a/chopseqscommand.cpp +++ b/chopseqscommand.cpp @@ -51,7 +51,27 @@ string ChopSeqsCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string ChopSeqsCommand::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 = "chop.fasta"; } + else if (type == "accnos") { outputFileName = "chop.accnos"; } + 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, "ChopSeqsCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** ChopSeqsCommand::ChopSeqsCommand(){ try { @@ -147,8 +167,8 @@ int ChopSeqsCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta"; - string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos"; + string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta"); + string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos"); ofstream out; m->openOutputFile(outputFileName, out);