X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=degapseqscommand.cpp;fp=degapseqscommand.cpp;h=81002c8385e78610794e2faa5f0241d67befbab7;hb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6;hp=7fd2803a4ec6c5e578d7b180a9e08fda1af33385;hpb=36a867cbd85d9c276d3c8d13f25a150bbbe2466b;p=mothur.git diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp index 7fd2803..81002c8 100644 --- a/degapseqscommand.cpp +++ b/degapseqscommand.cpp @@ -11,49 +11,50 @@ #include "sequence.hpp" //********************************************************************************************************************** -vector DegapSeqsCommand::getValidParameters(){ +vector DegapSeqsCommand::setParameters(){ try { - string Array[] = {"fasta", "outputdir","inputdir"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + + vector myArray; + for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } return myArray; } catch(exception& e) { - m->errorOut(e, "DegapSeqsCommand", "getValidParameters"); + m->errorOut(e, "DegapSeqsCommand", "setParameters"); exit(1); } } //********************************************************************************************************************** -DegapSeqsCommand::DegapSeqsCommand(){ +string DegapSeqsCommand::getHelpString(){ try { - abort = true; calledHelp = true; - vector tempOutNames; - outputTypes["fasta"] = tempOutNames; + string helpString = ""; + helpString += "The degap.seqs command reads a fastafile and removes all gap characters.\n"; + helpString += "The degap.seqs command parameter is fasta.\n"; + helpString += "The fasta parameter allows you to enter the fasta file containing your sequences, and is required unless you have a valid current fasta file. \n"; + helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n"; + helpString += "The degap.seqs command should be in the following format: \n"; + helpString += "degap.seqs(fasta=yourFastaFile) \n"; + helpString += "Example: degap.seqs(fasta=abrecovery.align) \n"; + helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n"; + return helpString; } catch(exception& e) { - m->errorOut(e, "DegapSeqsCommand", "DegapSeqsCommand"); + m->errorOut(e, "DegapSeqsCommand", "getHelpString"); exit(1); } } //********************************************************************************************************************** -vector DegapSeqsCommand::getRequiredParameters(){ - try { - string Array[] = {"fasta"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); - return myArray; - } - catch(exception& e) { - m->errorOut(e, "DegapSeqsCommand", "getRequiredParameters"); - exit(1); - } -} -//********************************************************************************************************************** -vector DegapSeqsCommand::getRequiredFiles(){ +DegapSeqsCommand::DegapSeqsCommand(){ try { - vector myArray; - return myArray; + abort = true; calledHelp = true; + setParameters(); + vector tempOutNames; + outputTypes["fasta"] = tempOutNames; } catch(exception& e) { - m->errorOut(e, "DegapSeqsCommand", "getRequiredFiles"); + m->errorOut(e, "DegapSeqsCommand", "DegapSeqsCommand"); exit(1); } } @@ -66,9 +67,7 @@ DegapSeqsCommand::DegapSeqsCommand(string option) { if(option == "help") { help(); abort = true; calledHelp = true; } else { - //valid paramters for this command - string Array[] = {"fasta", "outputdir","inputdir"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + vector myArray = setParameters(); OptionParser parser(option); map parameters = parser.getParameters(); @@ -92,7 +91,11 @@ DegapSeqsCommand::DegapSeqsCommand(string option) { //check for required parameters fastafile = validParameter.validFile(parameters, "fasta", false); - if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the degap.seqs command."); m->mothurOutEndLine(); abort = true; } + if (fastafile == "not found") { + fastafile = m->getFastaFile(); + if (fastafile != "") { fastaFileNames.push_back(fastafile); m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); } + else { m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; } + } else { m->splitAtDash(fastafile, fastaFileNames); @@ -159,32 +162,7 @@ DegapSeqsCommand::DegapSeqsCommand(string option) { exit(1); } } -//********************************************************************************************************************** - -void DegapSeqsCommand::help(){ - try { - m->mothurOut("The degap.seqs command reads a fastafile and removes all gap characters.\n"); - m->mothurOut("The degap.seqs command parameter is fasta.\n"); - m->mothurOut("The fasta parameter allows you to enter the fasta file containing your sequences, and is required. \n"); - m->mothurOut("You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n"); - m->mothurOut("The degap.seqs command should be in the following format: \n"); - m->mothurOut("degap.seqs(fasta=yourFastaFile) \n"); - m->mothurOut("Example: degap.seqs(fasta=abrecovery.align) \n"); - m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n"); - } - catch(exception& e) { - m->errorOut(e, "DegapSeqsCommand", "help"); - exit(1); - } -} - //*************************************************************************************************************** - -DegapSeqsCommand::~DegapSeqsCommand(){ /* do nothing */ } - -//*************************************************************************************************************** - - int DegapSeqsCommand::execute(){ try{