2 File autogenerated by gengetopt version 2.22.5
3 generated with the following command:
4 gengetopt -i RNAfold.ggo --file-name=RNAfold_cmdl --include-getopt --default-optional --func-name=RNAfold_cmdline_parser --arg-struct-name=RNAfold_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 "RNAfold_cmdl.h"
27 const char *RNAfold_args_info_purpose = "Calculate minimum free energy secondary structures and partition function of \nRNAs";
29 const char *RNAfold_args_info_usage = "Usage: RNAfold [OPTIONS]...";
31 const char *RNAfold_args_info_description = "The program reads RNA sequences from stdin, calculates their minimum free \nenergy (mfe) structure and prints to stdout the mfe structure in bracket \nnotation and its free energy. If the -p option was given it also computes the \npartition function (pf) and base pairing probability matrix, and prints the \nfree energy of the thermodynamic ensemble, the frequency of the mfe structure \nin the ensemble, and the ensemble diversity to stdout.\n\nIt also produces PostScript files with plots of the resulting secondary \nstructure graph and a \"dot plot\" of the base pairing matrix.\nThe dot plot shows a matrix of squares with area proportional to the pairing \nprobability in the upper right half, and one square for each pair in the \nminimum free energy structure in the lower left half. For each pair i-j with \nprobability p>10E-6 there is a line of the form\n\ni j sqrt(p) ubox\n\nin the PostScript file, so that the pair probabilities can be easily extracted.\n\nSequences may be provided in a simple text format where each sequence occupies \na single line. Output files are named \"rna.ps\" and \"dot.ps\". Existing files \nof the same name will be overwritten.\nIt is also possible to provide sequence data in FASTA format. In this case, the \nfirst word (max. 42 char) of the FASTA header will be used for output file \nnames. PostScript files \"name_ss.ps\" and \"name_dp.ps\" are produced for the \nstructure and dot plot, respectively.\nOnce FASTA input was provided all following sequences must be in FASTA format \ntoo.\nThe program will continue to read new sequences until a line consisting of the \nsingle character @ or an end of file condition is encountered.\n\n";
33 const char *RNAfold_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\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)",
43 " --noPS Do not produce postscript drawing of the mfe \n structure.\n\n (default=off)",
45 " 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",
46 " -p, --partfunc[=INT] Calculate the partition function and base \n pairing probability matrix.\n (default=`1')",
47 " 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, and the structural \n diversity (mean distance between the structures in the ensemble).\n See the description of pf_fold() and mean_bp_dist() and centroid() in the \n RNAlib documentation for details.\n Note that unless you also specify -d2 or -d0, the partition function and mfe \n calculations will use a slightly different energy model. See the discussion \n of dangling end options below.\n\n An additionally passed value to this option changes the behavior of partition \n function calculation:\n -p0 Calculate the partition function but not the pair probabilities, saving \n about 50% in runtime. This prints the ensemble free energy -kT ln(Z).\n -p2 Compute stack probabilities, i.e. the probability that a pair (i,j) and \n the immediately interior pair (i+1,j-1) are formed simultaneously in addition \n to pair probabilities. A second postscript dot plot called \"name_dp2.ps\", \n or \"dot2.ps\" (if the sequence does not have a name), is produced that \n contains pair probabilities in the upper right half and stack probabilities \n in the lower left.\n\n",
48 " --MEA[=gamma] Calculate an MEA (maximum expected accuracy) \n structure, where the expected accuracy is \n computed from the pair probabilities: each \n base pair (i,j) gets a score 2*gamma*p_ij and \n the score of an unpaired base is given by the \n probability of not forming a pair.\n (default=`1.')",
49 " The parameter gamma tunes the importance of correctly predicted pairs versus \n unpaired bases. Thus, for small values of gamma the MEA structure will \n contain only pairs with very high probability.\n Using --MEA implies -p for computing the pair probabilities.\n\n",
50 " -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",
51 " 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",
52 " -c, --circ Assume a circular (instead of linear) RNA \n molecule.\n (default=off)",
53 " --ImFeelingLucky Return exactly one stochastically backtracked \n structure\n (default=off)",
54 " This function computes the partition function and returns exactly one \n secondary structure stochastically sampled from the Boltzmann equilibrium \n according to its probability in the ensemble\n\n",
55 " --bppmThreshold=<value> Set the threshold for base pair probabilities \n included in the postscript output\n (default=`1e-5')",
56 " 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",
57 " -g, --gquad Incoorporate G-Quadruplex formation into the \n structure prediction algorithm\n (default=off)",
59 " -T, --temp=DOUBLE Rescale energy parameters to a temperature of \n temp C. Default is 37C.\n\n",
60 " -4, --noTetra Do not include special tabulated stabilizing \n energies for tri-, tetra- and hexaloop \n hairpins. Mostly for testing.\n\n (default=off)",
61 " -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')",
62 " \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",
63 " --noLP Produce structures without lonely pairs \n (helices of length 1).\n (default=off)",
64 " 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",
65 " --noGU Do not allow GU pairs\n\n (default=off)",
66 " --noClosingGU Do not allow GU pairs at the end of helices\n\n (default=off)",
67 " -P, --paramFile=paramfile Read energy parameters from paramfile, instead \n of using the default parameter set.\n",
68 " A sample parameter file should accompany your distribution.\n See the RNAlib documentation for details on the file format.\n\n",
69 " --nsp=STRING Allow other pairs in addition to the usual \n AU,GC,and GU pairs.\n",
70 " 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",
71 " -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",
72 " --betaScale=DOUBLE Set the scaling of the Boltzmann factors\n (default=`1.')",
73 " 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",
74 "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n\n",
78 init_full_help_array(void)
80 RNAfold_args_info_full_help[0] = RNAfold_args_info_detailed_help[0];
81 RNAfold_args_info_full_help[1] = RNAfold_args_info_detailed_help[1];
82 RNAfold_args_info_full_help[2] = RNAfold_args_info_detailed_help[2];
83 RNAfold_args_info_full_help[3] = RNAfold_args_info_detailed_help[3];
84 RNAfold_args_info_full_help[4] = RNAfold_args_info_detailed_help[4];
85 RNAfold_args_info_full_help[5] = RNAfold_args_info_detailed_help[5];
86 RNAfold_args_info_full_help[6] = RNAfold_args_info_detailed_help[6];
87 RNAfold_args_info_full_help[7] = RNAfold_args_info_detailed_help[8];
88 RNAfold_args_info_full_help[8] = RNAfold_args_info_detailed_help[9];
89 RNAfold_args_info_full_help[9] = RNAfold_args_info_detailed_help[10];
90 RNAfold_args_info_full_help[10] = RNAfold_args_info_detailed_help[11];
91 RNAfold_args_info_full_help[11] = RNAfold_args_info_detailed_help[12];
92 RNAfold_args_info_full_help[12] = RNAfold_args_info_detailed_help[14];
93 RNAfold_args_info_full_help[13] = RNAfold_args_info_detailed_help[16];
94 RNAfold_args_info_full_help[14] = RNAfold_args_info_detailed_help[18];
95 RNAfold_args_info_full_help[15] = RNAfold_args_info_detailed_help[19];
96 RNAfold_args_info_full_help[16] = RNAfold_args_info_detailed_help[21];
97 RNAfold_args_info_full_help[17] = RNAfold_args_info_detailed_help[23];
98 RNAfold_args_info_full_help[18] = RNAfold_args_info_detailed_help[24];
99 RNAfold_args_info_full_help[19] = RNAfold_args_info_detailed_help[25];
100 RNAfold_args_info_full_help[20] = RNAfold_args_info_detailed_help[26];
101 RNAfold_args_info_full_help[21] = RNAfold_args_info_detailed_help[27];
102 RNAfold_args_info_full_help[22] = RNAfold_args_info_detailed_help[29];
103 RNAfold_args_info_full_help[23] = RNAfold_args_info_detailed_help[31];
104 RNAfold_args_info_full_help[24] = RNAfold_args_info_detailed_help[32];
105 RNAfold_args_info_full_help[25] = RNAfold_args_info_detailed_help[33];
106 RNAfold_args_info_full_help[26] = RNAfold_args_info_detailed_help[35];
107 RNAfold_args_info_full_help[27] = RNAfold_args_info_detailed_help[37];
108 RNAfold_args_info_full_help[28] = RNAfold_args_info_detailed_help[38];
109 RNAfold_args_info_full_help[29] = RNAfold_args_info_detailed_help[40];
110 RNAfold_args_info_full_help[30] = 0;
114 const char *RNAfold_args_info_full_help[31];
117 init_help_array(void)
119 RNAfold_args_info_help[0] = RNAfold_args_info_detailed_help[0];
120 RNAfold_args_info_help[1] = RNAfold_args_info_detailed_help[1];
121 RNAfold_args_info_help[2] = RNAfold_args_info_detailed_help[2];
122 RNAfold_args_info_help[3] = RNAfold_args_info_detailed_help[3];
123 RNAfold_args_info_help[4] = RNAfold_args_info_detailed_help[4];
124 RNAfold_args_info_help[5] = RNAfold_args_info_detailed_help[5];
125 RNAfold_args_info_help[6] = RNAfold_args_info_detailed_help[6];
126 RNAfold_args_info_help[7] = RNAfold_args_info_detailed_help[8];
127 RNAfold_args_info_help[8] = RNAfold_args_info_detailed_help[9];
128 RNAfold_args_info_help[9] = RNAfold_args_info_detailed_help[10];
129 RNAfold_args_info_help[10] = RNAfold_args_info_detailed_help[11];
130 RNAfold_args_info_help[11] = RNAfold_args_info_detailed_help[12];
131 RNAfold_args_info_help[12] = RNAfold_args_info_detailed_help[14];
132 RNAfold_args_info_help[13] = RNAfold_args_info_detailed_help[18];
133 RNAfold_args_info_help[14] = RNAfold_args_info_detailed_help[23];
134 RNAfold_args_info_help[15] = RNAfold_args_info_detailed_help[24];
135 RNAfold_args_info_help[16] = RNAfold_args_info_detailed_help[25];
136 RNAfold_args_info_help[17] = RNAfold_args_info_detailed_help[26];
137 RNAfold_args_info_help[18] = RNAfold_args_info_detailed_help[27];
138 RNAfold_args_info_help[19] = RNAfold_args_info_detailed_help[29];
139 RNAfold_args_info_help[20] = RNAfold_args_info_detailed_help[31];
140 RNAfold_args_info_help[21] = RNAfold_args_info_detailed_help[32];
141 RNAfold_args_info_help[22] = RNAfold_args_info_detailed_help[33];
142 RNAfold_args_info_help[23] = RNAfold_args_info_detailed_help[40];
143 RNAfold_args_info_help[24] = 0;
147 const char *RNAfold_args_info_help[25];
155 } RNAfold_cmdline_parser_arg_type;
158 void clear_given (struct RNAfold_args_info *args_info);
160 void clear_args (struct RNAfold_args_info *args_info);
163 RNAfold_cmdline_parser_internal (int argc, char **argv, struct RNAfold_args_info *args_info,
164 struct RNAfold_cmdline_parser_params *params, const char *additional_error);
167 RNAfold_cmdline_parser_required2 (struct RNAfold_args_info *args_info, const char *prog_name, const char *additional_error);
170 gengetopt_strdup (const char *s);
173 void clear_given (struct RNAfold_args_info *args_info)
175 args_info->help_given = 0 ;
176 args_info->detailed_help_given = 0 ;
177 args_info->full_help_given = 0 ;
178 args_info->version_given = 0 ;
179 args_info->constraint_given = 0 ;
180 args_info->noconv_given = 0 ;
181 args_info->noPS_given = 0 ;
182 args_info->partfunc_given = 0 ;
183 args_info->MEA_given = 0 ;
184 args_info->pfScale_given = 0 ;
185 args_info->circ_given = 0 ;
186 args_info->ImFeelingLucky_given = 0 ;
187 args_info->bppmThreshold_given = 0 ;
188 args_info->gquad_given = 0 ;
189 args_info->temp_given = 0 ;
190 args_info->noTetra_given = 0 ;
191 args_info->dangles_given = 0 ;
192 args_info->noLP_given = 0 ;
193 args_info->noGU_given = 0 ;
194 args_info->noClosingGU_given = 0 ;
195 args_info->paramFile_given = 0 ;
196 args_info->nsp_given = 0 ;
197 args_info->energyModel_given = 0 ;
198 args_info->betaScale_given = 0 ;
202 void clear_args (struct RNAfold_args_info *args_info)
204 FIX_UNUSED (args_info);
205 args_info->constraint_flag = 0;
206 args_info->noconv_flag = 0;
207 args_info->noPS_flag = 0;
208 args_info->partfunc_arg = 1;
209 args_info->partfunc_orig = NULL;
210 args_info->MEA_arg = 1.;
211 args_info->MEA_orig = NULL;
212 args_info->pfScale_orig = NULL;
213 args_info->circ_flag = 0;
214 args_info->ImFeelingLucky_flag = 0;
215 args_info->bppmThreshold_arg = 1e-5;
216 args_info->bppmThreshold_orig = NULL;
217 args_info->gquad_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->paramFile_arg = NULL;
226 args_info->paramFile_orig = NULL;
227 args_info->nsp_arg = NULL;
228 args_info->nsp_orig = NULL;
229 args_info->energyModel_orig = NULL;
230 args_info->betaScale_arg = 1.;
231 args_info->betaScale_orig = NULL;
236 void init_args_info(struct RNAfold_args_info *args_info)
238 init_full_help_array();
240 args_info->help_help = RNAfold_args_info_detailed_help[0] ;
241 args_info->detailed_help_help = RNAfold_args_info_detailed_help[1] ;
242 args_info->full_help_help = RNAfold_args_info_detailed_help[2] ;
243 args_info->version_help = RNAfold_args_info_detailed_help[3] ;
244 args_info->constraint_help = RNAfold_args_info_detailed_help[6] ;
245 args_info->noconv_help = RNAfold_args_info_detailed_help[8] ;
246 args_info->noPS_help = RNAfold_args_info_detailed_help[9] ;
247 args_info->partfunc_help = RNAfold_args_info_detailed_help[12] ;
248 args_info->MEA_help = RNAfold_args_info_detailed_help[14] ;
249 args_info->pfScale_help = RNAfold_args_info_detailed_help[16] ;
250 args_info->circ_help = RNAfold_args_info_detailed_help[18] ;
251 args_info->ImFeelingLucky_help = RNAfold_args_info_detailed_help[19] ;
252 args_info->bppmThreshold_help = RNAfold_args_info_detailed_help[21] ;
253 args_info->gquad_help = RNAfold_args_info_detailed_help[23] ;
254 args_info->temp_help = RNAfold_args_info_detailed_help[25] ;
255 args_info->noTetra_help = RNAfold_args_info_detailed_help[26] ;
256 args_info->dangles_help = RNAfold_args_info_detailed_help[27] ;
257 args_info->noLP_help = RNAfold_args_info_detailed_help[29] ;
258 args_info->noGU_help = RNAfold_args_info_detailed_help[31] ;
259 args_info->noClosingGU_help = RNAfold_args_info_detailed_help[32] ;
260 args_info->paramFile_help = RNAfold_args_info_detailed_help[33] ;
261 args_info->nsp_help = RNAfold_args_info_detailed_help[35] ;
262 args_info->energyModel_help = RNAfold_args_info_detailed_help[37] ;
263 args_info->betaScale_help = RNAfold_args_info_detailed_help[38] ;
268 RNAfold_cmdline_parser_print_version (void)
271 (strlen(RNAFOLD_CMDLINE_PARSER_PACKAGE_NAME) ? RNAFOLD_CMDLINE_PARSER_PACKAGE_NAME : RNAFOLD_CMDLINE_PARSER_PACKAGE),
272 RNAFOLD_CMDLINE_PARSER_VERSION);
275 static void print_help_common(void) {
276 RNAfold_cmdline_parser_print_version ();
278 if (strlen(RNAfold_args_info_purpose) > 0)
279 printf("\n%s\n", RNAfold_args_info_purpose);
281 if (strlen(RNAfold_args_info_usage) > 0)
282 printf("\n%s\n", RNAfold_args_info_usage);
286 if (strlen(RNAfold_args_info_description) > 0)
287 printf("%s\n\n", RNAfold_args_info_description);
291 RNAfold_cmdline_parser_print_help (void)
295 while (RNAfold_args_info_help[i])
296 printf("%s\n", RNAfold_args_info_help[i++]);
300 RNAfold_cmdline_parser_print_full_help (void)
304 while (RNAfold_args_info_full_help[i])
305 printf("%s\n", RNAfold_args_info_full_help[i++]);
309 RNAfold_cmdline_parser_print_detailed_help (void)
313 while (RNAfold_args_info_detailed_help[i])
314 printf("%s\n", RNAfold_args_info_detailed_help[i++]);
318 RNAfold_cmdline_parser_init (struct RNAfold_args_info *args_info)
320 clear_given (args_info);
321 clear_args (args_info);
322 init_args_info (args_info);
326 RNAfold_cmdline_parser_params_init(struct RNAfold_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 RNAfold_cmdline_parser_params *
339 RNAfold_cmdline_parser_params_create(void)
341 struct RNAfold_cmdline_parser_params *params =
342 (struct RNAfold_cmdline_parser_params *)malloc(sizeof(struct RNAfold_cmdline_parser_params));
343 RNAfold_cmdline_parser_params_init(params);
348 free_string_field (char **s)
359 RNAfold_cmdline_parser_release (struct RNAfold_args_info *args_info)
362 free_string_field (&(args_info->partfunc_orig));
363 free_string_field (&(args_info->MEA_orig));
364 free_string_field (&(args_info->pfScale_orig));
365 free_string_field (&(args_info->bppmThreshold_orig));
366 free_string_field (&(args_info->temp_orig));
367 free_string_field (&(args_info->dangles_orig));
368 free_string_field (&(args_info->paramFile_arg));
369 free_string_field (&(args_info->paramFile_orig));
370 free_string_field (&(args_info->nsp_arg));
371 free_string_field (&(args_info->nsp_orig));
372 free_string_field (&(args_info->energyModel_orig));
373 free_string_field (&(args_info->betaScale_orig));
377 clear_given (args_info);
382 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
386 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
388 fprintf(outfile, "%s\n", opt);
394 RNAfold_cmdline_parser_dump(FILE *outfile, struct RNAfold_args_info *args_info)
400 fprintf (stderr, "%s: cannot dump options to stream\n", RNAFOLD_CMDLINE_PARSER_PACKAGE);
404 if (args_info->help_given)
405 write_into_file(outfile, "help", 0, 0 );
406 if (args_info->detailed_help_given)
407 write_into_file(outfile, "detailed-help", 0, 0 );
408 if (args_info->full_help_given)
409 write_into_file(outfile, "full-help", 0, 0 );
410 if (args_info->version_given)
411 write_into_file(outfile, "version", 0, 0 );
412 if (args_info->constraint_given)
413 write_into_file(outfile, "constraint", 0, 0 );
414 if (args_info->noconv_given)
415 write_into_file(outfile, "noconv", 0, 0 );
416 if (args_info->noPS_given)
417 write_into_file(outfile, "noPS", 0, 0 );
418 if (args_info->partfunc_given)
419 write_into_file(outfile, "partfunc", args_info->partfunc_orig, 0);
420 if (args_info->MEA_given)
421 write_into_file(outfile, "MEA", args_info->MEA_orig, 0);
422 if (args_info->pfScale_given)
423 write_into_file(outfile, "pfScale", args_info->pfScale_orig, 0);
424 if (args_info->circ_given)
425 write_into_file(outfile, "circ", 0, 0 );
426 if (args_info->ImFeelingLucky_given)
427 write_into_file(outfile, "ImFeelingLucky", 0, 0 );
428 if (args_info->bppmThreshold_given)
429 write_into_file(outfile, "bppmThreshold", args_info->bppmThreshold_orig, 0);
430 if (args_info->gquad_given)
431 write_into_file(outfile, "gquad", 0, 0 );
432 if (args_info->temp_given)
433 write_into_file(outfile, "temp", args_info->temp_orig, 0);
434 if (args_info->noTetra_given)
435 write_into_file(outfile, "noTetra", 0, 0 );
436 if (args_info->dangles_given)
437 write_into_file(outfile, "dangles", args_info->dangles_orig, 0);
438 if (args_info->noLP_given)
439 write_into_file(outfile, "noLP", 0, 0 );
440 if (args_info->noGU_given)
441 write_into_file(outfile, "noGU", 0, 0 );
442 if (args_info->noClosingGU_given)
443 write_into_file(outfile, "noClosingGU", 0, 0 );
444 if (args_info->paramFile_given)
445 write_into_file(outfile, "paramFile", args_info->paramFile_orig, 0);
446 if (args_info->nsp_given)
447 write_into_file(outfile, "nsp", args_info->nsp_orig, 0);
448 if (args_info->energyModel_given)
449 write_into_file(outfile, "energyModel", args_info->energyModel_orig, 0);
450 if (args_info->betaScale_given)
451 write_into_file(outfile, "betaScale", args_info->betaScale_orig, 0);
459 RNAfold_cmdline_parser_file_save(const char *filename, struct RNAfold_args_info *args_info)
464 outfile = fopen(filename, "w");
468 fprintf (stderr, "%s: cannot open file for writing: %s\n", RNAFOLD_CMDLINE_PARSER_PACKAGE, filename);
472 i = RNAfold_cmdline_parser_dump(outfile, args_info);
479 RNAfold_cmdline_parser_free (struct RNAfold_args_info *args_info)
481 RNAfold_cmdline_parser_release (args_info);
484 /** @brief replacement of strdup, which is not standard */
486 gengetopt_strdup (const char *s)
492 result = (char*)malloc(strlen(s) + 1);
493 if (result == (char*)0)
500 RNAfold_cmdline_parser (int argc, char **argv, struct RNAfold_args_info *args_info)
502 return RNAfold_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
506 RNAfold_cmdline_parser_ext (int argc, char **argv, struct RNAfold_args_info *args_info,
507 struct RNAfold_cmdline_parser_params *params)
510 result = RNAfold_cmdline_parser_internal (argc, argv, args_info, params, 0);
512 if (result == EXIT_FAILURE)
514 RNAfold_cmdline_parser_free (args_info);
522 RNAfold_cmdline_parser2 (int argc, char **argv, struct RNAfold_args_info *args_info, int override, int initialize, int check_required)
525 struct RNAfold_cmdline_parser_params params;
527 params.override = override;
528 params.initialize = initialize;
529 params.check_required = check_required;
530 params.check_ambiguity = 0;
531 params.print_errors = 1;
533 result = RNAfold_cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
535 if (result == EXIT_FAILURE)
537 RNAfold_cmdline_parser_free (args_info);
545 RNAfold_cmdline_parser_required (struct RNAfold_args_info *args_info, const char *prog_name)
547 int result = EXIT_SUCCESS;
549 if (RNAfold_cmdline_parser_required2(args_info, prog_name, 0) > 0)
550 result = EXIT_FAILURE;
552 if (result == EXIT_FAILURE)
554 RNAfold_cmdline_parser_free (args_info);
562 RNAfold_cmdline_parser_required2 (struct RNAfold_args_info *args_info, const char *prog_name, const char *additional_error)
565 FIX_UNUSED (additional_error);
567 /* checks for required options */
569 /* checks for dependences among options */
570 if (args_info->betaScale_given && ! args_info->partfunc_given)
572 fprintf (stderr, "%s: '--betaScale' option depends on option 'partfunc'%s\n", prog_name, (additional_error ? additional_error : ""));
580 * Extracted from the glibc source tree, version 2.3.6
582 * Licensed under the GPL as per the whole glibc source tree.
584 * This file was modified so that getopt_long can be called
585 * many times without risking previous memory to be spoiled.
587 * Modified by Andre Noll and Lorenzo Bettini for use in
588 * GNU gengetopt generated files.
593 * we must include anything we need since this file is not thought to be
594 * inserted in a file already using getopt.h
602 /* has_arg can't be an enum because some compilers complain about
603 type mismatches in all the code that assumes it is an int. */
609 /* This version of `getopt' appears to the caller like standard Unix `getopt'
610 but it behaves differently for the user, since it allows the user
611 to intersperse the options with the other arguments.
613 As `getopt' works, it permutes the elements of ARGV so that,
614 when it is done, all the options precede everything else. Thus
615 all application programs are extended to handle flexible argument order.
618 If the field `flag' is not NULL, it points to a variable that is set
619 to the value given in the field `val' when the option is found, but
620 left unchanged if the option is not found.
622 To have a long-named option do something other than set an `int' to
623 a compiled-in constant, such as set a value from `custom_optarg', set the
624 option's `flag' field to zero and its `val' field to a nonzero
625 value (the equivalent single-letter option character, if there is
626 one). For long options that have a zero `flag' field, `getopt'
627 returns the contents of the `val' field. */
629 /* Names for the values of the `has_arg' field of `struct option'. */
631 #define no_argument 0
634 #ifndef required_argument
635 #define required_argument 1
638 #ifndef optional_argument
639 #define optional_argument 2
642 struct custom_getopt_data {
644 * These have exactly the same meaning as the corresponding global variables,
645 * except that they are used for the reentrant versions of getopt.
652 /* True if the internal members have been initialized. */
656 * The next char to be scanned in the option-element in which the last option
657 * character we returned was found. This allows us to pick up the scan where
658 * we left off. If this is zero, or a null string, it means resume the scan by
659 * advancing to the next ARGV-element.
664 * Describe the part of ARGV that contains non-options that have been skipped.
665 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
666 * the index after the last of them.
673 * the variables optarg, optind, opterr and optopt are renamed with
674 * the custom_ prefix so that they don't interfere with getopt ones.
676 * Moreover they're static so they are visible only from within the
677 * file where this very file will be included.
681 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
682 * option that takes an argument, the argument value is returned here.
684 static char *custom_optarg;
687 * Index in ARGV of the next element to be scanned. This is used for
688 * communication to and from the caller and for communication between
689 * successive calls to `custom_getopt'.
691 * On entry to `custom_getopt', 1 means this is the first call; initialize.
693 * When `custom_getopt' returns -1, this is the index of the first of the non-option
694 * elements that the caller should itself scan.
696 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
697 * has been scanned so far.
699 * 1003.2 says this must be 1 before any call.
701 static int custom_optind = 1;
704 * Callers store zero here to inhibit the error message for unrecognized
707 static int custom_opterr = 1;
710 * Set to an option character which was unrecognized. This must be initialized
711 * on some systems to avoid linking in the system's own getopt implementation.
713 static int custom_optopt = '?';
716 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
717 * [first_nonopt,last_nonopt) which contains all the non-options that have been
718 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
719 * all the options processed since those non-options were skipped.
720 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
721 * indices of the non-options in ARGV after they are moved.
723 static void exchange(char **argv, struct custom_getopt_data *d)
725 int bottom = d->first_nonopt;
726 int middle = d->last_nonopt;
727 int top = d->custom_optind;
731 * Exchange the shorter segment with the far end of the longer segment.
732 * That puts the shorter segment into the right place. It leaves the
733 * longer segment in the right place overall, but it consists of two
734 * parts that need to be swapped next.
736 while (top > middle && middle > bottom) {
737 if (top - middle > middle - bottom) {
738 /* Bottom segment is the short one. */
739 int len = middle - bottom;
742 /* Swap it with the top part of the top segment. */
743 for (i = 0; i < len; i++) {
744 tem = argv[bottom + i];
746 argv[top - (middle - bottom) + i];
747 argv[top - (middle - bottom) + i] = tem;
749 /* Exclude the moved bottom segment from further swapping. */
752 /* Top segment is the short one. */
753 int len = top - middle;
756 /* Swap it with the bottom part of the bottom segment. */
757 for (i = 0; i < len; i++) {
758 tem = argv[bottom + i];
759 argv[bottom + i] = argv[middle + i];
760 argv[middle + i] = tem;
762 /* Exclude the moved top segment from further swapping. */
766 /* Update records for the slots the non-options now occupy. */
767 d->first_nonopt += (d->custom_optind - d->last_nonopt);
768 d->last_nonopt = d->custom_optind;
771 /* Initialize the internal data when the first call is made. */
772 static void custom_getopt_initialize(struct custom_getopt_data *d)
775 * Start processing options with ARGV-element 1 (since ARGV-element 0
776 * is the program name); the sequence of previously skipped non-option
777 * ARGV-elements is empty.
779 d->first_nonopt = d->last_nonopt = d->custom_optind;
784 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
786 /* return: zero: continue, nonzero: return given value to user */
787 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
788 struct custom_getopt_data *d)
791 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
792 * moved back by the user (who may also have changed the arguments).
794 if (d->last_nonopt > d->custom_optind)
795 d->last_nonopt = d->custom_optind;
796 if (d->first_nonopt > d->custom_optind)
797 d->first_nonopt = d->custom_optind;
799 * If we have just processed some options following some
800 * non-options, exchange them so that the options come first.
802 if (d->first_nonopt != d->last_nonopt &&
803 d->last_nonopt != d->custom_optind)
804 exchange((char **) argv, d);
805 else if (d->last_nonopt != d->custom_optind)
806 d->first_nonopt = d->custom_optind;
808 * Skip any additional non-options and extend the range of
809 * non-options previously skipped.
811 while (d->custom_optind < argc && NONOPTION_P)
813 d->last_nonopt = d->custom_optind;
815 * The special ARGV-element `--' means premature end of options. Skip
816 * it like a null option, then exchange with previous non-options as if
817 * it were an option, then skip everything else like a non-option.
819 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
821 if (d->first_nonopt != d->last_nonopt
822 && d->last_nonopt != d->custom_optind)
823 exchange((char **) argv, d);
824 else if (d->first_nonopt == d->last_nonopt)
825 d->first_nonopt = d->custom_optind;
826 d->last_nonopt = argc;
827 d->custom_optind = argc;
830 * If we have done all the ARGV-elements, stop the scan and back over
831 * any non-options that we skipped and permuted.
833 if (d->custom_optind == argc) {
835 * Set the next-arg-index to point at the non-options that we
836 * previously skipped, so the caller will digest them.
838 if (d->first_nonopt != d->last_nonopt)
839 d->custom_optind = d->first_nonopt;
843 * If we have come to a non-option and did not permute it, either stop
844 * the scan or describe it to the caller and pass it by.
847 d->custom_optarg = argv[d->custom_optind++];
851 * We have found another option-ARGV-element. Skip the initial
854 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
859 * Check whether the ARGV-element is a long option.
861 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
862 * that an abbreviation of the long option, just like "--fu", and not "-f" with
865 * This distinction seems to be the most useful approach.
868 static int check_long_opt(int argc, char *const *argv, const char *optstring,
869 const struct option *longopts, int *longind,
870 int print_errors, struct custom_getopt_data *d)
873 const struct option *p;
874 const struct option *pfound = NULL;
880 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
883 /* Test all long options for either exact match or abbreviated matches */
884 for (p = longopts, option_index = 0; p->name; p++, option_index++)
885 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
886 if ((unsigned int) (nameend - d->nextchar)
887 == (unsigned int) strlen(p->name)) {
888 /* Exact match found. */
890 indfound = option_index;
893 } else if (pfound == NULL) {
894 /* First nonexact match found. */
896 indfound = option_index;
897 } else if (pfound->has_arg != p->has_arg
898 || pfound->flag != p->flag
899 || pfound->val != p->val)
900 /* Second or later nonexact match found. */
903 if (ambig && !exact) {
906 "%s: option `%s' is ambiguous\n",
907 argv[0], argv[d->custom_optind]);
909 d->nextchar += strlen(d->nextchar);
911 d->custom_optopt = 0;
915 option_index = indfound;
918 if (pfound->has_arg != no_argument)
919 d->custom_optarg = nameend + 1;
922 if (argv[d->custom_optind - 1][1] == '-') {
924 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
925 argv[0], pfound->name);
927 /* +option or -option */
928 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
929 argv[0], argv[d->custom_optind - 1][0], pfound->name);
933 d->nextchar += strlen(d->nextchar);
934 d->custom_optopt = pfound->val;
937 } else if (pfound->has_arg == required_argument) {
938 if (d->custom_optind < argc)
939 d->custom_optarg = argv[d->custom_optind++];
943 "%s: option `%s' requires an argument\n",
945 argv[d->custom_optind - 1]);
947 d->nextchar += strlen(d->nextchar);
948 d->custom_optopt = pfound->val;
949 return optstring[0] == ':' ? ':' : '?';
952 d->nextchar += strlen(d->nextchar);
954 *longind = option_index;
956 *(pfound->flag) = pfound->val;
962 * Can't find it as a long option. If this is not getopt_long_only, or
963 * the option starts with '--' or is not a valid short option, then
964 * it's an error. Otherwise interpret it as a short option.
967 if (argv[d->custom_optind][1] == '-') {
970 "%s: unrecognized option `--%s'\n",
971 argv[0], d->nextchar);
973 /* +option or -option */
975 "%s: unrecognized option `%c%s'\n",
976 argv[0], argv[d->custom_optind][0],
980 d->nextchar = (char *) "";
982 d->custom_optopt = 0;
986 static int check_short_opt(int argc, char *const *argv, const char *optstring,
987 int print_errors, struct custom_getopt_data *d)
989 char c = *d->nextchar++;
990 const char *temp = strchr(optstring, c);
992 /* Increment `custom_optind' when we start to process its last character. */
993 if (*d->nextchar == '\0')
995 if (!temp || c == ':') {
997 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
999 d->custom_optopt = c;
1002 if (temp[1] == ':') {
1003 if (temp[2] == ':') {
1004 /* This is an option that accepts an argument optionally. */
1005 if (*d->nextchar != '\0') {
1006 d->custom_optarg = d->nextchar;
1009 d->custom_optarg = NULL;
1012 /* This is an option that requires an argument. */
1013 if (*d->nextchar != '\0') {
1014 d->custom_optarg = d->nextchar;
1016 * If we end this ARGV-element by taking the
1017 * rest as an arg, we must advance to the next
1021 } else if (d->custom_optind == argc) {
1024 "%s: option requires an argument -- %c\n",
1027 d->custom_optopt = c;
1028 if (optstring[0] == ':')
1034 * We already incremented `custom_optind' once;
1035 * increment it again when taking next ARGV-elt
1038 d->custom_optarg = argv[d->custom_optind++];
1046 * Scan elements of ARGV for option characters given in OPTSTRING.
1048 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
1049 * then it is an option element. The characters of this element
1050 * (aside from the initial '-') are option characters. If `getopt'
1051 * is called repeatedly, it returns successively each of the option characters
1052 * from each of the option elements.
1054 * If `getopt' finds another option character, it returns that character,
1055 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
1056 * resume the scan with the following option character or ARGV-element.
1058 * If there are no more option characters, `getopt' returns -1.
1059 * Then `custom_optind' is the index in ARGV of the first ARGV-element
1060 * that is not an option. (The ARGV-elements have been permuted
1061 * so that those that are not options now come last.)
1063 * OPTSTRING is a string containing the legitimate option characters.
1064 * If an option character is seen that is not listed in OPTSTRING,
1065 * return '?' after printing an error message. If you set `custom_opterr' to
1066 * zero, the error message is suppressed but we still return '?'.
1068 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
1069 * so the following text in the same ARGV-element, or the text of the following
1070 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
1071 * wants an optional arg; if there is text in the current ARGV-element,
1072 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
1074 * If OPTSTRING starts with `-' or `+', it requests different methods of
1075 * handling the non-option ARGV-elements.
1076 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
1078 * Long-named options begin with `--' instead of `-'.
1079 * Their names may be abbreviated as long as the abbreviation is unique
1080 * or is an exact match for some defined option. If they have an
1081 * argument, it follows the option name in the same ARGV-element, separated
1082 * from the option name by a `=', or else the in next ARGV-element.
1083 * When `getopt' finds a long-named option, it returns 0 if that option's
1084 * `flag' field is nonzero, the value of the option's `val' field
1085 * if the `flag' field is zero.
1087 * The elements of ARGV aren't really const, because we permute them.
1088 * But we pretend they're const in the prototype to be compatible
1089 * with other systems.
1091 * LONGOPTS is a vector of `struct option' terminated by an
1092 * element containing a name which is zero.
1094 * LONGIND returns the index in LONGOPT of the long-named option found.
1095 * It is only valid when a long-named option has been found by the most
1098 * Return the option character from OPTS just read. Return -1 when there are
1099 * no more options. For unrecognized options, or options missing arguments,
1100 * `custom_optopt' is set to the option letter, and '?' is returned.
1102 * The OPTS string is a list of characters which are recognized option letters,
1103 * optionally followed by colons, specifying that that letter takes an
1104 * argument, to be placed in `custom_optarg'.
1106 * If a letter in OPTS is followed by two colons, its argument is optional.
1107 * This behavior is specific to the GNU `getopt'.
1109 * The argument `--' causes premature termination of argument scanning,
1110 * explicitly telling `getopt' that there are no more options. If OPTS begins
1111 * with `--', then non-option arguments are treated as arguments to the option
1112 * '\0'. This behavior is specific to the GNU `getopt'.
1115 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
1116 const struct option *longopts, int *longind,
1117 struct custom_getopt_data *d)
1119 int ret, print_errors = d->custom_opterr;
1121 if (optstring[0] == ':')
1125 d->custom_optarg = NULL;
1128 * This is a big difference with GNU getopt, since optind == 0
1129 * means initialization while here 1 means first call.
1131 if (d->custom_optind == 0 || !d->initialized) {
1132 if (d->custom_optind == 0)
1133 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
1134 custom_getopt_initialize(d);
1136 if (d->nextchar == NULL || *d->nextchar == '\0') {
1137 ret = shuffle_argv(argc, argv, longopts, d);
1141 if (longopts && (argv[d->custom_optind][1] == '-' ))
1142 return check_long_opt(argc, argv, optstring, longopts,
1143 longind, print_errors, d);
1144 return check_short_opt(argc, argv, optstring, print_errors, d);
1147 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1148 const struct option *longopts, int *longind)
1151 /* Keep a global copy of all internal members of d */
1152 static struct custom_getopt_data d;
1154 d.custom_optind = custom_optind;
1155 d.custom_opterr = custom_opterr;
1156 result = getopt_internal_r(argc, argv, optstring, longopts,
1158 custom_optind = d.custom_optind;
1159 custom_optarg = d.custom_optarg;
1160 custom_optopt = d.custom_optopt;
1164 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1165 const struct option *long_options, int *opt_index)
1167 return custom_getopt_internal(argc, argv, options, long_options,
1172 static char *package_name = 0;
1175 * @brief updates an option
1176 * @param field the generic pointer to the field to update
1177 * @param orig_field the pointer to the orig field
1178 * @param field_given the pointer to the number of occurrence of this option
1179 * @param prev_given the pointer to the number of occurrence already seen
1180 * @param value the argument for this option (if null no arg was specified)
1181 * @param possible_values the possible values for this option (if specified)
1182 * @param default_value the default value (in case the option only accepts fixed values)
1183 * @param arg_type the type of this option
1184 * @param check_ambiguity @see RNAfold_cmdline_parser_params.check_ambiguity
1185 * @param override @see RNAfold_cmdline_parser_params.override
1186 * @param no_free whether to free a possible previous value
1187 * @param multiple_option whether this is a multiple option
1188 * @param long_opt the corresponding long option
1189 * @param short_opt the corresponding short option (or '-' if none)
1190 * @param additional_error possible further error specification
1193 int update_arg(void *field, char **orig_field,
1194 unsigned int *field_given, unsigned int *prev_given,
1195 char *value, const char *possible_values[],
1196 const char *default_value,
1197 RNAfold_cmdline_parser_arg_type arg_type,
1198 int check_ambiguity, int override,
1199 int no_free, int multiple_option,
1200 const char *long_opt, char short_opt,
1201 const char *additional_error)
1203 char *stop_char = 0;
1204 const char *val = value;
1206 char **string_field;
1212 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1214 if (short_opt != '-')
1215 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1216 package_name, long_opt, short_opt,
1217 (additional_error ? additional_error : ""));
1219 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1220 package_name, long_opt,
1221 (additional_error ? additional_error : ""));
1222 return 1; /* failure */
1225 FIX_UNUSED (default_value);
1227 if (field_given && *field_given && ! override)
1233 if (possible_values)
1234 val = possible_values[found];
1238 *((int *)field) = !*((int *)field);
1241 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1244 if (val) *((float *)field) = (float)strtod (val, &stop_char);
1247 if (val) *((double *)field) = strtod (val, &stop_char);
1251 string_field = (char **)field;
1252 if (!no_free && *string_field)
1253 free (*string_field); /* free previous string */
1254 *string_field = gengetopt_strdup (val);
1261 /* check numeric conversion */
1266 if (val && !(stop_char && *stop_char == '\0')) {
1267 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1268 return 1; /* failure */
1275 /* store the original value */
1281 if (value && orig_field) {
1283 *orig_field = value;
1286 free (*orig_field); /* free previous string */
1287 *orig_field = gengetopt_strdup (value);
1297 RNAfold_cmdline_parser_internal (
1298 int argc, char **argv, struct RNAfold_args_info *args_info,
1299 struct RNAfold_cmdline_parser_params *params, const char *additional_error)
1301 int c; /* Character of the parsed option. */
1304 struct RNAfold_args_info local_args_info;
1309 int check_ambiguity;
1316 package_name = argv[0];
1318 override = params->override;
1319 initialize = params->initialize;
1320 check_required = params->check_required;
1321 check_ambiguity = params->check_ambiguity;
1324 RNAfold_cmdline_parser_init (args_info);
1326 RNAfold_cmdline_parser_init (&local_args_info);
1330 opterr = params->print_errors;
1335 int option_index = 0;
1337 static struct option long_options[] = {
1338 { "help", 0, NULL, 'h' },
1339 { "detailed-help", 0, NULL, 0 },
1340 { "full-help", 0, NULL, 0 },
1341 { "version", 0, NULL, 'V' },
1342 { "constraint", 0, NULL, 'C' },
1343 { "noconv", 0, NULL, 0 },
1344 { "noPS", 0, NULL, 0 },
1345 { "partfunc", 2, NULL, 'p' },
1346 { "MEA", 2, NULL, 0 },
1347 { "pfScale", 1, NULL, 'S' },
1348 { "circ", 0, NULL, 'c' },
1349 { "ImFeelingLucky", 0, NULL, 0 },
1350 { "bppmThreshold", 1, NULL, 0 },
1351 { "gquad", 0, NULL, 'g' },
1352 { "temp", 1, NULL, 'T' },
1353 { "noTetra", 0, NULL, '4' },
1354 { "dangles", 1, NULL, 'd' },
1355 { "noLP", 0, NULL, 0 },
1356 { "noGU", 0, NULL, 0 },
1357 { "noClosingGU", 0, NULL, 0 },
1358 { "paramFile", 1, NULL, 'P' },
1359 { "nsp", 1, NULL, 0 },
1360 { "energyModel", 1, NULL, 'e' },
1361 { "betaScale", 1, NULL, 0 },
1365 custom_optarg = optarg;
1366 custom_optind = optind;
1367 custom_opterr = opterr;
1368 custom_optopt = optopt;
1370 c = custom_getopt_long (argc, argv, "hVCp::S:cgT:4d:P:e:", long_options, &option_index);
1372 optarg = custom_optarg;
1373 optind = custom_optind;
1374 opterr = custom_opterr;
1375 optopt = custom_optopt;
1377 if (c == -1) break; /* Exit from `while (1)' loop. */
1381 case 'h': /* Print help and exit. */
1382 RNAfold_cmdline_parser_print_help ();
1383 RNAfold_cmdline_parser_free (&local_args_info);
1384 exit (EXIT_SUCCESS);
1386 case 'V': /* Print version and exit. */
1387 RNAfold_cmdline_parser_print_version ();
1388 RNAfold_cmdline_parser_free (&local_args_info);
1389 exit (EXIT_SUCCESS);
1391 case 'C': /* Calculate structures subject to constraints.
1395 if (update_arg((void *)&(args_info->constraint_flag), 0, &(args_info->constraint_given),
1396 &(local_args_info.constraint_given), optarg, 0, 0, ARG_FLAG,
1397 check_ambiguity, override, 1, 0, "constraint", 'C',
1402 case 'p': /* Calculate the partition function and base pairing probability matrix.
1406 if (update_arg( (void *)&(args_info->partfunc_arg),
1407 &(args_info->partfunc_orig), &(args_info->partfunc_given),
1408 &(local_args_info.partfunc_given), optarg, 0, "1", ARG_INT,
1409 check_ambiguity, override, 0, 0,
1415 case 'S': /* In the calculation of the pf use scale*mfe as an estimate for the ensemble free energy (used to avoid overflows).
1419 if (update_arg( (void *)&(args_info->pfScale_arg),
1420 &(args_info->pfScale_orig), &(args_info->pfScale_given),
1421 &(local_args_info.pfScale_given), optarg, 0, 0, ARG_DOUBLE,
1422 check_ambiguity, override, 0, 0,
1428 case 'c': /* Assume a circular (instead of linear) RNA molecule.
1432 if (update_arg((void *)&(args_info->circ_flag), 0, &(args_info->circ_given),
1433 &(local_args_info.circ_given), optarg, 0, 0, ARG_FLAG,
1434 check_ambiguity, override, 1, 0, "circ", 'c',
1439 case 'g': /* Incoorporate G-Quadruplex formation into the structure prediction algorithm
1443 if (update_arg((void *)&(args_info->gquad_flag), 0, &(args_info->gquad_given),
1444 &(local_args_info.gquad_given), optarg, 0, 0, ARG_FLAG,
1445 check_ambiguity, override, 1, 0, "gquad", 'g',
1450 case 'T': /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1455 if (update_arg( (void *)&(args_info->temp_arg),
1456 &(args_info->temp_orig), &(args_info->temp_given),
1457 &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1458 check_ambiguity, override, 0, 0,
1464 case '4': /* Do not include special tabulated stabilizing energies for tri-, tetra- and hexaloop hairpins. Mostly for testing.
1469 if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1470 &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1471 check_ambiguity, override, 1, 0, "noTetra", '4',
1476 case 'd': /* How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops
1480 if (update_arg( (void *)&(args_info->dangles_arg),
1481 &(args_info->dangles_orig), &(args_info->dangles_given),
1482 &(local_args_info.dangles_given), optarg, 0, "2", ARG_INT,
1483 check_ambiguity, override, 0, 0,
1489 case 'P': /* Read energy parameters from paramfile, instead of using the default parameter set.
1493 if (update_arg( (void *)&(args_info->paramFile_arg),
1494 &(args_info->paramFile_orig), &(args_info->paramFile_given),
1495 &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1496 check_ambiguity, override, 0, 0,
1502 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.
1507 if (update_arg( (void *)&(args_info->energyModel_arg),
1508 &(args_info->energyModel_orig), &(args_info->energyModel_given),
1509 &(local_args_info.energyModel_given), optarg, 0, 0, ARG_INT,
1510 check_ambiguity, override, 0, 0,
1517 case 0: /* Long option with no short option */
1518 if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1519 RNAfold_cmdline_parser_print_detailed_help ();
1520 RNAfold_cmdline_parser_free (&local_args_info);
1521 exit (EXIT_SUCCESS);
1524 if (strcmp (long_options[option_index].name, "full-help") == 0) {
1525 RNAfold_cmdline_parser_print_full_help ();
1526 RNAfold_cmdline_parser_free (&local_args_info);
1527 exit (EXIT_SUCCESS);
1530 /* Do not automatically substitude nucleotide \"T\" with \"U\"
1533 if (strcmp (long_options[option_index].name, "noconv") == 0)
1537 if (update_arg((void *)&(args_info->noconv_flag), 0, &(args_info->noconv_given),
1538 &(local_args_info.noconv_given), optarg, 0, 0, ARG_FLAG,
1539 check_ambiguity, override, 1, 0, "noconv", '-',
1544 /* Do not produce postscript drawing of the mfe structure.
1547 else if (strcmp (long_options[option_index].name, "noPS") == 0)
1551 if (update_arg((void *)&(args_info->noPS_flag), 0, &(args_info->noPS_given),
1552 &(local_args_info.noPS_given), optarg, 0, 0, ARG_FLAG,
1553 check_ambiguity, override, 1, 0, "noPS", '-',
1558 /* Calculate an MEA (maximum expected accuracy) structure, where the expected accuracy is computed from the pair probabilities: each base pair (i,j) gets a score 2*gamma*p_ij and the score of an unpaired base is given by the probability of not forming a pair.
1560 else if (strcmp (long_options[option_index].name, "MEA") == 0)
1564 if (update_arg( (void *)&(args_info->MEA_arg),
1565 &(args_info->MEA_orig), &(args_info->MEA_given),
1566 &(local_args_info.MEA_given), optarg, 0, "1.", ARG_FLOAT,
1567 check_ambiguity, override, 0, 0,
1573 /* Return exactly one stochastically backtracked structure
1575 else if (strcmp (long_options[option_index].name, "ImFeelingLucky") == 0)
1579 if (update_arg((void *)&(args_info->ImFeelingLucky_flag), 0, &(args_info->ImFeelingLucky_given),
1580 &(local_args_info.ImFeelingLucky_given), optarg, 0, 0, ARG_FLAG,
1581 check_ambiguity, override, 1, 0, "ImFeelingLucky", '-',
1586 /* Set the threshold for base pair probabilities included in the postscript output
1588 else if (strcmp (long_options[option_index].name, "bppmThreshold") == 0)
1592 if (update_arg( (void *)&(args_info->bppmThreshold_arg),
1593 &(args_info->bppmThreshold_orig), &(args_info->bppmThreshold_given),
1594 &(local_args_info.bppmThreshold_given), optarg, 0, "1e-5", ARG_DOUBLE,
1595 check_ambiguity, override, 0, 0,
1596 "bppmThreshold", '-',
1601 /* Produce structures without lonely pairs (helices of length 1).
1603 else if (strcmp (long_options[option_index].name, "noLP") == 0)
1607 if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1608 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1609 check_ambiguity, override, 1, 0, "noLP", '-',
1614 /* Do not allow GU pairs
1617 else if (strcmp (long_options[option_index].name, "noGU") == 0)
1621 if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1622 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1623 check_ambiguity, override, 1, 0, "noGU", '-',
1628 /* Do not allow GU pairs at the end of helices
1631 else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1635 if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1636 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1637 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1642 /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1644 else if (strcmp (long_options[option_index].name, "nsp") == 0)
1648 if (update_arg( (void *)&(args_info->nsp_arg),
1649 &(args_info->nsp_orig), &(args_info->nsp_given),
1650 &(local_args_info.nsp_given), optarg, 0, 0, ARG_STRING,
1651 check_ambiguity, override, 0, 0,
1657 /* Set the scaling of the Boltzmann factors
1659 else if (strcmp (long_options[option_index].name, "betaScale") == 0)
1663 if (update_arg( (void *)&(args_info->betaScale_arg),
1664 &(args_info->betaScale_orig), &(args_info->betaScale_given),
1665 &(local_args_info.betaScale_given), optarg, 0, "1.", ARG_DOUBLE,
1666 check_ambiguity, override, 0, 0,
1674 case '?': /* Invalid option. */
1675 /* `getopt_long' already printed an error message. */
1678 default: /* bug: option not considered. */
1679 fprintf (stderr, "%s: option unknown: %c%s\n", RNAFOLD_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1688 error += RNAfold_cmdline_parser_required2 (args_info, argv[0], additional_error);
1691 RNAfold_cmdline_parser_release (&local_args_info);
1694 return (EXIT_FAILURE);
1700 RNAfold_cmdline_parser_release (&local_args_info);
1701 return (EXIT_FAILURE);