]> git.donarmstrong.com Git - mothur.git/blob - commandfactory.cpp
8056227c3bce48545f7422502a4a7cbda163201f
[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 "parselistcommand.h"
16 #include "collectcommand.h"
17 #include "collectsharedcommand.h"
18 #include "getgroupcommand.h"
19 #include "getlabelcommand.h"
20 #include "getlinecommand.h"
21 #include "rarefactcommand.h"
22 #include "summarycommand.h"
23 #include "summarysharedcommand.h"
24 #include "rarefactsharedcommand.h"
25 #include "quitcommand.h"
26 #include "helpcommand.h"
27 #include "commandfactory.hpp"
28 #include "deconvolutecommand.h"
29 #include "parsimonycommand.h"
30 #include "unifracunweightedcommand.h"
31 #include "unifracweightedcommand.h"
32 #include "libshuffcommand.h"
33 #include "heatmapcommand.h"
34 #include "filterseqscommand.h"
35 #include "mothur.h"
36 #include "venncommand.h"
37 #include "nocommands.h"
38 #include "binsequencecommand.h"
39 #include "getoturepcommand.h"
40 #include "treegroupscommand.h"
41 #include "bootstrapsharedcommand.h"
42 #include "concensuscommand.h"
43 #include "distancecommand.h"
44 #include "aligncommand.h"
45 #include "matrixoutputcommand.h"
46 #include "getsabundcommand.h"
47 #include "getrabundcommand.h"
48 #include "seqsummarycommand.h"
49 #include "screenseqscommand.h"
50 #include "reversecommand.h"
51 #include "trimseqscommand.h"
52
53 /***********************************************************/
54
55 /***********************************************************/
56 CommandFactory::CommandFactory(){
57         command = new NoCommand();
58 }
59 /***********************************************************/
60
61 /***********************************************************/
62 CommandFactory::~CommandFactory(){
63         delete command;
64 }
65
66 /***********************************************************/
67
68 /***********************************************************/
69 //This function calls the appropriate command fucntions based on user input.
70 Command* CommandFactory::getCommand(string commandName){
71         try {
72                 delete command;   //delete the old command
73
74                 if(commandName == "read.dist")                                  {       command = new ReadDistCommand();                        }
75                 else if(commandName == "read.otu")                              {       command = new ReadOtuCommand();                         }
76                 else if(commandName == "read.tree")                             {       command = new ReadTreeCommand();                        }
77                 else if(commandName == "cluster")                               {       command = new ClusterCommand();                         }
78                 else if(commandName == "unique.seqs")                   {       command = new DeconvoluteCommand();                     }
79                 else if(commandName == "parsimony")                             {       command = new ParsimonyCommand();                       }
80                 else if(commandName == "help")                                  {       command = new HelpCommand();                            }
81                 else if(commandName == "quit")                                  {       command = new QuitCommand();                            }
82                 else if(commandName == "collect.single")                {       command = new CollectCommand();                         }
83                 else if(commandName == "collect.shared")                {       command = new CollectSharedCommand();           }
84                 else if(commandName == "rarefaction.single")    {       command = new RareFactCommand();                        }
85                 else if(commandName == "rarefaction.shared")    {       command = new RareFactSharedCommand();          }
86                 else if(commandName == "summary.single")                {       command = new SummaryCommand();                         }
87                 else if(commandName == "summary.shared")                {       command = new SummarySharedCommand();           }
88                 else if(commandName == "unifrac.weighted")              {       command = new UnifracWeightedCommand();         }
89                 else if(commandName == "unifrac.unweighted")    {       command = new UnifracUnweightedCommand();       }
90                 else if(commandName == "get.group")             {   command = new GetgroupCommand();                    }
91                 else if(commandName == "get.label")             {   command = new GetlabelCommand();                    }
92                 else if(commandName == "get.line")              {   command = new GetlineCommand();                             }
93                 else if(commandName == "get.sabund")            {   command = new GetSAbundCommand();                   }
94                 else if(commandName == "get.rabund")            {   command = new GetRAbundCommand();                   }
95                 else if(commandName == "libshuff")              {   command = new LibShuffCommand();                    }
96                 else if(commandName == "heatmap")                               {   command = new HeatMapCommand();                             }
97                 else if(commandName == "filter.seqs")                   {   command = new FilterSeqsCommand();          }
98                 else if(commandName == "venn")                                  {   command = new VennCommand();                                }
99                 else if(commandName == "bin.seqs")                              {   command = new BinSeqCommand();                              }
100                 else if(commandName == "get.oturep")                    {   command = new GetOTURepCommand();                   }
101                 else if(commandName == "tree.shared")                   {   command = new TreeGroupCommand();                   }
102                 else if(commandName == "dist.shared")                   {   command = new MatrixOutputCommand();                }
103                 else if(commandName == "bootstrap.shared")              {   command = new BootSharedCommand();                  }
104                 else if(commandName == "concensus")                             {   command = new ConcensusCommand();                   }
105                 else if(commandName == "dist.seqs")                             {   command = new DistanceCommand();                    }
106                 else if(commandName == "align.seqs")                    {   command = new AlignCommand();                               }
107                 else if(commandName == "summary.seqs")                  {       command = new SeqSummaryCommand();                      }
108                 else if(commandName == "screen.seqs")                   {       command = new ScreenSeqsCommand();                      }
109                 else if(commandName == "reverse.seqs")                  {       command = new ReverseSeqsCommand();                     }
110                 else if(commandName == "trim.seqs")                             {       command = new TrimSeqsCommand();                        }
111                 else                                                                                    {       command = new NoCommand();                                      }
112
113                 return command;
114         }
115         catch(exception& e) {
116                 cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
117                 exit(1);
118         }
119         catch(...) {
120                 cout << "An unknown error has occurred in the CommandFactory class function getCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
121                 exit(1);
122         }
123
124 }
125 /***********************************************************/
126