X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=commandfactory.cpp;h=964847478ae6e9e42f7ebb7c8ef35b5f452ff3f5;hb=5a1e62397b91f57d0d3aff635891df04b8999a88;hp=635cff032a645b7e69c168c7b461eaca71bb364d;hpb=7af504f0a1c77582a6ea55e8b003685059c1c4a1;p=mothur.git diff --git a/commandfactory.cpp b/commandfactory.cpp index 635cff0..9648474 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -16,7 +16,6 @@ #include "collectsharedcommand.h" #include "getgroupcommand.h" #include "getlabelcommand.h" -#include "getlinecommand.h" #include "rarefactcommand.h" #include "summarycommand.h" #include "summarysharedcommand.h" @@ -60,7 +59,21 @@ #include "hclustercommand.h" #include "classifyseqscommand.h" #include "phylotypecommand.h" +#include "mgclustercommand.h" +#include "preclustercommand.h" +#include "pcacommand.h" +#include "otuhierarchycommand.h" +#include "setdircommand.h" +/*******************************************************/ + +/******************************************************/ +CommandFactory* CommandFactory::getInstance() { + if( _uniqueInstance == 0) { + _uniqueInstance = new CommandFactory(); + } + return _uniqueInstance; +} /***********************************************************/ /***********************************************************/ @@ -68,6 +81,7 @@ CommandFactory::CommandFactory(){ string s = ""; command = new NoCommand(s); + outputDir = ""; inputDir = ""; //initialize list of valid commands commands["read.dist"] = "read.dist"; @@ -95,7 +109,6 @@ CommandFactory::CommandFactory(){ 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"; @@ -119,12 +132,18 @@ CommandFactory::CommandFactory(){ commands["hcluster"] = "hcluster"; commands["classify.seqs"] = "classify.seqs"; commands["phylotype"] = "phylotype"; - + commands["mgcluster"] = "mgcluster"; + commands["pre.cluster"] = "pre.cluster"; + commands["pcoa"] = "pcoa"; + commands["otu.hierarchy"] = "otu.hierarchy"; + commands["set.dir"] = "set.dir"; + commands["merge.files"] = "merge.files"; } /***********************************************************/ /***********************************************************/ CommandFactory::~CommandFactory(){ + _uniqueInstance = 0; delete command; } @@ -135,7 +154,19 @@ CommandFactory::~CommandFactory(){ Command* CommandFactory::getCommand(string commandName, string optionString){ try { delete command; //delete the old command - + + //user has opted to redirect output from dir where input files are located to some other place + if (outputDir != "") { + if (optionString != "") { optionString += ", outputdir=" + outputDir; } + else { optionString += "outputdir=" + outputDir; } + } + + //user has opted to redirect input from dir where mothur.exe is located to some other place + if (inputDir != "") { + if (optionString != "") { optionString += ", inputdir=" + inputDir; } + else { optionString += "inputdir=" + inputDir; } + } + 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); } @@ -154,7 +185,6 @@ Command* CommandFactory::getCommand(string commandName, string 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); } @@ -181,11 +211,16 @@ Command* CommandFactory::getCommand(string commandName, string optionString){ else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); } else if(commandName == "system") { command = new SystemCommand(optionString); } else if(commandName == "align.check") { command = new AlignCheckCommand(optionString); } - else if(commandName == "get.sharedseqs") { command = new GetSharedOTUCommand(optionString); } + else if(commandName == "get.sharedseqs") { command = new GetSharedOTUCommand(optionString); } else if(commandName == "get.otulist") { command = new GetListCountCommand(optionString); } else if(commandName == "hcluster") { command = new HClusterCommand(optionString); } else if(commandName == "classify.seqs") { command = new ClassifySeqsCommand(optionString); } else if(commandName == "phylotype") { command = new PhylotypeCommand(optionString); } + else if(commandName == "mgcluster") { command = new MGClusterCommand(optionString); } + else if(commandName == "pre.cluster") { command = new PreClusterCommand(optionString); } + else if(commandName == "pcoa") { command = new PCACommand(optionString); } + else if(commandName == "otu.hierarchy") { command = new OtuHierarchyCommand(optionString); } + else if(commandName == "set.dir") { command = new SetDirectoryCommand(optionString); } else { command = new NoCommand(optionString); } return command; @@ -195,7 +230,22 @@ Command* CommandFactory::getCommand(string commandName, string optionString){ exit(1); } } +/***********************************************************/ +//This function is used to interrupt a command +Command* CommandFactory::getCommand(){ + try { + delete command; //delete the old command + string s = ""; + command = new NoCommand(s); + + return command; + } + catch(exception& e) { + errorOut(e, "CommandFactory", "getCommand"); + exit(1); + } +} /***********************************************************************/ bool CommandFactory::isValidCommand(string command) { try {