Next version of JABA
[jabaws.git] / binaries / src / clustalw / src / main.cpp
1 /**
2  * Author: Mark Larkin
3  * 
4  * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.  
5  */
6 #ifdef HAVE_CONFIG_H
7     #include "config.h"
8 #endif
9 #include <iostream>
10 #include "alignment/Alignment.h"
11 #include "alignment/Sequence.h"
12 #include "general/clustalw.h"
13 #include "general/UserParameters.h"
14 #include "substitutionMatrix/SubMatrix.h"
15 #include "general/Utility.h"
16 #include "fileInput/FileReader.h"
17 #include "interface/InteractiveMenu.h"
18 #include "interface/CommandLineParser.h"
19 #include "general/DebugLog.h"
20 #include "general/ClustalWResources.h"
21 #include "general/Stats.h"
22 #include <ctime>
23 namespace clustalw
24
25     UserParameters* userParameters;
26     Utility* utilityObject;
27     SubMatrix *subMatrix; 
28     DebugLog* logObject;
29     Stats* statsObject;
30 }
31 using namespace std;
32 using namespace clustalw;
33
34 int main(int argc, char **argv)
35 {      
36     userParameters = new UserParameters(false);
37     utilityObject = new Utility();   
38     subMatrix = new SubMatrix();
39     statsObject = new Stats();
40     ClustalWResources *resources = ClustalWResources::Instance();
41     resources->setPathToExecutable(string(argv[0]));
42     userParameters->setDisplayInfo(true);
43
44
45     
46     //userParameters->setDebug(5);       
47     #if DEBUGFULL    
48         if(DEBUGLOG)
49         {
50             cout << "debugging is on\n\n\n";
51             logObject = new DebugLog("logfile.txt");
52             logObject->logMsg("Loggin is on!");
53         }
54     #endif
55
56     if (argc > 1)
57     {    
58         //time_t start, end;
59         //double dif;
60         //start = time (NULL);
61         //userParameters->setDisplayInfo(false);        
62         vector<string> args;
63         for (int i = 1; i < argc; ++i)
64         {
65             args.push_back(argv[i]);
66         }
67         CommandLineParser cmdLineParser(&args, false);
68         
69         if (statsObject->isEnabled())
70             statsObject->logCmdLine(argc,argv);
71         
72         //end = time (NULL);
73         //dif = difftime(end, start);
74         //cout << "It took " << dif << " seconds\n";
75     }
76     if (argc<=1 || userParameters->getInteractive())
77     {
78         // FIXME: additional parameters like infile are ignored!
79         InteractiveMenu menu;
80         userParameters->setMenuFlag(true);
81         userParameters->setInteractive(true);
82         menu.mainMenu();
83     }
84     delete userParameters;
85     delete utilityObject;
86     delete subMatrix;
87     
88     if(logObject)
89     {
90         delete logObject;
91     }
92     return 0;
93 }
94