]> git.donarmstrong.com Git - mothur.git/commitdiff
added set.logfile command
authorwestcott <westcott>
Wed, 28 Apr 2010 11:09:48 +0000 (11:09 +0000)
committerwestcott <westcott>
Wed, 28 Apr 2010 11:09:48 +0000 (11:09 +0000)
Mothur.xcodeproj/project.pbxproj
commandfactory.cpp
commandfactory.hpp
engine.hpp
makefile
mothur.cpp
setlogfilecommand.cpp [new file with mode: 0644]
setlogfilecommand.h [new file with mode: 0644]

index cc3b4b6a472230fe32f51c559792ecc2f7bb3cc4..3ee1d81bc1944bdb301d2930b82b03cb51e2be63 100644 (file)
@@ -14,6 +14,8 @@
                A7639F8D1175DF35008F5578 /* makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = makefile; sourceTree = "<group>"; };
                A76AAD02117F322B003D8DA1 /* phylosummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylosummary.h; sourceTree = "<group>"; };
                A76AAD03117F322B003D8DA1 /* phylosummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylosummary.cpp; sourceTree = "<group>"; };
+               A76C4A1011876BAF0009460B /* setlogfilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setlogfilecommand.h; sourceTree = SOURCE_ROOT; };
+               A76C4A1111876BAF0009460B /* setlogfilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = setlogfilecommand.cpp; sourceTree = SOURCE_ROOT; };
                A78254461164D7790002E2DD /* chimerapintailcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerapintailcommand.h; sourceTree = "<group>"; };
                A78254471164D7790002E2DD /* chimerapintailcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimerapintailcommand.cpp; sourceTree = "<group>"; };
                A7825502116519F70002E2DD /* chimerabellerophoncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerabellerophoncommand.h; sourceTree = "<group>"; };
                                A7DA20FD113FECD400BF472F /* seqsummarycommand.h */,
                                A7DA2102113FECD400BF472F /* setdircommand.cpp */,
                                A7DA2103113FECD400BF472F /* setdircommand.h */,
+                               A76C4A1011876BAF0009460B /* setlogfilecommand.h */,
+                               A76C4A1111876BAF0009460B /* setlogfilecommand.cpp */,
                                A7DA210F113FECD400BF472F /* sharedcommand.cpp */,
                                A7DA2110113FECD400BF472F /* sharedcommand.h */,
                                A7DA2154113FECD400BF472F /* summarycommand.cpp */,
index aaeec67f1b4eec4e2194fc014e87064c1d5c2b5c..cad0442747f2ff7a5ada7b24d4ba18ad9138643c 100644 (file)
@@ -71,6 +71,7 @@
 #include "chimeraslayercommand.h"
 #include "chimerapintailcommand.h"
 #include "chimerabellerophoncommand.h"
+#include "setlogfilecommand.h"
 
 /*******************************************************/
 
@@ -97,6 +98,8 @@ CommandFactory::CommandFactory(){
        command = new NoCommand(s);
        
        outputDir = ""; inputDir = "";
+       logFileName = "";
+       append = false;
        
        //initialize list of valid commands
        commands["read.dist"]                   = "read.dist"; 
@@ -149,6 +152,7 @@ CommandFactory::CommandFactory(){
        commands["merge.files"]                 = "merge.files";
        commands["parse.list"]                  = "parse.list";
        commands["parse.sff"]                   = "parse.sff";
+       commands["set.logfile"]                 = "set.logfile";
        commands["classify.seqs"]               = "MPIEnabled"; 
        commands["dist.seqs"]                   = "MPIEnabled";
        commands["filter.seqs"]                 = "MPIEnabled";
@@ -260,6 +264,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                else if(commandName == "pcoa")                                  {       command = new PCACommand(optionString);                                         }
                else if(commandName == "otu.hierarchy")                 {       command = new OtuHierarchyCommand(optionString);                        }
                else if(commandName == "set.dir")                               {       command = new SetDirectoryCommand(optionString);                        }
+               else if(commandName == "set.logfile")                   {       command = new SetLogFileCommand(optionString);                          }
                else if(commandName == "parse.list")                    {       command = new ParseListCommand(optionString);                           }
                else if(commandName == "parse.sff")                             {       command = new ParseSFFCommand(optionString);                            }
                else                                                                                    {       command = new NoCommand(optionString);                                          }
index 3b6a17e38b2abb74b152da573a9bf2f1666e62e6..44e78fd66fa290d9664d773f470249f0600a2836 100644 (file)
@@ -22,9 +22,12 @@ public:
        Command* getCommand();\r
        bool isValidCommand(string);\r
        void printCommands(ostream&);\r
-       void setOutputDirectory(string o)       {       outputDir = o;          }\r
-       void setInputDirectory(string i)        {       inputDir = i;           }\r
-       string getOutputDir()                   {       return outputDir;               }\r
+       void setOutputDirectory(string o)               {       outputDir = o;          }\r
+       void setInputDirectory(string i)                {       inputDir = i;           }\r
+       void setLogfileName(string n, bool a)   {       logFileName = n;  append = a;           }\r
+       string getLogfileName()                                 {       return logFileName;     }\r
+       bool getAppend()                                                {       return append;                  }\r
+       string getOutputDir()                                   {       return outputDir;               }\r
        bool MPIEnabled(string);\r
 \r
 private:\r
@@ -32,7 +35,8 @@ private:
        MothurOut* m;\r
        map<string, string> commands;\r
        map<string, string>::iterator it;\r
-       string outputDir, inputDir;\r
+       string outputDir, inputDir, logFileName;\r
+       bool append;\r
        \r
        static CommandFactory* _uniqueInstance;\r
        CommandFactory( const CommandFactory& ); // Disable copy constructor\r
index 74687d2398c84a532b0ba6c68e17ed8cff1f7cf0..0020a7f8d9d83a24b5b24c60fb0f86263edd5e44 100644 (file)
@@ -27,7 +27,10 @@ public:
        virtual ~Engine(){}
        virtual bool getInput() = 0;
        virtual string getCommand();
-       virtual string getOutputDir()   {       return cFactory->getOutputDir();  }
+       virtual string getOutputDir()                   {       return cFactory->getOutputDir();        }
+       virtual string getLogFileName()                 {       return cFactory->getLogfileName();      }
+       virtual bool getAppend()                                {       return cFactory->getAppend();           }
+
        vector<string> getOptions()             {       return options;         }
 protected:
        vector<string> options;
index d4aac7f8f4fc2252cb51ab17ca553f36b265de00..181b897a16f87b1f5e1cd2689d4c1621dbeac3c1 100644 (file)
--- a/makefile
+++ b/makefile
@@ -239,7 +239,8 @@ mothur : \
                ./qstat.o\\r
                ./shen.o\\r
                ./logsd.o\\r
-               ./geom.o\r
+               ./geom.o\
+               ./setlogfilecommand.o\r
        $(CC) $(LNK_OPTIONS) \\r
                ./sharedutilities.o\\r
                ./treegroupscommand.o\\r
@@ -437,7 +438,8 @@ mothur : \
                ./qstat.o\\r
                ./shen.o\\r
                ./logsd.o\\r
-               ./geom.o\\r
+               ./geom.o\
+               ./setlogfilecommand.o\\r
                -o ../Release/mothur\r
 \r
 clean : \r
@@ -638,7 +640,8 @@ clean :
                ./qstat.o\\r
                ./shen.o\\r
                ./logsd.o\\r
-               ./geom.o\\r
+               ./geom.o\
+               ./setlogfilecommand.o\\r
                mothur\r
 \r
 install : mothur\r
@@ -1623,9 +1626,13 @@ install : mothur
 ./chimerabellerophoncommand.o : chimerabellerophoncommand.cpp\r
        $(CC) $(CC_OPTIONS) chimerabellerophoncommand.cpp -c $(INCLUDE) -o ./chimerabellerophoncommand.o\r
 
-# Item # 171 -- phylosummary --\r
+# Item # 197 -- phylosummary --\r
 ./phylosummary.o : phylosummary.cpp\r
        $(CC) $(CC_OPTIONS) phylosummary.cpp -c $(INCLUDE) -o ./phylosummary.o\r
+
+# Item # 198 -- setlogfilecommand --\r
+./setlogfilecommand.o : setlogfilecommand.cpp\r
+       $(CC) $(CC_OPTIONS) setlogfilecommand.cpp -c $(INCLUDE) -o ./setlogfilecommand.o\r
 \r
 \r
 \r
index 2d35c698cdb8bbcbb9a910a7b4c5e96f3fbd42f5..4f91c2e90a0b52aa8c3f51140e857660e8ba038f 100644 (file)
-/*\r
- *  interface.cpp\r
- *  \r
- *\r
- *  Created by Pat Schloss on 8/14/08.\r
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.\r
- *\r
- */\r
\r
-#include "mothur.h"\r
-#include "engine.hpp"\r
-#include "globaldata.hpp"\r
-#include "mothurout.h"\r
-\r
-\r
-/**************************************************************************************************/\r
-\r
-GlobalData* GlobalData::_uniqueInstance = 0;\r
-CommandFactory* CommandFactory::_uniqueInstance = 0;\r
-MothurOut* MothurOut::_uniqueInstance = 0;\r
-\r
-/***********************************************************************/\r
-volatile int ctrlc_pressed = 0;\r
-void ctrlc_handler ( int sig ) {\r
-       MothurOut* m = MothurOut::getInstance();\r
-    ctrlc_pressed = 1;\r
-       m->control_pressed = ctrlc_pressed;\r
-       \r
-       if (m->executing) { //if mid command quit execution, else quit mothur\r
-               m->mothurOutEndLine(); m->mothurOut("quitting command...");  m->mothurOutEndLine();\r
-       }else{\r
-               m->mothurOut("quitting mothur");  m->mothurOutEndLine();\r
-               exit(1);\r
-       }\r
-}\r
-/***********************************************************************/\r
-int main(int argc, char *argv[]){\r
-       MothurOut* m = MothurOut::getInstance();\r
-       try {\r
-               \r
-               signal(SIGINT, ctrlc_handler );\r
-                               \r
-               time_t ltime = time(NULL); /* calendar time */  \r
-               string logFileName = "mothur." + toString(ltime) + ".logfile";\r
-               \r
-               #ifdef USE_MPI\r
-                       MPI_Init(&argc, &argv); \r
-               #endif\r
-\r
-               m->setFileName(logFileName);\r
-               \r
-                               \r
-               //version\r
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)\r
-                       system("clear");\r
-                       #if defined (__APPLE__) || (__MACH__)\r
-                               m->mothurOutJustToLog("Mac version");\r
-                               m->mothurOutEndLine(); m->mothurOutEndLine();\r
-                       #else\r
-                               m->mothurOutJustToLog("Linux version");\r
-                               >m->mothurOutEndLine(); m->mothurOutEndLine();\r
-                       #endif\r
-\r
-               #else\r
-                       system("CLS");\r
-                       m->mothurOutJustToLog("Windows version");\r
-                       m->mothurOutEndLine(); m->mothurOutEndLine();\r
-               #endif          \r
-               \r
-               #ifdef USE_READLINE\r
-                       m->mothurOutJustToLog("Using ReadLine");\r
-                       m->mothurOutEndLine(); m->mothurOutEndLine();\r
-               #endif\r
-               \r
-               //header\r
-               m->mothurOut("mothur v.1.9");\r
-               m->mothurOutEndLine();          \r
-               m->mothurOut("Last updated: 4/16/2010");\r
-               m->mothurOutEndLine();  \r
-               m->mothurOutEndLine();          \r
-               m->mothurOut("by");\r
-               m->mothurOutEndLine();          \r
-               m->mothurOut("Patrick D. Schloss");\r
-               m->mothurOutEndLine();\r
-               m->mothurOutEndLine();                  \r
-               m->mothurOut("Department of Microbiology & Immunology");\r
-               m->mothurOutEndLine();  \r
-               m->mothurOut("University of Michigan");\r
-               m->mothurOutEndLine();                  \r
-               m->mothurOut("pschloss@umich.edu");\r
-               m->mothurOutEndLine();          \r
-               m->mothurOut("http://www.mothur.org");\r
-               m->mothurOutEndLine();\r
-               m->mothurOutEndLine();\r
-               m->mothurOut("When using, please cite:");\r
-               m->mothurOutEndLine();\r
-               m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41.");\r
-               m->mothurOutEndLine();  \r
-               m->mothurOutEndLine();          \r
-               m->mothurOut("Distributed under the GNU General Public License");\r
-               m->mothurOutEndLine();\r
-               m->mothurOutEndLine();                  \r
-               m->mothurOut("Type 'help()' for information on the commands that are available");\r
-               m->mothurOutEndLine();\r
-               m->mothurOutEndLine();                  \r
-               m->mothurOut("Type 'quit()' to exit program");\r
-               m->mothurOutEndLine();  \r
-               \r
-               #ifdef USE_MPI\r
-                       m->mothurOutJustToLog("Using MPI\tversion ");\r
-                       int version, subversion;\r
-                       MPI_Get_version(&version, &subversion);\r
-                       m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n");\r
-               #endif\r
-               \r
-               //srand(54321);\r
-               srand( (unsigned)time( NULL ) );\r
-               \r
-               Engine* mothur;\r
-               bool bail = 0;\r
-               string input;\r
-\r
-               if(argc>1){\r
-                       input = argv[1];\r
-\r
-                       if (input[0] == '#') {\r
-                               m->mothurOutJustToLog("Script Mode");\r
-                               m->mothurOutEndLine(); m->mothurOutEndLine();\r
-\r
-                               mothur = new ScriptEngine(argv[0], argv[1]);\r
-                       }else{\r
-                               m->mothurOutJustToLog("Batch Mode");\r
-                               m->mothurOutEndLine(); m->mothurOutEndLine();\r
-                               \r
-                               mothur = new BatchEngine(argv[0], argv[1]);\r
-                       }\r
-               }\r
-               else{\r
-                       m->mothurOutJustToLog("Interactive Mode");\r
-                       m->mothurOutEndLine(); m->mothurOutEndLine();\r
-                       \r
-                       mothur = new InteractEngine(argv[0]);   \r
-               }\r
-               \r
-               while(bail == 0)        {       bail = mothur->getInput();      }\r
-               \r
-               string outputDir = mothur->getOutputDir();\r
-               string newlogFileName = outputDir + logFileName;\r
-               \r
-               //closes logfile so we can rename\r
-               m->closeLog();\r
-       \r
-               //need this because m->mothurOut makes the logfile, but doesn't know where to put it\r
-               rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp\r
-               \r
-               delete mothur;\r
-               \r
-               #ifdef USE_MPI\r
-                       MPI_Finalize();\r
-               #endif\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "mothur", "main");\r
-               exit(1);\r
-       }\r
-}\r
-\r
-/**************************************************************************************************/\r
-\r
+/*
+ *  interface.cpp
+ *  
+ *
+ *  Created by Pat Schloss on 8/14/08.
+ *  Copyright 2008 Patrick D. Schloss. All rights reserved.
+ *
+ */
+#include "mothur.h"
+#include "engine.hpp"
+#include "globaldata.hpp"
+#include "mothurout.h"
+
+
+/**************************************************************************************************/
+
+GlobalData* GlobalData::_uniqueInstance = 0;
+CommandFactory* CommandFactory::_uniqueInstance = 0;
+MothurOut* MothurOut::_uniqueInstance = 0;
+
+/***********************************************************************/
+volatile int ctrlc_pressed = 0;
+void ctrlc_handler ( int sig ) {
+       MothurOut* m = MothurOut::getInstance();
+    ctrlc_pressed = 1;
+       m->control_pressed = ctrlc_pressed;
+       
+       if (m->executing) { //if mid command quit execution, else quit mothur
+               m->mothurOutEndLine(); m->mothurOut("quitting command...");  m->mothurOutEndLine();
+       }else{
+               m->mothurOut("quitting mothur");  m->mothurOutEndLine();
+               exit(1);
+       }
+}
+/***********************************************************************/
+int main(int argc, char *argv[]){
+       MothurOut* m = MothurOut::getInstance();
+       try {
+               
+               signal(SIGINT, ctrlc_handler );
+                               
+               time_t ltime = time(NULL); /* calendar time */  
+               string logFileName = "mothur." + toString(ltime) + ".logfile";
+               
+               #ifdef USE_MPI
+                       MPI_Init(&argc, &argv); 
+               #endif
+
+               m->setFileName(logFileName);
+               
+                               
+               //version
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       system("clear");
+                       #if defined (__APPLE__) || (__MACH__)
+                               m->mothurOutJustToLog("Mac version");
+                               m->mothurOutEndLine(); m->mothurOutEndLine();
+                       #else
+                               m->mothurOutJustToLog("Linux version");
+                               >m->mothurOutEndLine(); m->mothurOutEndLine();
+                       #endif
+
+               #else
+                       system("CLS");
+                       m->mothurOutJustToLog("Windows version");
+                       m->mothurOutEndLine(); m->mothurOutEndLine();
+               #endif          
+               
+               #ifdef USE_READLINE
+                       m->mothurOutJustToLog("Using ReadLine");
+                       m->mothurOutEndLine(); m->mothurOutEndLine();
+               #endif
+               
+               //header
+               m->mothurOut("mothur v.1.9");
+               m->mothurOutEndLine();          
+               m->mothurOut("Last updated: 4/16/2010");
+               m->mothurOutEndLine();  
+               m->mothurOutEndLine();          
+               m->mothurOut("by");
+               m->mothurOutEndLine();          
+               m->mothurOut("Patrick D. Schloss");
+               m->mothurOutEndLine();
+               m->mothurOutEndLine();                  
+               m->mothurOut("Department of Microbiology & Immunology");
+               m->mothurOutEndLine();  
+               m->mothurOut("University of Michigan");
+               m->mothurOutEndLine();                  
+               m->mothurOut("pschloss@umich.edu");
+               m->mothurOutEndLine();          
+               m->mothurOut("http://www.mothur.org");
+               m->mothurOutEndLine();
+               m->mothurOutEndLine();
+               m->mothurOut("When using, please cite:");
+               m->mothurOutEndLine();
+               m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41.");
+               m->mothurOutEndLine();  
+               m->mothurOutEndLine();          
+               m->mothurOut("Distributed under the GNU General Public License");
+               m->mothurOutEndLine();
+               m->mothurOutEndLine();                  
+               m->mothurOut("Type 'help()' for information on the commands that are available");
+               m->mothurOutEndLine();
+               m->mothurOutEndLine();                  
+               m->mothurOut("Type 'quit()' to exit program");
+               m->mothurOutEndLine();  
+               
+               #ifdef USE_MPI
+                       m->mothurOutJustToLog("Using MPI\tversion ");
+                       int version, subversion;
+                       MPI_Get_version(&version, &subversion);
+                       m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n");
+               #endif
+               
+               //srand(54321);
+               srand( (unsigned)time( NULL ) );
+               
+               Engine* mothur;
+               bool bail = 0;
+               string input;
+
+               if(argc>1){
+                       input = argv[1];
+
+                       if (input[0] == '#') {
+                               m->mothurOutJustToLog("Script Mode");
+                               m->mothurOutEndLine(); m->mothurOutEndLine();
+
+                               mothur = new ScriptEngine(argv[0], argv[1]);
+                       }else{
+                               m->mothurOutJustToLog("Batch Mode");
+                               m->mothurOutEndLine(); m->mothurOutEndLine();
+                               
+                               mothur = new BatchEngine(argv[0], argv[1]);
+                       }
+               }
+               else{
+                       m->mothurOutJustToLog("Interactive Mode");
+                       m->mothurOutEndLine(); m->mothurOutEndLine();
+                       
+                       mothur = new InteractEngine(argv[0]);   
+               }
+               
+               while(bail == 0)        {       bail = mothur->getInput();      }
+               
+               //closes logfile so we can rename
+               m->closeLog();
+               
+               string outputDir = mothur->getOutputDir();
+               string tempLog = mothur->getLogFileName();
+               bool append = mothur->getAppend();
+               
+               string newlogFileName;
+               if (tempLog != "") {
+                       newlogFileName = outputDir + tempLog;
+                       
+                       if (!append) {  
+                               //need this because m->mothurOut makes the logfile, but doesn't know where to put it
+                               rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
+
+                       }else {
+                               ofstream outNewLog;
+                               openOutputFileAppend(newlogFileName, outNewLog);
+                               outNewLog << endl << endl << "*********************************************************************************" << endl << endl;
+                               outNewLog.close();
+                               
+                               appendFiles(logFileName, newlogFileName);
+                               remove(logFileName.c_str());
+                       }
+               }else{  
+                       newlogFileName = outputDir + logFileName;
+                       //need this because m->mothurOut makes the logfile, but doesn't know where to put it
+                       rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
+               }
+               
+                               
+               delete mothur;
+               
+               #ifdef USE_MPI
+                       MPI_Finalize();
+               #endif
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "mothur", "main");
+               exit(1);
+       }
+}
+
+/**************************************************************************************************/
+
diff --git a/setlogfilecommand.cpp b/setlogfilecommand.cpp
new file mode 100644 (file)
index 0000000..593664e
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *  setlogfilecommand.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 4/27/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "setlogfilecommand.h"
+
+//**********************************************************************************************************************
+
+SetLogFileCommand::SetLogFileCommand(string option)  {
+       try {
+               abort = false;
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
+               
+               else {
+                       //valid paramters for this command
+                       string Array[] =  {"name","append","outputdir","inputdir"};
+                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+                       
+                       OptionParser parser(option);
+                       map<string, string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+                       //check to make sure all parameters are valid for command
+                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+               
+                       name = validParameter.validFile(parameters, "name", false);                     
+                       if (name == "not found") {  m->mothurOut("name is a required parameter for the set.logfile command."); abort = true; } 
+                       
+                       string temp = validParameter.validFile(parameters, "append", false);            if (temp == "not found") {  temp = "F";  }
+                       append = isTrue(temp);
+               }
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "SetLogFileCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void SetLogFileCommand::help(){
+       try {
+               m->mothurOut("The set.logfile command can be used to provide a specific name for your logfile and/or to append the log generated by mothur to an existing file.\n");
+               m->mothurOut("The set.logfile command parameters are name and append, name is required. Append is set to false by default.\n");
+               m->mothurOut("The set.logfile command should be in the following format: set.logfile(name=yourLogFileName, append=T).\n");
+               m->mothurOut("Example set.logfile(name=/Users/lab/desktop/output.txt, append=T).\n");
+               m->mothurOut("Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourLogFileName).\n\n");
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "help");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+SetLogFileCommand::~SetLogFileCommand(){}
+
+//**********************************************************************************************************************
+
+int SetLogFileCommand::execute(){
+       try {
+               
+               if (abort == true) { return 0; }
+               
+               commandFactory = CommandFactory::getInstance();
+               
+               commandFactory->setLogfileName(name, append);
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************/
diff --git a/setlogfilecommand.h b/setlogfilecommand.h
new file mode 100644 (file)
index 0000000..d16bcd6
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef SETLOGFILECOMMAND_H
+#define SETLOGFILECOMMAND_H
+
+/*
+ *  setlogfilecommand.h
+ *  Mothur
+ *
+ *  Created by westcott on 4/27/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+#include "commandfactory.hpp"
+
+/**********************************************************/
+
+class SetLogFileCommand : public Command {
+       
+public:
+       SetLogFileCommand(string);
+       ~SetLogFileCommand();
+       int execute();
+       void help();
+       
+private:
+       CommandFactory* commandFactory;
+       string name;
+       bool abort, append;
+               
+};
+
+/**********************************************************/
+#endif
+
+