X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deconvolutecommand.cpp;h=6c04c1255ab94010da7cacfb409d497b4f0354d4;hb=7c08fa69c0b89e7a08341af2aa724f206f182075;hp=fcfd320e0b6be3aa3572b661a579311c9dead5bf;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index fcfd320..6c04c12 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 = ""; } @@ -41,7 +94,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { it = parameters.find("fasta"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["fasta"] = inputDir + it->second; } } @@ -49,7 +102,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { it = parameters.find("name"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["name"] = inputDir + it->second; } } @@ -64,7 +117,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { //if the user changes the output directory command factory will send this info to us in the output parameter outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; - outputDir += hasPath(inFastaName); //if user entered a file with a path then preserve it + outputDir += m->hasPath(inFastaName); //if user entered a file with a path then preserve it } oldNameMapFName = validParameter.validFile(parameters, "name", true); @@ -99,24 +152,29 @@ 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 + getRootName(getSimpleName(inFastaName)) + "names"; - string outFastaFile = outputDir + getRootName(getSimpleName(inFastaName)) + "unique" + getExtension(inFastaName); + string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names"; + string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName); FastaMap fastamap; if(oldNameMapFName == "") { fastamap.readFastaFile(inFastaName); } else { fastamap.readFastaFile(inFastaName, oldNameMapFName); } + if (m->control_pressed) { return 0; } + fastamap.printCondensedFasta(outFastaFile); fastamap.printNamesFile(outNameFile); + 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();