]> git.donarmstrong.com Git - mothur.git/blob - mothur.cpp
fixed bugs for 1.8
[mothur.git] / mothur.cpp
1 /*
2  *  interface.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 8/14/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9  
10 #include "mothur.h"
11 #include "engine.hpp"
12 #include "globaldata.hpp"
13
14 /**************************************************************************************************/
15
16 GlobalData* GlobalData::_uniqueInstance = 0;
17 CommandFactory* CommandFactory::_uniqueInstance = 0;
18
19 int main(int argc, char *argv[]){
20         try {
21                 
22                 string log = "mothur.logFile";
23                 remove(log.c_str());
24                 
25                 time_t ltime = time(NULL); /* calendar time */  
26                 string logFileName = "mothur." + toString(ltime) + ".logfile";
27                 
28                 //version
29                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
30                         system("clear");
31                         #if defined (__APPLE__) || (__MACH__)
32                                 mothurOutJustToLog("Mac version");
33                                 mothurOutEndLine(); mothurOutEndLine();
34                         #else
35                                 mothurOutJustToLog("Linux version");
36                                 mothurOutEndLine(); mothurOutEndLine();
37                         #endif
38
39                 #else
40                         system("CLS");
41                         mothurOutJustToLog("Windows version");
42                         mothurOutEndLine(); mothurOutEndLine();
43                 #endif          
44
45                 
46                 //header
47                 mothurOut("mothur v.1.8");
48                 mothurOutEndLine();             
49                 mothurOut("Last updated: 2/02/2010");
50                 mothurOutEndLine();     
51                 mothurOutEndLine();             
52                 mothurOut("by");
53                 mothurOutEndLine();             
54                 mothurOut("Patrick D. Schloss");
55                 mothurOutEndLine();
56                 mothurOutEndLine();                     
57                 mothurOut("Department of Microbiology & Immunology");
58                 mothurOutEndLine();     
59                 mothurOut("University of Michigan");
60                 mothurOutEndLine();                     
61                 mothurOut("pschloss@umich.edu");
62                 mothurOutEndLine();             
63                 mothurOut("http://www.mothur.org");
64                 mothurOutEndLine();
65                 mothurOutEndLine();
66                 mothurOut("When using, please cite:");
67                 mothurOutEndLine();
68                 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.");
69                 mothurOutEndLine();     
70                 mothurOutEndLine();             
71                 mothurOut("Distributed under the GNU General Public License");
72                 mothurOutEndLine();
73                 mothurOutEndLine();                     
74                 mothurOut("Type 'help()' for information on the commands that are available");
75                 mothurOutEndLine();
76                 mothurOutEndLine();                     
77                 mothurOut("Type 'quit()' to exit program");
78                 mothurOutEndLine();     
79
80                                 
81                 //srand(54321);
82                 srand( (unsigned)time( NULL ) );
83                 
84                 Engine* mothur;
85                 bool bail = 0;
86                 string input;
87
88                 if(argc>1){
89                         input = argv[1];
90
91                         if (input[0] == '#') {
92                                 mothur = new ScriptEngine(argv[0], argv[1]);
93                         }else{
94                                 mothur = new BatchEngine(argv[0], argv[1]);
95                         }
96                 }
97                 else{
98                         mothur = new InteractEngine(argv[0]);   
99                 }
100                 
101                 while(bail == 0)                {       bail = mothur->getInput();                      }
102                 
103                 string outputDir = mothur->getOutputDir();
104                 logFileName = outputDir + logFileName;
105         
106                 //need this because mothur.h makes the logfile, but doesn't know where to put it
107                 rename(log.c_str(), logFileName.c_str()); //logfile with timestamp
108                 
109                 delete mothur;
110
111                 return 0;
112         }
113         catch(exception& e) {
114                 errorOut(e, "mothur", "main");
115                 exit(1);
116         }
117 }
118
119 /**************************************************************************************************/
120