5 * Created by Pat Schloss on 8/14/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
12 #include "globaldata.hpp"
13 #include "mothurout.h"
15 /**************************************************************************************************/
17 GlobalData* GlobalData::_uniqueInstance = 0;
18 CommandFactory* CommandFactory::_uniqueInstance = 0;
19 MothurOut* MothurOut::_uniqueInstance = 0;
21 /***********************************************************************/
22 volatile int ctrlc_pressed = 0;
23 void ctrlc_handler ( int sig ) {
24 MothurOut* m = MothurOut::getInstance();
26 m->control_pressed = ctrlc_pressed;
28 if (m->executing) { //if mid command quit execution, else quit mothur
29 m->mothurOutEndLine(); m->mothurOut("quitting command..."); m->mothurOutEndLine();
31 m->mothurOut("quitting mothur"); m->mothurOutEndLine();
35 /***********************************************************************/
36 int main(int argc, char *argv[]){
37 MothurOut* m = MothurOut::getInstance();
40 signal(SIGINT, ctrlc_handler );
42 time_t ltime = time(NULL); /* calendar time */
43 string logFileName = "mothur." + toString(ltime) + ".logfile";
45 m->setFileName(logFileName);
48 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
50 #if defined (__APPLE__) || (__MACH__)
51 m->mothurOutJustToLog("Mac version");
52 m->mothurOutEndLine(); m->mothurOutEndLine();
54 m->mothurOutJustToLog("Linux version");
55 >m->mothurOutEndLine(); m->mothurOutEndLine();
60 m->mothurOutJustToLog("Windows version");
61 m->mothurOutEndLine(); m->mothurOutEndLine();
65 m->mothurOutJustToLog("Using ReadLine");
66 m->mothurOutEndLine(); m->mothurOutEndLine();
70 m->mothurOut("mothur v.1.8");
71 m->mothurOutEndLine();
72 m->mothurOut("Last updated: 2/02/2010");
73 m->mothurOutEndLine();
74 m->mothurOutEndLine();
76 m->mothurOutEndLine();
77 m->mothurOut("Patrick D. Schloss");
78 m->mothurOutEndLine();
79 m->mothurOutEndLine();
80 m->mothurOut("Department of Microbiology & Immunology");
81 m->mothurOutEndLine();
82 m->mothurOut("University of Michigan");
83 m->mothurOutEndLine();
84 m->mothurOut("pschloss@umich.edu");
85 m->mothurOutEndLine();
86 m->mothurOut("http://www.mothur.org");
87 m->mothurOutEndLine();
88 m->mothurOutEndLine();
89 m->mothurOut("When using, please cite:");
90 m->mothurOutEndLine();
91 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.");
92 m->mothurOutEndLine();
93 m->mothurOutEndLine();
94 m->mothurOut("Distributed under the GNU General Public License");
95 m->mothurOutEndLine();
96 m->mothurOutEndLine();
97 m->mothurOut("Type 'help()' for information on the commands that are available");
98 m->mothurOutEndLine();
99 m->mothurOutEndLine();
100 m->mothurOut("Type 'quit()' to exit program");
101 m->mothurOutEndLine();
105 srand( (unsigned)time( NULL ) );
114 if (input[0] == '#') {
115 m->mothurOutJustToLog("Script Mode");
116 m->mothurOutEndLine(); m->mothurOutEndLine();
118 mothur = new ScriptEngine(argv[0], argv[1]);
120 m->mothurOutJustToLog("Batch Mode");
121 m->mothurOutEndLine(); m->mothurOutEndLine();
123 mothur = new BatchEngine(argv[0], argv[1]);
127 m->mothurOutJustToLog("Interactive Mode");
128 m->mothurOutEndLine(); m->mothurOutEndLine();
130 mothur = new InteractEngine(argv[0]);
133 while(bail == 0) { bail = mothur->getInput(); }
135 string outputDir = mothur->getOutputDir();
136 string newlogFileName = outputDir + logFileName;
138 //need this because m->mothurOut makes the logfile, but doesn't know where to put it
139 rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
145 catch(exception& e) {
146 m->errorOut(e, "mothur", "main");
151 /**************************************************************************************************/