X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clearcutcommand.cpp;h=6a0eb259379df8480341a5542a7456fc674aea74;hb=ea4f373c28543cd1002b0dd7dc6e55c526647d59;hp=afb215932958e273093726a3b71a398faabc4dc2;hpb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6;p=mothur.git diff --git a/clearcutcommand.cpp b/clearcutcommand.cpp index afb2159..6a0eb25 100644 --- a/clearcutcommand.cpp +++ b/clearcutcommand.cpp @@ -86,7 +86,27 @@ string ClearcutCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string ClearcutCommand::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 == "tree") { outputFileName = "tre"; } + else if (type == "matrixout") { outputFileName = ""; } + 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, "ClearcutCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** ClearcutCommand::ClearcutCommand(){ try { @@ -108,6 +128,7 @@ ClearcutCommand::ClearcutCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { vector myArray = setParameters(); @@ -154,21 +175,21 @@ ClearcutCommand::ClearcutCommand(string option) { fastafile = validParameter.validFile(parameters, "fasta", true); if (fastafile == "not open") { fastafile = ""; abort = true; } else if (fastafile == "not found") { fastafile = ""; } - else { inputFile = fastafile; } + else { inputFile = fastafile; m->setFastaFile(fastafile); } phylipfile = validParameter.validFile(parameters, "phylip", true); if (phylipfile == "not open") { phylipfile = ""; abort = true; } else if (phylipfile == "not found") { phylipfile = ""; } - else { inputFile = phylipfile; } + else { inputFile = phylipfile; m->setPhylipFile(phylipfile); } if ((phylipfile == "") && (fastafile == "")) { //is there are current file available for either of these? //give priority to phylip, then fasta phylipfile = m->getPhylipFile(); - if (phylipfile != "") { m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); } + if (phylipfile != "") { inputFile = phylipfile; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); } else { fastafile = m->getFastaFile(); - if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); } + if (fastafile != "") { inputFile = fastafile; m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); } else { m->mothurOut("No valid current files. You must provide a phylip or fasta file before you can use the clearcut command."); m->mothurOutEndLine(); abort = true; @@ -243,7 +264,7 @@ int ClearcutCommand::execute() { if (abort == true) { if (calledHelp) { return 0; } return 2; } //prepare filename - string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre"; + string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + getOutputFileNameTag("tree"); outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName); vector cPara;