]> git.donarmstrong.com Git - mothur.git/blob - mothur.cpp
added set.dir command and modified commands to redirect input and output, removed...
[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                 //remove old logfile
23 //              string log = "mothur.logFile";
24 //              remove(log.c_str());
25                 
26                 time_t ltime = time(NULL); /* calendar time */  
27                 string logFileName = "mothur." + toString(ltime) + ".logfile";
28                 
29                 //version
30                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
31                         system("clear");
32                         #if defined (__APPLE__) || (__MACH__)
33                                 mothurOutJustToLog("Mac version");
34                                 mothurOutEndLine(); mothurOutEndLine();
35                         #else
36                                 mothurOutJustToLog("Linux version");
37                                 mothurOutEndLine(); mothurOutEndLine();
38                         #endif
39
40                 #else
41                         system("CLS");
42                         mothurOutJustToLog("Windows version");
43                         mothurOutEndLine(); mothurOutEndLine();
44                 #endif          
45
46                 
47                 //header
48                 mothurOut("mothur v.1.7.2");
49                 mothurOutEndLine();             
50                 mothurOut("Last updated: 12/04/2009");
51                 mothurOutEndLine();     
52                 mothurOutEndLine();             
53                 mothurOut("by");
54                 mothurOutEndLine();             
55                 mothurOut("Patrick D. Schloss");
56                 mothurOutEndLine();
57                 mothurOutEndLine();                     
58                 mothurOut("Department of Microbiology & Immunology");
59                 mothurOutEndLine();     
60                 mothurOut("University of Michigan");
61                 mothurOutEndLine();                     
62                 mothurOut("pschloss@umich.edu");
63                 mothurOutEndLine();             
64                 mothurOut("http://www.mothur.org");
65                 mothurOutEndLine();
66                 mothurOutEndLine();
67                 mothurOut("When using, please cite:");
68                 mothurOutEndLine();
69                 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.");
70                 mothurOutEndLine();     
71                 mothurOutEndLine();             
72                 mothurOut("Distributed under the GNU General Public License");
73                 mothurOutEndLine();
74                 mothurOutEndLine();                     
75                 mothurOut("Type 'help()' for information on the commands that are available");
76                 mothurOutEndLine();
77                 mothurOutEndLine();                     
78                 mothurOut("Type 'quit()' to exit program");
79                 mothurOutEndLine();     
80
81                                 
82                 //srand(54321);
83                 srand( (unsigned)time( NULL ) );
84                 
85                 Engine* mothur;
86                 bool bail = 0;
87                 string input;
88
89                 if(argc>1){
90                         input = argv[1];
91
92                         if (input[0] == '#') {
93                                 mothur = new ScriptEngine(argv[0], argv[1]);
94                         }else{
95                                 mothur = new BatchEngine(argv[0], argv[1]);
96                         }
97                 }
98                 else{
99                         mothur = new InteractEngine(argv[0]);   
100                 }
101                 
102                 while(bail == 0)                {       bail = mothur->getInput();                      }
103                 
104                 string outputDir = mothur->getOutputDir();
105                 logFileName = outputDir + logFileName;
106         
107                 delete mothur;
108                 
109 //              rename(log.c_str(), logFileName.c_str()); //logfile with timestamp
110                 
111                 return 0;
112         }
113         catch(exception& e) {
114                 errorOut(e, "mothur", "main");
115                 exit(1);
116         }
117 }
118
119 /**************************************************************************************************/
120