2 File autogenerated by gengetopt version 2.22.5
3 generated with the following command:
4 gengetopt -i RNAalifold.ggo --file-name=RNAalifold_cmdl --include-getopt --default-optional --unamed-opts --func-name=RNAalifold_cmdline_parser --arg-struct-name=RNAalifold_args_info
6 The developers of gengetopt consider the fixed text that goes in all
7 gengetopt output files to be in the public domain:
8 we make no copyright claims on it.
11 /* If we use autoconf. */
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
25 #include "RNAalifold_cmdl.h"
27 const char *RNAalifold_args_info_purpose = "calculate secondary structures for a set of aligned RNAs";
29 const char *RNAalifold_args_info_usage = "Usage: RNAalifold [options] <file1.aln>";
31 const char *RNAalifold_args_info_description = "Read aligned RNA sequences from stdin or file.aln and calculate their minimum \nfree energy (mfe) structure, partition function (pf) and base pairing \nprobability matrix. Currently, the input alignment has to be in CLUSTAL format. \nIt returns the mfe structure in bracket notation, its energy, the free energy \nof the thermodynamic ensemble and the frequency of the mfe structure in the \nensemble to stdout. It also produces Postscript files with plots of the \nresulting secondary structure graph (\"alirna.ps\") and a \"dot plot\" of the \nbase pairing matrix (\"alidot.ps\"). The file \"alifold.out\" will contain a \nlist of likely pairs sorted by credibility, suitable for viewing with \n\"AliDot.pl\". Be warned that output file will overwrite any existing files of \nthe same name.\n\n";
33 const char *RNAalifold_args_info_detailed_help[] = {
34 " -h, --help Print help and exit",
35 " --detailed-help Print help, including all details and hidden \n options, and exit",
36 " --full-help Print help, including hidden options, and exit",
37 " -V, --version Print version and exit",
39 " Below are command line options which alter the general behavior of this \n program\n",
40 " -C, --constraint Calculate structures subject to constraints.\n The constraining structure will be read from \n 'stdin', the alignment has to be given as a \n file name on the command line.\n (default=off)",
41 " The program reads first the sequence, then a string containing constraints on \n the structure encoded with the symbols:\n\n . (no constraint for this base)\n\n | (the corresponding base has to be paired\n\n x (the base is unpaired)\n\n < (base i is paired with a base j>i)\n\n > (base i is paired with a base j<i)\n\n and matching brackets ( ) (base i pairs base j)\n\n With the exception of \"|\", constraints will disallow all pairs conflicting \n with the constraint. This is usually sufficient to enforce the constraint, \n but occasionally a base may stay unpaired in spite of constraints. PF folding \n ignores constraints of type \"|\".\n\n",
42 " --color Produce a colored version of the consensus \n strcture plot \"alirna.ps\" (default b&w \n only)\n\n (default=off)",
43 " --aln Produce a colored and structure annotated \n alignment in PostScript format in the file \n \"aln.ps\" in the current directory.\n\n (default=off)",
44 " --noPS Do not produce postscript output\n\n (default=off)",
46 " Select additional algorithms which should be included in the calculations.\n The Minimum free energy (MFE) and a structure representative are calculated \n in any case.\n\n",
47 " -p, --partfunc[=INT] Calculate the partition function and base \n pairing probability matrix in addition to the \n mfe structure. Default is calculation of mfe \n structure only.\n (default=`1')",
48 " In addition to the MFE structure we print a coarse representation of the pair \n probabilities in form of a pseudo bracket notation, followed by the ensemble \n free energy, as well as the centroid structure derived from the pair \n probabilities together with its free energy and distance to the ensemble. \n Finally it prints the frequency of the mfe structure.\n\n An additionally passed value to this option changes the behavior of partition \n function calculation:\n -p0 deactivates the calculation of the pair probabilities, saving about 50% \n in runtime. This prints the ensemble free energy -kT ln(Z).\n\n",
49 " --MEA[=gamma] Calculate an MEA (maximum expected accuracy) \n structure.\n (default=`1.')",
50 " If gamma is not specified a default of gamma=1 is used.\n Using --MEA implies -p\n See also RNAfold man page for details.\n\n",
51 " --mis Output \"most informative sequence\" instead of \n simple consensus: For each column of the \n alignment output the set of nucleotides with \n frequence greater than average in IUPAC \n notation.\n\n (default=off)",
52 " -s, --stochBT=INT Stochastic backtrack. Compute a certain number \n of random structures with a probability \n dependend on the partition function. See -p \n option in RNAsubopt.\n\n",
53 " --stochBT_en=INT same as \"-s\" but also print out the energies \n and probabilities of the backtraced \n structures.\n\n",
54 " -S, --pfScale=scaling factor In the calculation of the pf use scale*mfe as \n an estimate for the ensemble free energy \n (used to avoid overflows).\n",
55 " The default is 1.07, useful values are 1.0 to 1.2. Occasionally needed for \n long sequences.\n You can also recompile the program to use double precision (see the README \n file).\n\n",
56 " -c, --circ Assume a circular (instead of linear) RNA \n molecule.\n\n (default=off)",
57 " --bppmThreshold=<value> Set the threshold for base pair probabilities \n included in the postscript output\n (default=`1e-6')",
58 " By setting the threshold the base pair probabilities that are included in the \n output can be varied. By default only those exceeding 1e-5 in probability \n will be shown as squares in the dot plot. Changing the threshold to any other \n value allows for increase or decrease of data.\n\n",
59 " -g, --gquad Incoorporate G-Quadruplex formation into the \n structure prediction algorithm\n (default=off)",
61 " -T, --temp=DOUBLE Rescale energy parameters to a temperature of \n temp C. Default is 37C.\n\n",
62 " -4, --noTetra Do not include special tabulated stabilizing \n energies for tri-, tetra- and hexaloop \n hairpins. Mostly for testing.\n\n (default=off)",
63 " -d, --dangles=INT How to treat \"dangling end\" energies for \n bases adjacent to helices in free ends and \n multi-loops\n (default=`2')",
64 " \n With -d2 dangling energies will be added for the bases adjacent to a helix on \n both sides\n in any case.\n The option -d0 ignores dangling ends altogether (mostly for debugging).\n\n",
65 " --noLP Produce structures without lonely pairs \n (helices of length 1).\n (default=off)",
66 " For partition function folding this only disallows pairs that can only occur \n isolated. Other pairs may still occasionally occur as helices of length 1.\n\n",
67 " --noGU Do not allow GU pairs\n\n (default=off)",
68 " --noClosingGU Do not allow GU pairs at the end of helices\n\n (default=off)",
69 " --cfactor=DOUBLE Set the weight of the covariance term in the \n energy function\n\n (default=`1.0')",
70 " --nfactor=DOUBLE Set the penalty for non-compatible sequences in \n the covariance term of the energy function\n\n (default=`1.0')",
71 " -E, --endgaps Score pairs with endgaps same as gap-gap pairs.\n\n (default=off)",
72 " -R, --ribosum_file=ribosumfile\n use specified Ribosum Matrix instead of normal \n energy model. Matrixes to use should be 6x6 \n matrices, the order of the terms is AU, CG, \n GC, GU, UA, UG.\n\n",
73 " -r, --ribosum_scoring use ribosum scoring matrix. The matrix is \n chosen according to the minimal and maximal \n pairwise identities of the sequences in the \n file.\n\n (default=off)",
74 " --old use old energy evaluation, treating gaps as \n characters.\n\n (default=off)",
75 " -P, --paramFile=paramfile Read energy parameters from paramfile, instead \n of using the default parameter set.\n",
76 " A sample parameter file should accompany your distribution.\n See the RNAlib documentation for details on the file format.\n\n",
77 " --nsp=STRING Allow other pairs in addition to the usual \n AU,GC,and GU pairs.\n",
78 " Its argument is a comma separated list of additionally allowed pairs. If the \n first character is a \"-\" then AB will imply that AB and BA are allowed \n pairs.\n e.g. RNAfold -nsp -GA will allow GA and AG pairs. Nonstandard pairs are \n given 0 stacking energy.\n\n",
79 " -e, --energyModel=INT Rarely used option to fold sequences from the \n artificial ABCD... alphabet, where A pairs B, \n C-D etc. Use the energy parameters for GC \n (-e 1) or AU (-e 2) pairs.\n\n",
80 " --betaScale=DOUBLE Set the scaling of the Boltzmann factors\n (default=`1.')",
81 " The argument provided with this option enables to scale the thermodynamic \n temperature used in the Boltzmann factors independently from the temperature \n used to scale the individual energy contributions of the loop types. The \n Boltzmann factors then become exp(-dG/(kTn*betaScale)) where k is the \n Boltzmann constant, dG the free energy contribution of the state, T the \n absolute temperature and n the number of sequences.\n\n",
82 "Caveats:\n\nSequences are not weighted. If possible, do not mix very similar and dissimilar \nsequences. Duplicate sequences, for example, can distort the prediction.\n\n\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
86 init_full_help_array(void)
88 RNAalifold_args_info_full_help[0] = RNAalifold_args_info_detailed_help[0];
89 RNAalifold_args_info_full_help[1] = RNAalifold_args_info_detailed_help[1];
90 RNAalifold_args_info_full_help[2] = RNAalifold_args_info_detailed_help[2];
91 RNAalifold_args_info_full_help[3] = RNAalifold_args_info_detailed_help[3];
92 RNAalifold_args_info_full_help[4] = RNAalifold_args_info_detailed_help[4];
93 RNAalifold_args_info_full_help[5] = RNAalifold_args_info_detailed_help[5];
94 RNAalifold_args_info_full_help[6] = RNAalifold_args_info_detailed_help[6];
95 RNAalifold_args_info_full_help[7] = RNAalifold_args_info_detailed_help[8];
96 RNAalifold_args_info_full_help[8] = RNAalifold_args_info_detailed_help[9];
97 RNAalifold_args_info_full_help[9] = RNAalifold_args_info_detailed_help[10];
98 RNAalifold_args_info_full_help[10] = RNAalifold_args_info_detailed_help[11];
99 RNAalifold_args_info_full_help[11] = RNAalifold_args_info_detailed_help[12];
100 RNAalifold_args_info_full_help[12] = RNAalifold_args_info_detailed_help[13];
101 RNAalifold_args_info_full_help[13] = RNAalifold_args_info_detailed_help[15];
102 RNAalifold_args_info_full_help[14] = RNAalifold_args_info_detailed_help[17];
103 RNAalifold_args_info_full_help[15] = RNAalifold_args_info_detailed_help[18];
104 RNAalifold_args_info_full_help[16] = RNAalifold_args_info_detailed_help[19];
105 RNAalifold_args_info_full_help[17] = RNAalifold_args_info_detailed_help[20];
106 RNAalifold_args_info_full_help[18] = RNAalifold_args_info_detailed_help[22];
107 RNAalifold_args_info_full_help[19] = RNAalifold_args_info_detailed_help[23];
108 RNAalifold_args_info_full_help[20] = RNAalifold_args_info_detailed_help[25];
109 RNAalifold_args_info_full_help[21] = RNAalifold_args_info_detailed_help[26];
110 RNAalifold_args_info_full_help[22] = RNAalifold_args_info_detailed_help[27];
111 RNAalifold_args_info_full_help[23] = RNAalifold_args_info_detailed_help[28];
112 RNAalifold_args_info_full_help[24] = RNAalifold_args_info_detailed_help[29];
113 RNAalifold_args_info_full_help[25] = RNAalifold_args_info_detailed_help[31];
114 RNAalifold_args_info_full_help[26] = RNAalifold_args_info_detailed_help[33];
115 RNAalifold_args_info_full_help[27] = RNAalifold_args_info_detailed_help[34];
116 RNAalifold_args_info_full_help[28] = RNAalifold_args_info_detailed_help[35];
117 RNAalifold_args_info_full_help[29] = RNAalifold_args_info_detailed_help[36];
118 RNAalifold_args_info_full_help[30] = RNAalifold_args_info_detailed_help[37];
119 RNAalifold_args_info_full_help[31] = RNAalifold_args_info_detailed_help[38];
120 RNAalifold_args_info_full_help[32] = RNAalifold_args_info_detailed_help[39];
121 RNAalifold_args_info_full_help[33] = RNAalifold_args_info_detailed_help[40];
122 RNAalifold_args_info_full_help[34] = RNAalifold_args_info_detailed_help[41];
123 RNAalifold_args_info_full_help[35] = RNAalifold_args_info_detailed_help[43];
124 RNAalifold_args_info_full_help[36] = RNAalifold_args_info_detailed_help[45];
125 RNAalifold_args_info_full_help[37] = RNAalifold_args_info_detailed_help[46];
126 RNAalifold_args_info_full_help[38] = RNAalifold_args_info_detailed_help[48];
127 RNAalifold_args_info_full_help[39] = 0;
131 const char *RNAalifold_args_info_full_help[40];
134 init_help_array(void)
136 RNAalifold_args_info_help[0] = RNAalifold_args_info_detailed_help[0];
137 RNAalifold_args_info_help[1] = RNAalifold_args_info_detailed_help[1];
138 RNAalifold_args_info_help[2] = RNAalifold_args_info_detailed_help[2];
139 RNAalifold_args_info_help[3] = RNAalifold_args_info_detailed_help[3];
140 RNAalifold_args_info_help[4] = RNAalifold_args_info_detailed_help[4];
141 RNAalifold_args_info_help[5] = RNAalifold_args_info_detailed_help[5];
142 RNAalifold_args_info_help[6] = RNAalifold_args_info_detailed_help[6];
143 RNAalifold_args_info_help[7] = RNAalifold_args_info_detailed_help[8];
144 RNAalifold_args_info_help[8] = RNAalifold_args_info_detailed_help[9];
145 RNAalifold_args_info_help[9] = RNAalifold_args_info_detailed_help[10];
146 RNAalifold_args_info_help[10] = RNAalifold_args_info_detailed_help[11];
147 RNAalifold_args_info_help[11] = RNAalifold_args_info_detailed_help[12];
148 RNAalifold_args_info_help[12] = RNAalifold_args_info_detailed_help[13];
149 RNAalifold_args_info_help[13] = RNAalifold_args_info_detailed_help[15];
150 RNAalifold_args_info_help[14] = RNAalifold_args_info_detailed_help[17];
151 RNAalifold_args_info_help[15] = RNAalifold_args_info_detailed_help[18];
152 RNAalifold_args_info_help[16] = RNAalifold_args_info_detailed_help[19];
153 RNAalifold_args_info_help[17] = RNAalifold_args_info_detailed_help[22];
154 RNAalifold_args_info_help[18] = RNAalifold_args_info_detailed_help[25];
155 RNAalifold_args_info_help[19] = RNAalifold_args_info_detailed_help[26];
156 RNAalifold_args_info_help[20] = RNAalifold_args_info_detailed_help[27];
157 RNAalifold_args_info_help[21] = RNAalifold_args_info_detailed_help[28];
158 RNAalifold_args_info_help[22] = RNAalifold_args_info_detailed_help[29];
159 RNAalifold_args_info_help[23] = RNAalifold_args_info_detailed_help[31];
160 RNAalifold_args_info_help[24] = RNAalifold_args_info_detailed_help[33];
161 RNAalifold_args_info_help[25] = RNAalifold_args_info_detailed_help[34];
162 RNAalifold_args_info_help[26] = RNAalifold_args_info_detailed_help[35];
163 RNAalifold_args_info_help[27] = RNAalifold_args_info_detailed_help[36];
164 RNAalifold_args_info_help[28] = RNAalifold_args_info_detailed_help[37];
165 RNAalifold_args_info_help[29] = RNAalifold_args_info_detailed_help[38];
166 RNAalifold_args_info_help[30] = RNAalifold_args_info_detailed_help[39];
167 RNAalifold_args_info_help[31] = RNAalifold_args_info_detailed_help[40];
168 RNAalifold_args_info_help[32] = RNAalifold_args_info_detailed_help[41];
169 RNAalifold_args_info_help[33] = RNAalifold_args_info_detailed_help[48];
170 RNAalifold_args_info_help[34] = 0;
174 const char *RNAalifold_args_info_help[35];
182 } RNAalifold_cmdline_parser_arg_type;
185 void clear_given (struct RNAalifold_args_info *args_info);
187 void clear_args (struct RNAalifold_args_info *args_info);
190 RNAalifold_cmdline_parser_internal (int argc, char **argv, struct RNAalifold_args_info *args_info,
191 struct RNAalifold_cmdline_parser_params *params, const char *additional_error);
194 RNAalifold_cmdline_parser_required2 (struct RNAalifold_args_info *args_info, const char *prog_name, const char *additional_error);
197 gengetopt_strdup (const char *s);
200 void clear_given (struct RNAalifold_args_info *args_info)
202 args_info->help_given = 0 ;
203 args_info->detailed_help_given = 0 ;
204 args_info->full_help_given = 0 ;
205 args_info->version_given = 0 ;
206 args_info->constraint_given = 0 ;
207 args_info->color_given = 0 ;
208 args_info->aln_given = 0 ;
209 args_info->noPS_given = 0 ;
210 args_info->partfunc_given = 0 ;
211 args_info->MEA_given = 0 ;
212 args_info->mis_given = 0 ;
213 args_info->stochBT_given = 0 ;
214 args_info->stochBT_en_given = 0 ;
215 args_info->pfScale_given = 0 ;
216 args_info->circ_given = 0 ;
217 args_info->bppmThreshold_given = 0 ;
218 args_info->gquad_given = 0 ;
219 args_info->temp_given = 0 ;
220 args_info->noTetra_given = 0 ;
221 args_info->dangles_given = 0 ;
222 args_info->noLP_given = 0 ;
223 args_info->noGU_given = 0 ;
224 args_info->noClosingGU_given = 0 ;
225 args_info->cfactor_given = 0 ;
226 args_info->nfactor_given = 0 ;
227 args_info->endgaps_given = 0 ;
228 args_info->ribosum_file_given = 0 ;
229 args_info->ribosum_scoring_given = 0 ;
230 args_info->old_given = 0 ;
231 args_info->paramFile_given = 0 ;
232 args_info->nsp_given = 0 ;
233 args_info->energyModel_given = 0 ;
234 args_info->betaScale_given = 0 ;
238 void clear_args (struct RNAalifold_args_info *args_info)
240 FIX_UNUSED (args_info);
241 args_info->constraint_flag = 0;
242 args_info->color_flag = 0;
243 args_info->aln_flag = 0;
244 args_info->noPS_flag = 0;
245 args_info->partfunc_arg = 1;
246 args_info->partfunc_orig = NULL;
247 args_info->MEA_arg = 1.;
248 args_info->MEA_orig = NULL;
249 args_info->mis_flag = 0;
250 args_info->stochBT_orig = NULL;
251 args_info->stochBT_en_orig = NULL;
252 args_info->pfScale_orig = NULL;
253 args_info->circ_flag = 0;
254 args_info->bppmThreshold_arg = 1e-6;
255 args_info->bppmThreshold_orig = NULL;
256 args_info->gquad_flag = 0;
257 args_info->temp_orig = NULL;
258 args_info->noTetra_flag = 0;
259 args_info->dangles_arg = 2;
260 args_info->dangles_orig = NULL;
261 args_info->noLP_flag = 0;
262 args_info->noGU_flag = 0;
263 args_info->noClosingGU_flag = 0;
264 args_info->cfactor_arg = 1.0;
265 args_info->cfactor_orig = NULL;
266 args_info->nfactor_arg = 1.0;
267 args_info->nfactor_orig = NULL;
268 args_info->endgaps_flag = 0;
269 args_info->ribosum_file_arg = NULL;
270 args_info->ribosum_file_orig = NULL;
271 args_info->ribosum_scoring_flag = 0;
272 args_info->old_flag = 0;
273 args_info->paramFile_arg = NULL;
274 args_info->paramFile_orig = NULL;
275 args_info->nsp_arg = NULL;
276 args_info->nsp_orig = NULL;
277 args_info->energyModel_orig = NULL;
278 args_info->betaScale_arg = 1.;
279 args_info->betaScale_orig = NULL;
284 void init_args_info(struct RNAalifold_args_info *args_info)
286 init_full_help_array();
288 args_info->help_help = RNAalifold_args_info_detailed_help[0] ;
289 args_info->detailed_help_help = RNAalifold_args_info_detailed_help[1] ;
290 args_info->full_help_help = RNAalifold_args_info_detailed_help[2] ;
291 args_info->version_help = RNAalifold_args_info_detailed_help[3] ;
292 args_info->constraint_help = RNAalifold_args_info_detailed_help[6] ;
293 args_info->color_help = RNAalifold_args_info_detailed_help[8] ;
294 args_info->aln_help = RNAalifold_args_info_detailed_help[9] ;
295 args_info->noPS_help = RNAalifold_args_info_detailed_help[10] ;
296 args_info->partfunc_help = RNAalifold_args_info_detailed_help[13] ;
297 args_info->MEA_help = RNAalifold_args_info_detailed_help[15] ;
298 args_info->mis_help = RNAalifold_args_info_detailed_help[17] ;
299 args_info->stochBT_help = RNAalifold_args_info_detailed_help[18] ;
300 args_info->stochBT_en_help = RNAalifold_args_info_detailed_help[19] ;
301 args_info->pfScale_help = RNAalifold_args_info_detailed_help[20] ;
302 args_info->circ_help = RNAalifold_args_info_detailed_help[22] ;
303 args_info->bppmThreshold_help = RNAalifold_args_info_detailed_help[23] ;
304 args_info->gquad_help = RNAalifold_args_info_detailed_help[25] ;
305 args_info->temp_help = RNAalifold_args_info_detailed_help[27] ;
306 args_info->noTetra_help = RNAalifold_args_info_detailed_help[28] ;
307 args_info->dangles_help = RNAalifold_args_info_detailed_help[29] ;
308 args_info->noLP_help = RNAalifold_args_info_detailed_help[31] ;
309 args_info->noGU_help = RNAalifold_args_info_detailed_help[33] ;
310 args_info->noClosingGU_help = RNAalifold_args_info_detailed_help[34] ;
311 args_info->cfactor_help = RNAalifold_args_info_detailed_help[35] ;
312 args_info->nfactor_help = RNAalifold_args_info_detailed_help[36] ;
313 args_info->endgaps_help = RNAalifold_args_info_detailed_help[37] ;
314 args_info->ribosum_file_help = RNAalifold_args_info_detailed_help[38] ;
315 args_info->ribosum_scoring_help = RNAalifold_args_info_detailed_help[39] ;
316 args_info->old_help = RNAalifold_args_info_detailed_help[40] ;
317 args_info->paramFile_help = RNAalifold_args_info_detailed_help[41] ;
318 args_info->nsp_help = RNAalifold_args_info_detailed_help[43] ;
319 args_info->energyModel_help = RNAalifold_args_info_detailed_help[45] ;
320 args_info->betaScale_help = RNAalifold_args_info_detailed_help[46] ;
325 RNAalifold_cmdline_parser_print_version (void)
328 (strlen(RNAALIFOLD_CMDLINE_PARSER_PACKAGE_NAME) ? RNAALIFOLD_CMDLINE_PARSER_PACKAGE_NAME : RNAALIFOLD_CMDLINE_PARSER_PACKAGE),
329 RNAALIFOLD_CMDLINE_PARSER_VERSION);
332 static void print_help_common(void) {
333 RNAalifold_cmdline_parser_print_version ();
335 if (strlen(RNAalifold_args_info_purpose) > 0)
336 printf("\n%s\n", RNAalifold_args_info_purpose);
338 if (strlen(RNAalifold_args_info_usage) > 0)
339 printf("\n%s\n", RNAalifold_args_info_usage);
343 if (strlen(RNAalifold_args_info_description) > 0)
344 printf("%s\n\n", RNAalifold_args_info_description);
348 RNAalifold_cmdline_parser_print_help (void)
352 while (RNAalifold_args_info_help[i])
353 printf("%s\n", RNAalifold_args_info_help[i++]);
357 RNAalifold_cmdline_parser_print_full_help (void)
361 while (RNAalifold_args_info_full_help[i])
362 printf("%s\n", RNAalifold_args_info_full_help[i++]);
366 RNAalifold_cmdline_parser_print_detailed_help (void)
370 while (RNAalifold_args_info_detailed_help[i])
371 printf("%s\n", RNAalifold_args_info_detailed_help[i++]);
375 RNAalifold_cmdline_parser_init (struct RNAalifold_args_info *args_info)
377 clear_given (args_info);
378 clear_args (args_info);
379 init_args_info (args_info);
381 args_info->inputs = 0;
382 args_info->inputs_num = 0;
386 RNAalifold_cmdline_parser_params_init(struct RNAalifold_cmdline_parser_params *params)
390 params->override = 0;
391 params->initialize = 1;
392 params->check_required = 1;
393 params->check_ambiguity = 0;
394 params->print_errors = 1;
398 struct RNAalifold_cmdline_parser_params *
399 RNAalifold_cmdline_parser_params_create(void)
401 struct RNAalifold_cmdline_parser_params *params =
402 (struct RNAalifold_cmdline_parser_params *)malloc(sizeof(struct RNAalifold_cmdline_parser_params));
403 RNAalifold_cmdline_parser_params_init(params);
408 free_string_field (char **s)
419 RNAalifold_cmdline_parser_release (struct RNAalifold_args_info *args_info)
422 free_string_field (&(args_info->partfunc_orig));
423 free_string_field (&(args_info->MEA_orig));
424 free_string_field (&(args_info->stochBT_orig));
425 free_string_field (&(args_info->stochBT_en_orig));
426 free_string_field (&(args_info->pfScale_orig));
427 free_string_field (&(args_info->bppmThreshold_orig));
428 free_string_field (&(args_info->temp_orig));
429 free_string_field (&(args_info->dangles_orig));
430 free_string_field (&(args_info->cfactor_orig));
431 free_string_field (&(args_info->nfactor_orig));
432 free_string_field (&(args_info->ribosum_file_arg));
433 free_string_field (&(args_info->ribosum_file_orig));
434 free_string_field (&(args_info->paramFile_arg));
435 free_string_field (&(args_info->paramFile_orig));
436 free_string_field (&(args_info->nsp_arg));
437 free_string_field (&(args_info->nsp_orig));
438 free_string_field (&(args_info->energyModel_orig));
439 free_string_field (&(args_info->betaScale_orig));
442 for (i = 0; i < args_info->inputs_num; ++i)
443 free (args_info->inputs [i]);
445 if (args_info->inputs_num)
446 free (args_info->inputs);
448 clear_given (args_info);
453 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
457 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
459 fprintf(outfile, "%s\n", opt);
465 RNAalifold_cmdline_parser_dump(FILE *outfile, struct RNAalifold_args_info *args_info)
471 fprintf (stderr, "%s: cannot dump options to stream\n", RNAALIFOLD_CMDLINE_PARSER_PACKAGE);
475 if (args_info->help_given)
476 write_into_file(outfile, "help", 0, 0 );
477 if (args_info->detailed_help_given)
478 write_into_file(outfile, "detailed-help", 0, 0 );
479 if (args_info->full_help_given)
480 write_into_file(outfile, "full-help", 0, 0 );
481 if (args_info->version_given)
482 write_into_file(outfile, "version", 0, 0 );
483 if (args_info->constraint_given)
484 write_into_file(outfile, "constraint", 0, 0 );
485 if (args_info->color_given)
486 write_into_file(outfile, "color", 0, 0 );
487 if (args_info->aln_given)
488 write_into_file(outfile, "aln", 0, 0 );
489 if (args_info->noPS_given)
490 write_into_file(outfile, "noPS", 0, 0 );
491 if (args_info->partfunc_given)
492 write_into_file(outfile, "partfunc", args_info->partfunc_orig, 0);
493 if (args_info->MEA_given)
494 write_into_file(outfile, "MEA", args_info->MEA_orig, 0);
495 if (args_info->mis_given)
496 write_into_file(outfile, "mis", 0, 0 );
497 if (args_info->stochBT_given)
498 write_into_file(outfile, "stochBT", args_info->stochBT_orig, 0);
499 if (args_info->stochBT_en_given)
500 write_into_file(outfile, "stochBT_en", args_info->stochBT_en_orig, 0);
501 if (args_info->pfScale_given)
502 write_into_file(outfile, "pfScale", args_info->pfScale_orig, 0);
503 if (args_info->circ_given)
504 write_into_file(outfile, "circ", 0, 0 );
505 if (args_info->bppmThreshold_given)
506 write_into_file(outfile, "bppmThreshold", args_info->bppmThreshold_orig, 0);
507 if (args_info->gquad_given)
508 write_into_file(outfile, "gquad", 0, 0 );
509 if (args_info->temp_given)
510 write_into_file(outfile, "temp", args_info->temp_orig, 0);
511 if (args_info->noTetra_given)
512 write_into_file(outfile, "noTetra", 0, 0 );
513 if (args_info->dangles_given)
514 write_into_file(outfile, "dangles", args_info->dangles_orig, 0);
515 if (args_info->noLP_given)
516 write_into_file(outfile, "noLP", 0, 0 );
517 if (args_info->noGU_given)
518 write_into_file(outfile, "noGU", 0, 0 );
519 if (args_info->noClosingGU_given)
520 write_into_file(outfile, "noClosingGU", 0, 0 );
521 if (args_info->cfactor_given)
522 write_into_file(outfile, "cfactor", args_info->cfactor_orig, 0);
523 if (args_info->nfactor_given)
524 write_into_file(outfile, "nfactor", args_info->nfactor_orig, 0);
525 if (args_info->endgaps_given)
526 write_into_file(outfile, "endgaps", 0, 0 );
527 if (args_info->ribosum_file_given)
528 write_into_file(outfile, "ribosum_file", args_info->ribosum_file_orig, 0);
529 if (args_info->ribosum_scoring_given)
530 write_into_file(outfile, "ribosum_scoring", 0, 0 );
531 if (args_info->old_given)
532 write_into_file(outfile, "old", 0, 0 );
533 if (args_info->paramFile_given)
534 write_into_file(outfile, "paramFile", args_info->paramFile_orig, 0);
535 if (args_info->nsp_given)
536 write_into_file(outfile, "nsp", args_info->nsp_orig, 0);
537 if (args_info->energyModel_given)
538 write_into_file(outfile, "energyModel", args_info->energyModel_orig, 0);
539 if (args_info->betaScale_given)
540 write_into_file(outfile, "betaScale", args_info->betaScale_orig, 0);
548 RNAalifold_cmdline_parser_file_save(const char *filename, struct RNAalifold_args_info *args_info)
553 outfile = fopen(filename, "w");
557 fprintf (stderr, "%s: cannot open file for writing: %s\n", RNAALIFOLD_CMDLINE_PARSER_PACKAGE, filename);
561 i = RNAalifold_cmdline_parser_dump(outfile, args_info);
568 RNAalifold_cmdline_parser_free (struct RNAalifold_args_info *args_info)
570 RNAalifold_cmdline_parser_release (args_info);
573 /** @brief replacement of strdup, which is not standard */
575 gengetopt_strdup (const char *s)
581 result = (char*)malloc(strlen(s) + 1);
582 if (result == (char*)0)
589 RNAalifold_cmdline_parser (int argc, char **argv, struct RNAalifold_args_info *args_info)
591 return RNAalifold_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
595 RNAalifold_cmdline_parser_ext (int argc, char **argv, struct RNAalifold_args_info *args_info,
596 struct RNAalifold_cmdline_parser_params *params)
599 result = RNAalifold_cmdline_parser_internal (argc, argv, args_info, params, 0);
601 if (result == EXIT_FAILURE)
603 RNAalifold_cmdline_parser_free (args_info);
611 RNAalifold_cmdline_parser2 (int argc, char **argv, struct RNAalifold_args_info *args_info, int override, int initialize, int check_required)
614 struct RNAalifold_cmdline_parser_params params;
616 params.override = override;
617 params.initialize = initialize;
618 params.check_required = check_required;
619 params.check_ambiguity = 0;
620 params.print_errors = 1;
622 result = RNAalifold_cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
624 if (result == EXIT_FAILURE)
626 RNAalifold_cmdline_parser_free (args_info);
634 RNAalifold_cmdline_parser_required (struct RNAalifold_args_info *args_info, const char *prog_name)
636 int result = EXIT_SUCCESS;
638 if (RNAalifold_cmdline_parser_required2(args_info, prog_name, 0) > 0)
639 result = EXIT_FAILURE;
641 if (result == EXIT_FAILURE)
643 RNAalifold_cmdline_parser_free (args_info);
651 RNAalifold_cmdline_parser_required2 (struct RNAalifold_args_info *args_info, const char *prog_name, const char *additional_error)
654 FIX_UNUSED (additional_error);
656 /* checks for required options */
658 /* checks for dependences among options */
659 if (args_info->betaScale_given && ! args_info->partfunc_given)
661 fprintf (stderr, "%s: '--betaScale' option depends on option 'partfunc'%s\n", prog_name, (additional_error ? additional_error : ""));
669 * Extracted from the glibc source tree, version 2.3.6
671 * Licensed under the GPL as per the whole glibc source tree.
673 * This file was modified so that getopt_long can be called
674 * many times without risking previous memory to be spoiled.
676 * Modified by Andre Noll and Lorenzo Bettini for use in
677 * GNU gengetopt generated files.
682 * we must include anything we need since this file is not thought to be
683 * inserted in a file already using getopt.h
691 /* has_arg can't be an enum because some compilers complain about
692 type mismatches in all the code that assumes it is an int. */
698 /* This version of `getopt' appears to the caller like standard Unix `getopt'
699 but it behaves differently for the user, since it allows the user
700 to intersperse the options with the other arguments.
702 As `getopt' works, it permutes the elements of ARGV so that,
703 when it is done, all the options precede everything else. Thus
704 all application programs are extended to handle flexible argument order.
707 If the field `flag' is not NULL, it points to a variable that is set
708 to the value given in the field `val' when the option is found, but
709 left unchanged if the option is not found.
711 To have a long-named option do something other than set an `int' to
712 a compiled-in constant, such as set a value from `custom_optarg', set the
713 option's `flag' field to zero and its `val' field to a nonzero
714 value (the equivalent single-letter option character, if there is
715 one). For long options that have a zero `flag' field, `getopt'
716 returns the contents of the `val' field. */
718 /* Names for the values of the `has_arg' field of `struct option'. */
720 #define no_argument 0
723 #ifndef required_argument
724 #define required_argument 1
727 #ifndef optional_argument
728 #define optional_argument 2
731 struct custom_getopt_data {
733 * These have exactly the same meaning as the corresponding global variables,
734 * except that they are used for the reentrant versions of getopt.
741 /* True if the internal members have been initialized. */
745 * The next char to be scanned in the option-element in which the last option
746 * character we returned was found. This allows us to pick up the scan where
747 * we left off. If this is zero, or a null string, it means resume the scan by
748 * advancing to the next ARGV-element.
753 * Describe the part of ARGV that contains non-options that have been skipped.
754 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
755 * the index after the last of them.
762 * the variables optarg, optind, opterr and optopt are renamed with
763 * the custom_ prefix so that they don't interfere with getopt ones.
765 * Moreover they're static so they are visible only from within the
766 * file where this very file will be included.
770 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
771 * option that takes an argument, the argument value is returned here.
773 static char *custom_optarg;
776 * Index in ARGV of the next element to be scanned. This is used for
777 * communication to and from the caller and for communication between
778 * successive calls to `custom_getopt'.
780 * On entry to `custom_getopt', 1 means this is the first call; initialize.
782 * When `custom_getopt' returns -1, this is the index of the first of the non-option
783 * elements that the caller should itself scan.
785 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
786 * has been scanned so far.
788 * 1003.2 says this must be 1 before any call.
790 static int custom_optind = 1;
793 * Callers store zero here to inhibit the error message for unrecognized
796 static int custom_opterr = 1;
799 * Set to an option character which was unrecognized. This must be initialized
800 * on some systems to avoid linking in the system's own getopt implementation.
802 static int custom_optopt = '?';
805 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
806 * [first_nonopt,last_nonopt) which contains all the non-options that have been
807 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
808 * all the options processed since those non-options were skipped.
809 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
810 * indices of the non-options in ARGV after they are moved.
812 static void exchange(char **argv, struct custom_getopt_data *d)
814 int bottom = d->first_nonopt;
815 int middle = d->last_nonopt;
816 int top = d->custom_optind;
820 * Exchange the shorter segment with the far end of the longer segment.
821 * That puts the shorter segment into the right place. It leaves the
822 * longer segment in the right place overall, but it consists of two
823 * parts that need to be swapped next.
825 while (top > middle && middle > bottom) {
826 if (top - middle > middle - bottom) {
827 /* Bottom segment is the short one. */
828 int len = middle - bottom;
831 /* Swap it with the top part of the top segment. */
832 for (i = 0; i < len; i++) {
833 tem = argv[bottom + i];
835 argv[top - (middle - bottom) + i];
836 argv[top - (middle - bottom) + i] = tem;
838 /* Exclude the moved bottom segment from further swapping. */
841 /* Top segment is the short one. */
842 int len = top - middle;
845 /* Swap it with the bottom part of the bottom segment. */
846 for (i = 0; i < len; i++) {
847 tem = argv[bottom + i];
848 argv[bottom + i] = argv[middle + i];
849 argv[middle + i] = tem;
851 /* Exclude the moved top segment from further swapping. */
855 /* Update records for the slots the non-options now occupy. */
856 d->first_nonopt += (d->custom_optind - d->last_nonopt);
857 d->last_nonopt = d->custom_optind;
860 /* Initialize the internal data when the first call is made. */
861 static void custom_getopt_initialize(struct custom_getopt_data *d)
864 * Start processing options with ARGV-element 1 (since ARGV-element 0
865 * is the program name); the sequence of previously skipped non-option
866 * ARGV-elements is empty.
868 d->first_nonopt = d->last_nonopt = d->custom_optind;
873 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
875 /* return: zero: continue, nonzero: return given value to user */
876 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
877 struct custom_getopt_data *d)
880 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
881 * moved back by the user (who may also have changed the arguments).
883 if (d->last_nonopt > d->custom_optind)
884 d->last_nonopt = d->custom_optind;
885 if (d->first_nonopt > d->custom_optind)
886 d->first_nonopt = d->custom_optind;
888 * If we have just processed some options following some
889 * non-options, exchange them so that the options come first.
891 if (d->first_nonopt != d->last_nonopt &&
892 d->last_nonopt != d->custom_optind)
893 exchange((char **) argv, d);
894 else if (d->last_nonopt != d->custom_optind)
895 d->first_nonopt = d->custom_optind;
897 * Skip any additional non-options and extend the range of
898 * non-options previously skipped.
900 while (d->custom_optind < argc && NONOPTION_P)
902 d->last_nonopt = d->custom_optind;
904 * The special ARGV-element `--' means premature end of options. Skip
905 * it like a null option, then exchange with previous non-options as if
906 * it were an option, then skip everything else like a non-option.
908 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
910 if (d->first_nonopt != d->last_nonopt
911 && d->last_nonopt != d->custom_optind)
912 exchange((char **) argv, d);
913 else if (d->first_nonopt == d->last_nonopt)
914 d->first_nonopt = d->custom_optind;
915 d->last_nonopt = argc;
916 d->custom_optind = argc;
919 * If we have done all the ARGV-elements, stop the scan and back over
920 * any non-options that we skipped and permuted.
922 if (d->custom_optind == argc) {
924 * Set the next-arg-index to point at the non-options that we
925 * previously skipped, so the caller will digest them.
927 if (d->first_nonopt != d->last_nonopt)
928 d->custom_optind = d->first_nonopt;
932 * If we have come to a non-option and did not permute it, either stop
933 * the scan or describe it to the caller and pass it by.
936 d->custom_optarg = argv[d->custom_optind++];
940 * We have found another option-ARGV-element. Skip the initial
943 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
948 * Check whether the ARGV-element is a long option.
950 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
951 * that an abbreviation of the long option, just like "--fu", and not "-f" with
954 * This distinction seems to be the most useful approach.
957 static int check_long_opt(int argc, char *const *argv, const char *optstring,
958 const struct option *longopts, int *longind,
959 int print_errors, struct custom_getopt_data *d)
962 const struct option *p;
963 const struct option *pfound = NULL;
969 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
972 /* Test all long options for either exact match or abbreviated matches */
973 for (p = longopts, option_index = 0; p->name; p++, option_index++)
974 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
975 if ((unsigned int) (nameend - d->nextchar)
976 == (unsigned int) strlen(p->name)) {
977 /* Exact match found. */
979 indfound = option_index;
982 } else if (pfound == NULL) {
983 /* First nonexact match found. */
985 indfound = option_index;
986 } else if (pfound->has_arg != p->has_arg
987 || pfound->flag != p->flag
988 || pfound->val != p->val)
989 /* Second or later nonexact match found. */
992 if (ambig && !exact) {
995 "%s: option `%s' is ambiguous\n",
996 argv[0], argv[d->custom_optind]);
998 d->nextchar += strlen(d->nextchar);
1000 d->custom_optopt = 0;
1004 option_index = indfound;
1007 if (pfound->has_arg != no_argument)
1008 d->custom_optarg = nameend + 1;
1011 if (argv[d->custom_optind - 1][1] == '-') {
1013 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
1014 argv[0], pfound->name);
1016 /* +option or -option */
1017 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
1018 argv[0], argv[d->custom_optind - 1][0], pfound->name);
1022 d->nextchar += strlen(d->nextchar);
1023 d->custom_optopt = pfound->val;
1026 } else if (pfound->has_arg == required_argument) {
1027 if (d->custom_optind < argc)
1028 d->custom_optarg = argv[d->custom_optind++];
1032 "%s: option `%s' requires an argument\n",
1034 argv[d->custom_optind - 1]);
1036 d->nextchar += strlen(d->nextchar);
1037 d->custom_optopt = pfound->val;
1038 return optstring[0] == ':' ? ':' : '?';
1041 d->nextchar += strlen(d->nextchar);
1042 if (longind != NULL)
1043 *longind = option_index;
1045 *(pfound->flag) = pfound->val;
1051 * Can't find it as a long option. If this is not getopt_long_only, or
1052 * the option starts with '--' or is not a valid short option, then
1053 * it's an error. Otherwise interpret it as a short option.
1056 if (argv[d->custom_optind][1] == '-') {
1059 "%s: unrecognized option `--%s'\n",
1060 argv[0], d->nextchar);
1062 /* +option or -option */
1064 "%s: unrecognized option `%c%s'\n",
1065 argv[0], argv[d->custom_optind][0],
1069 d->nextchar = (char *) "";
1071 d->custom_optopt = 0;
1075 static int check_short_opt(int argc, char *const *argv, const char *optstring,
1076 int print_errors, struct custom_getopt_data *d)
1078 char c = *d->nextchar++;
1079 const char *temp = strchr(optstring, c);
1081 /* Increment `custom_optind' when we start to process its last character. */
1082 if (*d->nextchar == '\0')
1084 if (!temp || c == ':') {
1086 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
1088 d->custom_optopt = c;
1091 if (temp[1] == ':') {
1092 if (temp[2] == ':') {
1093 /* This is an option that accepts an argument optionally. */
1094 if (*d->nextchar != '\0') {
1095 d->custom_optarg = d->nextchar;
1098 d->custom_optarg = NULL;
1101 /* This is an option that requires an argument. */
1102 if (*d->nextchar != '\0') {
1103 d->custom_optarg = d->nextchar;
1105 * If we end this ARGV-element by taking the
1106 * rest as an arg, we must advance to the next
1110 } else if (d->custom_optind == argc) {
1113 "%s: option requires an argument -- %c\n",
1116 d->custom_optopt = c;
1117 if (optstring[0] == ':')
1123 * We already incremented `custom_optind' once;
1124 * increment it again when taking next ARGV-elt
1127 d->custom_optarg = argv[d->custom_optind++];
1135 * Scan elements of ARGV for option characters given in OPTSTRING.
1137 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
1138 * then it is an option element. The characters of this element
1139 * (aside from the initial '-') are option characters. If `getopt'
1140 * is called repeatedly, it returns successively each of the option characters
1141 * from each of the option elements.
1143 * If `getopt' finds another option character, it returns that character,
1144 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
1145 * resume the scan with the following option character or ARGV-element.
1147 * If there are no more option characters, `getopt' returns -1.
1148 * Then `custom_optind' is the index in ARGV of the first ARGV-element
1149 * that is not an option. (The ARGV-elements have been permuted
1150 * so that those that are not options now come last.)
1152 * OPTSTRING is a string containing the legitimate option characters.
1153 * If an option character is seen that is not listed in OPTSTRING,
1154 * return '?' after printing an error message. If you set `custom_opterr' to
1155 * zero, the error message is suppressed but we still return '?'.
1157 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
1158 * so the following text in the same ARGV-element, or the text of the following
1159 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
1160 * wants an optional arg; if there is text in the current ARGV-element,
1161 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
1163 * If OPTSTRING starts with `-' or `+', it requests different methods of
1164 * handling the non-option ARGV-elements.
1165 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
1167 * Long-named options begin with `--' instead of `-'.
1168 * Their names may be abbreviated as long as the abbreviation is unique
1169 * or is an exact match for some defined option. If they have an
1170 * argument, it follows the option name in the same ARGV-element, separated
1171 * from the option name by a `=', or else the in next ARGV-element.
1172 * When `getopt' finds a long-named option, it returns 0 if that option's
1173 * `flag' field is nonzero, the value of the option's `val' field
1174 * if the `flag' field is zero.
1176 * The elements of ARGV aren't really const, because we permute them.
1177 * But we pretend they're const in the prototype to be compatible
1178 * with other systems.
1180 * LONGOPTS is a vector of `struct option' terminated by an
1181 * element containing a name which is zero.
1183 * LONGIND returns the index in LONGOPT of the long-named option found.
1184 * It is only valid when a long-named option has been found by the most
1187 * Return the option character from OPTS just read. Return -1 when there are
1188 * no more options. For unrecognized options, or options missing arguments,
1189 * `custom_optopt' is set to the option letter, and '?' is returned.
1191 * The OPTS string is a list of characters which are recognized option letters,
1192 * optionally followed by colons, specifying that that letter takes an
1193 * argument, to be placed in `custom_optarg'.
1195 * If a letter in OPTS is followed by two colons, its argument is optional.
1196 * This behavior is specific to the GNU `getopt'.
1198 * The argument `--' causes premature termination of argument scanning,
1199 * explicitly telling `getopt' that there are no more options. If OPTS begins
1200 * with `--', then non-option arguments are treated as arguments to the option
1201 * '\0'. This behavior is specific to the GNU `getopt'.
1204 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
1205 const struct option *longopts, int *longind,
1206 struct custom_getopt_data *d)
1208 int ret, print_errors = d->custom_opterr;
1210 if (optstring[0] == ':')
1214 d->custom_optarg = NULL;
1217 * This is a big difference with GNU getopt, since optind == 0
1218 * means initialization while here 1 means first call.
1220 if (d->custom_optind == 0 || !d->initialized) {
1221 if (d->custom_optind == 0)
1222 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
1223 custom_getopt_initialize(d);
1225 if (d->nextchar == NULL || *d->nextchar == '\0') {
1226 ret = shuffle_argv(argc, argv, longopts, d);
1230 if (longopts && (argv[d->custom_optind][1] == '-' ))
1231 return check_long_opt(argc, argv, optstring, longopts,
1232 longind, print_errors, d);
1233 return check_short_opt(argc, argv, optstring, print_errors, d);
1236 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1237 const struct option *longopts, int *longind)
1240 /* Keep a global copy of all internal members of d */
1241 static struct custom_getopt_data d;
1243 d.custom_optind = custom_optind;
1244 d.custom_opterr = custom_opterr;
1245 result = getopt_internal_r(argc, argv, optstring, longopts,
1247 custom_optind = d.custom_optind;
1248 custom_optarg = d.custom_optarg;
1249 custom_optopt = d.custom_optopt;
1253 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1254 const struct option *long_options, int *opt_index)
1256 return custom_getopt_internal(argc, argv, options, long_options,
1261 static char *package_name = 0;
1264 * @brief updates an option
1265 * @param field the generic pointer to the field to update
1266 * @param orig_field the pointer to the orig field
1267 * @param field_given the pointer to the number of occurrence of this option
1268 * @param prev_given the pointer to the number of occurrence already seen
1269 * @param value the argument for this option (if null no arg was specified)
1270 * @param possible_values the possible values for this option (if specified)
1271 * @param default_value the default value (in case the option only accepts fixed values)
1272 * @param arg_type the type of this option
1273 * @param check_ambiguity @see RNAalifold_cmdline_parser_params.check_ambiguity
1274 * @param override @see RNAalifold_cmdline_parser_params.override
1275 * @param no_free whether to free a possible previous value
1276 * @param multiple_option whether this is a multiple option
1277 * @param long_opt the corresponding long option
1278 * @param short_opt the corresponding short option (or '-' if none)
1279 * @param additional_error possible further error specification
1282 int update_arg(void *field, char **orig_field,
1283 unsigned int *field_given, unsigned int *prev_given,
1284 char *value, const char *possible_values[],
1285 const char *default_value,
1286 RNAalifold_cmdline_parser_arg_type arg_type,
1287 int check_ambiguity, int override,
1288 int no_free, int multiple_option,
1289 const char *long_opt, char short_opt,
1290 const char *additional_error)
1292 char *stop_char = 0;
1293 const char *val = value;
1295 char **string_field;
1301 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1303 if (short_opt != '-')
1304 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1305 package_name, long_opt, short_opt,
1306 (additional_error ? additional_error : ""));
1308 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1309 package_name, long_opt,
1310 (additional_error ? additional_error : ""));
1311 return 1; /* failure */
1314 FIX_UNUSED (default_value);
1316 if (field_given && *field_given && ! override)
1322 if (possible_values)
1323 val = possible_values[found];
1327 *((int *)field) = !*((int *)field);
1330 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1333 if (val) *((float *)field) = (float)strtod (val, &stop_char);
1336 if (val) *((double *)field) = strtod (val, &stop_char);
1340 string_field = (char **)field;
1341 if (!no_free && *string_field)
1342 free (*string_field); /* free previous string */
1343 *string_field = gengetopt_strdup (val);
1350 /* check numeric conversion */
1355 if (val && !(stop_char && *stop_char == '\0')) {
1356 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1357 return 1; /* failure */
1364 /* store the original value */
1370 if (value && orig_field) {
1372 *orig_field = value;
1375 free (*orig_field); /* free previous string */
1376 *orig_field = gengetopt_strdup (value);
1386 RNAalifold_cmdline_parser_internal (
1387 int argc, char **argv, struct RNAalifold_args_info *args_info,
1388 struct RNAalifold_cmdline_parser_params *params, const char *additional_error)
1390 int c; /* Character of the parsed option. */
1393 struct RNAalifold_args_info local_args_info;
1398 int check_ambiguity;
1405 package_name = argv[0];
1407 override = params->override;
1408 initialize = params->initialize;
1409 check_required = params->check_required;
1410 check_ambiguity = params->check_ambiguity;
1413 RNAalifold_cmdline_parser_init (args_info);
1415 RNAalifold_cmdline_parser_init (&local_args_info);
1419 opterr = params->print_errors;
1424 int option_index = 0;
1426 static struct option long_options[] = {
1427 { "help", 0, NULL, 'h' },
1428 { "detailed-help", 0, NULL, 0 },
1429 { "full-help", 0, NULL, 0 },
1430 { "version", 0, NULL, 'V' },
1431 { "constraint", 0, NULL, 'C' },
1432 { "color", 0, NULL, 0 },
1433 { "aln", 0, NULL, 0 },
1434 { "noPS", 0, NULL, 0 },
1435 { "partfunc", 2, NULL, 'p' },
1436 { "MEA", 2, NULL, 0 },
1437 { "mis", 0, NULL, 0 },
1438 { "stochBT", 1, NULL, 's' },
1439 { "stochBT_en", 1, NULL, 0 },
1440 { "pfScale", 1, NULL, 'S' },
1441 { "circ", 0, NULL, 'c' },
1442 { "bppmThreshold", 1, NULL, 0 },
1443 { "gquad", 0, NULL, 'g' },
1444 { "temp", 1, NULL, 'T' },
1445 { "noTetra", 0, NULL, '4' },
1446 { "dangles", 1, NULL, 'd' },
1447 { "noLP", 0, NULL, 0 },
1448 { "noGU", 0, NULL, 0 },
1449 { "noClosingGU", 0, NULL, 0 },
1450 { "cfactor", 1, NULL, 0 },
1451 { "nfactor", 1, NULL, 0 },
1452 { "endgaps", 0, NULL, 'E' },
1453 { "ribosum_file", 1, NULL, 'R' },
1454 { "ribosum_scoring", 0, NULL, 'r' },
1455 { "old", 0, NULL, 0 },
1456 { "paramFile", 1, NULL, 'P' },
1457 { "nsp", 1, NULL, 0 },
1458 { "energyModel", 1, NULL, 'e' },
1459 { "betaScale", 1, NULL, 0 },
1463 custom_optarg = optarg;
1464 custom_optind = optind;
1465 custom_opterr = opterr;
1466 custom_optopt = optopt;
1468 c = custom_getopt_long (argc, argv, "hVCp::s:S:cgT:4d:ER:rP:e:", long_options, &option_index);
1470 optarg = custom_optarg;
1471 optind = custom_optind;
1472 opterr = custom_opterr;
1473 optopt = custom_optopt;
1475 if (c == -1) break; /* Exit from `while (1)' loop. */
1479 case 'h': /* Print help and exit. */
1480 RNAalifold_cmdline_parser_print_help ();
1481 RNAalifold_cmdline_parser_free (&local_args_info);
1482 exit (EXIT_SUCCESS);
1484 case 'V': /* Print version and exit. */
1485 RNAalifold_cmdline_parser_print_version ();
1486 RNAalifold_cmdline_parser_free (&local_args_info);
1487 exit (EXIT_SUCCESS);
1489 case 'C': /* Calculate structures subject to constraints.
1490 The constraining structure will be read from 'stdin', the alignment has to be given as a file name on the command line.
1494 if (update_arg((void *)&(args_info->constraint_flag), 0, &(args_info->constraint_given),
1495 &(local_args_info.constraint_given), optarg, 0, 0, ARG_FLAG,
1496 check_ambiguity, override, 1, 0, "constraint", 'C',
1501 case 'p': /* Calculate the partition function and base pairing probability matrix in addition to the mfe structure. Default is calculation of mfe structure only.
1505 if (update_arg( (void *)&(args_info->partfunc_arg),
1506 &(args_info->partfunc_orig), &(args_info->partfunc_given),
1507 &(local_args_info.partfunc_given), optarg, 0, "1", ARG_INT,
1508 check_ambiguity, override, 0, 0,
1514 case 's': /* Stochastic backtrack. Compute a certain number of random structures with a probability dependend on the partition function. See -p option in RNAsubopt.
1519 if (update_arg( (void *)&(args_info->stochBT_arg),
1520 &(args_info->stochBT_orig), &(args_info->stochBT_given),
1521 &(local_args_info.stochBT_given), optarg, 0, 0, ARG_INT,
1522 check_ambiguity, override, 0, 0,
1528 case 'S': /* In the calculation of the pf use scale*mfe as an estimate for the ensemble free energy (used to avoid overflows).
1532 if (update_arg( (void *)&(args_info->pfScale_arg),
1533 &(args_info->pfScale_orig), &(args_info->pfScale_given),
1534 &(local_args_info.pfScale_given), optarg, 0, 0, ARG_DOUBLE,
1535 check_ambiguity, override, 0, 0,
1541 case 'c': /* Assume a circular (instead of linear) RNA molecule.
1546 if (update_arg((void *)&(args_info->circ_flag), 0, &(args_info->circ_given),
1547 &(local_args_info.circ_given), optarg, 0, 0, ARG_FLAG,
1548 check_ambiguity, override, 1, 0, "circ", 'c',
1553 case 'g': /* Incoorporate G-Quadruplex formation into the structure prediction algorithm
1557 if (update_arg((void *)&(args_info->gquad_flag), 0, &(args_info->gquad_given),
1558 &(local_args_info.gquad_given), optarg, 0, 0, ARG_FLAG,
1559 check_ambiguity, override, 1, 0, "gquad", 'g',
1564 case 'T': /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1569 if (update_arg( (void *)&(args_info->temp_arg),
1570 &(args_info->temp_orig), &(args_info->temp_given),
1571 &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1572 check_ambiguity, override, 0, 0,
1578 case '4': /* Do not include special tabulated stabilizing energies for tri-, tetra- and hexaloop hairpins. Mostly for testing.
1583 if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1584 &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1585 check_ambiguity, override, 1, 0, "noTetra", '4',
1590 case 'd': /* How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops
1594 if (update_arg( (void *)&(args_info->dangles_arg),
1595 &(args_info->dangles_orig), &(args_info->dangles_given),
1596 &(local_args_info.dangles_given), optarg, 0, "2", ARG_INT,
1597 check_ambiguity, override, 0, 0,
1603 case 'E': /* Score pairs with endgaps same as gap-gap pairs.
1608 if (update_arg((void *)&(args_info->endgaps_flag), 0, &(args_info->endgaps_given),
1609 &(local_args_info.endgaps_given), optarg, 0, 0, ARG_FLAG,
1610 check_ambiguity, override, 1, 0, "endgaps", 'E',
1615 case 'R': /* use specified Ribosum Matrix instead of normal energy model. Matrixes to use should be 6x6 matrices, the order of the terms is AU, CG, GC, GU, UA, UG.
1620 if (update_arg( (void *)&(args_info->ribosum_file_arg),
1621 &(args_info->ribosum_file_orig), &(args_info->ribosum_file_given),
1622 &(local_args_info.ribosum_file_given), optarg, 0, 0, ARG_STRING,
1623 check_ambiguity, override, 0, 0,
1624 "ribosum_file", 'R',
1629 case 'r': /* use ribosum scoring matrix. The matrix is chosen according to the minimal and maximal pairwise identities of the sequences in the file.
1634 if (update_arg((void *)&(args_info->ribosum_scoring_flag), 0, &(args_info->ribosum_scoring_given),
1635 &(local_args_info.ribosum_scoring_given), optarg, 0, 0, ARG_FLAG,
1636 check_ambiguity, override, 1, 0, "ribosum_scoring", 'r',
1641 case 'P': /* Read energy parameters from paramfile, instead of using the default parameter set.
1645 if (update_arg( (void *)&(args_info->paramFile_arg),
1646 &(args_info->paramFile_orig), &(args_info->paramFile_given),
1647 &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1648 check_ambiguity, override, 0, 0,
1654 case 'e': /* Rarely used option to fold sequences from the artificial ABCD... alphabet, where A pairs B, C-D etc. Use the energy parameters for GC (-e 1) or AU (-e 2) pairs.
1659 if (update_arg( (void *)&(args_info->energyModel_arg),
1660 &(args_info->energyModel_orig), &(args_info->energyModel_given),
1661 &(local_args_info.energyModel_given), optarg, 0, 0, ARG_INT,
1662 check_ambiguity, override, 0, 0,
1669 case 0: /* Long option with no short option */
1670 if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1671 RNAalifold_cmdline_parser_print_detailed_help ();
1672 RNAalifold_cmdline_parser_free (&local_args_info);
1673 exit (EXIT_SUCCESS);
1676 if (strcmp (long_options[option_index].name, "full-help") == 0) {
1677 RNAalifold_cmdline_parser_print_full_help ();
1678 RNAalifold_cmdline_parser_free (&local_args_info);
1679 exit (EXIT_SUCCESS);
1682 /* Produce a colored version of the consensus strcture plot \"alirna.ps\" (default b&w only)
1685 if (strcmp (long_options[option_index].name, "color") == 0)
1689 if (update_arg((void *)&(args_info->color_flag), 0, &(args_info->color_given),
1690 &(local_args_info.color_given), optarg, 0, 0, ARG_FLAG,
1691 check_ambiguity, override, 1, 0, "color", '-',
1696 /* Produce a colored and structure annotated alignment in PostScript format in the file \"aln.ps\" in the current directory.
1699 else if (strcmp (long_options[option_index].name, "aln") == 0)
1703 if (update_arg((void *)&(args_info->aln_flag), 0, &(args_info->aln_given),
1704 &(local_args_info.aln_given), optarg, 0, 0, ARG_FLAG,
1705 check_ambiguity, override, 1, 0, "aln", '-',
1710 /* Do not produce postscript output
1713 else if (strcmp (long_options[option_index].name, "noPS") == 0)
1717 if (update_arg((void *)&(args_info->noPS_flag), 0, &(args_info->noPS_given),
1718 &(local_args_info.noPS_given), optarg, 0, 0, ARG_FLAG,
1719 check_ambiguity, override, 1, 0, "noPS", '-',
1724 /* Calculate an MEA (maximum expected accuracy) structure.
1726 else if (strcmp (long_options[option_index].name, "MEA") == 0)
1730 if (update_arg( (void *)&(args_info->MEA_arg),
1731 &(args_info->MEA_orig), &(args_info->MEA_given),
1732 &(local_args_info.MEA_given), optarg, 0, "1.", ARG_FLOAT,
1733 check_ambiguity, override, 0, 0,
1739 /* Output \"most informative sequence\" instead of simple consensus: For each column of the alignment output the set of nucleotides with frequence greater than average in IUPAC notation.
1742 else if (strcmp (long_options[option_index].name, "mis") == 0)
1746 if (update_arg((void *)&(args_info->mis_flag), 0, &(args_info->mis_given),
1747 &(local_args_info.mis_given), optarg, 0, 0, ARG_FLAG,
1748 check_ambiguity, override, 1, 0, "mis", '-',
1753 /* same as \"-s\" but also print out the energies and probabilities of the backtraced structures.
1756 else if (strcmp (long_options[option_index].name, "stochBT_en") == 0)
1760 if (update_arg( (void *)&(args_info->stochBT_en_arg),
1761 &(args_info->stochBT_en_orig), &(args_info->stochBT_en_given),
1762 &(local_args_info.stochBT_en_given), optarg, 0, 0, ARG_INT,
1763 check_ambiguity, override, 0, 0,
1769 /* Set the threshold for base pair probabilities included in the postscript output
1771 else if (strcmp (long_options[option_index].name, "bppmThreshold") == 0)
1775 if (update_arg( (void *)&(args_info->bppmThreshold_arg),
1776 &(args_info->bppmThreshold_orig), &(args_info->bppmThreshold_given),
1777 &(local_args_info.bppmThreshold_given), optarg, 0, "1e-6", ARG_DOUBLE,
1778 check_ambiguity, override, 0, 0,
1779 "bppmThreshold", '-',
1784 /* Produce structures without lonely pairs (helices of length 1).
1786 else if (strcmp (long_options[option_index].name, "noLP") == 0)
1790 if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1791 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1792 check_ambiguity, override, 1, 0, "noLP", '-',
1797 /* Do not allow GU pairs
1800 else if (strcmp (long_options[option_index].name, "noGU") == 0)
1804 if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1805 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1806 check_ambiguity, override, 1, 0, "noGU", '-',
1811 /* Do not allow GU pairs at the end of helices
1814 else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1818 if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1819 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1820 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1825 /* Set the weight of the covariance term in the energy function
1828 else if (strcmp (long_options[option_index].name, "cfactor") == 0)
1832 if (update_arg( (void *)&(args_info->cfactor_arg),
1833 &(args_info->cfactor_orig), &(args_info->cfactor_given),
1834 &(local_args_info.cfactor_given), optarg, 0, "1.0", ARG_DOUBLE,
1835 check_ambiguity, override, 0, 0,
1841 /* Set the penalty for non-compatible sequences in the covariance term of the energy function
1844 else if (strcmp (long_options[option_index].name, "nfactor") == 0)
1848 if (update_arg( (void *)&(args_info->nfactor_arg),
1849 &(args_info->nfactor_orig), &(args_info->nfactor_given),
1850 &(local_args_info.nfactor_given), optarg, 0, "1.0", ARG_DOUBLE,
1851 check_ambiguity, override, 0, 0,
1857 /* use old energy evaluation, treating gaps as characters.
1860 else if (strcmp (long_options[option_index].name, "old") == 0)
1864 if (update_arg((void *)&(args_info->old_flag), 0, &(args_info->old_given),
1865 &(local_args_info.old_given), optarg, 0, 0, ARG_FLAG,
1866 check_ambiguity, override, 1, 0, "old", '-',
1871 /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1873 else if (strcmp (long_options[option_index].name, "nsp") == 0)
1877 if (update_arg( (void *)&(args_info->nsp_arg),
1878 &(args_info->nsp_orig), &(args_info->nsp_given),
1879 &(local_args_info.nsp_given), optarg, 0, 0, ARG_STRING,
1880 check_ambiguity, override, 0, 0,
1886 /* Set the scaling of the Boltzmann factors
1888 else if (strcmp (long_options[option_index].name, "betaScale") == 0)
1892 if (update_arg( (void *)&(args_info->betaScale_arg),
1893 &(args_info->betaScale_orig), &(args_info->betaScale_given),
1894 &(local_args_info.betaScale_given), optarg, 0, "1.", ARG_DOUBLE,
1895 check_ambiguity, override, 0, 0,
1903 case '?': /* Invalid option. */
1904 /* `getopt_long' already printed an error message. */
1907 default: /* bug: option not considered. */
1908 fprintf (stderr, "%s: option unknown: %c%s\n", RNAALIFOLD_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1917 error += RNAalifold_cmdline_parser_required2 (args_info, argv[0], additional_error);
1920 RNAalifold_cmdline_parser_release (&local_args_info);
1923 return (EXIT_FAILURE);
1928 int found_prog_name = 0;
1929 /* whether program name, i.e., argv[0], is in the remaining args
1930 (this may happen with some implementations of getopt,
1931 but surely not with the one included by gengetopt) */
1934 args_info->inputs_num = argc - optind - found_prog_name;
1936 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1937 while (optind < argc)
1938 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
1945 RNAalifold_cmdline_parser_release (&local_args_info);
1946 return (EXIT_FAILURE);