]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.cpp
added set.dir command and modified commands to redirect input and output, removed...
[mothur.git] / mothur.cpp
index add60fa22f5c9a95137b651cf694dd6f27132ad7..d4177e3368be8d836374e935b9e884d6ff26c5f4 100644 (file)
 #include "engine.hpp"
 #include "globaldata.hpp"
 
-using namespace std;
-
 /**************************************************************************************************/
 
 GlobalData* GlobalData::_uniqueInstance = 0;
+CommandFactory* CommandFactory::_uniqueInstance = 0;
 
 int main(int argc, char *argv[]){
        try {
+               
+               //remove old logfile
+//             string log = "mothur.logFile";
+//             remove(log.c_str());
+               
+               time_t ltime = time(NULL); /* calendar time */  
+               string logFileName = "mothur." + toString(ltime) + ".logfile";
+               
+               //version
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       system("clear");
+                       #if defined (__APPLE__) || (__MACH__)
+                               mothurOutJustToLog("Mac version");
+                               mothurOutEndLine(); mothurOutEndLine();
+                       #else
+                               mothurOutJustToLog("Linux version");
+                               mothurOutEndLine(); mothurOutEndLine();
+                       #endif
+
+               #else
+                       system("CLS");
+                       mothurOutJustToLog("Windows version");
+                       mothurOutEndLine(); mothurOutEndLine();
+               #endif          
+
+               
+               //header
+               mothurOut("mothur v.1.7.2");
+               mothurOutEndLine();             
+               mothurOut("Last updated: 12/04/2009");
+               mothurOutEndLine();     
+               mothurOutEndLine();             
+               mothurOut("by");
+               mothurOutEndLine();             
+               mothurOut("Patrick D. Schloss");
+               mothurOutEndLine();
+               mothurOutEndLine();                     
+               mothurOut("Department of Microbiology & Immunology");
+               mothurOutEndLine();     
+               mothurOut("University of Michigan");
+               mothurOutEndLine();                     
+               mothurOut("pschloss@umich.edu");
+               mothurOutEndLine();             
+               mothurOut("http://www.mothur.org");
+               mothurOutEndLine();
+               mothurOutEndLine();
+               mothurOut("When using, please cite:");
+               mothurOutEndLine();
+               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.");
+               mothurOutEndLine();     
+               mothurOutEndLine();             
+               mothurOut("Distributed under the GNU General Public License");
+               mothurOutEndLine();
+               mothurOutEndLine();                     
+               mothurOut("Type 'help()' for information on the commands that are available");
+               mothurOutEndLine();
+               mothurOutEndLine();                     
+               mothurOut("Type 'quit()' to exit program");
+               mothurOutEndLine();     
+
+                               
                //srand(54321);
                srand( (unsigned)time( NULL ) );
-
+               
                Engine* mothur;
                bool bail = 0;
+               string input;
 
                if(argc>1){
-                       mothur = new BatchEngine(argv[0], argv[1]);
+                       input = argv[1];
+
+                       if (input[0] == '#') {
+                               mothur = new ScriptEngine(argv[0], argv[1]);
+                       }else{
+                               mothur = new BatchEngine(argv[0], argv[1]);
+                       }
                }
                else{
-                       mothur = new InteractEngine(argv[0]);           
+                       mothur = new InteractEngine(argv[0]);   
                }
-
+               
                while(bail == 0)                {       bail = mothur->getInput();                      }
+               
+               string outputDir = mothur->getOutputDir();
+               logFileName = outputDir + logFileName;
        
                delete mothur;
-       
+               
+//             rename(log.c_str(), logFileName.c_str()); //logfile with timestamp
+               
                return 0;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the dotur class Function main. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the dotur class function main. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "mothur", "main");
                exit(1);
        }
 }