]> git.donarmstrong.com Git - mothur.git/blobdiff - commandfactory.cpp
added out.hierarchy command
[mothur.git] / commandfactory.cpp
index 030079ed21e3a6d4f35263f45d46a67878715e5b..0da5986187ec2a3d4c2920c854cd34d101529528 100644 (file)
 #include "getlistcountcommand.h"
 #include "hclustercommand.h"
 #include "classifyseqscommand.h"
+#include "phylotypecommand.h"
+#include "mgclustercommand.h"
+#include "preclustercommand.h"
+#include "pcacommand.h"
+#include "otuhierarchycommand.h"
 
+/*******************************************************/
+
+/******************************************************/
+CommandFactory* CommandFactory::getInstance() {
+       if( _uniqueInstance == 0) {
+               _uniqueInstance = new CommandFactory();
+       }
+       return _uniqueInstance;
+}
 /***********************************************************/
 
 /***********************************************************/
 CommandFactory::CommandFactory(){
+       _uniqueInstance = 0;
        string s = "";
        command = new NoCommand(s);
        
@@ -112,11 +127,16 @@ CommandFactory::CommandFactory(){
        commands["remove.seqs"]                 = "get.seqs";
        commands["system"]                              = "system";
        commands["align.check"]                 = "align.check";
-       commands["get.sharedotu"]               = "get.sharedotu";
-       commands["get.listcount"]               = "get.listcount";
+       commands["get.sharedseqs"]              = "get.sharedseqs";
+       commands["get.otulist"]                 = "get.otulist";
        commands["quit"]                                = "quit"; 
        commands["hcluster"]                    = "hcluster"; 
        commands["classify.seqs"]               = "classify.seqs"; 
+       commands["phylotype"]                   = "phylotype";
+       commands["mgcluster"]                   = "mgcluster";
+       commands["pre.cluster"]                 = "pre.cluster";
+       commands["pca"]                                 = "pca";
+       commands["otu.hierarchy"]               = "otu.hierarchy";
 
 }
 /***********************************************************/
@@ -179,10 +199,15 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                else if(commandName == "merge.files")                   {       command = new MergeFileCommand(optionString);                   }
                else if(commandName == "system")                                {       command = new SystemCommand(optionString);                              }
                else if(commandName == "align.check")                   {       command = new AlignCheckCommand(optionString);                  }
-               else if(commandName == "get.sharedotu")                 {       command = new GetSharedOTUCommand(optionString);                }
-               else if(commandName == "get.listcount")                 {       command = new GetListCountCommand(optionString);                }
+               else if(commandName == "get.sharedseqs")                {       command = new GetSharedOTUCommand(optionString);                }
+               else if(commandName == "get.otulist")                   {       command = new GetListCountCommand(optionString);                }
                else if(commandName == "hcluster")                              {       command = new HClusterCommand(optionString);                    }
                else if(commandName == "classify.seqs")                 {       command = new ClassifySeqsCommand(optionString);                }
+               else if(commandName == "phylotype")                             {       command = new PhylotypeCommand(optionString);                   }
+               else if(commandName == "mgcluster")                             {       command = new MGClusterCommand(optionString);                   }
+               else if(commandName == "pre.cluster")                   {       command = new PreClusterCommand(optionString);                  }
+               else if(commandName == "pca")                                   {       command = new PCACommand(optionString);                                 }
+               else if(commandName == "otu.hierarchy")                 {       command = new OtuHierarchyCommand(optionString);                }
                else                                                                                    {       command = new NoCommand(optionString);                                  }
 
                return command;
@@ -192,7 +217,22 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                exit(1);
        }
 }
+/***********************************************************/
+//This function is used to interrupt a command
+Command* CommandFactory::getCommand(){
+       try {
+               delete command;   //delete the old command
 
+               string s = "";
+           command = new NoCommand(s);
+       
+               return command;
+       }
+       catch(exception& e) {
+               errorOut(e, "CommandFactory", "getCommand");
+               exit(1);
+       }
+}
 /***********************************************************************/
 bool CommandFactory::isValidCommand(string command) {
        try {