]> git.donarmstrong.com Git - mothur.git/blob - mothur.cpp
chimeras, fix to sabundvector and sharedsabundvector that caused getRabundVector...
[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                 #ifdef USE_READLINE
46                         mothurOutJustToLog("Using ReadLine");
47                         mothurOutEndLine(); mothurOutEndLine();
48                 #endif
49                 
50                 //header
51                 mothurOut("mothur v.1.8");
52                 mothurOutEndLine();             
53                 mothurOut("Last updated: 2/02/2010");
54                 mothurOutEndLine();     
55                 mothurOutEndLine();             
56                 mothurOut("by");
57                 mothurOutEndLine();             
58                 mothurOut("Patrick D. Schloss");
59                 mothurOutEndLine();
60                 mothurOutEndLine();                     
61                 mothurOut("Department of Microbiology & Immunology");
62                 mothurOutEndLine();     
63                 mothurOut("University of Michigan");
64                 mothurOutEndLine();                     
65                 mothurOut("pschloss@umich.edu");
66                 mothurOutEndLine();             
67                 mothurOut("http://www.mothur.org");
68                 mothurOutEndLine();
69                 mothurOutEndLine();
70                 mothurOut("When using, please cite:");
71                 mothurOutEndLine();
72                 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.");
73                 mothurOutEndLine();     
74                 mothurOutEndLine();             
75                 mothurOut("Distributed under the GNU General Public License");
76                 mothurOutEndLine();
77                 mothurOutEndLine();                     
78                 mothurOut("Type 'help()' for information on the commands that are available");
79                 mothurOutEndLine();
80                 mothurOutEndLine();                     
81                 mothurOut("Type 'quit()' to exit program");
82                 mothurOutEndLine();     
83
84                                 
85                 //srand(54321);
86                 srand( (unsigned)time( NULL ) );
87                 
88                 Engine* mothur;
89                 bool bail = 0;
90                 string input;
91
92                 if(argc>1){
93                         input = argv[1];
94
95                         if (input[0] == '#') {
96                                 mothurOutJustToLog("Script Mode");
97                                 mothurOutEndLine(); mothurOutEndLine();
98
99                                 mothur = new ScriptEngine(argv[0], argv[1]);
100                         }else{
101                                 mothurOutJustToLog("Batch Mode");
102                                 mothurOutEndLine(); mothurOutEndLine();
103                                 
104                                 mothur = new BatchEngine(argv[0], argv[1]);
105                         }
106                 }
107                 else{
108                         mothurOutJustToLog("Interactive Mode");
109                         mothurOutEndLine(); mothurOutEndLine();
110                         
111                         mothur = new InteractEngine(argv[0]);   
112                 }
113                 
114                 while(bail == 0)                {       bail = mothur->getInput();                      }
115                 
116                 string outputDir = mothur->getOutputDir();
117                 logFileName = outputDir + logFileName;
118         
119                 //need this because mothur.h makes the logfile, but doesn't know where to put it
120                 rename(log.c_str(), logFileName.c_str()); //logfile with timestamp
121                 
122                 delete mothur;
123
124                 return 0;
125         }
126         catch(exception& e) {
127                 errorOut(e, "mothur", "main");
128                 exit(1);
129         }
130 }
131
132 /**************************************************************************************************/
133