Next version of JABA
[jabaws.git] / binaries / src / clustalw / src / interface / CommandLineParser.h
1 /**
2  * Author: Mark Larkin
3  * 
4  * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.  
5  */
6 /**
7  * The class CommandLineParser is used to parse the command line arguments. It then
8  * sets some parameters, and calls the required functions.
9  * To get it to parse the command line, and execute the required job, create a 
10  * CommandLineParser object and pass the list of arguments to the constructor.
11  */
12
13 #ifndef COMMANDLINEPARSER_H
14 #define COMMANDLINEPARSER_H
15
16 #include <vector>
17 #include <string>
18 #include "../Clustal.h"
19 #include "../general/clustalw.h"
20 #include "../general/userparams.h"
21 #include "../general/utils.h"
22 #include "../general/debuglogObject.h"
23 #include "../general/statsObject.h"
24 namespace clustalw
25 {
26
27 typedef std::vector<std::string> StringArray;
28
29 typedef struct {
30     const char *str;
31     int *flag;
32     int type;
33     StringArray* arg;
34 } CmdLineData;
35
36 class CommandLineParser
37 {
38     public:
39         /* Functions */
40         CommandLineParser(StringArray* args, bool xmenus);
41         ~CommandLineParser();
42
43     private:
44         /* Functions */
45         
46         /** separate argument options and values
47          * 
48          * put all the parameters and their values in the
49          * vectors, and also to check that all parameters that require a value
50          * have it.
51          *
52          * @param args contains parameters as value and optional option pairs
53          * @param parameters used for storing parsed arguments
54          * @param paramArgs used for storing values of parsed arguments
55          * @return number of parsed parameters or -1 on error
56          */
57         int checkParam(StringArray* args, StringArray* params, StringArray* paramArg);
58
59         /** Parse all parameters
60          */
61         void parseParams(StringArray* args, bool xmenus);
62         void setOptionalParam();
63         int findMatch(string probe, StringArray* list, int n);
64         CmdLineData getCmdLineDataStruct(const char *str, int *flag, int type, StringArray* arg);
65         void printCmdLineData(const CmdLineData& temp);
66         string ConvertStringToLower(string strToConvert);
67         void exitWithErrorMsg(string msg);
68         void reportBadOptionAndExit(string option, string expectedType);
69         void reportInvalidOptionAndExit(string option);
70
71         
72         /* Attributes */
73         Clustal *clustalObj;
74         
75         static const int MAXARGS = 100;
76         static const int NOARG = 0;
77         static const int INTARG = 1;
78         static const int FLTARG = 2;
79         static const int STRARG = 3;
80         static const int FILARG = 4;
81         static const int OPTARG = 5;
82         
83         int setOptions;
84         int setHelp;
85         int setFullHelp;
86         int setQuiet;
87         int setInteractive;
88         int setBatch;
89         int setGapOpen;
90         int setGapExtend;
91         int setPWGapOpen;
92         int setPWGapExtend;
93         int setOutOrder;
94         int setBootLabels;
95         int setPWMatrix;
96         int setMatrix;
97         int setPWDNAMatrix;
98         int setDNAMatrix;
99         int setNegative;
100         int setNoWeights;
101         int setOutput;
102         int setOutputTree;
103         int setQuickTree;
104         int setType;
105         int setCase;
106         int setSeqNo;
107         int setSeqNoRange;
108         int setRange;
109         int setTransWeight;
110         int setSeed;
111         int setScore;
112         int setWindow;
113         int setKtuple;
114         int setKimura;
115         int setTopDiags;
116         int setPairGap;
117         int setTossGaps;
118         int setNoPGap;
119         int setNoHGap;
120         int setNoVGap;
121         int setHGapRes;
122         int setUseEndGaps;
123         int setMaxDiv;
124         int setGapDist;
125         int setDebug;
126         int setOutfile;
127         int setInfile;
128         int setProfile1;
129         int setProfile2;
130         int setAlign;
131         int setConvert;
132         int setNewTree;
133         int setUseTree;
134         int setNewTree1;
135         int setUseTree1;
136         int setNewTree2;
137         int setUseTree2;
138         int setBootstrap;
139         int setTree;
140         int setProfile;
141         int setSequences;
142         int setSecStruct1;
143         int setSecStruct2;
144         int setSecStructOutput;
145         int setHelixGap;
146         int setStrandGap;
147         int setLoopGap;
148         int setTerminalGap;
149         int setHelixEndIn;
150         int setHelixEndOut;
151         int setStrandEndIn;
152         int setStrandEndOut;
153         int profileType;
154         int setDoIteration;
155         int setNumIterations;
156         int setTreeAlgorithm;
157         int setMaxSeqLen;
158         int setStatsFile;
159         int setOutputPim;
160         
161         string userMatrixName;
162         string pwUserMatrixName;
163         string DNAUserMatrixName;
164         string pwDNAUserMatrixName;
165         
166         CmdLineData cmdLineFile[4];
167         CmdLineData cmdLineVerb[20];
168         CmdLineData cmdLinePara[56];
169         
170         string clustalTreeName;
171         string distTreeName;
172         string phylipTreeName;
173         string nexusTreeName;
174         string p1TreeName;
175         string p2TreeName;
176         string pimName;
177         
178         StringArray* typeArg;
179         StringArray* bootLabelsArg;
180         StringArray* outOrderArg;
181         StringArray* caseArg;
182         StringArray* seqNoArg;
183         StringArray* seqNoRangeArg;
184         StringArray* scoreArg;
185         StringArray* outputArg;
186         StringArray* outputTreeArg;
187         StringArray* outputSecStrArg;
188         StringArray* cmdLineType;
189         StringArray* clusterAlgorithm;
190         StringArray* iterationArg;
191         
192         StringArray* params; // parameter names
193         StringArray* paramArg; // parameter values
194 };
195
196 }
197 #endif