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