X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=seqsummarycommand.cpp;h=8b07b857c73930bb24265c58da93b7702dccf42d;hp=9ab27f9cbd439fe55ed1856c6940f0e42e6ee7e0;hb=315e38cf393c82be238da5b32574f225a020d25c;hpb=c99f3846e7a7b6f06ab46508baa5409204ad6290 diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 9ab27f9..8b07b85 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -21,24 +21,45 @@ SeqSummaryCommand::SeqSummaryCommand(string option){ else { //valid paramters for this command - string Array[] = {"fasta"}; + string Array[] = {"fasta","outputdir","inputdir"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); map parameters = parser.getParameters(); ValidParameters validParameter; + map::iterator it; //check to make sure all parameters are valid for command - for (map::iterator it = parameters.begin(); it != parameters.end(); it++) { + for (it = parameters.begin(); it != parameters.end(); it++) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //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 = ""; } + else { + string path; + it = parameters.find("fasta"); + //user has given a template file + if(it != parameters.end()){ + path = 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; } + } + } + //check for required parameters fastafile = validParameter.validFile(parameters, "fasta", true); if (fastafile == "not open") { abort = true; } else if (fastafile == "not found") { fastafile = ""; mothurOut("fasta is a required parameter for the summary.seqs command."); mothurOutEndLine(); abort = true; } + //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(fastafile); //if user entered a file with a path then preserve it + } + } } catch(exception& e) { @@ -78,7 +99,7 @@ int SeqSummaryCommand::execute(){ int numSeqs = 0; ofstream outSummary; - string summaryFile = fastafile + ".summary"; + string summaryFile = outputDir + getSimpleName(fastafile) + ".summary"; openOutputFile(summaryFile, outSummary); vector startPosition;