2 File autogenerated by gengetopt version 2.22.5
3 generated with the following command:
4 gengetopt -i RNAsubopt.ggo --file-name=RNAsubopt_cmdl --include-getopt --default-optional --func-name=RNAsubopt_cmdline_parser --arg-struct-name=RNAsubopt_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 "RNAsubopt_cmdl.h"
27 const char *RNAsubopt_args_info_purpose = "calculate suboptimal secondary structures of RNAs";
29 const char *RNAsubopt_args_info_usage = "Usage: RNAsubopt [OPTIONS]...";
31 const char *RNAsubopt_args_info_description = "reads RNA sequences from stdin and (in the default -e mode) calculates all \nsuboptimal secondary structures within a user defined energy range above the \nminimum free energy (mfe). It prints the suboptimal structures in dot-bracket \nnotation followed by the energy in kcal/mol to stdout. Be careful, the number \nof structures returned grows exponentially with both sequence length and energy \nrange.\n\nAlternatively, when used with the -p option, RNAsubopt produces Boltzmann \nweighted samples of secondary structures.\n";
33 const char *RNAsubopt_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 (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 " --noconv Do not automatically substitude nucleotide \n \"T\" with \"U\"\n\n (default=off)",
44 " Select the algorithms which should be applied to the given RNA sequence.\n",
45 " -e, --deltaEnergy=range Compute suboptimal structures with energy in a \n certain range of the optimum (kcal/mol). \n Default is calculation of mfe structure only.\n\n",
46 " --deltaEnergyPost=range Only print structures with energy within range \n of the mfe after post reevaluation of \n energies.\n",
47 " Useful in conjunction with -logML, -d1 or -d3: while the -e option specifies \n the range before energies are re-evaluated, this option specifies the maximum \n energy after re-evaluation.\n\n",
48 " -s, --sorted Sort the suboptimal structures by energy.\n (default=off)",
49 " Since the sort in is done in memory, this becomes impractical when the number \n of structures produced goes into millions. In such cases better pipe the \n output through \"sort +1n\".\n\n",
50 " -p, --stochBT=number Instead of producing all suboptimals in an \n energy range, produce a random sample of \n suboptimal structures, drawn with \n probabilities equal to their Boltzmann \n weights via stochastic backtracking in the \n partition function. The -e and -p options are \n mutually exclusive.\n\n",
51 " -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). Needed by \n stochastic backtracking\n",
52 " 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",
53 " -c, --circ Assume a circular (instead of linear) RNA \n molecule.\n\n (default=off)",
54 " -D, --dos Compute density of states instead of secondary \n structures\n (default=off)",
55 " This option enables the evaluation of the number of secondary structures in \n certain energy bands arround the MFE.\n",
56 " -z, --zuker Compute Zuker suboptimals instead of all \n suboptimal structures within an engery band \n arround the MFE.\n\n (default=off)",
58 " -T, --temp=DOUBLE Rescale energy parameters to a temperature of \n temp C. Default is 37C.\n\n",
59 " -4, --noTetra Do not include special tabulated stabilizing \n energies for tri-, tetra- and hexaloop \n hairpins. Mostly for testing.\n\n (default=off)",
60 " -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')",
61 " \n With -d1 only unpaired bases can participate in at most one dangling end, \n this is the default for mfe folding but unsupported for the partition \n function folding.\n\n With -d2 this check is ignored, dangling energies will be added for the bases \n adjacent to a helix on both sides in any case; this is the default for \n partition function folding (-p).\n The option -d0 ignores dangling ends altogether (mostly for debugging).\n With -d3 mfe folding will allow coaxial stacking of adjacent helices in \n multi-loops. At the moment the implementation will not allow coaxial stacking \n of the two interior pairs in a loop of degree 3 and works only for mfe \n folding.\n\n Note that by default (as well as with -d1 and -d3) pf and mfe folding treat \n dangling ends differently. Use -d2 in addition to -p to ensure that both \n algorithms use the same energy model.\n\n",
62 " --noLP Produce structures without lonely pairs \n (helices of length 1).\n (default=off)",
63 " 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",
64 " --noGU Do not allow GU pairs\n\n (default=off)",
65 " --noClosingGU Do not allow GU pairs at the end of helices\n\n (default=off)",
66 " --logML Recalculate energies of structures using a \n logarithmic energy function for multi-loops \n before output. (default=off)",
67 " This option does not effect structure generation, only the energies that are \n printed out. Since logML lowers energies somewhat, some structures may be \n missing.\n\n",
68 " --betaScale=DOUBLE Set the scaling of the Boltzmann factors\n (default=`1.')",
69 " 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/(kT*betaScale)) where k is the \n Boltzmann constant, dG the free energy contribution of the state and T the \n absolute temperature.\n\n",
70 " -P, --paramFile=paramfile Read energy parameters from paramfile, instead \n of using the default parameter set.\n",
71 " A sample parameter file should accompany your distribution.\n See the RNAlib documentation for details on the file format.\n\n",
72 " --nsp=STRING Allow other pairs in addition to the usual \n AU,GC,and GU pairs.\n",
73 " 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",
74 "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
78 init_full_help_array(void)
80 RNAsubopt_args_info_full_help[0] = RNAsubopt_args_info_detailed_help[0];
81 RNAsubopt_args_info_full_help[1] = RNAsubopt_args_info_detailed_help[1];
82 RNAsubopt_args_info_full_help[2] = RNAsubopt_args_info_detailed_help[2];
83 RNAsubopt_args_info_full_help[3] = RNAsubopt_args_info_detailed_help[3];
84 RNAsubopt_args_info_full_help[4] = RNAsubopt_args_info_detailed_help[4];
85 RNAsubopt_args_info_full_help[5] = RNAsubopt_args_info_detailed_help[5];
86 RNAsubopt_args_info_full_help[6] = RNAsubopt_args_info_detailed_help[6];
87 RNAsubopt_args_info_full_help[7] = RNAsubopt_args_info_detailed_help[8];
88 RNAsubopt_args_info_full_help[8] = RNAsubopt_args_info_detailed_help[9];
89 RNAsubopt_args_info_full_help[9] = RNAsubopt_args_info_detailed_help[10];
90 RNAsubopt_args_info_full_help[10] = RNAsubopt_args_info_detailed_help[11];
91 RNAsubopt_args_info_full_help[11] = RNAsubopt_args_info_detailed_help[12];
92 RNAsubopt_args_info_full_help[12] = RNAsubopt_args_info_detailed_help[14];
93 RNAsubopt_args_info_full_help[13] = RNAsubopt_args_info_detailed_help[16];
94 RNAsubopt_args_info_full_help[14] = RNAsubopt_args_info_detailed_help[17];
95 RNAsubopt_args_info_full_help[15] = RNAsubopt_args_info_detailed_help[19];
96 RNAsubopt_args_info_full_help[16] = RNAsubopt_args_info_detailed_help[20];
97 RNAsubopt_args_info_full_help[17] = RNAsubopt_args_info_detailed_help[22];
98 RNAsubopt_args_info_full_help[18] = RNAsubopt_args_info_detailed_help[23];
99 RNAsubopt_args_info_full_help[19] = RNAsubopt_args_info_detailed_help[24];
100 RNAsubopt_args_info_full_help[20] = RNAsubopt_args_info_detailed_help[25];
101 RNAsubopt_args_info_full_help[21] = RNAsubopt_args_info_detailed_help[26];
102 RNAsubopt_args_info_full_help[22] = RNAsubopt_args_info_detailed_help[28];
103 RNAsubopt_args_info_full_help[23] = RNAsubopt_args_info_detailed_help[30];
104 RNAsubopt_args_info_full_help[24] = RNAsubopt_args_info_detailed_help[31];
105 RNAsubopt_args_info_full_help[25] = RNAsubopt_args_info_detailed_help[32];
106 RNAsubopt_args_info_full_help[26] = RNAsubopt_args_info_detailed_help[34];
107 RNAsubopt_args_info_full_help[27] = RNAsubopt_args_info_detailed_help[36];
108 RNAsubopt_args_info_full_help[28] = RNAsubopt_args_info_detailed_help[38];
109 RNAsubopt_args_info_full_help[29] = RNAsubopt_args_info_detailed_help[40];
110 RNAsubopt_args_info_full_help[30] = 0;
114 const char *RNAsubopt_args_info_full_help[31];
117 init_help_array(void)
119 RNAsubopt_args_info_help[0] = RNAsubopt_args_info_detailed_help[0];
120 RNAsubopt_args_info_help[1] = RNAsubopt_args_info_detailed_help[1];
121 RNAsubopt_args_info_help[2] = RNAsubopt_args_info_detailed_help[2];
122 RNAsubopt_args_info_help[3] = RNAsubopt_args_info_detailed_help[3];
123 RNAsubopt_args_info_help[4] = RNAsubopt_args_info_detailed_help[4];
124 RNAsubopt_args_info_help[5] = RNAsubopt_args_info_detailed_help[5];
125 RNAsubopt_args_info_help[6] = RNAsubopt_args_info_detailed_help[6];
126 RNAsubopt_args_info_help[7] = RNAsubopt_args_info_detailed_help[8];
127 RNAsubopt_args_info_help[8] = RNAsubopt_args_info_detailed_help[9];
128 RNAsubopt_args_info_help[9] = RNAsubopt_args_info_detailed_help[10];
129 RNAsubopt_args_info_help[10] = RNAsubopt_args_info_detailed_help[11];
130 RNAsubopt_args_info_help[11] = RNAsubopt_args_info_detailed_help[12];
131 RNAsubopt_args_info_help[12] = RNAsubopt_args_info_detailed_help[14];
132 RNAsubopt_args_info_help[13] = RNAsubopt_args_info_detailed_help[16];
133 RNAsubopt_args_info_help[14] = RNAsubopt_args_info_detailed_help[19];
134 RNAsubopt_args_info_help[15] = RNAsubopt_args_info_detailed_help[20];
135 RNAsubopt_args_info_help[16] = RNAsubopt_args_info_detailed_help[22];
136 RNAsubopt_args_info_help[17] = RNAsubopt_args_info_detailed_help[23];
137 RNAsubopt_args_info_help[18] = RNAsubopt_args_info_detailed_help[24];
138 RNAsubopt_args_info_help[19] = RNAsubopt_args_info_detailed_help[25];
139 RNAsubopt_args_info_help[20] = RNAsubopt_args_info_detailed_help[26];
140 RNAsubopt_args_info_help[21] = RNAsubopt_args_info_detailed_help[28];
141 RNAsubopt_args_info_help[22] = RNAsubopt_args_info_detailed_help[30];
142 RNAsubopt_args_info_help[23] = RNAsubopt_args_info_detailed_help[31];
143 RNAsubopt_args_info_help[24] = RNAsubopt_args_info_detailed_help[32];
144 RNAsubopt_args_info_help[25] = RNAsubopt_args_info_detailed_help[36];
145 RNAsubopt_args_info_help[26] = RNAsubopt_args_info_detailed_help[40];
146 RNAsubopt_args_info_help[27] = 0;
150 const char *RNAsubopt_args_info_help[28];
158 } RNAsubopt_cmdline_parser_arg_type;
161 void clear_given (struct RNAsubopt_args_info *args_info);
163 void clear_args (struct RNAsubopt_args_info *args_info);
166 RNAsubopt_cmdline_parser_internal (int argc, char **argv, struct RNAsubopt_args_info *args_info,
167 struct RNAsubopt_cmdline_parser_params *params, const char *additional_error);
170 RNAsubopt_cmdline_parser_required2 (struct RNAsubopt_args_info *args_info, const char *prog_name, const char *additional_error);
173 gengetopt_strdup (const char *s);
176 void clear_given (struct RNAsubopt_args_info *args_info)
178 args_info->help_given = 0 ;
179 args_info->detailed_help_given = 0 ;
180 args_info->full_help_given = 0 ;
181 args_info->version_given = 0 ;
182 args_info->constraint_given = 0 ;
183 args_info->noconv_given = 0 ;
184 args_info->deltaEnergy_given = 0 ;
185 args_info->deltaEnergyPost_given = 0 ;
186 args_info->sorted_given = 0 ;
187 args_info->stochBT_given = 0 ;
188 args_info->pfScale_given = 0 ;
189 args_info->circ_given = 0 ;
190 args_info->dos_given = 0 ;
191 args_info->zuker_given = 0 ;
192 args_info->temp_given = 0 ;
193 args_info->noTetra_given = 0 ;
194 args_info->dangles_given = 0 ;
195 args_info->noLP_given = 0 ;
196 args_info->noGU_given = 0 ;
197 args_info->noClosingGU_given = 0 ;
198 args_info->logML_given = 0 ;
199 args_info->betaScale_given = 0 ;
200 args_info->paramFile_given = 0 ;
201 args_info->nsp_given = 0 ;
205 void clear_args (struct RNAsubopt_args_info *args_info)
207 FIX_UNUSED (args_info);
208 args_info->constraint_flag = 0;
209 args_info->noconv_flag = 0;
210 args_info->deltaEnergy_orig = NULL;
211 args_info->deltaEnergyPost_orig = NULL;
212 args_info->sorted_flag = 0;
213 args_info->stochBT_orig = NULL;
214 args_info->pfScale_orig = NULL;
215 args_info->circ_flag = 0;
216 args_info->dos_flag = 0;
217 args_info->zuker_flag = 0;
218 args_info->temp_orig = NULL;
219 args_info->noTetra_flag = 0;
220 args_info->dangles_arg = 2;
221 args_info->dangles_orig = NULL;
222 args_info->noLP_flag = 0;
223 args_info->noGU_flag = 0;
224 args_info->noClosingGU_flag = 0;
225 args_info->logML_flag = 0;
226 args_info->betaScale_arg = 1.;
227 args_info->betaScale_orig = NULL;
228 args_info->paramFile_arg = NULL;
229 args_info->paramFile_orig = NULL;
230 args_info->nsp_arg = NULL;
231 args_info->nsp_orig = NULL;
236 void init_args_info(struct RNAsubopt_args_info *args_info)
238 init_full_help_array();
240 args_info->help_help = RNAsubopt_args_info_detailed_help[0] ;
241 args_info->detailed_help_help = RNAsubopt_args_info_detailed_help[1] ;
242 args_info->full_help_help = RNAsubopt_args_info_detailed_help[2] ;
243 args_info->version_help = RNAsubopt_args_info_detailed_help[3] ;
244 args_info->constraint_help = RNAsubopt_args_info_detailed_help[6] ;
245 args_info->noconv_help = RNAsubopt_args_info_detailed_help[8] ;
246 args_info->deltaEnergy_help = RNAsubopt_args_info_detailed_help[11] ;
247 args_info->deltaEnergyPost_help = RNAsubopt_args_info_detailed_help[12] ;
248 args_info->sorted_help = RNAsubopt_args_info_detailed_help[14] ;
249 args_info->stochBT_help = RNAsubopt_args_info_detailed_help[16] ;
250 args_info->pfScale_help = RNAsubopt_args_info_detailed_help[17] ;
251 args_info->circ_help = RNAsubopt_args_info_detailed_help[19] ;
252 args_info->dos_help = RNAsubopt_args_info_detailed_help[20] ;
253 args_info->zuker_help = RNAsubopt_args_info_detailed_help[22] ;
254 args_info->temp_help = RNAsubopt_args_info_detailed_help[24] ;
255 args_info->noTetra_help = RNAsubopt_args_info_detailed_help[25] ;
256 args_info->dangles_help = RNAsubopt_args_info_detailed_help[26] ;
257 args_info->noLP_help = RNAsubopt_args_info_detailed_help[28] ;
258 args_info->noGU_help = RNAsubopt_args_info_detailed_help[30] ;
259 args_info->noClosingGU_help = RNAsubopt_args_info_detailed_help[31] ;
260 args_info->logML_help = RNAsubopt_args_info_detailed_help[32] ;
261 args_info->betaScale_help = RNAsubopt_args_info_detailed_help[34] ;
262 args_info->paramFile_help = RNAsubopt_args_info_detailed_help[36] ;
263 args_info->nsp_help = RNAsubopt_args_info_detailed_help[38] ;
268 RNAsubopt_cmdline_parser_print_version (void)
271 (strlen(RNASUBOPT_CMDLINE_PARSER_PACKAGE_NAME) ? RNASUBOPT_CMDLINE_PARSER_PACKAGE_NAME : RNASUBOPT_CMDLINE_PARSER_PACKAGE),
272 RNASUBOPT_CMDLINE_PARSER_VERSION);
275 static void print_help_common(void) {
276 RNAsubopt_cmdline_parser_print_version ();
278 if (strlen(RNAsubopt_args_info_purpose) > 0)
279 printf("\n%s\n", RNAsubopt_args_info_purpose);
281 if (strlen(RNAsubopt_args_info_usage) > 0)
282 printf("\n%s\n", RNAsubopt_args_info_usage);
286 if (strlen(RNAsubopt_args_info_description) > 0)
287 printf("%s\n\n", RNAsubopt_args_info_description);
291 RNAsubopt_cmdline_parser_print_help (void)
295 while (RNAsubopt_args_info_help[i])
296 printf("%s\n", RNAsubopt_args_info_help[i++]);
300 RNAsubopt_cmdline_parser_print_full_help (void)
304 while (RNAsubopt_args_info_full_help[i])
305 printf("%s\n", RNAsubopt_args_info_full_help[i++]);
309 RNAsubopt_cmdline_parser_print_detailed_help (void)
313 while (RNAsubopt_args_info_detailed_help[i])
314 printf("%s\n", RNAsubopt_args_info_detailed_help[i++]);
318 RNAsubopt_cmdline_parser_init (struct RNAsubopt_args_info *args_info)
320 clear_given (args_info);
321 clear_args (args_info);
322 init_args_info (args_info);
326 RNAsubopt_cmdline_parser_params_init(struct RNAsubopt_cmdline_parser_params *params)
330 params->override = 0;
331 params->initialize = 1;
332 params->check_required = 1;
333 params->check_ambiguity = 0;
334 params->print_errors = 1;
338 struct RNAsubopt_cmdline_parser_params *
339 RNAsubopt_cmdline_parser_params_create(void)
341 struct RNAsubopt_cmdline_parser_params *params =
342 (struct RNAsubopt_cmdline_parser_params *)malloc(sizeof(struct RNAsubopt_cmdline_parser_params));
343 RNAsubopt_cmdline_parser_params_init(params);
348 free_string_field (char **s)
359 RNAsubopt_cmdline_parser_release (struct RNAsubopt_args_info *args_info)
362 free_string_field (&(args_info->deltaEnergy_orig));
363 free_string_field (&(args_info->deltaEnergyPost_orig));
364 free_string_field (&(args_info->stochBT_orig));
365 free_string_field (&(args_info->pfScale_orig));
366 free_string_field (&(args_info->temp_orig));
367 free_string_field (&(args_info->dangles_orig));
368 free_string_field (&(args_info->betaScale_orig));
369 free_string_field (&(args_info->paramFile_arg));
370 free_string_field (&(args_info->paramFile_orig));
371 free_string_field (&(args_info->nsp_arg));
372 free_string_field (&(args_info->nsp_orig));
376 clear_given (args_info);
381 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
385 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
387 fprintf(outfile, "%s\n", opt);
393 RNAsubopt_cmdline_parser_dump(FILE *outfile, struct RNAsubopt_args_info *args_info)
399 fprintf (stderr, "%s: cannot dump options to stream\n", RNASUBOPT_CMDLINE_PARSER_PACKAGE);
403 if (args_info->help_given)
404 write_into_file(outfile, "help", 0, 0 );
405 if (args_info->detailed_help_given)
406 write_into_file(outfile, "detailed-help", 0, 0 );
407 if (args_info->full_help_given)
408 write_into_file(outfile, "full-help", 0, 0 );
409 if (args_info->version_given)
410 write_into_file(outfile, "version", 0, 0 );
411 if (args_info->constraint_given)
412 write_into_file(outfile, "constraint", 0, 0 );
413 if (args_info->noconv_given)
414 write_into_file(outfile, "noconv", 0, 0 );
415 if (args_info->deltaEnergy_given)
416 write_into_file(outfile, "deltaEnergy", args_info->deltaEnergy_orig, 0);
417 if (args_info->deltaEnergyPost_given)
418 write_into_file(outfile, "deltaEnergyPost", args_info->deltaEnergyPost_orig, 0);
419 if (args_info->sorted_given)
420 write_into_file(outfile, "sorted", 0, 0 );
421 if (args_info->stochBT_given)
422 write_into_file(outfile, "stochBT", args_info->stochBT_orig, 0);
423 if (args_info->pfScale_given)
424 write_into_file(outfile, "pfScale", args_info->pfScale_orig, 0);
425 if (args_info->circ_given)
426 write_into_file(outfile, "circ", 0, 0 );
427 if (args_info->dos_given)
428 write_into_file(outfile, "dos", 0, 0 );
429 if (args_info->zuker_given)
430 write_into_file(outfile, "zuker", 0, 0 );
431 if (args_info->temp_given)
432 write_into_file(outfile, "temp", args_info->temp_orig, 0);
433 if (args_info->noTetra_given)
434 write_into_file(outfile, "noTetra", 0, 0 );
435 if (args_info->dangles_given)
436 write_into_file(outfile, "dangles", args_info->dangles_orig, 0);
437 if (args_info->noLP_given)
438 write_into_file(outfile, "noLP", 0, 0 );
439 if (args_info->noGU_given)
440 write_into_file(outfile, "noGU", 0, 0 );
441 if (args_info->noClosingGU_given)
442 write_into_file(outfile, "noClosingGU", 0, 0 );
443 if (args_info->logML_given)
444 write_into_file(outfile, "logML", 0, 0 );
445 if (args_info->betaScale_given)
446 write_into_file(outfile, "betaScale", args_info->betaScale_orig, 0);
447 if (args_info->paramFile_given)
448 write_into_file(outfile, "paramFile", args_info->paramFile_orig, 0);
449 if (args_info->nsp_given)
450 write_into_file(outfile, "nsp", args_info->nsp_orig, 0);
458 RNAsubopt_cmdline_parser_file_save(const char *filename, struct RNAsubopt_args_info *args_info)
463 outfile = fopen(filename, "w");
467 fprintf (stderr, "%s: cannot open file for writing: %s\n", RNASUBOPT_CMDLINE_PARSER_PACKAGE, filename);
471 i = RNAsubopt_cmdline_parser_dump(outfile, args_info);
478 RNAsubopt_cmdline_parser_free (struct RNAsubopt_args_info *args_info)
480 RNAsubopt_cmdline_parser_release (args_info);
483 /** @brief replacement of strdup, which is not standard */
485 gengetopt_strdup (const char *s)
491 result = (char*)malloc(strlen(s) + 1);
492 if (result == (char*)0)
499 RNAsubopt_cmdline_parser (int argc, char **argv, struct RNAsubopt_args_info *args_info)
501 return RNAsubopt_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
505 RNAsubopt_cmdline_parser_ext (int argc, char **argv, struct RNAsubopt_args_info *args_info,
506 struct RNAsubopt_cmdline_parser_params *params)
509 result = RNAsubopt_cmdline_parser_internal (argc, argv, args_info, params, 0);
511 if (result == EXIT_FAILURE)
513 RNAsubopt_cmdline_parser_free (args_info);
521 RNAsubopt_cmdline_parser2 (int argc, char **argv, struct RNAsubopt_args_info *args_info, int override, int initialize, int check_required)
524 struct RNAsubopt_cmdline_parser_params params;
526 params.override = override;
527 params.initialize = initialize;
528 params.check_required = check_required;
529 params.check_ambiguity = 0;
530 params.print_errors = 1;
532 result = RNAsubopt_cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
534 if (result == EXIT_FAILURE)
536 RNAsubopt_cmdline_parser_free (args_info);
544 RNAsubopt_cmdline_parser_required (struct RNAsubopt_args_info *args_info, const char *prog_name)
546 int result = EXIT_SUCCESS;
548 if (RNAsubopt_cmdline_parser_required2(args_info, prog_name, 0) > 0)
549 result = EXIT_FAILURE;
551 if (result == EXIT_FAILURE)
553 RNAsubopt_cmdline_parser_free (args_info);
561 RNAsubopt_cmdline_parser_required2 (struct RNAsubopt_args_info *args_info, const char *prog_name, const char *additional_error)
564 FIX_UNUSED (additional_error);
566 /* checks for required options */
568 /* checks for dependences among options */
569 if (args_info->betaScale_given && ! args_info->stochBT_given)
571 fprintf (stderr, "%s: '--betaScale' option depends on option 'stochBT'%s\n", prog_name, (additional_error ? additional_error : ""));
579 * Extracted from the glibc source tree, version 2.3.6
581 * Licensed under the GPL as per the whole glibc source tree.
583 * This file was modified so that getopt_long can be called
584 * many times without risking previous memory to be spoiled.
586 * Modified by Andre Noll and Lorenzo Bettini for use in
587 * GNU gengetopt generated files.
592 * we must include anything we need since this file is not thought to be
593 * inserted in a file already using getopt.h
601 /* has_arg can't be an enum because some compilers complain about
602 type mismatches in all the code that assumes it is an int. */
608 /* This version of `getopt' appears to the caller like standard Unix `getopt'
609 but it behaves differently for the user, since it allows the user
610 to intersperse the options with the other arguments.
612 As `getopt' works, it permutes the elements of ARGV so that,
613 when it is done, all the options precede everything else. Thus
614 all application programs are extended to handle flexible argument order.
617 If the field `flag' is not NULL, it points to a variable that is set
618 to the value given in the field `val' when the option is found, but
619 left unchanged if the option is not found.
621 To have a long-named option do something other than set an `int' to
622 a compiled-in constant, such as set a value from `custom_optarg', set the
623 option's `flag' field to zero and its `val' field to a nonzero
624 value (the equivalent single-letter option character, if there is
625 one). For long options that have a zero `flag' field, `getopt'
626 returns the contents of the `val' field. */
628 /* Names for the values of the `has_arg' field of `struct option'. */
630 #define no_argument 0
633 #ifndef required_argument
634 #define required_argument 1
637 #ifndef optional_argument
638 #define optional_argument 2
641 struct custom_getopt_data {
643 * These have exactly the same meaning as the corresponding global variables,
644 * except that they are used for the reentrant versions of getopt.
651 /* True if the internal members have been initialized. */
655 * The next char to be scanned in the option-element in which the last option
656 * character we returned was found. This allows us to pick up the scan where
657 * we left off. If this is zero, or a null string, it means resume the scan by
658 * advancing to the next ARGV-element.
663 * Describe the part of ARGV that contains non-options that have been skipped.
664 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
665 * the index after the last of them.
672 * the variables optarg, optind, opterr and optopt are renamed with
673 * the custom_ prefix so that they don't interfere with getopt ones.
675 * Moreover they're static so they are visible only from within the
676 * file where this very file will be included.
680 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
681 * option that takes an argument, the argument value is returned here.
683 static char *custom_optarg;
686 * Index in ARGV of the next element to be scanned. This is used for
687 * communication to and from the caller and for communication between
688 * successive calls to `custom_getopt'.
690 * On entry to `custom_getopt', 1 means this is the first call; initialize.
692 * When `custom_getopt' returns -1, this is the index of the first of the non-option
693 * elements that the caller should itself scan.
695 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
696 * has been scanned so far.
698 * 1003.2 says this must be 1 before any call.
700 static int custom_optind = 1;
703 * Callers store zero here to inhibit the error message for unrecognized
706 static int custom_opterr = 1;
709 * Set to an option character which was unrecognized. This must be initialized
710 * on some systems to avoid linking in the system's own getopt implementation.
712 static int custom_optopt = '?';
715 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
716 * [first_nonopt,last_nonopt) which contains all the non-options that have been
717 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
718 * all the options processed since those non-options were skipped.
719 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
720 * indices of the non-options in ARGV after they are moved.
722 static void exchange(char **argv, struct custom_getopt_data *d)
724 int bottom = d->first_nonopt;
725 int middle = d->last_nonopt;
726 int top = d->custom_optind;
730 * Exchange the shorter segment with the far end of the longer segment.
731 * That puts the shorter segment into the right place. It leaves the
732 * longer segment in the right place overall, but it consists of two
733 * parts that need to be swapped next.
735 while (top > middle && middle > bottom) {
736 if (top - middle > middle - bottom) {
737 /* Bottom segment is the short one. */
738 int len = middle - bottom;
741 /* Swap it with the top part of the top segment. */
742 for (i = 0; i < len; i++) {
743 tem = argv[bottom + i];
745 argv[top - (middle - bottom) + i];
746 argv[top - (middle - bottom) + i] = tem;
748 /* Exclude the moved bottom segment from further swapping. */
751 /* Top segment is the short one. */
752 int len = top - middle;
755 /* Swap it with the bottom part of the bottom segment. */
756 for (i = 0; i < len; i++) {
757 tem = argv[bottom + i];
758 argv[bottom + i] = argv[middle + i];
759 argv[middle + i] = tem;
761 /* Exclude the moved top segment from further swapping. */
765 /* Update records for the slots the non-options now occupy. */
766 d->first_nonopt += (d->custom_optind - d->last_nonopt);
767 d->last_nonopt = d->custom_optind;
770 /* Initialize the internal data when the first call is made. */
771 static void custom_getopt_initialize(struct custom_getopt_data *d)
774 * Start processing options with ARGV-element 1 (since ARGV-element 0
775 * is the program name); the sequence of previously skipped non-option
776 * ARGV-elements is empty.
778 d->first_nonopt = d->last_nonopt = d->custom_optind;
783 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
785 /* return: zero: continue, nonzero: return given value to user */
786 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
787 struct custom_getopt_data *d)
790 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
791 * moved back by the user (who may also have changed the arguments).
793 if (d->last_nonopt > d->custom_optind)
794 d->last_nonopt = d->custom_optind;
795 if (d->first_nonopt > d->custom_optind)
796 d->first_nonopt = d->custom_optind;
798 * If we have just processed some options following some
799 * non-options, exchange them so that the options come first.
801 if (d->first_nonopt != d->last_nonopt &&
802 d->last_nonopt != d->custom_optind)
803 exchange((char **) argv, d);
804 else if (d->last_nonopt != d->custom_optind)
805 d->first_nonopt = d->custom_optind;
807 * Skip any additional non-options and extend the range of
808 * non-options previously skipped.
810 while (d->custom_optind < argc && NONOPTION_P)
812 d->last_nonopt = d->custom_optind;
814 * The special ARGV-element `--' means premature end of options. Skip
815 * it like a null option, then exchange with previous non-options as if
816 * it were an option, then skip everything else like a non-option.
818 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
820 if (d->first_nonopt != d->last_nonopt
821 && d->last_nonopt != d->custom_optind)
822 exchange((char **) argv, d);
823 else if (d->first_nonopt == d->last_nonopt)
824 d->first_nonopt = d->custom_optind;
825 d->last_nonopt = argc;
826 d->custom_optind = argc;
829 * If we have done all the ARGV-elements, stop the scan and back over
830 * any non-options that we skipped and permuted.
832 if (d->custom_optind == argc) {
834 * Set the next-arg-index to point at the non-options that we
835 * previously skipped, so the caller will digest them.
837 if (d->first_nonopt != d->last_nonopt)
838 d->custom_optind = d->first_nonopt;
842 * If we have come to a non-option and did not permute it, either stop
843 * the scan or describe it to the caller and pass it by.
846 d->custom_optarg = argv[d->custom_optind++];
850 * We have found another option-ARGV-element. Skip the initial
853 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
858 * Check whether the ARGV-element is a long option.
860 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
861 * that an abbreviation of the long option, just like "--fu", and not "-f" with
864 * This distinction seems to be the most useful approach.
867 static int check_long_opt(int argc, char *const *argv, const char *optstring,
868 const struct option *longopts, int *longind,
869 int print_errors, struct custom_getopt_data *d)
872 const struct option *p;
873 const struct option *pfound = NULL;
879 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
882 /* Test all long options for either exact match or abbreviated matches */
883 for (p = longopts, option_index = 0; p->name; p++, option_index++)
884 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
885 if ((unsigned int) (nameend - d->nextchar)
886 == (unsigned int) strlen(p->name)) {
887 /* Exact match found. */
889 indfound = option_index;
892 } else if (pfound == NULL) {
893 /* First nonexact match found. */
895 indfound = option_index;
896 } else if (pfound->has_arg != p->has_arg
897 || pfound->flag != p->flag
898 || pfound->val != p->val)
899 /* Second or later nonexact match found. */
902 if (ambig && !exact) {
905 "%s: option `%s' is ambiguous\n",
906 argv[0], argv[d->custom_optind]);
908 d->nextchar += strlen(d->nextchar);
910 d->custom_optopt = 0;
914 option_index = indfound;
917 if (pfound->has_arg != no_argument)
918 d->custom_optarg = nameend + 1;
921 if (argv[d->custom_optind - 1][1] == '-') {
923 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
924 argv[0], pfound->name);
926 /* +option or -option */
927 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
928 argv[0], argv[d->custom_optind - 1][0], pfound->name);
932 d->nextchar += strlen(d->nextchar);
933 d->custom_optopt = pfound->val;
936 } else if (pfound->has_arg == required_argument) {
937 if (d->custom_optind < argc)
938 d->custom_optarg = argv[d->custom_optind++];
942 "%s: option `%s' requires an argument\n",
944 argv[d->custom_optind - 1]);
946 d->nextchar += strlen(d->nextchar);
947 d->custom_optopt = pfound->val;
948 return optstring[0] == ':' ? ':' : '?';
951 d->nextchar += strlen(d->nextchar);
953 *longind = option_index;
955 *(pfound->flag) = pfound->val;
961 * Can't find it as a long option. If this is not getopt_long_only, or
962 * the option starts with '--' or is not a valid short option, then
963 * it's an error. Otherwise interpret it as a short option.
966 if (argv[d->custom_optind][1] == '-') {
969 "%s: unrecognized option `--%s'\n",
970 argv[0], d->nextchar);
972 /* +option or -option */
974 "%s: unrecognized option `%c%s'\n",
975 argv[0], argv[d->custom_optind][0],
979 d->nextchar = (char *) "";
981 d->custom_optopt = 0;
985 static int check_short_opt(int argc, char *const *argv, const char *optstring,
986 int print_errors, struct custom_getopt_data *d)
988 char c = *d->nextchar++;
989 const char *temp = strchr(optstring, c);
991 /* Increment `custom_optind' when we start to process its last character. */
992 if (*d->nextchar == '\0')
994 if (!temp || c == ':') {
996 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
998 d->custom_optopt = c;
1001 if (temp[1] == ':') {
1002 if (temp[2] == ':') {
1003 /* This is an option that accepts an argument optionally. */
1004 if (*d->nextchar != '\0') {
1005 d->custom_optarg = d->nextchar;
1008 d->custom_optarg = NULL;
1011 /* This is an option that requires an argument. */
1012 if (*d->nextchar != '\0') {
1013 d->custom_optarg = d->nextchar;
1015 * If we end this ARGV-element by taking the
1016 * rest as an arg, we must advance to the next
1020 } else if (d->custom_optind == argc) {
1023 "%s: option requires an argument -- %c\n",
1026 d->custom_optopt = c;
1027 if (optstring[0] == ':')
1033 * We already incremented `custom_optind' once;
1034 * increment it again when taking next ARGV-elt
1037 d->custom_optarg = argv[d->custom_optind++];
1045 * Scan elements of ARGV for option characters given in OPTSTRING.
1047 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
1048 * then it is an option element. The characters of this element
1049 * (aside from the initial '-') are option characters. If `getopt'
1050 * is called repeatedly, it returns successively each of the option characters
1051 * from each of the option elements.
1053 * If `getopt' finds another option character, it returns that character,
1054 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
1055 * resume the scan with the following option character or ARGV-element.
1057 * If there are no more option characters, `getopt' returns -1.
1058 * Then `custom_optind' is the index in ARGV of the first ARGV-element
1059 * that is not an option. (The ARGV-elements have been permuted
1060 * so that those that are not options now come last.)
1062 * OPTSTRING is a string containing the legitimate option characters.
1063 * If an option character is seen that is not listed in OPTSTRING,
1064 * return '?' after printing an error message. If you set `custom_opterr' to
1065 * zero, the error message is suppressed but we still return '?'.
1067 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
1068 * so the following text in the same ARGV-element, or the text of the following
1069 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
1070 * wants an optional arg; if there is text in the current ARGV-element,
1071 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
1073 * If OPTSTRING starts with `-' or `+', it requests different methods of
1074 * handling the non-option ARGV-elements.
1075 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
1077 * Long-named options begin with `--' instead of `-'.
1078 * Their names may be abbreviated as long as the abbreviation is unique
1079 * or is an exact match for some defined option. If they have an
1080 * argument, it follows the option name in the same ARGV-element, separated
1081 * from the option name by a `=', or else the in next ARGV-element.
1082 * When `getopt' finds a long-named option, it returns 0 if that option's
1083 * `flag' field is nonzero, the value of the option's `val' field
1084 * if the `flag' field is zero.
1086 * The elements of ARGV aren't really const, because we permute them.
1087 * But we pretend they're const in the prototype to be compatible
1088 * with other systems.
1090 * LONGOPTS is a vector of `struct option' terminated by an
1091 * element containing a name which is zero.
1093 * LONGIND returns the index in LONGOPT of the long-named option found.
1094 * It is only valid when a long-named option has been found by the most
1097 * Return the option character from OPTS just read. Return -1 when there are
1098 * no more options. For unrecognized options, or options missing arguments,
1099 * `custom_optopt' is set to the option letter, and '?' is returned.
1101 * The OPTS string is a list of characters which are recognized option letters,
1102 * optionally followed by colons, specifying that that letter takes an
1103 * argument, to be placed in `custom_optarg'.
1105 * If a letter in OPTS is followed by two colons, its argument is optional.
1106 * This behavior is specific to the GNU `getopt'.
1108 * The argument `--' causes premature termination of argument scanning,
1109 * explicitly telling `getopt' that there are no more options. If OPTS begins
1110 * with `--', then non-option arguments are treated as arguments to the option
1111 * '\0'. This behavior is specific to the GNU `getopt'.
1114 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
1115 const struct option *longopts, int *longind,
1116 struct custom_getopt_data *d)
1118 int ret, print_errors = d->custom_opterr;
1120 if (optstring[0] == ':')
1124 d->custom_optarg = NULL;
1127 * This is a big difference with GNU getopt, since optind == 0
1128 * means initialization while here 1 means first call.
1130 if (d->custom_optind == 0 || !d->initialized) {
1131 if (d->custom_optind == 0)
1132 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
1133 custom_getopt_initialize(d);
1135 if (d->nextchar == NULL || *d->nextchar == '\0') {
1136 ret = shuffle_argv(argc, argv, longopts, d);
1140 if (longopts && (argv[d->custom_optind][1] == '-' ))
1141 return check_long_opt(argc, argv, optstring, longopts,
1142 longind, print_errors, d);
1143 return check_short_opt(argc, argv, optstring, print_errors, d);
1146 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1147 const struct option *longopts, int *longind)
1150 /* Keep a global copy of all internal members of d */
1151 static struct custom_getopt_data d;
1153 d.custom_optind = custom_optind;
1154 d.custom_opterr = custom_opterr;
1155 result = getopt_internal_r(argc, argv, optstring, longopts,
1157 custom_optind = d.custom_optind;
1158 custom_optarg = d.custom_optarg;
1159 custom_optopt = d.custom_optopt;
1163 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1164 const struct option *long_options, int *opt_index)
1166 return custom_getopt_internal(argc, argv, options, long_options,
1171 static char *package_name = 0;
1174 * @brief updates an option
1175 * @param field the generic pointer to the field to update
1176 * @param orig_field the pointer to the orig field
1177 * @param field_given the pointer to the number of occurrence of this option
1178 * @param prev_given the pointer to the number of occurrence already seen
1179 * @param value the argument for this option (if null no arg was specified)
1180 * @param possible_values the possible values for this option (if specified)
1181 * @param default_value the default value (in case the option only accepts fixed values)
1182 * @param arg_type the type of this option
1183 * @param check_ambiguity @see RNAsubopt_cmdline_parser_params.check_ambiguity
1184 * @param override @see RNAsubopt_cmdline_parser_params.override
1185 * @param no_free whether to free a possible previous value
1186 * @param multiple_option whether this is a multiple option
1187 * @param long_opt the corresponding long option
1188 * @param short_opt the corresponding short option (or '-' if none)
1189 * @param additional_error possible further error specification
1192 int update_arg(void *field, char **orig_field,
1193 unsigned int *field_given, unsigned int *prev_given,
1194 char *value, const char *possible_values[],
1195 const char *default_value,
1196 RNAsubopt_cmdline_parser_arg_type arg_type,
1197 int check_ambiguity, int override,
1198 int no_free, int multiple_option,
1199 const char *long_opt, char short_opt,
1200 const char *additional_error)
1202 char *stop_char = 0;
1203 const char *val = value;
1205 char **string_field;
1211 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1213 if (short_opt != '-')
1214 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1215 package_name, long_opt, short_opt,
1216 (additional_error ? additional_error : ""));
1218 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1219 package_name, long_opt,
1220 (additional_error ? additional_error : ""));
1221 return 1; /* failure */
1224 FIX_UNUSED (default_value);
1226 if (field_given && *field_given && ! override)
1232 if (possible_values)
1233 val = possible_values[found];
1237 *((int *)field) = !*((int *)field);
1240 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1243 if (val) *((float *)field) = (float)strtod (val, &stop_char);
1246 if (val) *((double *)field) = strtod (val, &stop_char);
1250 string_field = (char **)field;
1251 if (!no_free && *string_field)
1252 free (*string_field); /* free previous string */
1253 *string_field = gengetopt_strdup (val);
1260 /* check numeric conversion */
1265 if (val && !(stop_char && *stop_char == '\0')) {
1266 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1267 return 1; /* failure */
1274 /* store the original value */
1280 if (value && orig_field) {
1282 *orig_field = value;
1285 free (*orig_field); /* free previous string */
1286 *orig_field = gengetopt_strdup (value);
1296 RNAsubopt_cmdline_parser_internal (
1297 int argc, char **argv, struct RNAsubopt_args_info *args_info,
1298 struct RNAsubopt_cmdline_parser_params *params, const char *additional_error)
1300 int c; /* Character of the parsed option. */
1303 struct RNAsubopt_args_info local_args_info;
1308 int check_ambiguity;
1315 package_name = argv[0];
1317 override = params->override;
1318 initialize = params->initialize;
1319 check_required = params->check_required;
1320 check_ambiguity = params->check_ambiguity;
1323 RNAsubopt_cmdline_parser_init (args_info);
1325 RNAsubopt_cmdline_parser_init (&local_args_info);
1329 opterr = params->print_errors;
1334 int option_index = 0;
1336 static struct option long_options[] = {
1337 { "help", 0, NULL, 'h' },
1338 { "detailed-help", 0, NULL, 0 },
1339 { "full-help", 0, NULL, 0 },
1340 { "version", 0, NULL, 'V' },
1341 { "constraint", 0, NULL, 'C' },
1342 { "noconv", 0, NULL, 0 },
1343 { "deltaEnergy", 1, NULL, 'e' },
1344 { "deltaEnergyPost", 1, NULL, 0 },
1345 { "sorted", 0, NULL, 's' },
1346 { "stochBT", 1, NULL, 'p' },
1347 { "pfScale", 1, NULL, 'S' },
1348 { "circ", 0, NULL, 'c' },
1349 { "dos", 0, NULL, 'D' },
1350 { "zuker", 0, NULL, 'z' },
1351 { "temp", 1, NULL, 'T' },
1352 { "noTetra", 0, NULL, '4' },
1353 { "dangles", 1, NULL, 'd' },
1354 { "noLP", 0, NULL, 0 },
1355 { "noGU", 0, NULL, 0 },
1356 { "noClosingGU", 0, NULL, 0 },
1357 { "logML", 0, NULL, 0 },
1358 { "betaScale", 1, NULL, 0 },
1359 { "paramFile", 1, NULL, 'P' },
1360 { "nsp", 1, NULL, 0 },
1364 custom_optarg = optarg;
1365 custom_optind = optind;
1366 custom_opterr = opterr;
1367 custom_optopt = optopt;
1369 c = custom_getopt_long (argc, argv, "hVCe:sp:S:cDzT:4d:P:", long_options, &option_index);
1371 optarg = custom_optarg;
1372 optind = custom_optind;
1373 opterr = custom_opterr;
1374 optopt = custom_optopt;
1376 if (c == -1) break; /* Exit from `while (1)' loop. */
1380 case 'h': /* Print help and exit. */
1381 RNAsubopt_cmdline_parser_print_help ();
1382 RNAsubopt_cmdline_parser_free (&local_args_info);
1383 exit (EXIT_SUCCESS);
1385 case 'V': /* Print version and exit. */
1386 RNAsubopt_cmdline_parser_print_version ();
1387 RNAsubopt_cmdline_parser_free (&local_args_info);
1388 exit (EXIT_SUCCESS);
1390 case 'C': /* Calculate structures subject to constraints.
1394 if (update_arg((void *)&(args_info->constraint_flag), 0, &(args_info->constraint_given),
1395 &(local_args_info.constraint_given), optarg, 0, 0, ARG_FLAG,
1396 check_ambiguity, override, 1, 0, "constraint", 'C',
1401 case 'e': /* Compute suboptimal structures with energy in a certain range of the optimum (kcal/mol). Default is calculation of mfe structure only.
1406 if (update_arg( (void *)&(args_info->deltaEnergy_arg),
1407 &(args_info->deltaEnergy_orig), &(args_info->deltaEnergy_given),
1408 &(local_args_info.deltaEnergy_given), optarg, 0, 0, ARG_FLOAT,
1409 check_ambiguity, override, 0, 0,
1415 case 's': /* Sort the suboptimal structures by energy.
1419 if (update_arg((void *)&(args_info->sorted_flag), 0, &(args_info->sorted_given),
1420 &(local_args_info.sorted_given), optarg, 0, 0, ARG_FLAG,
1421 check_ambiguity, override, 1, 0, "sorted", 's',
1426 case 'p': /* Instead of producing all suboptimals in an energy range, produce a random sample of suboptimal structures, drawn with probabilities equal to their Boltzmann weights via stochastic backtracking in the partition function. The -e and -p options are mutually exclusive.
1431 if (update_arg( (void *)&(args_info->stochBT_arg),
1432 &(args_info->stochBT_orig), &(args_info->stochBT_given),
1433 &(local_args_info.stochBT_given), optarg, 0, 0, ARG_INT,
1434 check_ambiguity, override, 0, 0,
1440 case 'S': /* In the calculation of the pf use scale*mfe as an estimate for the ensemble free energy (used to avoid overflows). Needed by stochastic backtracking
1444 if (update_arg( (void *)&(args_info->pfScale_arg),
1445 &(args_info->pfScale_orig), &(args_info->pfScale_given),
1446 &(local_args_info.pfScale_given), optarg, 0, 0, ARG_DOUBLE,
1447 check_ambiguity, override, 0, 0,
1453 case 'c': /* Assume a circular (instead of linear) RNA molecule.
1458 if (update_arg((void *)&(args_info->circ_flag), 0, &(args_info->circ_given),
1459 &(local_args_info.circ_given), optarg, 0, 0, ARG_FLAG,
1460 check_ambiguity, override, 1, 0, "circ", 'c',
1465 case 'D': /* Compute density of states instead of secondary structures
1469 if (update_arg((void *)&(args_info->dos_flag), 0, &(args_info->dos_given),
1470 &(local_args_info.dos_given), optarg, 0, 0, ARG_FLAG,
1471 check_ambiguity, override, 1, 0, "dos", 'D',
1476 case 'z': /* Compute Zuker suboptimals instead of all suboptimal structures within an engery band arround the MFE.
1481 if (update_arg((void *)&(args_info->zuker_flag), 0, &(args_info->zuker_given),
1482 &(local_args_info.zuker_given), optarg, 0, 0, ARG_FLAG,
1483 check_ambiguity, override, 1, 0, "zuker", 'z',
1488 case 'T': /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1493 if (update_arg( (void *)&(args_info->temp_arg),
1494 &(args_info->temp_orig), &(args_info->temp_given),
1495 &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1496 check_ambiguity, override, 0, 0,
1502 case '4': /* Do not include special tabulated stabilizing energies for tri-, tetra- and hexaloop hairpins. Mostly for testing.
1507 if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1508 &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1509 check_ambiguity, override, 1, 0, "noTetra", '4',
1514 case 'd': /* How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops
1518 if (update_arg( (void *)&(args_info->dangles_arg),
1519 &(args_info->dangles_orig), &(args_info->dangles_given),
1520 &(local_args_info.dangles_given), optarg, 0, "2", ARG_INT,
1521 check_ambiguity, override, 0, 0,
1527 case 'P': /* Read energy parameters from paramfile, instead of using the default parameter set.
1531 if (update_arg( (void *)&(args_info->paramFile_arg),
1532 &(args_info->paramFile_orig), &(args_info->paramFile_given),
1533 &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1534 check_ambiguity, override, 0, 0,
1541 case 0: /* Long option with no short option */
1542 if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1543 RNAsubopt_cmdline_parser_print_detailed_help ();
1544 RNAsubopt_cmdline_parser_free (&local_args_info);
1545 exit (EXIT_SUCCESS);
1548 if (strcmp (long_options[option_index].name, "full-help") == 0) {
1549 RNAsubopt_cmdline_parser_print_full_help ();
1550 RNAsubopt_cmdline_parser_free (&local_args_info);
1551 exit (EXIT_SUCCESS);
1554 /* Do not automatically substitude nucleotide \"T\" with \"U\"
1557 if (strcmp (long_options[option_index].name, "noconv") == 0)
1561 if (update_arg((void *)&(args_info->noconv_flag), 0, &(args_info->noconv_given),
1562 &(local_args_info.noconv_given), optarg, 0, 0, ARG_FLAG,
1563 check_ambiguity, override, 1, 0, "noconv", '-',
1568 /* Only print structures with energy within range of the mfe after post reevaluation of energies.
1570 else if (strcmp (long_options[option_index].name, "deltaEnergyPost") == 0)
1574 if (update_arg( (void *)&(args_info->deltaEnergyPost_arg),
1575 &(args_info->deltaEnergyPost_orig), &(args_info->deltaEnergyPost_given),
1576 &(local_args_info.deltaEnergyPost_given), optarg, 0, 0, ARG_FLOAT,
1577 check_ambiguity, override, 0, 0,
1578 "deltaEnergyPost", '-',
1583 /* Produce structures without lonely pairs (helices of length 1).
1585 else if (strcmp (long_options[option_index].name, "noLP") == 0)
1589 if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1590 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1591 check_ambiguity, override, 1, 0, "noLP", '-',
1596 /* Do not allow GU pairs
1599 else if (strcmp (long_options[option_index].name, "noGU") == 0)
1603 if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1604 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1605 check_ambiguity, override, 1, 0, "noGU", '-',
1610 /* Do not allow GU pairs at the end of helices
1613 else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1617 if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1618 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1619 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1624 /* Recalculate energies of structures using a logarithmic energy function for multi-loops before output.. */
1625 else if (strcmp (long_options[option_index].name, "logML") == 0)
1629 if (update_arg((void *)&(args_info->logML_flag), 0, &(args_info->logML_given),
1630 &(local_args_info.logML_given), optarg, 0, 0, ARG_FLAG,
1631 check_ambiguity, override, 1, 0, "logML", '-',
1636 /* Set the scaling of the Boltzmann factors
1638 else if (strcmp (long_options[option_index].name, "betaScale") == 0)
1642 if (update_arg( (void *)&(args_info->betaScale_arg),
1643 &(args_info->betaScale_orig), &(args_info->betaScale_given),
1644 &(local_args_info.betaScale_given), optarg, 0, "1.", ARG_DOUBLE,
1645 check_ambiguity, override, 0, 0,
1651 /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1653 else if (strcmp (long_options[option_index].name, "nsp") == 0)
1657 if (update_arg( (void *)&(args_info->nsp_arg),
1658 &(args_info->nsp_orig), &(args_info->nsp_given),
1659 &(local_args_info.nsp_given), optarg, 0, 0, ARG_STRING,
1660 check_ambiguity, override, 0, 0,
1668 case '?': /* Invalid option. */
1669 /* `getopt_long' already printed an error message. */
1672 default: /* bug: option not considered. */
1673 fprintf (stderr, "%s: option unknown: %c%s\n", RNASUBOPT_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1682 error += RNAsubopt_cmdline_parser_required2 (args_info, argv[0], additional_error);
1685 RNAsubopt_cmdline_parser_release (&local_args_info);
1688 return (EXIT_FAILURE);
1694 RNAsubopt_cmdline_parser_release (&local_args_info);
1695 return (EXIT_FAILURE);