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"
16 /**************************************************************************************************/
18 GlobalData* GlobalData::_uniqueInstance = 0;
19 CommandFactory* CommandFactory::_uniqueInstance = 0;
20 MothurOut* MothurOut::_uniqueInstance = 0;
22 /***********************************************************************/
23 volatile int ctrlc_pressed = 0;
24 void ctrlc_handler ( int sig ) {
25 MothurOut* m = MothurOut::getInstance();
27 m->control_pressed = ctrlc_pressed;
29 if (m->executing) { //if mid command quit execution, else quit mothur
30 m->mothurOutEndLine(); m->mothurOut("quitting command..."); m->mothurOutEndLine();
32 m->mothurOut("quitting mothur"); m->mothurOutEndLine();
36 /***********************************************************************/
37 int main(int argc, char *argv[]){
38 MothurOut* m = MothurOut::getInstance();
41 signal(SIGINT, ctrlc_handler );
43 time_t ltime = time(NULL); /* calendar time */
44 string logFileName = "mothur." + toString(ltime) + ".logfile";
46 m->setFileName(logFileName);
49 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
51 #if defined (__APPLE__) || (__MACH__)
52 m->mothurOutJustToLog("Mac version");
53 m->mothurOutEndLine(); m->mothurOutEndLine();
55 m->mothurOutJustToLog("Linux version");
56 >m->mothurOutEndLine(); m->mothurOutEndLine();
61 m->mothurOutJustToLog("Windows version");
62 m->mothurOutEndLine(); m->mothurOutEndLine();
66 m->mothurOutJustToLog("Using ReadLine");
67 m->mothurOutEndLine(); m->mothurOutEndLine();
71 m->mothurOut("mothur v.1.8");
72 m->mothurOutEndLine();
73 m->mothurOut("Last updated: 2/02/2010");
74 m->mothurOutEndLine();
75 m->mothurOutEndLine();
77 m->mothurOutEndLine();
78 m->mothurOut("Patrick D. Schloss");
79 m->mothurOutEndLine();
80 m->mothurOutEndLine();
81 m->mothurOut("Department of Microbiology & Immunology");
82 m->mothurOutEndLine();
83 m->mothurOut("University of Michigan");
84 m->mothurOutEndLine();
85 m->mothurOut("pschloss@umich.edu");
86 m->mothurOutEndLine();
87 m->mothurOut("http://www.mothur.org");
88 m->mothurOutEndLine();
89 m->mothurOutEndLine();
90 m->mothurOut("When using, please cite:");
91 m->mothurOutEndLine();
92 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.");
93 m->mothurOutEndLine();
94 m->mothurOutEndLine();
95 m->mothurOut("Distributed under the GNU General Public License");
96 m->mothurOutEndLine();
97 m->mothurOutEndLine();
98 m->mothurOut("Type 'help()' for information on the commands that are available");
99 m->mothurOutEndLine();
100 m->mothurOutEndLine();
101 m->mothurOut("Type 'quit()' to exit program");
102 m->mothurOutEndLine();
105 m->mothurOutJustToLog("Using MPI\n");
106 MPI_Init(&argc, &argv);
110 srand( (unsigned)time( NULL ) );
119 if (input[0] == '#') {
120 m->mothurOutJustToLog("Script Mode");
121 m->mothurOutEndLine(); m->mothurOutEndLine();
123 mothur = new ScriptEngine(argv[0], argv[1]);
125 m->mothurOutJustToLog("Batch Mode");
126 m->mothurOutEndLine(); m->mothurOutEndLine();
128 mothur = new BatchEngine(argv[0], argv[1]);
132 m->mothurOutJustToLog("Interactive Mode");
133 m->mothurOutEndLine(); m->mothurOutEndLine();
135 mothur = new InteractEngine(argv[0]);
138 while(bail == 0) { bail = mothur->getInput(); }
140 string outputDir = mothur->getOutputDir();
141 string newlogFileName = outputDir + logFileName;
143 //need this because m->mothurOut makes the logfile, but doesn't know where to put it
144 rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
154 catch(exception& e) {
155 m->errorOut(e, "mothur", "main");
160 /**************************************************************************************************/