X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deconvolutecommand.cpp;h=62daa612d52a04fa72b85c1c621b89b539d14ab0;hb=348de0f8b17d84ede77081dcf67bd6ef43496677;hp=b3fa7ddd397e973b7ac3895acfb8c0ebf0505f1f;hpb=260ae19c36cb11a53ddc5a75b5e507f8dd8b31d6;p=mothur.git diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index b3fa7dd..62daa61 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -9,13 +9,61 @@ #include "deconvolutecommand.h" +//********************************************************************************************************************** +vector DeconvoluteCommand::getValidParameters(){ + try { + string Array[] = {"fasta", "name","outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "DeconvoluteCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +DeconvoluteCommand::DeconvoluteCommand(){ + try { + abort = true; calledHelp = true; + vector tempOutNames; + outputTypes["fasta"] = tempOutNames; + outputTypes["name"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector DeconvoluteCommand::getRequiredParameters(){ + try { + string Array[] = {"fasta"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "DeconvoluteCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector DeconvoluteCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "DeconvoluteCommand", "getRequiredFiles"); + exit(1); + } +} /**************************************************************************************/ DeconvoluteCommand::DeconvoluteCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -33,6 +81,11 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["fasta"] = tempOutNames; + outputTypes["name"] = tempOutNames; + //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; } @@ -99,7 +152,7 @@ void DeconvoluteCommand::help(){ int DeconvoluteCommand::execute() { try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } //prepare filenames and open files string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names"; @@ -115,15 +168,26 @@ int DeconvoluteCommand::execute() { fastamap.printCondensedFasta(outFastaFile); fastamap.printNamesFile(outNameFile); - if (m->control_pressed) { remove(outFastaFile.c_str()); remove(outNameFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); remove(outNameFile.c_str()); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outFastaFile); m->mothurOutEndLine(); m->mothurOut(outNameFile); m->mothurOutEndLine(); + outputNames.push_back(outFastaFile); outputNames.push_back(outNameFile); outputTypes["fasta"].push_back(outFastaFile); outputTypes["name"].push_back(outNameFile); m->mothurOutEndLine(); - + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } return 0; }