5 * Created by Pat Schloss on 10/25/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
10 #include "command.hpp"
11 #include "readdistcommand.h"
12 #include "readtreecommand.h"
13 #include "readotucommand.h"
14 #include "clustercommand.h"
15 #include "collectcommand.h"
16 #include "collectsharedcommand.h"
17 #include "getgroupcommand.h"
18 #include "getlabelcommand.h"
19 #include "rarefactcommand.h"
20 #include "summarycommand.h"
21 #include "summarysharedcommand.h"
22 #include "rarefactsharedcommand.h"
23 #include "quitcommand.h"
24 #include "helpcommand.h"
25 #include "commandfactory.hpp"
26 #include "deconvolutecommand.h"
27 #include "parsimonycommand.h"
28 #include "unifracunweightedcommand.h"
29 #include "unifracweightedcommand.h"
30 #include "libshuffcommand.h"
31 #include "heatmapcommand.h"
32 #include "heatmapsimcommand.h"
33 #include "filterseqscommand.h"
34 #include "venncommand.h"
35 #include "nocommands.h"
36 #include "binsequencecommand.h"
37 #include "getoturepcommand.h"
38 #include "treegroupscommand.h"
39 #include "bootstrapsharedcommand.h"
40 //#include "consensuscommand.h"
41 #include "distancecommand.h"
42 #include "aligncommand.h"
43 #include "matrixoutputcommand.h"
44 #include "getsabundcommand.h"
45 #include "getrabundcommand.h"
46 #include "seqsummarycommand.h"
47 #include "screenseqscommand.h"
48 #include "reversecommand.h"
49 #include "trimseqscommand.h"
50 #include "mergefilecommand.h"
51 #include "listseqscommand.h"
52 #include "getseqscommand.h"
53 #include "removeseqscommand.h"
54 #include "systemcommand.h"
55 #include "secondarystructurecommand.h"
56 #include "getsharedotucommand.h"
57 #include "getlistcountcommand.h"
58 #include "hclustercommand.h"
59 #include "classifyseqscommand.h"
60 #include "phylotypecommand.h"
61 #include "mgclustercommand.h"
62 #include "preclustercommand.h"
63 #include "pcoacommand.h"
64 #include "otuhierarchycommand.h"
65 #include "setdircommand.h"
66 #include "parselistscommand.h"
67 #include "chimeraccodecommand.h"
68 #include "chimeracheckcommand.h"
69 #include "chimeraslayercommand.h"
70 #include "chimerapintailcommand.h"
71 #include "chimerabellerophoncommand.h"
72 #include "setlogfilecommand.h"
73 #include "phylodiversitycommand.h"
74 #include "makegroupcommand.h"
75 #include "chopseqscommand.h"
76 #include "clearcutcommand.h"
77 #include "catchallcommand.h"
78 #include "splitabundcommand.h"
79 #include "clustersplitcommand.h"
80 #include "classifyotucommand.h"
81 #include "degapseqscommand.h"
82 #include "getrelabundcommand.h"
83 #include "sensspeccommand.h"
84 #include "sffinfocommand.h"
85 #include "seqerrorcommand.h"
86 #include "normalizesharedcommand.h"
87 #include "metastatscommand.h"
88 #include "splitgroupscommand.h"
89 #include "clusterfragmentscommand.h"
90 #include "getlineagecommand.h"
91 #include "removelineagecommand.h"
92 #include "parsefastaqcommand.h"
93 #include "pipelinepdscommand.h"
94 #include "deuniqueseqscommand.h"
95 #include "pairwiseseqscommand.h"
96 #include "clusterdoturcommand.h"
97 #include "subsamplecommand.h"
98 #include "removegroupscommand.h"
99 #include "getgroupscommand.h"
100 #include "getotuscommand.h"
101 #include "removeotuscommand.h"
102 #include "indicatorcommand.h"
103 #include "consensusseqscommand.h"
104 #include "trimflowscommand.h"
105 #include "corraxescommand.h"
106 #include "shhhercommand.h"
107 #include "pcacommand.h"
108 #include "nmdscommand.h"
109 #include "removerarecommand.h"
110 #include "mergegroupscommand.h"
111 #include "amovacommand.h"
112 #include "homovacommand.h"
113 #include "mantelcommand.h"
114 #include "makefastqcommand.h"
115 #include "anosimcommand.h"
116 #include "getcurrentcommand.h"
117 #include "setcurrentcommand.h"
118 #include "sharedcommand.h"
119 #include "getcommandinfocommand.h"
121 /*******************************************************/
123 /******************************************************/
124 CommandFactory* CommandFactory::getInstance() {
125 if( _uniqueInstance == 0) {
126 _uniqueInstance = new CommandFactory();
128 return _uniqueInstance;
130 /***********************************************************/
132 /***********************************************************/
133 //note: This class is resposible for knowing which commands are mpiEnabled,
134 //If a command is not enabled only process 0 will execute the command.
135 //This avoids redundant outputs on pieces of code we have not paralellized.
136 //If you add mpi code to a existing command you need to modify the list below or the code will hang on MPI blocking commands like FIle_open.
137 //example: commands["dist.seqs"] = "MPIEnabled";
139 CommandFactory::CommandFactory(){
141 m = MothurOut::getInstance();
143 command = new NoCommand(s);
144 shellcommand = new NoCommand(s);
145 pipecommand = new NoCommand(s);
147 outputDir = ""; inputDir = "";
151 //initialize list of valid commands
152 commands["read.dist"] = "read.dist";
153 commands["read.otu"] = "read.otu";
154 commands["read.tree"] = "read.tree";
155 commands["make.shared"] = "make.shared";
156 commands["bin.seqs"] = "bin.seqs";
157 commands["get.oturep"] = "get.oturep";
158 commands["cluster"] = "cluster";
159 commands["unique.seqs"] = "unique.seqs";
160 commands["dist.shared"] = "dist.shared";
161 commands["collect.single"] = "collect.single";
162 commands["collect.shared"] = "collect.shared";
163 commands["rarefaction.single"] = "rarefaction.single";
164 commands["rarefaction.shared"] = "rarefaction.shared";
165 commands["summary.single"] = "summary.single";
166 commands["summary.shared"] = "summary.shared";
167 commands["parsimony"] = "parsimony";
168 commands["unifrac.weighted"] = "unifrac.weighted";
169 commands["unifrac.unweighted"] = "unifrac.unweighted";
170 commands["libshuff"] = "libshuff";
171 commands["tree.shared"] = "tree.shared";
172 commands["heatmap.bin"] = "heatmap.bin";
173 commands["heatmap.sim"] = "heatmap.sim";
174 commands["venn"] = "venn";
175 commands["get.group"] = "get.group";
176 commands["get.label"] = "get.label";
177 commands["get.sabund"] = "get.sabund";
178 commands["get.rabund"] = "get.rabund";
179 commands["bootstrap.shared"] = "bootstrap.shared";
180 //commands["consensus"] = "consensus";
181 commands["help"] = "help";
182 commands["reverse.seqs"] = "reverse.seqs";
183 commands["trim.seqs"] = "trim.seqs";
184 commands["trim.flows"] = "trim.flows";
185 commands["list.seqs"] = "list.seqs";
186 commands["get.seqs"] = "get.seqs";
187 commands["remove.seqs"] = "get.seqs";
188 commands["system"] = "system";
189 commands["align.check"] = "align.check";
190 commands["get.sharedseqs"] = "get.sharedseqs";
191 commands["get.otulist"] = "get.otulist";
192 commands["hcluster"] = "hcluster";
193 commands["phylotype"] = "phylotype";
194 commands["mgcluster"] = "mgcluster";
195 commands["pre.cluster"] = "pre.cluster";
196 commands["pcoa"] = "pcoa";
197 commands["otu.hierarchy"] = "otu.hierarchy";
198 commands["set.dir"] = "set.dir";
199 commands["merge.files"] = "merge.files";
200 commands["parse.list"] = "parse.list";
201 commands["set.logfile"] = "set.logfile";
202 commands["phylo.diversity"] = "phylo.diversity";
203 commands["make.group"] = "make.group";
204 commands["chop.seqs"] = "chop.seqs";
205 commands["clearcut"] = "clearcut";
206 commands["catchall"] = "catchall";
207 commands["split.abund"] = "split.abund";
208 commands["classify.otu"] = "classify.otu";
209 commands["degap.seqs"] = "degap.seqs";
210 commands["get.relabund"] = "get.relabund";
211 commands["sffinfo"] = "sffinfo";
212 commands["normalize.shared"] = "normalize.shared";
213 commands["metastats"] = "metastats";
214 commands["split.groups"] = "split.groups";
215 commands["cluster.fragments"] = "cluster.fragments";
216 commands["get.lineage"] = "get.lineage";
217 commands["remove.lineage"] = "remove.lineage";
218 commands["fastq.info"] = "fastq.info";
219 commands["deunique.seqs"] = "deunique.seqs";
220 commands["cluster.classic"] = "cluster.classic";
221 commands["sub.sample"] = "sub.sample";
222 commands["remove.groups"] = "remove.groups";
223 commands["get.groups"] = "get.groups";
224 commands["get.otus"] = "get.otus";
225 commands["remove.otus"] = "remove.otus";
226 commands["indicator"] = "indicator";
227 commands["consensus.seqs"] = "consensus.seqs";
228 commands["corr.axes"] = "corr.axes";
229 commands["pca"] = "pca";
230 commands["nmds"] = "nmds";
231 commands["remove.rare"] = "remove.rare";
232 commands["amova"] = "amova";
233 commands["homova"] = "homova";
234 commands["mantel"] = "mantel";
235 commands["anosim"] = "anosim";
236 commands["make.fastq"] = "make.fastq";
237 commands["merge.groups"] = "merge.groups";
238 commands["get.current"] = "get.current";
239 commands["set.current"] = "set.current";
240 commands["get.commandinfo"] = "get.commandinfo";
241 commands["pairwise.seqs"] = "MPIEnabled";
242 commands["pipeline.pds"] = "MPIEnabled";
243 commands["classify.seqs"] = "MPIEnabled";
244 commands["dist.seqs"] = "MPIEnabled";
245 commands["filter.seqs"] = "MPIEnabled";
246 commands["align.seqs"] = "MPIEnabled";
247 commands["chimera.ccode"] = "MPIEnabled";
248 commands["chimera.check"] = "MPIEnabled";
249 commands["chimera.slayer"] = "MPIEnabled";
250 commands["chimera.pintail"] = "MPIEnabled";
251 commands["chimera.bellerophon"] = "MPIEnabled";
252 commands["screen.seqs"] = "MPIEnabled";
253 commands["summary.seqs"] = "MPIEnabled";
254 commands["cluster.split"] = "MPIEnabled";
255 commands["shhh.seqs"] = "MPIEnabled";
256 commands["sens.spec"] = "sens.spec";
257 commands["seq.error"] = "seq.error";
258 commands["quit"] = "MPIEnabled";
261 /***********************************************************/
263 /***********************************************************/
264 bool CommandFactory::MPIEnabled(string commandName) {
266 it = commands.find(commandName);
267 if (it != commands.end()) {
268 if (it->second == "MPIEnabled") { return true; }
272 /***********************************************************/
274 /***********************************************************/
275 CommandFactory::~CommandFactory(){
282 /***********************************************************/
284 /***********************************************************/
285 //This function calls the appropriate command fucntions based on user input.
286 Command* CommandFactory::getCommand(string commandName, string optionString){
288 delete command; //delete the old command
290 //user has opted to redirect output from dir where input files are located to some other place
291 if (outputDir != "") {
292 if (optionString != "") { optionString += ", outputdir=" + outputDir; }
293 else { optionString += "outputdir=" + outputDir; }
296 //user has opted to redirect input from dir where mothur.exe is located to some other place
297 if (inputDir != "") {
298 if (optionString != "") { optionString += ", inputdir=" + inputDir; }
299 else { optionString += "inputdir=" + inputDir; }
302 if(commandName == "read.dist") { command = new ReadDistCommand(optionString); }
303 else if(commandName == "read.otu") { command = new ReadOtuCommand(optionString); }
304 else if(commandName == "read.tree") { command = new ReadTreeCommand(optionString); }
305 else if(commandName == "cluster") { command = new ClusterCommand(optionString); }
306 else if(commandName == "unique.seqs") { command = new DeconvoluteCommand(optionString); }
307 else if(commandName == "parsimony") { command = new ParsimonyCommand(optionString); }
308 else if(commandName == "help") { command = new HelpCommand(optionString); }
309 else if(commandName == "quit") { command = new QuitCommand(optionString); }
310 else if(commandName == "collect.single") { command = new CollectCommand(optionString); }
311 else if(commandName == "collect.shared") { command = new CollectSharedCommand(optionString); }
312 else if(commandName == "rarefaction.single") { command = new RareFactCommand(optionString); }
313 else if(commandName == "rarefaction.shared") { command = new RareFactSharedCommand(optionString); }
314 else if(commandName == "summary.single") { command = new SummaryCommand(optionString); }
315 else if(commandName == "summary.shared") { command = new SummarySharedCommand(optionString); }
316 else if(commandName == "unifrac.weighted") { command = new UnifracWeightedCommand(optionString); }
317 else if(commandName == "unifrac.unweighted") { command = new UnifracUnweightedCommand(optionString); }
318 else if(commandName == "get.group") { command = new GetgroupCommand(optionString); }
319 else if(commandName == "get.label") { command = new GetlabelCommand(optionString); }
320 else if(commandName == "get.sabund") { command = new GetSAbundCommand(optionString); }
321 else if(commandName == "get.rabund") { command = new GetRAbundCommand(optionString); }
322 else if(commandName == "libshuff") { command = new LibShuffCommand(optionString); }
323 else if(commandName == "heatmap.bin") { command = new HeatMapCommand(optionString); }
324 else if(commandName == "heatmap.sim") { command = new HeatMapSimCommand(optionString); }
325 else if(commandName == "filter.seqs") { command = new FilterSeqsCommand(optionString); }
326 else if(commandName == "venn") { command = new VennCommand(optionString); }
327 else if(commandName == "bin.seqs") { command = new BinSeqCommand(optionString); }
328 else if(commandName == "get.oturep") { command = new GetOTURepCommand(optionString); }
329 else if(commandName == "tree.shared") { command = new TreeGroupCommand(optionString); }
330 else if(commandName == "dist.shared") { command = new MatrixOutputCommand(optionString); }
331 else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(optionString); }
332 else if(commandName == "consensus") { command = new ConcensusCommand(optionString); }
333 else if(commandName == "dist.seqs") { command = new DistanceCommand(optionString); }
334 else if(commandName == "align.seqs") { command = new AlignCommand(optionString); }
335 else if(commandName == "summary.seqs") { command = new SeqSummaryCommand(optionString); }
336 else if(commandName == "screen.seqs") { command = new ScreenSeqsCommand(optionString); }
337 else if(commandName == "reverse.seqs") { command = new ReverseSeqsCommand(optionString); }
338 else if(commandName == "trim.seqs") { command = new TrimSeqsCommand(optionString); }
339 else if(commandName == "trim.flows") { command = new TrimFlowsCommand(optionString); }
340 else if(commandName == "shhh.seqs") { command = new ShhherCommand(optionString); }
341 else if(commandName == "list.seqs") { command = new ListSeqsCommand(optionString); }
342 else if(commandName == "get.seqs") { command = new GetSeqsCommand(optionString); }
343 else if(commandName == "remove.seqs") { command = new RemoveSeqsCommand(optionString); }
344 else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); }
345 else if(commandName == "system") { command = new SystemCommand(optionString); }
346 else if(commandName == "align.check") { command = new AlignCheckCommand(optionString); }
347 else if(commandName == "get.sharedseqs") { command = new GetSharedOTUCommand(optionString); }
348 else if(commandName == "get.otulist") { command = new GetListCountCommand(optionString); }
349 else if(commandName == "hcluster") { command = new HClusterCommand(optionString); }
350 else if(commandName == "classify.seqs") { command = new ClassifySeqsCommand(optionString); }
351 else if(commandName == "chimera.ccode") { command = new ChimeraCcodeCommand(optionString); }
352 else if(commandName == "chimera.check") { command = new ChimeraCheckCommand(optionString); }
353 else if(commandName == "chimera.slayer") { command = new ChimeraSlayerCommand(optionString); }
354 else if(commandName == "chimera.pintail") { command = new ChimeraPintailCommand(optionString); }
355 else if(commandName == "chimera.bellerophon") { command = new ChimeraBellerophonCommand(optionString); }
356 else if(commandName == "phylotype") { command = new PhylotypeCommand(optionString); }
357 else if(commandName == "mgcluster") { command = new MGClusterCommand(optionString); }
358 else if(commandName == "pre.cluster") { command = new PreClusterCommand(optionString); }
359 else if(commandName == "pcoa") { command = new PCOACommand(optionString); }
360 else if(commandName == "pca") { command = new PCACommand(optionString); }
361 else if(commandName == "nmds") { command = new NMDSCommand(optionString); }
362 else if(commandName == "otu.hierarchy") { command = new OtuHierarchyCommand(optionString); }
363 else if(commandName == "set.dir") { command = new SetDirectoryCommand(optionString); }
364 else if(commandName == "set.logfile") { command = new SetLogFileCommand(optionString); }
365 else if(commandName == "parse.list") { command = new ParseListCommand(optionString); }
366 else if(commandName == "phylo.diversity") { command = new PhyloDiversityCommand(optionString); }
367 else if(commandName == "make.group") { command = new MakeGroupCommand(optionString); }
368 else if(commandName == "chop.seqs") { command = new ChopSeqsCommand(optionString); }
369 else if(commandName == "clearcut") { command = new ClearcutCommand(optionString); }
370 else if(commandName == "catchall") { command = new CatchAllCommand(optionString); }
371 else if(commandName == "split.abund") { command = new SplitAbundCommand(optionString); }
372 else if(commandName == "cluster.split") { command = new ClusterSplitCommand(optionString); }
373 else if(commandName == "classify.otu") { command = new ClassifyOtuCommand(optionString); }
374 else if(commandName == "degap.seqs") { command = new DegapSeqsCommand(optionString); }
375 else if(commandName == "get.relabund") { command = new GetRelAbundCommand(optionString); }
376 else if(commandName == "sens.spec") { command = new SensSpecCommand(optionString); }
377 else if(commandName == "seq.error") { command = new SeqErrorCommand(optionString); }
378 else if(commandName == "sffinfo") { command = new SffInfoCommand(optionString); }
379 else if(commandName == "normalize.shared") { command = new NormalizeSharedCommand(optionString); }
380 else if(commandName == "metastats") { command = new MetaStatsCommand(optionString); }
381 else if(commandName == "split.groups") { command = new SplitGroupCommand(optionString); }
382 else if(commandName == "cluster.fragments") { command = new ClusterFragmentsCommand(optionString); }
383 else if(commandName == "get.lineage") { command = new GetLineageCommand(optionString); }
384 else if(commandName == "remove.lineage") { command = new RemoveLineageCommand(optionString); }
385 else if(commandName == "get.groups") { command = new GetGroupsCommand(optionString); }
386 else if(commandName == "remove.groups") { command = new RemoveGroupsCommand(optionString); }
387 else if(commandName == "get.otus") { command = new GetOtusCommand(optionString); }
388 else if(commandName == "remove.otus") { command = new RemoveOtusCommand(optionString); }
389 else if(commandName == "fastq.info") { command = new ParseFastaQCommand(optionString); }
390 else if(commandName == "pipeline.pds") { command = new PipelineCommand(optionString); }
391 else if(commandName == "deunique.seqs") { command = new DeUniqueSeqsCommand(optionString); }
392 else if(commandName == "pairwise.seqs") { command = new PairwiseSeqsCommand(optionString); }
393 else if(commandName == "cluster.classic") { command = new ClusterDoturCommand(optionString); }
394 else if(commandName == "sub.sample") { command = new SubSampleCommand(optionString); }
395 else if(commandName == "indicator") { command = new IndicatorCommand(optionString); }
396 else if(commandName == "consensus.seqs") { command = new ConsensusSeqsCommand(optionString); }
397 else if(commandName == "corr.axes") { command = new CorrAxesCommand(optionString); }
398 else if(commandName == "remove.rare") { command = new RemoveRareCommand(optionString); }
399 else if(commandName == "merge.groups") { command = new MergeGroupsCommand(optionString); }
400 else if(commandName == "amova") { command = new AmovaCommand(optionString); }
401 else if(commandName == "homova") { command = new HomovaCommand(optionString); }
402 else if(commandName == "mantel") { command = new MantelCommand(optionString); }
403 else if(commandName == "make.fastq") { command = new MakeFastQCommand(optionString); }
404 else if(commandName == "get.current") { command = new GetCurrentCommand(optionString); }
405 else if(commandName == "set.current") { command = new SetCurrentCommand(optionString); }
406 else if(commandName == "anosim") { command = new AnosimCommand(optionString); }
407 else if(commandName == "make.shared") { command = new SharedCommand(optionString); }
408 else if(commandName == "get.commandinfo") { command = new GetCommandInfoCommand(optionString); }
409 else { command = new NoCommand(optionString); }
413 catch(exception& e) {
414 m->errorOut(e, "CommandFactory", "getCommand");
418 /***********************************************************/
420 /***********************************************************/
421 //This function calls the appropriate command fucntions based on user input.
422 Command* CommandFactory::getCommand(string commandName, string optionString, string mode){
424 delete pipecommand; //delete the old command
426 //user has opted to redirect output from dir where input files are located to some other place
427 if (outputDir != "") {
428 if (optionString != "") { optionString += ", outputdir=" + outputDir; }
429 else { optionString += "outputdir=" + outputDir; }
432 //user has opted to redirect input from dir where mothur.exe is located to some other place
433 if (inputDir != "") {
434 if (optionString != "") { optionString += ", inputdir=" + inputDir; }
435 else { optionString += "inputdir=" + inputDir; }
438 if(commandName == "read.dist") { pipecommand = new ReadDistCommand(optionString); }
439 else if(commandName == "read.otu") { pipecommand = new ReadOtuCommand(optionString); }
440 else if(commandName == "read.tree") { pipecommand = new ReadTreeCommand(optionString); }
441 else if(commandName == "cluster") { pipecommand = new ClusterCommand(optionString); }
442 else if(commandName == "unique.seqs") { pipecommand = new DeconvoluteCommand(optionString); }
443 else if(commandName == "parsimony") { pipecommand = new ParsimonyCommand(optionString); }
444 else if(commandName == "help") { pipecommand = new HelpCommand(optionString); }
445 else if(commandName == "quit") { pipecommand = new QuitCommand(optionString); }
446 else if(commandName == "collect.single") { pipecommand = new CollectCommand(optionString); }
447 else if(commandName == "collect.shared") { pipecommand = new CollectSharedCommand(optionString); }
448 else if(commandName == "rarefaction.single") { pipecommand = new RareFactCommand(optionString); }
449 else if(commandName == "rarefaction.shared") { pipecommand = new RareFactSharedCommand(optionString); }
450 else if(commandName == "summary.single") { pipecommand = new SummaryCommand(optionString); }
451 else if(commandName == "summary.shared") { pipecommand = new SummarySharedCommand(optionString); }
452 else if(commandName == "unifrac.weighted") { pipecommand = new UnifracWeightedCommand(optionString); }
453 else if(commandName == "unifrac.unweighted") { pipecommand = new UnifracUnweightedCommand(optionString); }
454 else if(commandName == "get.group") { pipecommand = new GetgroupCommand(optionString); }
455 else if(commandName == "get.label") { pipecommand = new GetlabelCommand(optionString); }
456 else if(commandName == "get.sabund") { pipecommand = new GetSAbundCommand(optionString); }
457 else if(commandName == "get.rabund") { pipecommand = new GetRAbundCommand(optionString); }
458 else if(commandName == "libshuff") { pipecommand = new LibShuffCommand(optionString); }
459 else if(commandName == "heatmap.bin") { pipecommand = new HeatMapCommand(optionString); }
460 else if(commandName == "heatmap.sim") { pipecommand = new HeatMapSimCommand(optionString); }
461 else if(commandName == "filter.seqs") { pipecommand = new FilterSeqsCommand(optionString); }
462 else if(commandName == "venn") { pipecommand = new VennCommand(optionString); }
463 else if(commandName == "bin.seqs") { pipecommand = new BinSeqCommand(optionString); }
464 else if(commandName == "get.oturep") { pipecommand = new GetOTURepCommand(optionString); }
465 else if(commandName == "tree.shared") { pipecommand = new TreeGroupCommand(optionString); }
466 else if(commandName == "dist.shared") { pipecommand = new MatrixOutputCommand(optionString); }
467 else if(commandName == "bootstrap.shared") { pipecommand = new BootSharedCommand(optionString); }
468 else if(commandName == "consensus") { pipecommand = new ConcensusCommand(optionString); }
469 else if(commandName == "dist.seqs") { pipecommand = new DistanceCommand(optionString); }
470 else if(commandName == "align.seqs") { pipecommand = new AlignCommand(optionString); }
471 else if(commandName == "summary.seqs") { pipecommand = new SeqSummaryCommand(optionString); }
472 else if(commandName == "screen.seqs") { pipecommand = new ScreenSeqsCommand(optionString); }
473 else if(commandName == "reverse.seqs") { pipecommand = new ReverseSeqsCommand(optionString); }
474 else if(commandName == "trim.seqs") { pipecommand = new TrimSeqsCommand(optionString); }
475 else if(commandName == "trim.flows") { pipecommand = new TrimFlowsCommand(optionString); }
476 else if(commandName == "shhh.seqs") { pipecommand = new ShhherCommand(optionString); }
477 else if(commandName == "list.seqs") { pipecommand = new ListSeqsCommand(optionString); }
478 else if(commandName == "get.seqs") { pipecommand = new GetSeqsCommand(optionString); }
479 else if(commandName == "remove.seqs") { pipecommand = new RemoveSeqsCommand(optionString); }
480 else if(commandName == "merge.files") { pipecommand = new MergeFileCommand(optionString); }
481 else if(commandName == "system") { pipecommand = new SystemCommand(optionString); }
482 else if(commandName == "align.check") { pipecommand = new AlignCheckCommand(optionString); }
483 else if(commandName == "get.sharedseqs") { pipecommand = new GetSharedOTUCommand(optionString); }
484 else if(commandName == "get.otulist") { pipecommand = new GetListCountCommand(optionString); }
485 else if(commandName == "hcluster") { pipecommand = new HClusterCommand(optionString); }
486 else if(commandName == "classify.seqs") { pipecommand = new ClassifySeqsCommand(optionString); }
487 else if(commandName == "chimera.ccode") { pipecommand = new ChimeraCcodeCommand(optionString); }
488 else if(commandName == "chimera.check") { pipecommand = new ChimeraCheckCommand(optionString); }
489 else if(commandName == "chimera.slayer") { pipecommand = new ChimeraSlayerCommand(optionString); }
490 else if(commandName == "chimera.pintail") { pipecommand = new ChimeraPintailCommand(optionString); }
491 else if(commandName == "chimera.bellerophon") { pipecommand = new ChimeraBellerophonCommand(optionString); }
492 else if(commandName == "phylotype") { pipecommand = new PhylotypeCommand(optionString); }
493 else if(commandName == "mgcluster") { pipecommand = new MGClusterCommand(optionString); }
494 else if(commandName == "pre.cluster") { pipecommand = new PreClusterCommand(optionString); }
495 else if(commandName == "pcoa") { pipecommand = new PCOACommand(optionString); }
496 else if(commandName == "pca") { pipecommand = new PCACommand(optionString); }
497 else if(commandName == "nmds") { pipecommand = new NMDSCommand(optionString); }
498 else if(commandName == "otu.hierarchy") { pipecommand = new OtuHierarchyCommand(optionString); }
499 else if(commandName == "set.dir") { pipecommand = new SetDirectoryCommand(optionString); }
500 else if(commandName == "set.logfile") { pipecommand = new SetLogFileCommand(optionString); }
501 else if(commandName == "parse.list") { pipecommand = new ParseListCommand(optionString); }
502 else if(commandName == "phylo.diversity") { pipecommand = new PhyloDiversityCommand(optionString); }
503 else if(commandName == "make.group") { pipecommand = new MakeGroupCommand(optionString); }
504 else if(commandName == "chop.seqs") { pipecommand = new ChopSeqsCommand(optionString); }
505 else if(commandName == "clearcut") { pipecommand = new ClearcutCommand(optionString); }
506 else if(commandName == "catchall") { pipecommand = new CatchAllCommand(optionString); }
507 else if(commandName == "split.abund") { pipecommand = new SplitAbundCommand(optionString); }
508 else if(commandName == "cluster.split") { pipecommand = new ClusterSplitCommand(optionString); }
509 else if(commandName == "classify.otu") { pipecommand = new ClassifyOtuCommand(optionString); }
510 else if(commandName == "degap.seqs") { pipecommand = new DegapSeqsCommand(optionString); }
511 else if(commandName == "get.relabund") { pipecommand = new GetRelAbundCommand(optionString); }
512 else if(commandName == "sens.spec") { pipecommand = new SensSpecCommand(optionString); }
513 else if(commandName == "seq.error") { pipecommand = new SeqErrorCommand(optionString); }
514 else if(commandName == "sffinfo") { pipecommand = new SffInfoCommand(optionString); }
515 else if(commandName == "normalize.shared") { pipecommand = new NormalizeSharedCommand(optionString); }
516 else if(commandName == "metastats") { pipecommand = new MetaStatsCommand(optionString); }
517 else if(commandName == "split.groups") { pipecommand = new SplitGroupCommand(optionString); }
518 else if(commandName == "cluster.fragments") { pipecommand = new ClusterFragmentsCommand(optionString); }
519 else if(commandName == "get.lineage") { pipecommand = new GetLineageCommand(optionString); }
520 else if(commandName == "get.groups") { pipecommand = new GetGroupsCommand(optionString); }
521 else if(commandName == "remove.lineage") { pipecommand = new RemoveLineageCommand(optionString); }
522 else if(commandName == "remove.groups") { pipecommand = new RemoveGroupsCommand(optionString); }
523 else if(commandName == "get.otus") { pipecommand = new GetOtusCommand(optionString); }
524 else if(commandName == "remove.otus") { pipecommand = new RemoveOtusCommand(optionString); }
525 else if(commandName == "fastq.info") { pipecommand = new ParseFastaQCommand(optionString); }
526 else if(commandName == "deunique.seqs") { pipecommand = new DeUniqueSeqsCommand(optionString); }
527 else if(commandName == "pairwise.seqs") { pipecommand = new PairwiseSeqsCommand(optionString); }
528 else if(commandName == "cluster.classic") { pipecommand = new ClusterDoturCommand(optionString); }
529 else if(commandName == "sub.sample") { pipecommand = new SubSampleCommand(optionString); }
530 else if(commandName == "indicator") { pipecommand = new IndicatorCommand(optionString); }
531 else if(commandName == "consensus.seqs") { pipecommand = new ConsensusSeqsCommand(optionString); }
532 else if(commandName == "corr.axes") { pipecommand = new CorrAxesCommand(optionString); }
533 else if(commandName == "remove.rare") { pipecommand = new RemoveRareCommand(optionString); }
534 else if(commandName == "merge.groups") { pipecommand = new MergeGroupsCommand(optionString); }
535 else if(commandName == "amova") { pipecommand = new AmovaCommand(optionString); }
536 else if(commandName == "homova") { pipecommand = new HomovaCommand(optionString); }
537 else if(commandName == "mantel") { pipecommand = new MantelCommand(optionString); }
538 else if(commandName == "anosim") { pipecommand = new AnosimCommand(optionString); }
539 else if(commandName == "make.fastq") { pipecommand = new MakeFastQCommand(optionString); }
540 else if(commandName == "get.current") { pipecommand = new GetCurrentCommand(optionString); }
541 else if(commandName == "set.current") { pipecommand = new SetCurrentCommand(optionString); }
542 else if(commandName == "make.shared") { pipecommand = new SharedCommand(optionString); }
543 else if(commandName == "get.commandinfo") { pipecommand = new GetCommandInfoCommand(optionString); }
544 else { pipecommand = new NoCommand(optionString); }
548 catch(exception& e) {
549 m->errorOut(e, "CommandFactory", "getCommand");
553 /***********************************************************/
555 /***********************************************************/
556 //This function calls the appropriate command fucntions based on user input, this is used by the pipeline command to check a users piepline for errors before running
557 Command* CommandFactory::getCommand(string commandName){
559 delete shellcommand; //delete the old command
561 if(commandName == "read.dist") { shellcommand = new ReadDistCommand(); }
562 else if(commandName == "read.otu") { shellcommand = new ReadOtuCommand(); }
563 else if(commandName == "read.tree") { shellcommand = new ReadTreeCommand(); }
564 else if(commandName == "cluster") { shellcommand = new ClusterCommand(); }
565 else if(commandName == "unique.seqs") { shellcommand = new DeconvoluteCommand(); }
566 else if(commandName == "parsimony") { shellcommand = new ParsimonyCommand(); }
567 else if(commandName == "help") { shellcommand = new HelpCommand(); }
568 else if(commandName == "quit") { shellcommand = new QuitCommand(); }
569 else if(commandName == "collect.single") { shellcommand = new CollectCommand(); }
570 else if(commandName == "collect.shared") { shellcommand = new CollectSharedCommand(); }
571 else if(commandName == "rarefaction.single") { shellcommand = new RareFactCommand(); }
572 else if(commandName == "rarefaction.shared") { shellcommand = new RareFactSharedCommand(); }
573 else if(commandName == "summary.single") { shellcommand = new SummaryCommand(); }
574 else if(commandName == "summary.shared") { shellcommand = new SummarySharedCommand(); }
575 else if(commandName == "unifrac.weighted") { shellcommand = new UnifracWeightedCommand(); }
576 else if(commandName == "unifrac.unweighted") { shellcommand = new UnifracUnweightedCommand(); }
577 else if(commandName == "get.group") { shellcommand = new GetgroupCommand(); }
578 else if(commandName == "get.label") { shellcommand = new GetlabelCommand(); }
579 else if(commandName == "get.sabund") { shellcommand = new GetSAbundCommand(); }
580 else if(commandName == "get.rabund") { shellcommand = new GetRAbundCommand(); }
581 else if(commandName == "libshuff") { shellcommand = new LibShuffCommand(); }
582 else if(commandName == "heatmap.bin") { shellcommand = new HeatMapCommand(); }
583 else if(commandName == "heatmap.sim") { shellcommand = new HeatMapSimCommand(); }
584 else if(commandName == "filter.seqs") { shellcommand = new FilterSeqsCommand(); }
585 else if(commandName == "venn") { shellcommand = new VennCommand(); }
586 else if(commandName == "bin.seqs") { shellcommand = new BinSeqCommand(); }
587 else if(commandName == "get.oturep") { shellcommand = new GetOTURepCommand(); }
588 else if(commandName == "tree.shared") { shellcommand = new TreeGroupCommand(); }
589 else if(commandName == "dist.shared") { shellcommand = new MatrixOutputCommand(); }
590 else if(commandName == "bootstrap.shared") { shellcommand = new BootSharedCommand(); }
591 else if(commandName == "consensus") { shellcommand = new ConcensusCommand(); }
592 else if(commandName == "dist.seqs") { shellcommand = new DistanceCommand(); }
593 else if(commandName == "align.seqs") { shellcommand = new AlignCommand(); }
594 else if(commandName == "summary.seqs") { shellcommand = new SeqSummaryCommand(); }
595 else if(commandName == "screen.seqs") { shellcommand = new ScreenSeqsCommand(); }
596 else if(commandName == "reverse.seqs") { shellcommand = new ReverseSeqsCommand(); }
597 else if(commandName == "trim.seqs") { shellcommand = new TrimSeqsCommand(); }
598 else if(commandName == "trim.flows") { shellcommand = new TrimFlowsCommand(); }
599 else if(commandName == "shhh.seqs") { shellcommand = new ShhherCommand(); }
600 else if(commandName == "list.seqs") { shellcommand = new ListSeqsCommand(); }
601 else if(commandName == "get.seqs") { shellcommand = new GetSeqsCommand(); }
602 else if(commandName == "remove.seqs") { shellcommand = new RemoveSeqsCommand(); }
603 else if(commandName == "merge.files") { shellcommand = new MergeFileCommand(); }
604 else if(commandName == "system") { shellcommand = new SystemCommand(); }
605 else if(commandName == "align.check") { shellcommand = new AlignCheckCommand(); }
606 else if(commandName == "get.sharedseqs") { shellcommand = new GetSharedOTUCommand(); }
607 else if(commandName == "get.otulist") { shellcommand = new GetListCountCommand(); }
608 else if(commandName == "hcluster") { shellcommand = new HClusterCommand(); }
609 else if(commandName == "classify.seqs") { shellcommand = new ClassifySeqsCommand(); }
610 else if(commandName == "chimera.ccode") { shellcommand = new ChimeraCcodeCommand(); }
611 else if(commandName == "chimera.check") { shellcommand = new ChimeraCheckCommand(); }
612 else if(commandName == "chimera.slayer") { shellcommand = new ChimeraSlayerCommand(); }
613 else if(commandName == "chimera.pintail") { shellcommand = new ChimeraPintailCommand(); }
614 else if(commandName == "chimera.bellerophon") { shellcommand = new ChimeraBellerophonCommand(); }
615 else if(commandName == "phylotype") { shellcommand = new PhylotypeCommand(); }
616 else if(commandName == "mgcluster") { shellcommand = new MGClusterCommand(); }
617 else if(commandName == "pre.cluster") { shellcommand = new PreClusterCommand(); }
618 else if(commandName == "pcoa") { shellcommand = new PCOACommand(); }
619 else if(commandName == "pca") { shellcommand = new PCACommand(); }
620 else if(commandName == "nmds") { shellcommand = new NMDSCommand(); }
621 else if(commandName == "otu.hierarchy") { shellcommand = new OtuHierarchyCommand(); }
622 else if(commandName == "set.dir") { shellcommand = new SetDirectoryCommand(); }
623 else if(commandName == "set.logfile") { shellcommand = new SetLogFileCommand(); }
624 else if(commandName == "parse.list") { shellcommand = new ParseListCommand(); }
625 else if(commandName == "phylo.diversity") { shellcommand = new PhyloDiversityCommand(); }
626 else if(commandName == "make.group") { shellcommand = new MakeGroupCommand(); }
627 else if(commandName == "chop.seqs") { shellcommand = new ChopSeqsCommand(); }
628 else if(commandName == "clearcut") { shellcommand = new ClearcutCommand(); }
629 else if(commandName == "catchall") { shellcommand = new CatchAllCommand(); }
630 else if(commandName == "split.abund") { shellcommand = new SplitAbundCommand(); }
631 else if(commandName == "cluster.split") { shellcommand = new ClusterSplitCommand(); }
632 else if(commandName == "classify.otu") { shellcommand = new ClassifyOtuCommand(); }
633 else if(commandName == "degap.seqs") { shellcommand = new DegapSeqsCommand(); }
634 else if(commandName == "get.relabund") { shellcommand = new GetRelAbundCommand(); }
635 else if(commandName == "sens.spec") { shellcommand = new SensSpecCommand(); }
636 else if(commandName == "seq.error") { shellcommand = new SeqErrorCommand(); }
637 else if(commandName == "sffinfo") { shellcommand = new SffInfoCommand(); }
638 else if(commandName == "normalize.shared") { shellcommand = new NormalizeSharedCommand(); }
639 else if(commandName == "metastats") { shellcommand = new MetaStatsCommand(); }
640 else if(commandName == "split.groups") { shellcommand = new SplitGroupCommand(); }
641 else if(commandName == "cluster.fragments") { shellcommand = new ClusterFragmentsCommand(); }
642 else if(commandName == "get.lineage") { shellcommand = new GetLineageCommand(); }
643 else if(commandName == "remove.lineage") { shellcommand = new RemoveLineageCommand(); }
644 else if(commandName == "get.groups") { shellcommand = new GetGroupsCommand(); }
645 else if(commandName == "remove.groups") { shellcommand = new RemoveGroupsCommand(); }
646 else if(commandName == "get.otus") { shellcommand = new GetOtusCommand(); }
647 else if(commandName == "remove.otus") { shellcommand = new RemoveOtusCommand(); }
648 else if(commandName == "fastq.info") { shellcommand = new ParseFastaQCommand(); }
649 else if(commandName == "deunique.seqs") { shellcommand = new DeUniqueSeqsCommand(); }
650 else if(commandName == "pairwise.seqs") { shellcommand = new PairwiseSeqsCommand(); }
651 else if(commandName == "cluster.classic") { shellcommand = new ClusterDoturCommand(); }
652 else if(commandName == "sub.sample") { shellcommand = new SubSampleCommand(); }
653 else if(commandName == "indicator") { shellcommand = new IndicatorCommand(); }
654 else if(commandName == "consensus.seqs") { shellcommand = new ConsensusSeqsCommand(); }
655 else if(commandName == "corr.axes") { shellcommand = new CorrAxesCommand(); }
656 else if(commandName == "remove.rare") { shellcommand = new RemoveRareCommand(); }
657 else if(commandName == "merge.groups") { shellcommand = new MergeGroupsCommand(); }
658 else if(commandName == "amova") { shellcommand = new AmovaCommand(); }
659 else if(commandName == "homova") { shellcommand = new HomovaCommand(); }
660 else if(commandName == "mantel") { shellcommand = new MantelCommand(); }
661 else if(commandName == "anosim") { shellcommand = new AnosimCommand(); }
662 else if(commandName == "make.fastq") { shellcommand = new MakeFastQCommand(); }
663 else if(commandName == "get.current") { shellcommand = new GetCurrentCommand(); }
664 else if(commandName == "set.current") { shellcommand = new SetCurrentCommand(); }
665 else if(commandName == "make.shared") { shellcommand = new SharedCommand(); }
666 else if(commandName == "get.commandinfo") { shellcommand = new GetCommandInfoCommand(); }
667 else { shellcommand = new NoCommand(); }
671 catch(exception& e) {
672 m->errorOut(e, "CommandFactory", "getCommand");
676 /***********************************************************
677 //This function is used to interrupt a command
678 Command* CommandFactory::getCommand(){
680 delete command; //delete the old command
683 command = new NoCommand(s);
687 catch(exception& e) {
688 m->errorOut(e, "CommandFactory", "getCommand");
692 /***********************************************************************/
693 bool CommandFactory::isValidCommand(string command) {
696 //is the command in the map
697 if ((commands.find(command)) != (commands.end())) {
700 m->mothurOut(command + " is not a valid command in Mothur. Valid commands are ");
701 for (it = commands.begin(); it != commands.end(); it++) {
702 m->mothurOut(it->first + ", ");
704 m->mothurOutEndLine();
709 catch(exception& e) {
710 m->errorOut(e, "CommandFactory", "isValidCommand");
714 /***********************************************************************/
715 bool CommandFactory::isValidCommand(string command, string noError) {
718 //is the command in the map
719 if ((commands.find(command)) != (commands.end())) {
726 catch(exception& e) {
727 m->errorOut(e, "CommandFactory", "isValidCommand");
731 /***********************************************************************/
732 void CommandFactory::printCommands(ostream& out) {
734 out << "Valid commands are: ";
735 for (it = commands.begin(); it != commands.end(); it++) {
736 out << it->first << ",";
740 catch(exception& e) {
741 m->errorOut(e, "CommandFactory", "printCommands");
745 /***********************************************************************/