X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=commandfactory.cpp;h=3d90269590b3f42e2d140821ba39220ccde9c251;hb=861f46b74c17adec8c6ad6d89f232ae7485797bf;hp=dbcfb54be8c09fbf6177ad2d4ed10be8773d0358;hpb=d037597badc8d18e235c59f0c1114180edb7f98f;p=mothur.git diff --git a/commandfactory.cpp b/commandfactory.cpp index dbcfb54..3d90269 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -12,14 +12,15 @@ #include "readtreecommand.h" #include "readotucommand.h" #include "clustercommand.h" -#include "parselistcommand.h" #include "collectcommand.h" #include "collectsharedcommand.h" +#include "getgroupcommand.h" +#include "getlabelcommand.h" +#include "getlinecommand.h" #include "rarefactcommand.h" #include "summarycommand.h" #include "summarysharedcommand.h" #include "rarefactsharedcommand.h" -#include "nocommand.h" #include "quitcommand.h" #include "helpcommand.h" #include "commandfactory.hpp" @@ -27,16 +28,81 @@ #include "parsimonycommand.h" #include "unifracunweightedcommand.h" #include "unifracweightedcommand.h" -#include - +#include "libshuffcommand.h" +#include "heatmapcommand.h" +#include "heatmapsimcommand.h" +#include "filterseqscommand.h" +#include "venncommand.h" +#include "nocommands.h" +#include "binsequencecommand.h" +#include "getoturepcommand.h" +#include "treegroupscommand.h" +#include "bootstrapsharedcommand.h" +//#include "consensuscommand.h" +#include "distancecommand.h" +#include "aligncommand.h" +#include "matrixoutputcommand.h" +#include "getsabundcommand.h" +#include "getrabundcommand.h" +#include "seqsummarycommand.h" +#include "screenseqscommand.h" +#include "reversecommand.h" +#include "trimseqscommand.h" +#include "mergefilecommand.h" +#include "chimeraseqscommand.h" +#include "listseqscommand.h" /***********************************************************/ /***********************************************************/ CommandFactory::CommandFactory(){ - command = new NoCommand(); -} + string s = ""; + command = new NoCommand(s); + + + //initialize list of valid commands + commands["read.dist"] = "read.dist"; + commands["read.otu"] = "read.otu"; + commands["read.tree"] = "read.tree"; + commands["bin.seqs"] = "bin.seqs"; + commands["get.oturep"] = "get.oturep"; + commands["cluster"] = "cluster"; + commands["unique.seqs"] = "unique.seqs"; + commands["dist.seqs"] = "dist.seqs"; + commands["dist.shared"] = "dist.shared"; + commands["collect.single"] = "collect.single"; + commands["collect.shared"] = "collect.shared"; + commands["rarefaction.single"] = "rarefaction.single"; + commands["rarefaction.shared"] = "rarefaction.shared"; + commands["summary.single"] = "summary.single"; + commands["summary.shared"] = "summary.shared"; + commands["parsimony"] = "parsimony"; + commands["unifrac.weighted"] = "unifrac.weighted"; + commands["unifrac.unweighted"] = "unifrac.unweighted"; + commands["libshuff"] = "libshuff"; + commands["tree.shared"] = "tree.shared"; + commands["heatmap.bin"] = "heatmap.bin"; + commands["heatmap.sim"] = "heatmap.sim"; + commands["venn"] = "venn"; + commands["get.group"] = "get.group"; + commands["get.label"] = "get.label"; + commands["get.line"] = "get.line"; + commands["get.sabund"] = "get.sabund"; + commands["get.rabund"] = "get.rabund"; + commands["bootstrap.shared"] = "bootstrap.shared"; + //commands["consensus"] = "consensus"; + commands["help"] = "help"; + commands["filter.seqs"] = "filter.seqs"; + commands["align.seqs"] = "align.seqs"; + commands["summary.seqs"] = "summary.seqs"; + commands["screen.seqs"] = "screen.seqs"; + commands["reverse.seqs"] = "reverse.seqs"; + commands["trim.seqs"] = "trim.seqs"; + commands["chimera.seqs"] = "chimera.seqs"; + commands["list.seqs"] = "list.seqs"; + commands["quit"] = "quit"; +} /***********************************************************/ /***********************************************************/ @@ -48,39 +114,100 @@ CommandFactory::~CommandFactory(){ /***********************************************************/ //This function calls the appropriate command fucntions based on user input. -Command* CommandFactory::getCommand(string commandName){ +Command* CommandFactory::getCommand(string commandName, string optionString){ try { delete command; //delete the old command - if(commandName == "read.dist") { command = new ReadDistCommand(); } - else if(commandName == "read.otu") { command = new ReadOtuCommand(); } - else if(commandName == "read.tree") { command = new ReadTreeCommand(); } - else if(commandName == "cluster") { command = new ClusterCommand(); } - else if(commandName == "deconvolute") { command = new DeconvoluteCommand(); } - else if(commandName == "parsimony") { command = new ParsimonyCommand(); } - else if(commandName == "help") { command = new HelpCommand(); } - else if(commandName == "quit") { command = new QuitCommand(); } - else if(commandName == "collect.single") { command = new CollectCommand(); } - else if(commandName == "collect.shared") { command = new CollectSharedCommand(); } - else if(commandName == "rarefaction.single") { command = new RareFactCommand(); } - else if(commandName == "rarefaction.shared") { command = new RareFactSharedCommand(); } - else if(commandName == "summary.single") { command = new SummaryCommand(); } - else if(commandName == "summary.shared") { command = new SummarySharedCommand(); } - else if(commandName == "unifrac.weighted") { command = new UnifracWeightedCommand(); } - else if(commandName == "unifrac.unweighted") { command = new UnifracUnweightedCommand(); } - else { command = new NoCommand(); } - + if(commandName == "read.dist") { command = new ReadDistCommand(optionString); } + else if(commandName == "read.otu") { command = new ReadOtuCommand(optionString); } + else if(commandName == "read.tree") { command = new ReadTreeCommand(optionString); } + else if(commandName == "cluster") { command = new ClusterCommand(optionString); } + else if(commandName == "unique.seqs") { command = new DeconvoluteCommand(optionString); } + else if(commandName == "parsimony") { command = new ParsimonyCommand(optionString); } + else if(commandName == "help") { command = new HelpCommand(optionString); } + else if(commandName == "quit") { command = new QuitCommand(optionString); } + else if(commandName == "collect.single") { command = new CollectCommand(optionString); } + else if(commandName == "collect.shared") { command = new CollectSharedCommand(optionString); } + else if(commandName == "rarefaction.single") { command = new RareFactCommand(optionString); } + else if(commandName == "rarefaction.shared") { command = new RareFactSharedCommand(optionString); } + else if(commandName == "summary.single") { command = new SummaryCommand(optionString); } + else if(commandName == "summary.shared") { command = new SummarySharedCommand(optionString); } + else if(commandName == "unifrac.weighted") { command = new UnifracWeightedCommand(optionString); } + else if(commandName == "unifrac.unweighted") { command = new UnifracUnweightedCommand(optionString); } + else if(commandName == "get.group") { command = new GetgroupCommand(optionString); } + else if(commandName == "get.label") { command = new GetlabelCommand(optionString); } + else if(commandName == "get.line") { command = new GetlineCommand(optionString); } + else if(commandName == "get.sabund") { command = new GetSAbundCommand(optionString); } + else if(commandName == "get.rabund") { command = new GetRAbundCommand(optionString); } + else if(commandName == "libshuff") { command = new LibShuffCommand(optionString); } + else if(commandName == "heatmap.bin") { command = new HeatMapCommand(optionString); } + else if(commandName == "heatmap.sim") { command = new HeatMapSimCommand(optionString); } + else if(commandName == "filter.seqs") { command = new FilterSeqsCommand(optionString); } + else if(commandName == "venn") { command = new VennCommand(optionString); } + else if(commandName == "bin.seqs") { command = new BinSeqCommand(optionString); } + else if(commandName == "get.oturep") { command = new GetOTURepCommand(optionString); } + else if(commandName == "tree.shared") { command = new TreeGroupCommand(optionString); } + else if(commandName == "dist.shared") { command = new MatrixOutputCommand(optionString); } + else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(optionString); } + //else if(commandName == "consensus") { command = new ConcensusCommand(optionString); } + else if(commandName == "dist.seqs") { command = new DistanceCommand(optionString); } + else if(commandName == "align.seqs") { command = new AlignCommand(optionString); } + else if(commandName == "summary.seqs") { command = new SeqSummaryCommand(optionString); } + else if(commandName == "screen.seqs") { command = new ScreenSeqsCommand(optionString); } + else if(commandName == "reverse.seqs") { command = new ReverseSeqsCommand(optionString); } + else if(commandName == "trim.seqs") { command = new TrimSeqsCommand(optionString); } + else if(commandName == "chimera.seqs") { command = new ChimeraSeqsCommand(optionString); } + else if(commandName == "list.seqs") { command = new ListSeqsCommand(optionString); } + else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); } + else { command = new NoCommand(optionString); } + return command; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "CommandFactory", "getCommand"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the CommandFactory class function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; +} + +/***********************************************************************/ +bool CommandFactory::isValidCommand(string command) { + try { + + //is the command in the map + if ((commands.find(command)) != (commands.end())) { + return true; + }else{ + mothurOut(command + " is not a valid command in Mothur. Valid commands are "); + for (it = commands.begin(); it != commands.end(); it++) { + mothurOut(it->first + ", "); + } + mothurOutEndLine(); + return false; + } + + } + catch(exception& e) { + errorOut(e, "CommandFactory", "isValidCommand"); exit(1); } +} +/***********************************************************************/ +void CommandFactory::printCommands(ostream& out) { + try { + out << "Valid commands are "; + for (it = commands.begin(); it != commands.end(); it++) { + out << it->first << ", "; + } + out << endl; + } + catch(exception& e) { + errorOut(e, "CommandFactory", "printCommands"); + exit(1); + } } -/***********************************************************/ +/***********************************************************************/ + + +