]> git.donarmstrong.com Git - mothur.git/blob - commandfactory.cpp
Added summary.qual command. Added fontsize parameter to heatmap.sim and venn commands
[mothur.git] / commandfactory.cpp
1 /*
2  *  commandfactory.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 10/25/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
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 "chimerauchimecommand.h"
73 #include "setlogfilecommand.h"
74 #include "phylodiversitycommand.h"
75 #include "makegroupcommand.h"
76 #include "chopseqscommand.h"
77 #include "clearcutcommand.h"
78 #include "catchallcommand.h"
79 #include "splitabundcommand.h"
80 #include "clustersplitcommand.h"
81 #include "classifyotucommand.h"
82 #include "degapseqscommand.h"
83 #include "getrelabundcommand.h"
84 #include "sensspeccommand.h"
85 #include "sffinfocommand.h"
86 #include "seqerrorcommand.h"
87 #include "normalizesharedcommand.h"
88 #include "metastatscommand.h"
89 #include "splitgroupscommand.h"
90 #include "clusterfragmentscommand.h"
91 #include "getlineagecommand.h"
92 #include "removelineagecommand.h"
93 #include "parsefastaqcommand.h"
94 #include "pipelinepdscommand.h"
95 #include "deuniqueseqscommand.h"
96 #include "pairwiseseqscommand.h"
97 #include "clusterdoturcommand.h"
98 #include "subsamplecommand.h"
99 #include "removegroupscommand.h"
100 #include "getgroupscommand.h"
101 #include "getotuscommand.h"
102 #include "removeotuscommand.h"
103 #include "indicatorcommand.h"
104 #include "consensusseqscommand.h"
105 #include "trimflowscommand.h"
106 #include "corraxescommand.h"
107 #include "shhhercommand.h"
108 #include "pcacommand.h"
109 #include "nmdscommand.h"
110 #include "removerarecommand.h"
111 #include "mergegroupscommand.h"
112 #include "amovacommand.h"
113 #include "homovacommand.h"
114 #include "mantelcommand.h"
115 #include "makefastqcommand.h"
116 #include "anosimcommand.h"
117 #include "getcurrentcommand.h"
118 #include "setcurrentcommand.h"
119 #include "sharedcommand.h"
120 #include "getcommandinfocommand.h"
121 #include "deuniquetreecommand.h"
122 #include "countseqscommand.h"
123 #include "countgroupscommand.h"
124 #include "clearmemorycommand.h"
125 #include "summarytaxcommand.h"
126 #include "chimeraperseuscommand.h"
127 #include "shhhseqscommand.h"
128 #include "summaryqualcommand.h"
129
130 /*******************************************************/
131
132 /******************************************************/
133 CommandFactory* CommandFactory::getInstance() {
134         if( _uniqueInstance == 0) {
135                 _uniqueInstance = new CommandFactory();
136         }
137         return _uniqueInstance;
138 }
139 /***********************************************************/
140
141 /***********************************************************/
142 //note: This class is resposible for knowing which commands are mpiEnabled,
143 //If a command is not enabled only process 0 will execute the command. 
144 //This avoids redundant outputs on pieces of code we have not paralellized. 
145 //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. 
146 //example:  commands["dist.seqs"] = "MPIEnabled";
147
148 CommandFactory::CommandFactory(){
149         string s = "";
150         m = MothurOut::getInstance();
151         
152         command = new NoCommand(s);
153         shellcommand = new NoCommand(s);
154         pipecommand = new NoCommand(s);
155         
156         outputDir = ""; inputDir = "";
157         logFileName = "";
158         append = false;
159         
160         //initialize list of valid commands
161         commands["read.dist"]                   = "read.dist"; 
162         commands["read.otu"]                    = "read.otu";
163         commands["read.tree"]                   = "read.tree"; 
164         commands["make.shared"]                 = "make.shared"; 
165         commands["bin.seqs"]                    = "bin.seqs"; 
166         commands["get.oturep"]                  = "get.oturep";
167         commands["cluster"]                             = "cluster"; 
168         commands["unique.seqs"]                 = "unique.seqs"; 
169         commands["dist.shared"]                 = "dist.shared";
170         commands["collect.single"]              = "collect.single"; 
171         commands["collect.shared"]              = "collect.shared"; 
172         commands["rarefaction.single"]  = "rarefaction.single"; 
173         commands["rarefaction.shared"]  = "rarefaction.shared"; 
174         commands["summary.single"]              = "summary.single"; 
175         commands["summary.shared"]              = "summary.shared"; 
176         commands["parsimony"]                   = "parsimony";
177         commands["unifrac.weighted"]    = "unifrac.weighted"; 
178         commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
179         commands["libshuff"]                    = "libshuff";
180         commands["tree.shared"]                 = "tree.shared";
181         commands["heatmap.bin"]                 = "heatmap.bin";
182         commands["heatmap.sim"]                 = "heatmap.sim";
183         commands["venn"]                                = "venn";
184         commands["get.group"]           = "get.group";
185         commands["get.label"]           = "get.label";
186         commands["get.sabund"]          = "get.sabund";
187         commands["get.rabund"]          = "get.rabund";
188         commands["bootstrap.shared"]    = "bootstrap.shared";
189         //commands["consensus"]                 = "consensus";
190         commands["help"]                                = "help";
191         commands["reverse.seqs"]                = "reverse.seqs";
192         commands["trim.seqs"]                   = "trim.seqs";
193         commands["trim.flows"]                  = "trim.flows";
194         commands["list.seqs"]                   = "list.seqs";
195         commands["get.seqs"]                    = "get.seqs";
196         commands["remove.seqs"]                 = "remove.seqs";
197         commands["system"]                              = "system";
198         commands["align.check"]                 = "align.check";
199         commands["get.sharedseqs"]              = "get.sharedseqs";
200         commands["get.otulist"]                 = "get.otulist";
201         commands["hcluster"]                    = "hcluster"; 
202         commands["phylotype"]                   = "phylotype";
203         commands["mgcluster"]                   = "mgcluster";
204         commands["pre.cluster"]                 = "pre.cluster";
205         commands["pcoa"]                                = "pcoa";
206         commands["otu.hierarchy"]               = "otu.hierarchy";
207         commands["set.dir"]                             = "MPIEnabled";
208         commands["merge.files"]                 = "merge.files";
209         commands["parse.list"]                  = "parse.list";
210         commands["set.logfile"]                 = "set.logfile";
211         commands["phylo.diversity"]             = "phylo.diversity";
212         commands["make.group"]                  = "make.group";
213         commands["chop.seqs"]                   = "chop.seqs";
214         commands["clearcut"]                    = "clearcut";
215         commands["catchall"]                    = "catchall";
216         commands["split.abund"]                 = "split.abund";
217         commands["classify.otu"]                = "classify.otu";
218         commands["degap.seqs"]                  = "degap.seqs";
219         commands["get.relabund"]                = "get.relabund";
220         commands["sffinfo"]                             = "sffinfo";
221         commands["normalize.shared"]    = "normalize.shared";
222         commands["metastats"]                   = "metastats";
223         commands["split.groups"]                = "split.groups";
224         commands["cluster.fragments"]   = "cluster.fragments";
225         commands["get.lineage"]                 = "get.lineage";
226         commands["remove.lineage"]              = "remove.lineage";
227         commands["fastq.info"]                  = "fastq.info";
228         commands["deunique.seqs"]               = "deunique.seqs";
229         commands["cluster.classic"]             = "cluster.classic";
230         commands["sub.sample"]                  = "sub.sample";
231         commands["remove.groups"]               = "remove.groups";
232         commands["get.groups"]                  = "get.groups";
233         commands["get.otus"]                    = "get.otus";
234         commands["remove.otus"]                 = "remove.otus";
235         commands["indicator"]                   = "indicator";
236         commands["consensus.seqs"]              = "consensus.seqs";
237         commands["corr.axes"]                   = "corr.axes";
238         commands["pca"]                                 = "pca";
239         commands["nmds"]                                = "nmds";
240         commands["remove.rare"]                 = "remove.rare";
241         commands["amova"]                               = "amova";
242         commands["homova"]                              = "homova";
243         commands["mantel"]                              = "mantel";
244         commands["anosim"]                              = "anosim";
245         commands["make.fastq"]                  = "make.fastq";
246         commands["merge.groups"]                = "merge.groups";
247         commands["get.current"]                 = "MPIEnabled";
248         commands["set.current"]                 = "MPIEnabled";
249         commands["get.commandinfo"]             = "get.commandinfo";
250         commands["deunique.tree"]               = "deunique.tree";
251         commands["count.seqs"]                  = "count.seqs";
252         commands["count.groups"]                = "count.groups";
253         commands["clear.memory"]                = "clear.memory";
254         commands["pairwise.seqs"]               = "MPIEnabled";
255         commands["pipeline.pds"]                = "MPIEnabled";
256         commands["classify.seqs"]               = "MPIEnabled"; 
257         commands["dist.seqs"]                   = "MPIEnabled";
258         commands["filter.seqs"]                 = "MPIEnabled";
259         commands["align.seqs"]                  = "MPIEnabled";
260         commands["chimera.ccode"]               = "MPIEnabled";
261         commands["chimera.check"]               = "MPIEnabled";
262         commands["chimera.slayer"]              = "MPIEnabled";
263         commands["chimera.uchime"]              = "chimera.uchime";
264         commands["chimera.perseus"]             = "chimera.perseus";
265         commands["chimera.pintail"]             = "MPIEnabled";
266         commands["chimera.bellerophon"] = "MPIEnabled";
267         commands["screen.seqs"]                 = "MPIEnabled";
268         commands["summary.seqs"]                = "MPIEnabled";
269         commands["cluster.split"]               = "MPIEnabled";
270         commands["shhh.flows"]                  = "MPIEnabled";
271         commands["sens.spec"]                   = "sens.spec";
272         commands["seq.error"]                   = "seq.error";
273         commands["summary.tax"]                 = "summary.tax";
274         commands["summary.qual"]                = "summary.qual";
275         commands["shhh.seqs"]                   = "shhh.seqs";
276         commands["quit"]                                = "MPIEnabled"; 
277
278 }
279 /***********************************************************/
280
281 /***********************************************************/
282 bool CommandFactory::MPIEnabled(string commandName) {
283         bool mpi = false;
284         it = commands.find(commandName);
285         if (it != commands.end()) { 
286                 if (it->second == "MPIEnabled") { return true; }
287         }
288         return mpi;
289 }
290 /***********************************************************/
291
292 /***********************************************************/
293 CommandFactory::~CommandFactory(){
294         _uniqueInstance = 0;
295         delete command;
296         delete shellcommand;
297         delete pipecommand;
298 }
299
300 /***********************************************************/
301
302 /***********************************************************/
303 //This function calls the appropriate command fucntions based on user input.
304 Command* CommandFactory::getCommand(string commandName, string optionString){
305         try {
306                 delete command;   //delete the old command
307                 
308                 //user has opted to redirect output from dir where input files are located to some other place
309                 if (outputDir != "") { 
310                         if (optionString != "") { optionString += ", outputdir=" + outputDir; }
311                         else { optionString += "outputdir=" + outputDir; }
312                 }
313                 
314                 //user has opted to redirect input from dir where mothur.exe is located to some other place
315                 if (inputDir != "") { 
316                         if (optionString != "") { optionString += ", inputdir=" + inputDir; }
317                         else { optionString += "inputdir=" + inputDir; }
318                 }
319                 
320                 if(commandName == "read.dist")                                  {       command = new ReadDistCommand(optionString);                            }
321                 else if(commandName == "read.otu")                              {       command = new ReadOtuCommand(optionString);                                     }
322                 else if(commandName == "read.tree")                             {       command = new ReadTreeCommand(optionString);                            }
323                 else if(commandName == "cluster")                               {       command = new ClusterCommand(optionString);                                     }
324                 else if(commandName == "unique.seqs")                   {       command = new DeconvoluteCommand(optionString);                         }
325                 else if(commandName == "parsimony")                             {       command = new ParsimonyCommand(optionString);                           }
326                 else if(commandName == "help")                                  {       command = new HelpCommand(optionString);                                        }
327                 else if(commandName == "quit")                                  {       command = new QuitCommand(optionString);                                        }
328                 else if(commandName == "collect.single")                {       command = new CollectCommand(optionString);                                     }
329                 else if(commandName == "collect.shared")                {       command = new CollectSharedCommand(optionString);                       }
330                 else if(commandName == "rarefaction.single")    {       command = new RareFactCommand(optionString);                            }
331                 else if(commandName == "rarefaction.shared")    {       command = new RareFactSharedCommand(optionString);                      }
332                 else if(commandName == "summary.single")                {       command = new SummaryCommand(optionString);                                     }
333                 else if(commandName == "summary.shared")                {       command = new SummarySharedCommand(optionString);                       }
334                 else if(commandName == "unifrac.weighted")              {       command = new UnifracWeightedCommand(optionString);                     }
335                 else if(commandName == "unifrac.unweighted")    {       command = new UnifracUnweightedCommand(optionString);           }
336                 else if(commandName == "get.group")             {   command = new GetgroupCommand(optionString);                                }
337                 else if(commandName == "get.label")             {   command = new GetlabelCommand(optionString);                                }
338                 else if(commandName == "get.sabund")            {   command = new GetSAbundCommand(optionString);                               }
339                 else if(commandName == "get.rabund")            {   command = new GetRAbundCommand(optionString);                               }
340                 else if(commandName == "libshuff")              {   command = new LibShuffCommand(optionString);                                }
341                 else if(commandName == "heatmap.bin")                   {   command = new HeatMapCommand(optionString);                                 }
342                 else if(commandName == "heatmap.sim")                   {   command = new HeatMapSimCommand(optionString);                              }
343                 else if(commandName == "filter.seqs")                   {   command = new FilterSeqsCommand(optionString);                              }
344                 else if(commandName == "venn")                                  {   command = new VennCommand(optionString);                                    }
345                 else if(commandName == "bin.seqs")                              {   command = new BinSeqCommand(optionString);                                  }
346                 else if(commandName == "get.oturep")                    {   command = new GetOTURepCommand(optionString);                               }
347                 else if(commandName == "tree.shared")                   {   command = new TreeGroupCommand(optionString);                               }
348                 else if(commandName == "dist.shared")                   {   command = new MatrixOutputCommand(optionString);                    }
349                 else if(commandName == "bootstrap.shared")              {   command = new BootSharedCommand(optionString);                              }
350                 else if(commandName == "consensus")                             {   command = new ConcensusCommand(optionString);                               }
351                 else if(commandName == "dist.seqs")                             {   command = new DistanceCommand(optionString);                                }
352                 else if(commandName == "align.seqs")                    {   command = new AlignCommand(optionString);                                   }
353                 else if(commandName == "summary.seqs")                  {       command = new SeqSummaryCommand(optionString);                          }
354                 else if(commandName == "screen.seqs")                   {       command = new ScreenSeqsCommand(optionString);                          }
355                 else if(commandName == "reverse.seqs")                  {       command = new ReverseSeqsCommand(optionString);                         }
356                 else if(commandName == "trim.seqs")                             {       command = new TrimSeqsCommand(optionString);                            }
357                 else if(commandName == "trim.flows")                    {       command = new TrimFlowsCommand(optionString);                           }
358                 else if(commandName == "shhh.flows")                    {       command = new ShhherCommand(optionString);                                      }
359                 else if(commandName == "list.seqs")                             {       command = new ListSeqsCommand(optionString);                            }
360                 else if(commandName == "get.seqs")                              {       command = new GetSeqsCommand(optionString);                                     }
361                 else if(commandName == "remove.seqs")                   {       command = new RemoveSeqsCommand(optionString);                          }
362                 else if(commandName == "merge.files")                   {       command = new MergeFileCommand(optionString);                           }
363                 else if(commandName == "system")                                {       command = new SystemCommand(optionString);                                      }
364                 else if(commandName == "align.check")                   {       command = new AlignCheckCommand(optionString);                          }
365                 else if(commandName == "get.sharedseqs")                {       command = new GetSharedOTUCommand(optionString);                        }
366                 else if(commandName == "get.otulist")                   {       command = new GetListCountCommand(optionString);                        }
367                 else if(commandName == "hcluster")                              {       command = new HClusterCommand(optionString);                            }
368                 else if(commandName == "classify.seqs")                 {       command = new ClassifySeqsCommand(optionString);                        }
369                 else if(commandName == "chimera.ccode")                 {       command = new ChimeraCcodeCommand(optionString);                        }
370                 else if(commandName == "chimera.check")                 {       command = new ChimeraCheckCommand(optionString);                        }
371                 else if(commandName == "chimera.slayer")                {       command = new ChimeraSlayerCommand(optionString);                       }
372                 else if(commandName == "chimera.uchime")                {       command = new ChimeraUchimeCommand(optionString);                       }
373                 else if(commandName == "chimera.pintail")               {       command = new ChimeraPintailCommand(optionString);                      }
374                 else if(commandName == "chimera.bellerophon")   {       command = new ChimeraBellerophonCommand(optionString);          }
375                 else if(commandName == "phylotype")                             {       command = new PhylotypeCommand(optionString);                           }
376                 else if(commandName == "mgcluster")                             {       command = new MGClusterCommand(optionString);                           }
377                 else if(commandName == "pre.cluster")                   {       command = new PreClusterCommand(optionString);                          }
378                 else if(commandName == "pcoa")                                  {       command = new PCOACommand(optionString);                                        }
379                 else if(commandName == "pca")                                   {       command = new PCACommand(optionString);                                         }
380                 else if(commandName == "nmds")                                  {       command = new NMDSCommand(optionString);                                        }
381                 else if(commandName == "otu.hierarchy")                 {       command = new OtuHierarchyCommand(optionString);                        }
382                 else if(commandName == "set.dir")                               {       command = new SetDirectoryCommand(optionString);                        }
383                 else if(commandName == "set.logfile")                   {       command = new SetLogFileCommand(optionString);                          }
384                 else if(commandName == "parse.list")                    {       command = new ParseListCommand(optionString);                           }
385                 else if(commandName == "phylo.diversity")               {       command = new PhyloDiversityCommand(optionString);                      }
386                 else if(commandName == "make.group")                    {       command = new MakeGroupCommand(optionString);                           }
387                 else if(commandName == "chop.seqs")                             {       command = new ChopSeqsCommand(optionString);                            }
388                 else if(commandName == "clearcut")                              {       command = new ClearcutCommand(optionString);                            }
389                 else if(commandName == "catchall")                              {       command = new CatchAllCommand(optionString);                            }
390                 else if(commandName == "split.abund")                   {       command = new SplitAbundCommand(optionString);                          }
391                 else if(commandName == "cluster.split")                 {       command = new ClusterSplitCommand(optionString);                        }
392                 else if(commandName == "classify.otu")                  {       command = new ClassifyOtuCommand(optionString);                         }
393                 else if(commandName == "degap.seqs")                    {       command = new DegapSeqsCommand(optionString);                           }
394                 else if(commandName == "get.relabund")                  {       command = new GetRelAbundCommand(optionString);                         }
395                 else if(commandName == "sens.spec")                             {       command = new SensSpecCommand(optionString);                            }
396                 else if(commandName == "seq.error")                             {       command = new SeqErrorCommand(optionString);                            }
397                 else if(commandName == "sffinfo")                               {       command = new SffInfoCommand(optionString);                                     }
398                 else if(commandName == "normalize.shared")              {       command = new NormalizeSharedCommand(optionString);                     }
399                 else if(commandName == "metastats")                             {       command = new MetaStatsCommand(optionString);                           }
400                 else if(commandName == "split.groups")                  {       command = new SplitGroupCommand(optionString);                          }
401                 else if(commandName == "cluster.fragments")             {       command = new ClusterFragmentsCommand(optionString);            }
402                 else if(commandName == "get.lineage")                   {       command = new GetLineageCommand(optionString);                          }
403                 else if(commandName == "remove.lineage")                {       command = new RemoveLineageCommand(optionString);                       }
404                 else if(commandName == "get.groups")                    {       command = new GetGroupsCommand(optionString);                           }
405                 else if(commandName == "remove.groups")                 {       command = new RemoveGroupsCommand(optionString);                        }
406                 else if(commandName == "get.otus")                              {       command = new GetOtusCommand(optionString);                                     }
407                 else if(commandName == "remove.otus")                   {       command = new RemoveOtusCommand(optionString);                          }
408                 else if(commandName == "fastq.info")                    {       command = new ParseFastaQCommand(optionString);                         }
409                 else if(commandName == "pipeline.pds")                  {       command = new PipelineCommand(optionString);                            }
410                 else if(commandName == "deunique.seqs")                 {       command = new DeUniqueSeqsCommand(optionString);                        }
411                 else if(commandName == "pairwise.seqs")                 {       command = new PairwiseSeqsCommand(optionString);                        }
412                 else if(commandName == "cluster.classic")               {       command = new ClusterDoturCommand(optionString);                        }
413                 else if(commandName == "sub.sample")                    {       command = new SubSampleCommand(optionString);                           }
414                 else if(commandName == "indicator")                             {       command = new IndicatorCommand(optionString);                           }
415                 else if(commandName == "consensus.seqs")                {       command = new ConsensusSeqsCommand(optionString);                       }
416                 else if(commandName == "corr.axes")                             {       command = new CorrAxesCommand(optionString);                            }
417                 else if(commandName == "remove.rare")                   {       command = new RemoveRareCommand(optionString);                          }
418                 else if(commandName == "merge.groups")                  {       command = new MergeGroupsCommand(optionString);                         }
419                 else if(commandName == "amova")                                 {       command = new AmovaCommand(optionString);                                       }
420                 else if(commandName == "homova")                                {       command = new HomovaCommand(optionString);                                      }
421                 else if(commandName == "mantel")                                {       command = new MantelCommand(optionString);                                      }
422                 else if(commandName == "make.fastq")                    {       command = new MakeFastQCommand(optionString);                           }
423                 else if(commandName == "get.current")                   {       command = new GetCurrentCommand(optionString);                          }
424                 else if(commandName == "set.current")                   {       command = new SetCurrentCommand(optionString);                          }
425                 else if(commandName == "anosim")                                {       command = new AnosimCommand(optionString);                                      }
426                 else if(commandName == "make.shared")                   {       command = new SharedCommand(optionString);                                      }
427                 else if(commandName == "get.commandinfo")               {       command = new GetCommandInfoCommand(optionString);                      }
428                 else if(commandName == "deunique.tree")                 {       command = new DeuniqueTreeCommand(optionString);                        }
429                 else if(commandName == "count.seqs")                    {       command = new CountSeqsCommand(optionString);                           }
430                 else if(commandName == "count.groups")                  {       command = new CountGroupsCommand(optionString);                         }
431                 else if(commandName == "clear.memory")                  {       command = new ClearMemoryCommand(optionString);                         }
432                 else if(commandName == "summary.tax")                   {       command = new SummaryTaxCommand(optionString);                          }
433                 else if(commandName == "summary.qual")                  {       command = new SummaryQualCommand(optionString);                         }
434                 else if(commandName == "chimera.perseus")               {       command = new ChimeraPerseusCommand(optionString);                      }
435                 else if(commandName == "shhh.seqs")                             {       command = new ShhhSeqsCommand(optionString);                            }
436                 else                                                                                    {       command = new NoCommand(optionString);                                          }
437
438                 return command;
439         }
440         catch(exception& e) {
441                 m->errorOut(e, "CommandFactory", "getCommand");
442                 exit(1);
443         }
444 }
445 /***********************************************************/
446
447 /***********************************************************/
448 //This function calls the appropriate command fucntions based on user input.
449 Command* CommandFactory::getCommand(string commandName, string optionString, string mode){
450         try {
451                 delete pipecommand;   //delete the old command
452                 
453                 //user has opted to redirect output from dir where input files are located to some other place
454                 if (outputDir != "") { 
455                         if (optionString != "") { optionString += ", outputdir=" + outputDir; }
456                         else { optionString += "outputdir=" + outputDir; }
457                 }
458                 
459                 //user has opted to redirect input from dir where mothur.exe is located to some other place
460                 if (inputDir != "") { 
461                         if (optionString != "") { optionString += ", inputdir=" + inputDir; }
462                         else { optionString += "inputdir=" + inputDir; }
463                 }
464                 
465                 if(commandName == "read.dist")                                  {       pipecommand = new ReadDistCommand(optionString);                                }
466                 else if(commandName == "read.otu")                              {       pipecommand = new ReadOtuCommand(optionString);                                 }
467                 else if(commandName == "read.tree")                             {       pipecommand = new ReadTreeCommand(optionString);                                }
468                 else if(commandName == "cluster")                               {       pipecommand = new ClusterCommand(optionString);                                 }
469                 else if(commandName == "unique.seqs")                   {       pipecommand = new DeconvoluteCommand(optionString);                             }
470                 else if(commandName == "parsimony")                             {       pipecommand = new ParsimonyCommand(optionString);                               }
471                 else if(commandName == "help")                                  {       pipecommand = new HelpCommand(optionString);                                    }
472                 else if(commandName == "quit")                                  {       pipecommand = new QuitCommand(optionString);                                    }
473                 else if(commandName == "collect.single")                {       pipecommand = new CollectCommand(optionString);                                 }
474                 else if(commandName == "collect.shared")                {       pipecommand = new CollectSharedCommand(optionString);                   }
475                 else if(commandName == "rarefaction.single")    {       pipecommand = new RareFactCommand(optionString);                                }
476                 else if(commandName == "rarefaction.shared")    {       pipecommand = new RareFactSharedCommand(optionString);                  }
477                 else if(commandName == "summary.single")                {       pipecommand = new SummaryCommand(optionString);                                 }
478                 else if(commandName == "summary.shared")                {       pipecommand = new SummarySharedCommand(optionString);                   }
479                 else if(commandName == "unifrac.weighted")              {       pipecommand = new UnifracWeightedCommand(optionString);                 }
480                 else if(commandName == "unifrac.unweighted")    {       pipecommand = new UnifracUnweightedCommand(optionString);               }
481                 else if(commandName == "get.group")             {   pipecommand = new GetgroupCommand(optionString);                            }
482                 else if(commandName == "get.label")             {   pipecommand = new GetlabelCommand(optionString);                            }
483                 else if(commandName == "get.sabund")            {   pipecommand = new GetSAbundCommand(optionString);                           }
484                 else if(commandName == "get.rabund")            {   pipecommand = new GetRAbundCommand(optionString);                           }
485                 else if(commandName == "libshuff")              {   pipecommand = new LibShuffCommand(optionString);                            }
486                 else if(commandName == "heatmap.bin")                   {   pipecommand = new HeatMapCommand(optionString);                                     }
487                 else if(commandName == "heatmap.sim")                   {   pipecommand = new HeatMapSimCommand(optionString);                          }
488                 else if(commandName == "filter.seqs")                   {   pipecommand = new FilterSeqsCommand(optionString);                          }
489                 else if(commandName == "venn")                                  {   pipecommand = new VennCommand(optionString);                                        }
490                 else if(commandName == "bin.seqs")                              {   pipecommand = new BinSeqCommand(optionString);                                      }
491                 else if(commandName == "get.oturep")                    {   pipecommand = new GetOTURepCommand(optionString);                           }
492                 else if(commandName == "tree.shared")                   {   pipecommand = new TreeGroupCommand(optionString);                           }
493                 else if(commandName == "dist.shared")                   {   pipecommand = new MatrixOutputCommand(optionString);                        }
494                 else if(commandName == "bootstrap.shared")              {   pipecommand = new BootSharedCommand(optionString);                          }
495                 else if(commandName == "consensus")                             {   pipecommand = new ConcensusCommand(optionString);                           }
496                 else if(commandName == "dist.seqs")                             {   pipecommand = new DistanceCommand(optionString);                            }
497                 else if(commandName == "align.seqs")                    {   pipecommand = new AlignCommand(optionString);                                       }
498                 else if(commandName == "summary.seqs")                  {       pipecommand = new SeqSummaryCommand(optionString);                              }
499                 else if(commandName == "screen.seqs")                   {       pipecommand = new ScreenSeqsCommand(optionString);                              }
500                 else if(commandName == "reverse.seqs")                  {       pipecommand = new ReverseSeqsCommand(optionString);                             }
501                 else if(commandName == "trim.seqs")                             {       pipecommand = new TrimSeqsCommand(optionString);                                }
502                 else if(commandName == "trim.flows")                    {       pipecommand = new TrimFlowsCommand(optionString);                               }
503                 else if(commandName == "shhh.flows")                    {       pipecommand = new ShhherCommand(optionString);                                  }
504                 else if(commandName == "list.seqs")                             {       pipecommand = new ListSeqsCommand(optionString);                                }
505                 else if(commandName == "get.seqs")                              {       pipecommand = new GetSeqsCommand(optionString);                                 }
506                 else if(commandName == "remove.seqs")                   {       pipecommand = new RemoveSeqsCommand(optionString);                              }
507                 else if(commandName == "merge.files")                   {       pipecommand = new MergeFileCommand(optionString);                               }
508                 else if(commandName == "system")                                {       pipecommand = new SystemCommand(optionString);                                  }
509                 else if(commandName == "align.check")                   {       pipecommand = new AlignCheckCommand(optionString);                              }
510                 else if(commandName == "get.sharedseqs")                {       pipecommand = new GetSharedOTUCommand(optionString);                    }
511                 else if(commandName == "get.otulist")                   {       pipecommand = new GetListCountCommand(optionString);                    }
512                 else if(commandName == "hcluster")                              {       pipecommand = new HClusterCommand(optionString);                                }
513                 else if(commandName == "classify.seqs")                 {       pipecommand = new ClassifySeqsCommand(optionString);                    }
514                 else if(commandName == "chimera.ccode")                 {       pipecommand = new ChimeraCcodeCommand(optionString);                    }
515                 else if(commandName == "chimera.check")                 {       pipecommand = new ChimeraCheckCommand(optionString);                    }
516                 else if(commandName == "chimera.uchime")                {       pipecommand = new ChimeraUchimeCommand(optionString);                   }
517                 else if(commandName == "chimera.slayer")                {       pipecommand = new ChimeraSlayerCommand(optionString);                   }
518                 else if(commandName == "chimera.pintail")               {       pipecommand = new ChimeraPintailCommand(optionString);                  }
519                 else if(commandName == "chimera.bellerophon")   {       pipecommand = new ChimeraBellerophonCommand(optionString);              }
520                 else if(commandName == "phylotype")                             {       pipecommand = new PhylotypeCommand(optionString);                               }
521                 else if(commandName == "mgcluster")                             {       pipecommand = new MGClusterCommand(optionString);                               }
522                 else if(commandName == "pre.cluster")                   {       pipecommand = new PreClusterCommand(optionString);                              }
523                 else if(commandName == "pcoa")                                  {       pipecommand = new PCOACommand(optionString);                                    }
524                 else if(commandName == "pca")                                   {       pipecommand = new PCACommand(optionString);                                             }
525                 else if(commandName == "nmds")                                  {       pipecommand = new NMDSCommand(optionString);                                    }
526                 else if(commandName == "otu.hierarchy")                 {       pipecommand = new OtuHierarchyCommand(optionString);                    }
527                 else if(commandName == "set.dir")                               {       pipecommand = new SetDirectoryCommand(optionString);                    }
528                 else if(commandName == "set.logfile")                   {       pipecommand = new SetLogFileCommand(optionString);                              }
529                 else if(commandName == "parse.list")                    {       pipecommand = new ParseListCommand(optionString);                               }
530                 else if(commandName == "phylo.diversity")               {       pipecommand = new PhyloDiversityCommand(optionString);                  }
531                 else if(commandName == "make.group")                    {       pipecommand = new MakeGroupCommand(optionString);                               }
532                 else if(commandName == "chop.seqs")                             {       pipecommand = new ChopSeqsCommand(optionString);                                }
533                 else if(commandName == "clearcut")                              {       pipecommand = new ClearcutCommand(optionString);                                }
534                 else if(commandName == "catchall")                              {       pipecommand = new CatchAllCommand(optionString);                                }
535                 else if(commandName == "split.abund")                   {       pipecommand = new SplitAbundCommand(optionString);                              }
536                 else if(commandName == "cluster.split")                 {       pipecommand = new ClusterSplitCommand(optionString);                    }
537                 else if(commandName == "classify.otu")                  {       pipecommand = new ClassifyOtuCommand(optionString);                             }
538                 else if(commandName == "degap.seqs")                    {       pipecommand = new DegapSeqsCommand(optionString);                               }
539                 else if(commandName == "get.relabund")                  {       pipecommand = new GetRelAbundCommand(optionString);                             }
540                 else if(commandName == "sens.spec")                             {       pipecommand = new SensSpecCommand(optionString);                                }
541                 else if(commandName == "seq.error")                             {       pipecommand = new SeqErrorCommand(optionString);                                }
542                 else if(commandName == "sffinfo")                               {       pipecommand = new SffInfoCommand(optionString);                                 }
543                 else if(commandName == "normalize.shared")              {       pipecommand = new NormalizeSharedCommand(optionString);                 }
544                 else if(commandName == "metastats")                             {       pipecommand = new MetaStatsCommand(optionString);                               }
545                 else if(commandName == "split.groups")                  {       pipecommand = new SplitGroupCommand(optionString);                              }
546                 else if(commandName == "cluster.fragments")             {       pipecommand = new ClusterFragmentsCommand(optionString);                }
547                 else if(commandName == "get.lineage")                   {       pipecommand = new GetLineageCommand(optionString);                              }
548                 else if(commandName == "get.groups")                    {       pipecommand = new GetGroupsCommand(optionString);                               }
549                 else if(commandName == "remove.lineage")                {       pipecommand = new RemoveLineageCommand(optionString);                   }
550                 else if(commandName == "remove.groups")                 {       pipecommand = new RemoveGroupsCommand(optionString);                    }
551                 else if(commandName == "get.otus")                              {       pipecommand = new GetOtusCommand(optionString);                                 }
552                 else if(commandName == "remove.otus")                   {       pipecommand = new RemoveOtusCommand(optionString);                              }
553                 else if(commandName == "fastq.info")                    {       pipecommand = new ParseFastaQCommand(optionString);                             }
554                 else if(commandName == "deunique.seqs")                 {       pipecommand = new DeUniqueSeqsCommand(optionString);                    }
555                 else if(commandName == "pairwise.seqs")                 {       pipecommand = new PairwiseSeqsCommand(optionString);                    }
556                 else if(commandName == "cluster.classic")               {       pipecommand = new ClusterDoturCommand(optionString);                    }
557                 else if(commandName == "sub.sample")                    {       pipecommand = new SubSampleCommand(optionString);                               }
558                 else if(commandName == "indicator")                             {       pipecommand = new IndicatorCommand(optionString);                               }
559                 else if(commandName == "consensus.seqs")                {       pipecommand = new ConsensusSeqsCommand(optionString);                   }
560                 else if(commandName == "corr.axes")                             {       pipecommand = new CorrAxesCommand(optionString);                                }
561                 else if(commandName == "remove.rare")                   {       pipecommand = new RemoveRareCommand(optionString);                              }
562                 else if(commandName == "merge.groups")                  {       pipecommand = new MergeGroupsCommand(optionString);                             }
563                 else if(commandName == "amova")                                 {       pipecommand = new AmovaCommand(optionString);                                   }
564                 else if(commandName == "homova")                                {       pipecommand = new HomovaCommand(optionString);                                  }
565                 else if(commandName == "mantel")                                {       pipecommand = new MantelCommand(optionString);                                  }
566                 else if(commandName == "anosim")                                {       pipecommand = new AnosimCommand(optionString);                                  }
567                 else if(commandName == "make.fastq")                    {       pipecommand = new MakeFastQCommand(optionString);                               }
568                 else if(commandName == "get.current")                   {       pipecommand = new GetCurrentCommand(optionString);                              }
569                 else if(commandName == "set.current")                   {       pipecommand = new SetCurrentCommand(optionString);                              }
570                 else if(commandName == "make.shared")                   {       pipecommand = new SharedCommand(optionString);                                  }
571                 else if(commandName == "get.commandinfo")               {       pipecommand = new GetCommandInfoCommand(optionString);                  }
572                 else if(commandName == "deunique.tree")                 {       pipecommand = new DeuniqueTreeCommand(optionString);                    }
573                 else if(commandName == "count.seqs")                    {       pipecommand = new CountSeqsCommand(optionString);                               }
574                 else if(commandName == "count.groups")                  {       pipecommand = new CountGroupsCommand(optionString);                             }
575                 else if(commandName == "clear.memory")                  {       pipecommand = new ClearMemoryCommand(optionString);                             }
576                 else if(commandName == "summary.tax")                   {       pipecommand = new SummaryTaxCommand(optionString);                              }
577                 else if(commandName == "summary.qual")                  {       pipecommand = new SummaryQualCommand(optionString);                             }
578                 else if(commandName == "chimera.perseus")               {       pipecommand = new ChimeraPerseusCommand(optionString);                  }
579                 else if(commandName == "shhh.seqs")                             {       pipecommand = new ShhhSeqsCommand(optionString);                                }
580                 else                                                                                    {       pipecommand = new NoCommand(optionString);                                              }
581
582                 return pipecommand;
583         }
584         catch(exception& e) {
585                 m->errorOut(e, "CommandFactory", "getCommand");
586                 exit(1);
587         }
588 }
589 /***********************************************************/
590
591 /***********************************************************/
592 //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
593 Command* CommandFactory::getCommand(string commandName){
594         try {
595                 delete shellcommand;   //delete the old command
596                 
597                 if(commandName == "read.dist")                                  {       shellcommand = new ReadDistCommand();                           }
598                 else if(commandName == "read.otu")                              {       shellcommand = new ReadOtuCommand();                            }
599                 else if(commandName == "read.tree")                             {       shellcommand = new ReadTreeCommand();                           }
600                 else if(commandName == "cluster")                               {       shellcommand = new ClusterCommand();                            }
601                 else if(commandName == "unique.seqs")                   {       shellcommand = new DeconvoluteCommand();                        }
602                 else if(commandName == "parsimony")                             {       shellcommand = new ParsimonyCommand();                          }
603                 else if(commandName == "help")                                  {       shellcommand = new HelpCommand();                                       }
604                 else if(commandName == "quit")                                  {       shellcommand = new QuitCommand();                                       }
605                 else if(commandName == "collect.single")                {       shellcommand = new CollectCommand();                            }
606                 else if(commandName == "collect.shared")                {       shellcommand = new CollectSharedCommand();                      }
607                 else if(commandName == "rarefaction.single")    {       shellcommand = new RareFactCommand();                           }
608                 else if(commandName == "rarefaction.shared")    {       shellcommand = new RareFactSharedCommand();                     }
609                 else if(commandName == "summary.single")                {       shellcommand = new SummaryCommand();                            }
610                 else if(commandName == "summary.shared")                {       shellcommand = new SummarySharedCommand();                      }
611                 else if(commandName == "unifrac.weighted")              {       shellcommand = new UnifracWeightedCommand();            }
612                 else if(commandName == "unifrac.unweighted")    {       shellcommand = new UnifracUnweightedCommand();          }
613                 else if(commandName == "get.group")             {   shellcommand = new GetgroupCommand();                               }
614                 else if(commandName == "get.label")             {   shellcommand = new GetlabelCommand();                               }
615                 else if(commandName == "get.sabund")            {   shellcommand = new GetSAbundCommand();                              }
616                 else if(commandName == "get.rabund")            {   shellcommand = new GetRAbundCommand();                              }
617                 else if(commandName == "libshuff")              {   shellcommand = new LibShuffCommand();                               }
618                 else if(commandName == "heatmap.bin")                   {   shellcommand = new HeatMapCommand();                                }
619                 else if(commandName == "heatmap.sim")                   {   shellcommand = new HeatMapSimCommand();                             }
620                 else if(commandName == "filter.seqs")                   {   shellcommand = new FilterSeqsCommand();                             }
621                 else if(commandName == "venn")                                  {   shellcommand = new VennCommand();                                   }
622                 else if(commandName == "bin.seqs")                              {   shellcommand = new BinSeqCommand();                                 }
623                 else if(commandName == "get.oturep")                    {   shellcommand = new GetOTURepCommand();                              }
624                 else if(commandName == "tree.shared")                   {   shellcommand = new TreeGroupCommand();                              }
625                 else if(commandName == "dist.shared")                   {   shellcommand = new MatrixOutputCommand();                   }
626                 else if(commandName == "bootstrap.shared")              {   shellcommand = new BootSharedCommand();                             }
627                 else if(commandName == "consensus")                             {   shellcommand = new ConcensusCommand();                              }
628                 else if(commandName == "dist.seqs")                             {   shellcommand = new DistanceCommand();                               }
629                 else if(commandName == "align.seqs")                    {   shellcommand = new AlignCommand();                                  }
630                 else if(commandName == "summary.seqs")                  {       shellcommand = new SeqSummaryCommand();                         }
631                 else if(commandName == "screen.seqs")                   {       shellcommand = new ScreenSeqsCommand();                         }
632                 else if(commandName == "reverse.seqs")                  {       shellcommand = new ReverseSeqsCommand();                        }
633                 else if(commandName == "trim.seqs")                             {       shellcommand = new TrimSeqsCommand();                           }
634                 else if(commandName == "trim.flows")                    {       shellcommand = new TrimFlowsCommand();                          }
635                 else if(commandName == "shhh.flows")                    {       shellcommand = new ShhherCommand();                                     }
636                 else if(commandName == "list.seqs")                             {       shellcommand = new ListSeqsCommand();                           }
637                 else if(commandName == "get.seqs")                              {       shellcommand = new GetSeqsCommand();                            }
638                 else if(commandName == "remove.seqs")                   {       shellcommand = new RemoveSeqsCommand();                         }
639                 else if(commandName == "merge.files")                   {       shellcommand = new MergeFileCommand();                          }
640                 else if(commandName == "system")                                {       shellcommand = new SystemCommand();                                     }
641                 else if(commandName == "align.check")                   {       shellcommand = new AlignCheckCommand();                         }
642                 else if(commandName == "get.sharedseqs")                {       shellcommand = new GetSharedOTUCommand();                       }
643                 else if(commandName == "get.otulist")                   {       shellcommand = new GetListCountCommand();                       }
644                 else if(commandName == "hcluster")                              {       shellcommand = new HClusterCommand();                           }
645                 else if(commandName == "classify.seqs")                 {       shellcommand = new ClassifySeqsCommand();                       }
646                 else if(commandName == "chimera.ccode")                 {       shellcommand = new ChimeraCcodeCommand();                       }
647                 else if(commandName == "chimera.check")                 {       shellcommand = new ChimeraCheckCommand();                       }
648                 else if(commandName == "chimera.slayer")                {       shellcommand = new ChimeraSlayerCommand();                      }
649                 else if(commandName == "chimera.uchime")                {       shellcommand = new ChimeraUchimeCommand();                      }
650                 else if(commandName == "chimera.pintail")               {       shellcommand = new ChimeraPintailCommand();                     }
651                 else if(commandName == "chimera.bellerophon")   {       shellcommand = new ChimeraBellerophonCommand();         }
652                 else if(commandName == "phylotype")                             {       shellcommand = new PhylotypeCommand();                          }
653                 else if(commandName == "mgcluster")                             {       shellcommand = new MGClusterCommand();                          }
654                 else if(commandName == "pre.cluster")                   {       shellcommand = new PreClusterCommand();                         }
655                 else if(commandName == "pcoa")                                  {       shellcommand = new PCOACommand();                                       }
656                 else if(commandName == "pca")                                   {       shellcommand = new PCACommand();                                        }
657                 else if(commandName == "nmds")                                  {       shellcommand = new NMDSCommand();                                       }
658                 else if(commandName == "otu.hierarchy")                 {       shellcommand = new OtuHierarchyCommand();                       }
659                 else if(commandName == "set.dir")                               {       shellcommand = new SetDirectoryCommand();                       }
660                 else if(commandName == "set.logfile")                   {       shellcommand = new SetLogFileCommand();                         }
661                 else if(commandName == "parse.list")                    {       shellcommand = new ParseListCommand();                          }
662                 else if(commandName == "phylo.diversity")               {       shellcommand = new PhyloDiversityCommand();                     }
663                 else if(commandName == "make.group")                    {       shellcommand = new MakeGroupCommand();                          }
664                 else if(commandName == "chop.seqs")                             {       shellcommand = new ChopSeqsCommand();                           }
665                 else if(commandName == "clearcut")                              {       shellcommand = new ClearcutCommand();                           }
666                 else if(commandName == "catchall")                              {       shellcommand = new CatchAllCommand();                           }
667                 else if(commandName == "split.abund")                   {       shellcommand = new SplitAbundCommand();                         }
668                 else if(commandName == "cluster.split")                 {       shellcommand = new ClusterSplitCommand();                       }
669                 else if(commandName == "classify.otu")                  {       shellcommand = new ClassifyOtuCommand();                        }
670                 else if(commandName == "degap.seqs")                    {       shellcommand = new DegapSeqsCommand();                          }
671                 else if(commandName == "get.relabund")                  {       shellcommand = new GetRelAbundCommand();                        }
672                 else if(commandName == "sens.spec")                             {       shellcommand = new SensSpecCommand();                           }
673                 else if(commandName == "seq.error")                             {       shellcommand = new SeqErrorCommand();                           }
674                 else if(commandName == "sffinfo")                               {       shellcommand = new SffInfoCommand();                            }
675                 else if(commandName == "normalize.shared")              {       shellcommand = new NormalizeSharedCommand();            }
676                 else if(commandName == "metastats")                             {       shellcommand = new MetaStatsCommand();                          }
677                 else if(commandName == "split.groups")                  {       shellcommand = new SplitGroupCommand();                         }
678                 else if(commandName == "cluster.fragments")             {       shellcommand = new ClusterFragmentsCommand();           }
679                 else if(commandName == "get.lineage")                   {       shellcommand = new GetLineageCommand();                         }
680                 else if(commandName == "remove.lineage")                {       shellcommand = new RemoveLineageCommand();                      }
681                 else if(commandName == "get.groups")                    {       shellcommand = new GetGroupsCommand();                          }
682                 else if(commandName == "remove.groups")                 {       shellcommand = new RemoveGroupsCommand();                       }
683                 else if(commandName == "get.otus")                              {       shellcommand = new GetOtusCommand();                            }
684                 else if(commandName == "remove.otus")                   {       shellcommand = new RemoveOtusCommand();                         }
685                 else if(commandName == "fastq.info")                    {       shellcommand = new ParseFastaQCommand();                        }
686                 else if(commandName == "deunique.seqs")                 {       shellcommand = new DeUniqueSeqsCommand();                       }
687                 else if(commandName == "pairwise.seqs")                 {       shellcommand = new PairwiseSeqsCommand();                       }
688                 else if(commandName == "cluster.classic")               {       shellcommand = new ClusterDoturCommand();                       }
689                 else if(commandName == "sub.sample")                    {       shellcommand = new SubSampleCommand();                          }
690                 else if(commandName == "indicator")                             {       shellcommand = new IndicatorCommand();                          }
691                 else if(commandName == "consensus.seqs")                {       shellcommand = new ConsensusSeqsCommand();                      }
692                 else if(commandName == "corr.axes")                             {       shellcommand = new CorrAxesCommand();                           }
693                 else if(commandName == "remove.rare")                   {       shellcommand = new RemoveRareCommand();                         }
694                 else if(commandName == "merge.groups")                  {       shellcommand = new MergeGroupsCommand();                        }
695                 else if(commandName == "amova")                                 {       shellcommand = new AmovaCommand();                                      }
696                 else if(commandName == "homova")                                {       shellcommand = new HomovaCommand();                                     }
697                 else if(commandName == "mantel")                                {       shellcommand = new MantelCommand();                                     }
698                 else if(commandName == "anosim")                                {       shellcommand = new AnosimCommand();                                     }
699                 else if(commandName == "make.fastq")                    {       shellcommand = new MakeFastQCommand();                          }
700                 else if(commandName == "get.current")                   {       shellcommand = new GetCurrentCommand();                         }
701                 else if(commandName == "set.current")                   {       shellcommand = new SetCurrentCommand();                         }
702                 else if(commandName == "make.shared")                   {       shellcommand = new SharedCommand();                                     }
703                 else if(commandName == "get.commandinfo")               {       shellcommand = new GetCommandInfoCommand();                     }
704                 else if(commandName == "deunique.tree")                 {       shellcommand = new DeuniqueTreeCommand();                       }
705                 else if(commandName == "count.seqs")                    {       shellcommand = new CountSeqsCommand();                          }
706                 else if(commandName == "count.groups")                  {       shellcommand = new CountGroupsCommand();                        }
707                 else if(commandName == "clear.memory")                  {       shellcommand = new ClearMemoryCommand();                        }
708                 else if(commandName == "summary.tax")                   {       shellcommand = new SummaryTaxCommand();                         }
709                 else if(commandName == "summary.qual")                  {       shellcommand = new SummaryQualCommand();                        }
710                 else if(commandName == "chimera.perseus")               {       shellcommand = new ChimeraPerseusCommand();                     }
711                 else if(commandName == "shhh.seqs")                             {       shellcommand = new ShhhSeqsCommand();                           }
712                 else                                                                                    {       shellcommand = new NoCommand();                                         }
713
714                 return shellcommand;
715         }
716         catch(exception& e) {
717                 m->errorOut(e, "CommandFactory", "getCommand");
718                 exit(1);
719         }
720 }
721 /***********************************************************
722 //This function is used to interrupt a command
723 Command* CommandFactory::getCommand(){
724         try {
725                 delete command;   //delete the old command
726
727                 string s = "";
728             command = new NoCommand(s);
729         
730                 return command;
731         }
732         catch(exception& e) {
733                 m->errorOut(e, "CommandFactory", "getCommand");
734                 exit(1);
735         }
736 }
737 /***********************************************************************/
738 bool CommandFactory::isValidCommand(string command) {
739         try {   
740         
741                 //is the command in the map
742                 if ((commands.find(command)) != (commands.end())) {
743                         return true;
744                 }else{
745                         m->mothurOut(command + " is not a valid command in Mothur.  Valid commands are ");
746                         for (it = commands.begin(); it != commands.end(); it++) {
747                                 m->mothurOut(it->first + ", ");
748                         }
749                         m->mothurOutEndLine();
750                         return false;
751                 }
752                 
753         }
754         catch(exception& e) {
755                 m->errorOut(e, "CommandFactory", "isValidCommand");
756                 exit(1);
757         }
758 }
759 /***********************************************************************/
760 bool CommandFactory::isValidCommand(string command, string noError) {
761         try {   
762         
763                 //is the command in the map
764                 if ((commands.find(command)) != (commands.end())) {
765                         return true;
766                 }else{
767                         return false;
768                 }
769                 
770         }
771         catch(exception& e) {
772                 m->errorOut(e, "CommandFactory", "isValidCommand");
773                 exit(1);
774         }
775 }
776 /***********************************************************************/
777 void CommandFactory::printCommands(ostream& out) {
778         try {   
779                 out << "Valid commands are: ";
780                 for (it = commands.begin(); it != commands.end(); it++) {
781                         out << it->first << ",";
782                 }
783                 out << endl;
784         }
785         catch(exception& e) {
786                 m->errorOut(e, "CommandFactory", "printCommands");
787                 exit(1);
788         }
789 }
790 /***********************************************************************/
791
792
793
794