]> git.donarmstrong.com Git - mothur.git/commitdiff
removed validcommands and put its checking in commandfactory.
authorwestcott <westcott>
Mon, 15 Jun 2009 12:08:39 +0000 (12:08 +0000)
committerwestcott <westcott>
Mon, 15 Jun 2009 12:08:39 +0000 (12:08 +0000)
Mothur.xcodeproj/project.pbxproj
commandfactory.cpp
commandfactory.hpp
helpcommand.cpp
helpcommand.h
nocommands.cpp
nocommands.h
validcommands.cpp [deleted file]
validcommands.h [deleted file]

index 6244917530ee18b9f7ac9033bd16e8c5b6ed147b..8b890ae6b59a2088be0ac1b385d30620ef2a65ab 100644 (file)
                37D9289B0F21331F001D4494 /* summarysharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */; };
                37D9289C0F21331F001D4494 /* uvest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9284D0F21331F001D4494 /* uvest.cpp */; };
                37D9289D0F21331F001D4494 /* validcalculator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9284F0F21331F001D4494 /* validcalculator.cpp */; };
-               37D9289E0F21331F001D4494 /* validcommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928510F21331F001D4494 /* validcommands.cpp */; };
                37D9289F0F21331F001D4494 /* validparameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928530F21331F001D4494 /* validparameter.cpp */; };
                37E5F3E30F29FD4200F8D827 /* treenode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F3E20F29FD4200F8D827 /* treenode.cpp */; };
                37E5F4920F2A3DA800F8D827 /* readtreecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */; };
                37D9284E0F21331F001D4494 /* uvest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uvest.h; sourceTree = SOURCE_ROOT; };
                37D9284F0F21331F001D4494 /* validcalculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validcalculator.cpp; sourceTree = SOURCE_ROOT; };
                37D928500F21331F001D4494 /* validcalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = validcalculator.h; sourceTree = SOURCE_ROOT; };
-               37D928510F21331F001D4494 /* validcommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validcommands.cpp; sourceTree = SOURCE_ROOT; };
-               37D928520F21331F001D4494 /* validcommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = validcommands.h; sourceTree = SOURCE_ROOT; };
                37D928530F21331F001D4494 /* validparameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validparameter.cpp; sourceTree = SOURCE_ROOT; };
                37D928540F21331F001D4494 /* validparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = validparameter.h; sourceTree = SOURCE_ROOT; };
                37E3ED800F4D9D0D00B5DF02 /* mothur.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothur.h; sourceTree = SOURCE_ROOT; };
                        children = (
                                37D928500F21331F001D4494 /* validcalculator.h */,
                                37D9284F0F21331F001D4494 /* validcalculator.cpp */,
-                               37D928520F21331F001D4494 /* validcommands.h */,
-                               37D928510F21331F001D4494 /* validcommands.cpp */,
                                37D928540F21331F001D4494 /* validparameter.h */,
                                37D928530F21331F001D4494 /* validparameter.cpp */,
                        );
                                37D9289B0F21331F001D4494 /* summarysharedcommand.cpp in Sources */,
                                37D9289C0F21331F001D4494 /* uvest.cpp in Sources */,
                                37D9289D0F21331F001D4494 /* validcalculator.cpp in Sources */,
-                               37D9289E0F21331F001D4494 /* validcommands.cpp in Sources */,
                                37D9289F0F21331F001D4494 /* validparameter.cpp in Sources */,
                                372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */,
                                372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */,
index eeaf8ee38ee287691dc8023307f95e098026c9ac..7dd35fd673a7bc62e109a0095efe847d5b097588 100644 (file)
 CommandFactory::CommandFactory(){
        string s = "";
        command = new NoCommand(s);
+       
+       
+       //initialize list of valid commands
+       commands["read.dist"]                   = "read.dist"; 
+       commands["read.otu"]                    = "read.otu";
+       commands["read.tree"]                   = "read.tree"; 
+       commands["bin.seqs"]                    = "bin.seqs"; 
+       commands["get.oturep"]                  = "get.oturep";
+       commands["cluster"]                             = "cluster"; 
+       commands["unique.seqs"]                 = "unique.seqs"; 
+       commands["dist.seqs"]                   = "dist.seqs";
+       commands["dist.shared"]                 = "dist.shared";
+       commands["collect.single"]              = "collect.single"; 
+       commands["collect.shared"]              = "collect.shared"; 
+       commands["rarefaction.single"]  = "rarefaction.single"; 
+       commands["rarefaction.shared"]  = "rarefaction.shared"; 
+       commands["summary.single"]              = "summary.single"; 
+       commands["summary.shared"]              = "summary.shared"; 
+       commands["parsimony"]                   = "parsimony";
+       commands["unifrac.weighted"]    = "unifrac.weighted"; 
+       commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
+       commands["libshuff"]                    = "libshuff";
+       commands["tree.shared"]                 = "tree.shared";
+       commands["heatmap.bin"]                 = "heatmap.bin";
+       commands["heatmap.sim"]                 = "heatmap.sim";
+       commands["venn"]                                = "venn";
+       commands["get.group"]           = "get.group";
+       commands["get.label"]           = "get.label";
+       commands["get.line"]            = "get.line";
+       commands["get.sabund"]          = "get.sabund";
+       commands["get.rabund"]          = "get.rabund";
+       commands["bootstrap.shared"]    = "bootstrap.shared";
+       commands["concensus"]                   = "concensus";
+       commands["help"]                                = "help"; 
+       commands["filter.seqs"]                 = "filter.seqs";
+       commands["align.seqs"]                  = "align.seqs";
+       commands["summary.seqs"]                = "summary.seqs";
+       commands["screen.seqs"]                 = "screen.seqs";
+       commands["reverse.seqs"]                = "reverse.seqs";
+       commands["trim.seqs"]                   = "trim.seqs";
+       commands["quit"]                                = "quit"; 
+
 }
 /***********************************************************/
 
@@ -126,5 +168,54 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
        }
 
 }
-/***********************************************************/
+
+/***********************************************************************/
+bool CommandFactory::isValidCommand(string command) {
+       try {   
+       
+               //is the command in the map
+               if ((commands.find(command)) != (commands.end())) {
+                       return true;
+               }else{
+                       cout << command << " is not a valid command in Mothur.  Valid commands are ";
+                       for (it = commands.begin(); it != commands.end(); it++) {
+                               cout << it->first << ", ";
+                       }
+                       cout << endl;
+                       return false;
+               }
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the CommandFactory class function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+/***********************************************************************/
+void CommandFactory::printCommands(ostream& out) {
+       try {   
+               out << "Valid commands are ";
+               for (it = commands.begin(); it != commands.end(); it++) {
+                       out << it->first << ", ";
+               }
+               out << endl;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the CommandFactory class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the CommandFactory class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+/***********************************************************************/
+
+
+
 
index e3eea41cd73e3583e57f5f2ce503233b54a02d55..0cede38b05904dd9252f8987c8782f32f04cc297 100644 (file)
@@ -19,8 +19,15 @@ public:
        CommandFactory();
        ~CommandFactory();
        Command* getCommand(string, string);
+       bool isValidCommand(string);
+       void printCommands(ostream&);
+
 private:
        Command* command;
+       map<string, string> commands;
+       map<string, string>::iterator it;
+
+       
 
 };
 
index 4a97342c27f801ea7bb959f0c411ace6f33393dc..93def59137b8ecadb3e45b26ff3fac35bc976405 100644 (file)
 //**********************************************************************************************************************
 
 HelpCommand::HelpCommand(string option){
+
+       
+       if (option != "") { cout << "There are no valid parameters for the help() command." << endl;  }
        
-       if (option != "") { cout << "There are no valid parameters for the help() command." << endl;  } 
-       validCommands = new ValidCommands();
+       validCommands = new CommandFactory();
 }
 
 //**********************************************************************************************************************
index 4e68388d278c85b69a9a4fb7be9db6e19a4a1253..f6a4aa38570aa047de43839895fc40d30e984fe7 100644 (file)
@@ -12,8 +12,7 @@
 /* This class is designed to aid the user in running mothur. */
 
 #include "command.hpp"
-#include "validcommands.h"
-
+#include "commandfactory.hpp"
 
 class HelpCommand : public Command {
        
@@ -24,7 +23,7 @@ public:
        void help() {};
        
 private:
-       ValidCommands* validCommands;
+       CommandFactory* validCommands;
        
 private:
                
index 9ac565bd49088f594a03e30351279b4231d242ea..18a294801c961b7294bcf3985e733798cfe4d77a 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include "nocommands.h"
-#include "validcommands.h"
 
 //**********************************************************************************************************************
 
@@ -24,7 +23,7 @@ int NoCommand::execute(){
        //Could choose to give more help here?fdsah
        cout << "Invalid command." << "\n";
        
-       ValidCommands* valid = new ValidCommands();
+       CommandFactory* valid = new CommandFactory();
        valid->printCommands(cout);
        delete valid;
        
index 2da23d931a1577fb25e93928a6720dffce60fbc9..5b84b65d5a518e77ea754d580e46fe9681db9ae1 100644 (file)
@@ -12,6 +12,7 @@
 /* This command is run if the user enters an invalid command. */
 
 #include "command.hpp"
+#include "commandfactory.hpp"
 
 class NoCommand : public Command {
 
diff --git a/validcommands.cpp b/validcommands.cpp
deleted file mode 100644 (file)
index e5f93a9..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *  validcommands.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "validcommands.h"
-
-/***********************************************************************/
-
-ValidCommands::ValidCommands() {
-       try {
-       
-               commands["read.dist"]                   = "read.dist"; 
-               commands["read.otu"]                    = "read.otu";
-               commands["read.tree"]                   = "read.tree"; 
-               commands["bin.seqs"]                    = "bin.seqs"; 
-               commands["get.oturep"]                  = "get.oturep";
-               commands["cluster"]                             = "cluster"; 
-               commands["unique.seqs"]                 = "unique.seqs"; 
-               commands["dist.seqs"]                   = "dist.seqs";
-               commands["dist.shared"]                 = "dist.shared";
-               commands["collect.single"]              = "collect.single"; 
-               commands["collect.shared"]              = "collect.shared"; 
-               commands["rarefaction.single"]  = "rarefaction.single"; 
-               commands["rarefaction.shared"]  = "rarefaction.shared"; 
-               commands["summary.single"]              = "summary.single"; 
-               commands["summary.shared"]              = "summary.shared"; 
-               commands["parsimony"]                   = "parsimony";
-               commands["unifrac.weighted"]    = "unifrac.weighted"; 
-               commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
-               commands["libshuff"]                    = "libshuff";
-               commands["tree.shared"]                 = "tree.shared";
-               commands["heatmap.bin"]                 = "heatmap.bin";
-               commands["heatmap.sim"]                 = "heatmap.sim";
-               commands["venn"]                                = "venn";
-               commands["get.group"]           = "get.group";
-               commands["get.label"]           = "get.label";
-               commands["get.line"]            = "get.line";
-               commands["get.sabund"]          = "get.sabund";
-               commands["get.rabund"]          = "get.rabund";
-               commands["bootstrap.shared"]    = "bootstrap.shared";
-               commands["concensus"]                   = "concensus";
-               commands["help"]                                = "help"; 
-               commands["filter.seqs"]                 = "filter.seqs";
-               commands["align.seqs"]                  = "align.seqs";
-               commands["summary.seqs"]                = "summary.seqs";
-               commands["screen.seqs"]                 = "screen.seqs";
-               commands["reverse.seqs"]                = "reverse.seqs";
-               commands["trim.seqs"]                   = "trim.seqs";
-               commands["quit"]                                = "quit"; 
-
-                               
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCommands class function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-
-ValidCommands::~ValidCommands() {}
-
-/***********************************************************************/
-bool ValidCommands::isValidCommand(string command) {
-       try {   
-       
-               //is the command in the map
-               if ((commands.find(command)) != (commands.end())) {
-                       return true;
-               }else{
-                       cout << command << " is not a valid command in Mothur.  Valid commands are ";
-                       for (it = commands.begin(); it != commands.end(); it++) {
-                               cout << it->first << ", ";
-                       }
-                       cout << endl;
-                       return false;
-               }
-               
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCommands class function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void ValidCommands::printCommands(ostream& out) {
-       try {   
-               out << "Valid commands are ";
-               for (it = commands.begin(); it != commands.end(); it++) {
-                       out << it->first << ", ";
-               }
-               out << endl;
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ValidCommands class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-
-
-
diff --git a/validcommands.h b/validcommands.h
deleted file mode 100644 (file)
index 091281e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef VALIDCOMMANDS_H
-#define VALIDCOMMANDS_H
-
-/*
- *  validcommands.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-//This class contains a list of all valid commands in Mothur.  
-//It has a function which will tell you if your command is valid.
-//When adding a new command you must add it to the valid list in the class constructor.
-
-class ValidCommands {
-
-       public:
-               ValidCommands();
-               ~ValidCommands();
-               bool isValidCommand(string);
-               void printCommands(ostream&);
-       private:
-               map<string, string> commands;
-               map<string, string>::iterator it;
-
-};
-
-#endif