2 File autogenerated by gengetopt version 2.22.5
3 generated with the following command:
4 gengetopt -i RNAcofold.ggo --file-name=RNAcofold_cmdl --include-getopt --default-optional --func-name=RNAcofold_cmdline_parser --arg-struct-name=RNAcofold_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 "RNAcofold_cmdl.h"
27 const char *RNAcofold_args_info_purpose = "calculate secondary structures of two RNAs with dimerization";
29 const char *RNAcofold_args_info_usage = "Usage: RNAcofold [OPTIONS]...";
31 const char *RNAcofold_args_info_description = "The program works much like RNAfold, but allows to specify two RNA sequences \nwich are then allowed to form a dimer structure. RNA sequences are read from \nstdin in the usual format, i.e. each line of input corresponds to one sequence, \nexcept for lines starting with \">\" which contain the name of the next \nsequence.\nTo compute the hybrid structure of two molecules, the two sequences must be \nconcatenated using the \'&\' character as separator.\nRNAcofold can compute minimum free energy (mfe) structures, as well as \npartition function (pf) and base pairing probability matrix (using the -p \nswitch)\nSince dimer formation is concentration dependent, RNAcofold can be used to \ncompute equilibrium concentrations for all five monomer and (homo/hetero)-dimer \nspecies, given input concentrations for the monomers.\nOutput consists of the mfe structure in bracket notation as well as PostScript \nstructure plots and \"dot plot\" files containing the pair probabilities, see \nthe RNAfold man page for details. In the dot plots a cross marks the chain \nbreak between the two concatenated sequences.\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 *RNAcofold_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)",
43 " --noPS Do not produce postscript output\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 in addition to the \n mfe structure. Default is calculation of mfe \n structure only.\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\n In order to calculate the partition function but not the pair probabilities \n use the -p0 option and save about\n 50% in runtime. This prints the ensemble free energy -kT ln(Z).\n\n",
48 " -a, --all_pf Compute the partition function and free \n energies not only of the hetero-dimer \n consisting of the two input sequences (the \n \"AB dimer\"), but also of the homo-dimers AA \n and BB as well as A and B monomers.\n (default=off)",
49 " The output will contain the free energies for each of these species, as well \n as 5 dot plots containing the conditional pair probabilities, called \n ABname5.ps, AAname5.ps and so on. For later use, these dot plot files also \n contain the free energy of the ensemble as a comment. Using -a automatically \n toggles the -p option.\n\n",
50 " -c, --concentrations In addition to everything listed under the -a \n option, read in initial monomer \n concentrations and compute the expected \n equilibrium concentrations of the 5 possible \n species (AB, AA, BB, A, B).\n (default=off)",
51 " Start concentrations are read from stdin (unless the -f option is used) in \n [mol/l], equilibrium concentrations are given realtive to the sum of the two \n inputs. An arbitrary number of initial concentrations can be specified (one \n pair of concentrations per line).\n\n",
52 " -f, --concfile=filename Specify a file with initial concentrations for \n the to sequences.",
53 " The table consits of arbitrary many lines with just two numbers (the \n concentration of sequence A and B). This option will automatically toggle the \n -c (and thus -a and -p) options (see above).\n\n",
54 " -S, --pfScale=scaling factor In the calculation of the pf use scale*mfe as \n an estimate for the ensemble free energy \n (used to avoid overflows).\n",
55 " The default is 1.07, useful values are 1.0 to 1.2. Occasionally needed for \n long sequences.\n You can also recompile the program to use double precision (see the README \n file).\n\n",
56 " --bppmThreshold=<value> Set the threshold for base pair probabilities \n included in the postscript output\n (default=`1e-5')",
57 " 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",
58 " -g, --gquad Incoorporate G-Quadruplex formation into the \n structure prediction algorithm\n (default=off)",
60 " -T, --temp=DOUBLE Rescale energy parameters to a temperature of \n temp C. Default is 37C.\n\n",
61 " -4, --noTetra Do not include special stabilizing energies for \n certain tetra-loops. Mostly for testing.\n\n (default=off)",
62 " -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')",
63 " \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",
64 " --noLP Produce structures without lonely pairs \n (helices of length 1).\n (default=off)",
65 " 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",
66 " --noGU Do not allow GU pairs\n\n (default=off)",
67 " --noClosingGU Do not allow GU pairs at the end of helices\n\n (default=off)",
68 " -P, --paramFile=paramfile Read energy parameters from paramfile, instead \n of using the default parameter set.\n",
69 " A sample parameter file should accompany your distribution.\n See the RNAlib documentation for details on the file format.\n\n",
70 " --nsp=STRING Allow other pairs in addition to the usual \n AU,GC,and GU pairs.\n",
71 " 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",
72 " -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",
73 " --betaScale=DOUBLE Set the scaling of the Boltzmann factors\n (default=`1.')",
74 " 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",
75 "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
79 init_full_help_array(void)
81 RNAcofold_args_info_full_help[0] = RNAcofold_args_info_detailed_help[0];
82 RNAcofold_args_info_full_help[1] = RNAcofold_args_info_detailed_help[1];
83 RNAcofold_args_info_full_help[2] = RNAcofold_args_info_detailed_help[2];
84 RNAcofold_args_info_full_help[3] = RNAcofold_args_info_detailed_help[3];
85 RNAcofold_args_info_full_help[4] = RNAcofold_args_info_detailed_help[4];
86 RNAcofold_args_info_full_help[5] = RNAcofold_args_info_detailed_help[5];
87 RNAcofold_args_info_full_help[6] = RNAcofold_args_info_detailed_help[6];
88 RNAcofold_args_info_full_help[7] = RNAcofold_args_info_detailed_help[8];
89 RNAcofold_args_info_full_help[8] = RNAcofold_args_info_detailed_help[9];
90 RNAcofold_args_info_full_help[9] = RNAcofold_args_info_detailed_help[10];
91 RNAcofold_args_info_full_help[10] = RNAcofold_args_info_detailed_help[11];
92 RNAcofold_args_info_full_help[11] = RNAcofold_args_info_detailed_help[12];
93 RNAcofold_args_info_full_help[12] = RNAcofold_args_info_detailed_help[14];
94 RNAcofold_args_info_full_help[13] = RNAcofold_args_info_detailed_help[16];
95 RNAcofold_args_info_full_help[14] = RNAcofold_args_info_detailed_help[18];
96 RNAcofold_args_info_full_help[15] = RNAcofold_args_info_detailed_help[20];
97 RNAcofold_args_info_full_help[16] = RNAcofold_args_info_detailed_help[22];
98 RNAcofold_args_info_full_help[17] = RNAcofold_args_info_detailed_help[24];
99 RNAcofold_args_info_full_help[18] = RNAcofold_args_info_detailed_help[25];
100 RNAcofold_args_info_full_help[19] = RNAcofold_args_info_detailed_help[26];
101 RNAcofold_args_info_full_help[20] = RNAcofold_args_info_detailed_help[27];
102 RNAcofold_args_info_full_help[21] = RNAcofold_args_info_detailed_help[28];
103 RNAcofold_args_info_full_help[22] = RNAcofold_args_info_detailed_help[30];
104 RNAcofold_args_info_full_help[23] = RNAcofold_args_info_detailed_help[32];
105 RNAcofold_args_info_full_help[24] = RNAcofold_args_info_detailed_help[33];
106 RNAcofold_args_info_full_help[25] = RNAcofold_args_info_detailed_help[34];
107 RNAcofold_args_info_full_help[26] = RNAcofold_args_info_detailed_help[36];
108 RNAcofold_args_info_full_help[27] = RNAcofold_args_info_detailed_help[38];
109 RNAcofold_args_info_full_help[28] = RNAcofold_args_info_detailed_help[39];
110 RNAcofold_args_info_full_help[29] = RNAcofold_args_info_detailed_help[41];
111 RNAcofold_args_info_full_help[30] = 0;
115 const char *RNAcofold_args_info_full_help[31];
118 init_help_array(void)
120 RNAcofold_args_info_help[0] = RNAcofold_args_info_detailed_help[0];
121 RNAcofold_args_info_help[1] = RNAcofold_args_info_detailed_help[1];
122 RNAcofold_args_info_help[2] = RNAcofold_args_info_detailed_help[2];
123 RNAcofold_args_info_help[3] = RNAcofold_args_info_detailed_help[3];
124 RNAcofold_args_info_help[4] = RNAcofold_args_info_detailed_help[4];
125 RNAcofold_args_info_help[5] = RNAcofold_args_info_detailed_help[5];
126 RNAcofold_args_info_help[6] = RNAcofold_args_info_detailed_help[6];
127 RNAcofold_args_info_help[7] = RNAcofold_args_info_detailed_help[8];
128 RNAcofold_args_info_help[8] = RNAcofold_args_info_detailed_help[9];
129 RNAcofold_args_info_help[9] = RNAcofold_args_info_detailed_help[10];
130 RNAcofold_args_info_help[10] = RNAcofold_args_info_detailed_help[11];
131 RNAcofold_args_info_help[11] = RNAcofold_args_info_detailed_help[12];
132 RNAcofold_args_info_help[12] = RNAcofold_args_info_detailed_help[14];
133 RNAcofold_args_info_help[13] = RNAcofold_args_info_detailed_help[16];
134 RNAcofold_args_info_help[14] = RNAcofold_args_info_detailed_help[18];
135 RNAcofold_args_info_help[15] = RNAcofold_args_info_detailed_help[24];
136 RNAcofold_args_info_help[16] = RNAcofold_args_info_detailed_help[25];
137 RNAcofold_args_info_help[17] = RNAcofold_args_info_detailed_help[26];
138 RNAcofold_args_info_help[18] = RNAcofold_args_info_detailed_help[27];
139 RNAcofold_args_info_help[19] = RNAcofold_args_info_detailed_help[28];
140 RNAcofold_args_info_help[20] = RNAcofold_args_info_detailed_help[30];
141 RNAcofold_args_info_help[21] = RNAcofold_args_info_detailed_help[32];
142 RNAcofold_args_info_help[22] = RNAcofold_args_info_detailed_help[33];
143 RNAcofold_args_info_help[23] = RNAcofold_args_info_detailed_help[34];
144 RNAcofold_args_info_help[24] = RNAcofold_args_info_detailed_help[41];
145 RNAcofold_args_info_help[25] = 0;
149 const char *RNAcofold_args_info_help[26];
156 } RNAcofold_cmdline_parser_arg_type;
159 void clear_given (struct RNAcofold_args_info *args_info);
161 void clear_args (struct RNAcofold_args_info *args_info);
164 RNAcofold_cmdline_parser_internal (int argc, char **argv, struct RNAcofold_args_info *args_info,
165 struct RNAcofold_cmdline_parser_params *params, const char *additional_error);
169 gengetopt_strdup (const char *s);
172 void clear_given (struct RNAcofold_args_info *args_info)
174 args_info->help_given = 0 ;
175 args_info->detailed_help_given = 0 ;
176 args_info->full_help_given = 0 ;
177 args_info->version_given = 0 ;
178 args_info->constraint_given = 0 ;
179 args_info->noconv_given = 0 ;
180 args_info->noPS_given = 0 ;
181 args_info->partfunc_given = 0 ;
182 args_info->all_pf_given = 0 ;
183 args_info->concentrations_given = 0 ;
184 args_info->concfile_given = 0 ;
185 args_info->pfScale_given = 0 ;
186 args_info->bppmThreshold_given = 0 ;
187 args_info->gquad_given = 0 ;
188 args_info->temp_given = 0 ;
189 args_info->noTetra_given = 0 ;
190 args_info->dangles_given = 0 ;
191 args_info->noLP_given = 0 ;
192 args_info->noGU_given = 0 ;
193 args_info->noClosingGU_given = 0 ;
194 args_info->paramFile_given = 0 ;
195 args_info->nsp_given = 0 ;
196 args_info->energyModel_given = 0 ;
197 args_info->betaScale_given = 0 ;
201 void clear_args (struct RNAcofold_args_info *args_info)
203 FIX_UNUSED (args_info);
204 args_info->constraint_flag = 0;
205 args_info->noconv_flag = 0;
206 args_info->noPS_flag = 0;
207 args_info->partfunc_arg = 1;
208 args_info->partfunc_orig = NULL;
209 args_info->all_pf_flag = 0;
210 args_info->concentrations_flag = 0;
211 args_info->concfile_arg = NULL;
212 args_info->concfile_orig = NULL;
213 args_info->pfScale_orig = NULL;
214 args_info->bppmThreshold_arg = 1e-5;
215 args_info->bppmThreshold_orig = NULL;
216 args_info->gquad_flag = 0;
217 args_info->temp_orig = NULL;
218 args_info->noTetra_flag = 0;
219 args_info->dangles_arg = 2;
220 args_info->dangles_orig = NULL;
221 args_info->noLP_flag = 0;
222 args_info->noGU_flag = 0;
223 args_info->noClosingGU_flag = 0;
224 args_info->paramFile_arg = NULL;
225 args_info->paramFile_orig = NULL;
226 args_info->nsp_arg = NULL;
227 args_info->nsp_orig = NULL;
228 args_info->energyModel_orig = NULL;
229 args_info->betaScale_arg = 1.;
230 args_info->betaScale_orig = NULL;
235 void init_args_info(struct RNAcofold_args_info *args_info)
237 init_full_help_array();
239 args_info->help_help = RNAcofold_args_info_detailed_help[0] ;
240 args_info->detailed_help_help = RNAcofold_args_info_detailed_help[1] ;
241 args_info->full_help_help = RNAcofold_args_info_detailed_help[2] ;
242 args_info->version_help = RNAcofold_args_info_detailed_help[3] ;
243 args_info->constraint_help = RNAcofold_args_info_detailed_help[6] ;
244 args_info->noconv_help = RNAcofold_args_info_detailed_help[8] ;
245 args_info->noPS_help = RNAcofold_args_info_detailed_help[9] ;
246 args_info->partfunc_help = RNAcofold_args_info_detailed_help[12] ;
247 args_info->all_pf_help = RNAcofold_args_info_detailed_help[14] ;
248 args_info->concentrations_help = RNAcofold_args_info_detailed_help[16] ;
249 args_info->concfile_help = RNAcofold_args_info_detailed_help[18] ;
250 args_info->pfScale_help = RNAcofold_args_info_detailed_help[20] ;
251 args_info->bppmThreshold_help = RNAcofold_args_info_detailed_help[22] ;
252 args_info->gquad_help = RNAcofold_args_info_detailed_help[24] ;
253 args_info->temp_help = RNAcofold_args_info_detailed_help[26] ;
254 args_info->noTetra_help = RNAcofold_args_info_detailed_help[27] ;
255 args_info->dangles_help = RNAcofold_args_info_detailed_help[28] ;
256 args_info->noLP_help = RNAcofold_args_info_detailed_help[30] ;
257 args_info->noGU_help = RNAcofold_args_info_detailed_help[32] ;
258 args_info->noClosingGU_help = RNAcofold_args_info_detailed_help[33] ;
259 args_info->paramFile_help = RNAcofold_args_info_detailed_help[34] ;
260 args_info->nsp_help = RNAcofold_args_info_detailed_help[36] ;
261 args_info->energyModel_help = RNAcofold_args_info_detailed_help[38] ;
262 args_info->betaScale_help = RNAcofold_args_info_detailed_help[39] ;
267 RNAcofold_cmdline_parser_print_version (void)
270 (strlen(RNACOFOLD_CMDLINE_PARSER_PACKAGE_NAME) ? RNACOFOLD_CMDLINE_PARSER_PACKAGE_NAME : RNACOFOLD_CMDLINE_PARSER_PACKAGE),
271 RNACOFOLD_CMDLINE_PARSER_VERSION);
274 static void print_help_common(void) {
275 RNAcofold_cmdline_parser_print_version ();
277 if (strlen(RNAcofold_args_info_purpose) > 0)
278 printf("\n%s\n", RNAcofold_args_info_purpose);
280 if (strlen(RNAcofold_args_info_usage) > 0)
281 printf("\n%s\n", RNAcofold_args_info_usage);
285 if (strlen(RNAcofold_args_info_description) > 0)
286 printf("%s\n\n", RNAcofold_args_info_description);
290 RNAcofold_cmdline_parser_print_help (void)
294 while (RNAcofold_args_info_help[i])
295 printf("%s\n", RNAcofold_args_info_help[i++]);
299 RNAcofold_cmdline_parser_print_full_help (void)
303 while (RNAcofold_args_info_full_help[i])
304 printf("%s\n", RNAcofold_args_info_full_help[i++]);
308 RNAcofold_cmdline_parser_print_detailed_help (void)
312 while (RNAcofold_args_info_detailed_help[i])
313 printf("%s\n", RNAcofold_args_info_detailed_help[i++]);
317 RNAcofold_cmdline_parser_init (struct RNAcofold_args_info *args_info)
319 clear_given (args_info);
320 clear_args (args_info);
321 init_args_info (args_info);
325 RNAcofold_cmdline_parser_params_init(struct RNAcofold_cmdline_parser_params *params)
329 params->override = 0;
330 params->initialize = 1;
331 params->check_required = 1;
332 params->check_ambiguity = 0;
333 params->print_errors = 1;
337 struct RNAcofold_cmdline_parser_params *
338 RNAcofold_cmdline_parser_params_create(void)
340 struct RNAcofold_cmdline_parser_params *params =
341 (struct RNAcofold_cmdline_parser_params *)malloc(sizeof(struct RNAcofold_cmdline_parser_params));
342 RNAcofold_cmdline_parser_params_init(params);
347 free_string_field (char **s)
358 RNAcofold_cmdline_parser_release (struct RNAcofold_args_info *args_info)
361 free_string_field (&(args_info->partfunc_orig));
362 free_string_field (&(args_info->concfile_arg));
363 free_string_field (&(args_info->concfile_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 RNAcofold_cmdline_parser_dump(FILE *outfile, struct RNAcofold_args_info *args_info)
400 fprintf (stderr, "%s: cannot dump options to stream\n", RNACOFOLD_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->all_pf_given)
421 write_into_file(outfile, "all_pf", 0, 0 );
422 if (args_info->concentrations_given)
423 write_into_file(outfile, "concentrations", 0, 0 );
424 if (args_info->concfile_given)
425 write_into_file(outfile, "concfile", args_info->concfile_orig, 0);
426 if (args_info->pfScale_given)
427 write_into_file(outfile, "pfScale", args_info->pfScale_orig, 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 RNAcofold_cmdline_parser_file_save(const char *filename, struct RNAcofold_args_info *args_info)
464 outfile = fopen(filename, "w");
468 fprintf (stderr, "%s: cannot open file for writing: %s\n", RNACOFOLD_CMDLINE_PARSER_PACKAGE, filename);
472 i = RNAcofold_cmdline_parser_dump(outfile, args_info);
479 RNAcofold_cmdline_parser_free (struct RNAcofold_args_info *args_info)
481 RNAcofold_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 RNAcofold_cmdline_parser (int argc, char **argv, struct RNAcofold_args_info *args_info)
502 return RNAcofold_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
506 RNAcofold_cmdline_parser_ext (int argc, char **argv, struct RNAcofold_args_info *args_info,
507 struct RNAcofold_cmdline_parser_params *params)
510 result = RNAcofold_cmdline_parser_internal (argc, argv, args_info, params, 0);
512 if (result == EXIT_FAILURE)
514 RNAcofold_cmdline_parser_free (args_info);
522 RNAcofold_cmdline_parser2 (int argc, char **argv, struct RNAcofold_args_info *args_info, int override, int initialize, int check_required)
525 struct RNAcofold_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 = RNAcofold_cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
535 if (result == EXIT_FAILURE)
537 RNAcofold_cmdline_parser_free (args_info);
545 RNAcofold_cmdline_parser_required (struct RNAcofold_args_info *args_info, const char *prog_name)
547 FIX_UNUSED (args_info);
548 FIX_UNUSED (prog_name);
553 * Extracted from the glibc source tree, version 2.3.6
555 * Licensed under the GPL as per the whole glibc source tree.
557 * This file was modified so that getopt_long can be called
558 * many times without risking previous memory to be spoiled.
560 * Modified by Andre Noll and Lorenzo Bettini for use in
561 * GNU gengetopt generated files.
566 * we must include anything we need since this file is not thought to be
567 * inserted in a file already using getopt.h
575 /* has_arg can't be an enum because some compilers complain about
576 type mismatches in all the code that assumes it is an int. */
582 /* This version of `getopt' appears to the caller like standard Unix `getopt'
583 but it behaves differently for the user, since it allows the user
584 to intersperse the options with the other arguments.
586 As `getopt' works, it permutes the elements of ARGV so that,
587 when it is done, all the options precede everything else. Thus
588 all application programs are extended to handle flexible argument order.
591 If the field `flag' is not NULL, it points to a variable that is set
592 to the value given in the field `val' when the option is found, but
593 left unchanged if the option is not found.
595 To have a long-named option do something other than set an `int' to
596 a compiled-in constant, such as set a value from `custom_optarg', set the
597 option's `flag' field to zero and its `val' field to a nonzero
598 value (the equivalent single-letter option character, if there is
599 one). For long options that have a zero `flag' field, `getopt'
600 returns the contents of the `val' field. */
602 /* Names for the values of the `has_arg' field of `struct option'. */
604 #define no_argument 0
607 #ifndef required_argument
608 #define required_argument 1
611 #ifndef optional_argument
612 #define optional_argument 2
615 struct custom_getopt_data {
617 * These have exactly the same meaning as the corresponding global variables,
618 * except that they are used for the reentrant versions of getopt.
625 /* True if the internal members have been initialized. */
629 * The next char to be scanned in the option-element in which the last option
630 * character we returned was found. This allows us to pick up the scan where
631 * we left off. If this is zero, or a null string, it means resume the scan by
632 * advancing to the next ARGV-element.
637 * Describe the part of ARGV that contains non-options that have been skipped.
638 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
639 * the index after the last of them.
646 * the variables optarg, optind, opterr and optopt are renamed with
647 * the custom_ prefix so that they don't interfere with getopt ones.
649 * Moreover they're static so they are visible only from within the
650 * file where this very file will be included.
654 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
655 * option that takes an argument, the argument value is returned here.
657 static char *custom_optarg;
660 * Index in ARGV of the next element to be scanned. This is used for
661 * communication to and from the caller and for communication between
662 * successive calls to `custom_getopt'.
664 * On entry to `custom_getopt', 1 means this is the first call; initialize.
666 * When `custom_getopt' returns -1, this is the index of the first of the non-option
667 * elements that the caller should itself scan.
669 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
670 * has been scanned so far.
672 * 1003.2 says this must be 1 before any call.
674 static int custom_optind = 1;
677 * Callers store zero here to inhibit the error message for unrecognized
680 static int custom_opterr = 1;
683 * Set to an option character which was unrecognized. This must be initialized
684 * on some systems to avoid linking in the system's own getopt implementation.
686 static int custom_optopt = '?';
689 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
690 * [first_nonopt,last_nonopt) which contains all the non-options that have been
691 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
692 * all the options processed since those non-options were skipped.
693 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
694 * indices of the non-options in ARGV after they are moved.
696 static void exchange(char **argv, struct custom_getopt_data *d)
698 int bottom = d->first_nonopt;
699 int middle = d->last_nonopt;
700 int top = d->custom_optind;
704 * Exchange the shorter segment with the far end of the longer segment.
705 * That puts the shorter segment into the right place. It leaves the
706 * longer segment in the right place overall, but it consists of two
707 * parts that need to be swapped next.
709 while (top > middle && middle > bottom) {
710 if (top - middle > middle - bottom) {
711 /* Bottom segment is the short one. */
712 int len = middle - bottom;
715 /* Swap it with the top part of the top segment. */
716 for (i = 0; i < len; i++) {
717 tem = argv[bottom + i];
719 argv[top - (middle - bottom) + i];
720 argv[top - (middle - bottom) + i] = tem;
722 /* Exclude the moved bottom segment from further swapping. */
725 /* Top segment is the short one. */
726 int len = top - middle;
729 /* Swap it with the bottom part of the bottom segment. */
730 for (i = 0; i < len; i++) {
731 tem = argv[bottom + i];
732 argv[bottom + i] = argv[middle + i];
733 argv[middle + i] = tem;
735 /* Exclude the moved top segment from further swapping. */
739 /* Update records for the slots the non-options now occupy. */
740 d->first_nonopt += (d->custom_optind - d->last_nonopt);
741 d->last_nonopt = d->custom_optind;
744 /* Initialize the internal data when the first call is made. */
745 static void custom_getopt_initialize(struct custom_getopt_data *d)
748 * Start processing options with ARGV-element 1 (since ARGV-element 0
749 * is the program name); the sequence of previously skipped non-option
750 * ARGV-elements is empty.
752 d->first_nonopt = d->last_nonopt = d->custom_optind;
757 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
759 /* return: zero: continue, nonzero: return given value to user */
760 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
761 struct custom_getopt_data *d)
764 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
765 * moved back by the user (who may also have changed the arguments).
767 if (d->last_nonopt > d->custom_optind)
768 d->last_nonopt = d->custom_optind;
769 if (d->first_nonopt > d->custom_optind)
770 d->first_nonopt = d->custom_optind;
772 * If we have just processed some options following some
773 * non-options, exchange them so that the options come first.
775 if (d->first_nonopt != d->last_nonopt &&
776 d->last_nonopt != d->custom_optind)
777 exchange((char **) argv, d);
778 else if (d->last_nonopt != d->custom_optind)
779 d->first_nonopt = d->custom_optind;
781 * Skip any additional non-options and extend the range of
782 * non-options previously skipped.
784 while (d->custom_optind < argc && NONOPTION_P)
786 d->last_nonopt = d->custom_optind;
788 * The special ARGV-element `--' means premature end of options. Skip
789 * it like a null option, then exchange with previous non-options as if
790 * it were an option, then skip everything else like a non-option.
792 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
794 if (d->first_nonopt != d->last_nonopt
795 && d->last_nonopt != d->custom_optind)
796 exchange((char **) argv, d);
797 else if (d->first_nonopt == d->last_nonopt)
798 d->first_nonopt = d->custom_optind;
799 d->last_nonopt = argc;
800 d->custom_optind = argc;
803 * If we have done all the ARGV-elements, stop the scan and back over
804 * any non-options that we skipped and permuted.
806 if (d->custom_optind == argc) {
808 * Set the next-arg-index to point at the non-options that we
809 * previously skipped, so the caller will digest them.
811 if (d->first_nonopt != d->last_nonopt)
812 d->custom_optind = d->first_nonopt;
816 * If we have come to a non-option and did not permute it, either stop
817 * the scan or describe it to the caller and pass it by.
820 d->custom_optarg = argv[d->custom_optind++];
824 * We have found another option-ARGV-element. Skip the initial
827 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
832 * Check whether the ARGV-element is a long option.
834 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
835 * that an abbreviation of the long option, just like "--fu", and not "-f" with
838 * This distinction seems to be the most useful approach.
841 static int check_long_opt(int argc, char *const *argv, const char *optstring,
842 const struct option *longopts, int *longind,
843 int print_errors, struct custom_getopt_data *d)
846 const struct option *p;
847 const struct option *pfound = NULL;
853 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
856 /* Test all long options for either exact match or abbreviated matches */
857 for (p = longopts, option_index = 0; p->name; p++, option_index++)
858 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
859 if ((unsigned int) (nameend - d->nextchar)
860 == (unsigned int) strlen(p->name)) {
861 /* Exact match found. */
863 indfound = option_index;
866 } else if (pfound == NULL) {
867 /* First nonexact match found. */
869 indfound = option_index;
870 } else if (pfound->has_arg != p->has_arg
871 || pfound->flag != p->flag
872 || pfound->val != p->val)
873 /* Second or later nonexact match found. */
876 if (ambig && !exact) {
879 "%s: option `%s' is ambiguous\n",
880 argv[0], argv[d->custom_optind]);
882 d->nextchar += strlen(d->nextchar);
884 d->custom_optopt = 0;
888 option_index = indfound;
891 if (pfound->has_arg != no_argument)
892 d->custom_optarg = nameend + 1;
895 if (argv[d->custom_optind - 1][1] == '-') {
897 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
898 argv[0], pfound->name);
900 /* +option or -option */
901 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
902 argv[0], argv[d->custom_optind - 1][0], pfound->name);
906 d->nextchar += strlen(d->nextchar);
907 d->custom_optopt = pfound->val;
910 } else if (pfound->has_arg == required_argument) {
911 if (d->custom_optind < argc)
912 d->custom_optarg = argv[d->custom_optind++];
916 "%s: option `%s' requires an argument\n",
918 argv[d->custom_optind - 1]);
920 d->nextchar += strlen(d->nextchar);
921 d->custom_optopt = pfound->val;
922 return optstring[0] == ':' ? ':' : '?';
925 d->nextchar += strlen(d->nextchar);
927 *longind = option_index;
929 *(pfound->flag) = pfound->val;
935 * Can't find it as a long option. If this is not getopt_long_only, or
936 * the option starts with '--' or is not a valid short option, then
937 * it's an error. Otherwise interpret it as a short option.
940 if (argv[d->custom_optind][1] == '-') {
943 "%s: unrecognized option `--%s'\n",
944 argv[0], d->nextchar);
946 /* +option or -option */
948 "%s: unrecognized option `%c%s'\n",
949 argv[0], argv[d->custom_optind][0],
953 d->nextchar = (char *) "";
955 d->custom_optopt = 0;
959 static int check_short_opt(int argc, char *const *argv, const char *optstring,
960 int print_errors, struct custom_getopt_data *d)
962 char c = *d->nextchar++;
963 const char *temp = strchr(optstring, c);
965 /* Increment `custom_optind' when we start to process its last character. */
966 if (*d->nextchar == '\0')
968 if (!temp || c == ':') {
970 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
972 d->custom_optopt = c;
975 if (temp[1] == ':') {
976 if (temp[2] == ':') {
977 /* This is an option that accepts an argument optionally. */
978 if (*d->nextchar != '\0') {
979 d->custom_optarg = d->nextchar;
982 d->custom_optarg = NULL;
985 /* This is an option that requires an argument. */
986 if (*d->nextchar != '\0') {
987 d->custom_optarg = d->nextchar;
989 * If we end this ARGV-element by taking the
990 * rest as an arg, we must advance to the next
994 } else if (d->custom_optind == argc) {
997 "%s: option requires an argument -- %c\n",
1000 d->custom_optopt = c;
1001 if (optstring[0] == ':')
1007 * We already incremented `custom_optind' once;
1008 * increment it again when taking next ARGV-elt
1011 d->custom_optarg = argv[d->custom_optind++];
1019 * Scan elements of ARGV for option characters given in OPTSTRING.
1021 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
1022 * then it is an option element. The characters of this element
1023 * (aside from the initial '-') are option characters. If `getopt'
1024 * is called repeatedly, it returns successively each of the option characters
1025 * from each of the option elements.
1027 * If `getopt' finds another option character, it returns that character,
1028 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
1029 * resume the scan with the following option character or ARGV-element.
1031 * If there are no more option characters, `getopt' returns -1.
1032 * Then `custom_optind' is the index in ARGV of the first ARGV-element
1033 * that is not an option. (The ARGV-elements have been permuted
1034 * so that those that are not options now come last.)
1036 * OPTSTRING is a string containing the legitimate option characters.
1037 * If an option character is seen that is not listed in OPTSTRING,
1038 * return '?' after printing an error message. If you set `custom_opterr' to
1039 * zero, the error message is suppressed but we still return '?'.
1041 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
1042 * so the following text in the same ARGV-element, or the text of the following
1043 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
1044 * wants an optional arg; if there is text in the current ARGV-element,
1045 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
1047 * If OPTSTRING starts with `-' or `+', it requests different methods of
1048 * handling the non-option ARGV-elements.
1049 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
1051 * Long-named options begin with `--' instead of `-'.
1052 * Their names may be abbreviated as long as the abbreviation is unique
1053 * or is an exact match for some defined option. If they have an
1054 * argument, it follows the option name in the same ARGV-element, separated
1055 * from the option name by a `=', or else the in next ARGV-element.
1056 * When `getopt' finds a long-named option, it returns 0 if that option's
1057 * `flag' field is nonzero, the value of the option's `val' field
1058 * if the `flag' field is zero.
1060 * The elements of ARGV aren't really const, because we permute them.
1061 * But we pretend they're const in the prototype to be compatible
1062 * with other systems.
1064 * LONGOPTS is a vector of `struct option' terminated by an
1065 * element containing a name which is zero.
1067 * LONGIND returns the index in LONGOPT of the long-named option found.
1068 * It is only valid when a long-named option has been found by the most
1071 * Return the option character from OPTS just read. Return -1 when there are
1072 * no more options. For unrecognized options, or options missing arguments,
1073 * `custom_optopt' is set to the option letter, and '?' is returned.
1075 * The OPTS string is a list of characters which are recognized option letters,
1076 * optionally followed by colons, specifying that that letter takes an
1077 * argument, to be placed in `custom_optarg'.
1079 * If a letter in OPTS is followed by two colons, its argument is optional.
1080 * This behavior is specific to the GNU `getopt'.
1082 * The argument `--' causes premature termination of argument scanning,
1083 * explicitly telling `getopt' that there are no more options. If OPTS begins
1084 * with `--', then non-option arguments are treated as arguments to the option
1085 * '\0'. This behavior is specific to the GNU `getopt'.
1088 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
1089 const struct option *longopts, int *longind,
1090 struct custom_getopt_data *d)
1092 int ret, print_errors = d->custom_opterr;
1094 if (optstring[0] == ':')
1098 d->custom_optarg = NULL;
1101 * This is a big difference with GNU getopt, since optind == 0
1102 * means initialization while here 1 means first call.
1104 if (d->custom_optind == 0 || !d->initialized) {
1105 if (d->custom_optind == 0)
1106 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
1107 custom_getopt_initialize(d);
1109 if (d->nextchar == NULL || *d->nextchar == '\0') {
1110 ret = shuffle_argv(argc, argv, longopts, d);
1114 if (longopts && (argv[d->custom_optind][1] == '-' ))
1115 return check_long_opt(argc, argv, optstring, longopts,
1116 longind, print_errors, d);
1117 return check_short_opt(argc, argv, optstring, print_errors, d);
1120 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1121 const struct option *longopts, int *longind)
1124 /* Keep a global copy of all internal members of d */
1125 static struct custom_getopt_data d;
1127 d.custom_optind = custom_optind;
1128 d.custom_opterr = custom_opterr;
1129 result = getopt_internal_r(argc, argv, optstring, longopts,
1131 custom_optind = d.custom_optind;
1132 custom_optarg = d.custom_optarg;
1133 custom_optopt = d.custom_optopt;
1137 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1138 const struct option *long_options, int *opt_index)
1140 return custom_getopt_internal(argc, argv, options, long_options,
1145 static char *package_name = 0;
1148 * @brief updates an option
1149 * @param field the generic pointer to the field to update
1150 * @param orig_field the pointer to the orig field
1151 * @param field_given the pointer to the number of occurrence of this option
1152 * @param prev_given the pointer to the number of occurrence already seen
1153 * @param value the argument for this option (if null no arg was specified)
1154 * @param possible_values the possible values for this option (if specified)
1155 * @param default_value the default value (in case the option only accepts fixed values)
1156 * @param arg_type the type of this option
1157 * @param check_ambiguity @see RNAcofold_cmdline_parser_params.check_ambiguity
1158 * @param override @see RNAcofold_cmdline_parser_params.override
1159 * @param no_free whether to free a possible previous value
1160 * @param multiple_option whether this is a multiple option
1161 * @param long_opt the corresponding long option
1162 * @param short_opt the corresponding short option (or '-' if none)
1163 * @param additional_error possible further error specification
1166 int update_arg(void *field, char **orig_field,
1167 unsigned int *field_given, unsigned int *prev_given,
1168 char *value, const char *possible_values[],
1169 const char *default_value,
1170 RNAcofold_cmdline_parser_arg_type arg_type,
1171 int check_ambiguity, int override,
1172 int no_free, int multiple_option,
1173 const char *long_opt, char short_opt,
1174 const char *additional_error)
1176 char *stop_char = 0;
1177 const char *val = value;
1179 char **string_field;
1185 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1187 if (short_opt != '-')
1188 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1189 package_name, long_opt, short_opt,
1190 (additional_error ? additional_error : ""));
1192 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1193 package_name, long_opt,
1194 (additional_error ? additional_error : ""));
1195 return 1; /* failure */
1198 FIX_UNUSED (default_value);
1200 if (field_given && *field_given && ! override)
1206 if (possible_values)
1207 val = possible_values[found];
1211 *((int *)field) = !*((int *)field);
1214 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1217 if (val) *((double *)field) = strtod (val, &stop_char);
1221 string_field = (char **)field;
1222 if (!no_free && *string_field)
1223 free (*string_field); /* free previous string */
1224 *string_field = gengetopt_strdup (val);
1231 /* check numeric conversion */
1235 if (val && !(stop_char && *stop_char == '\0')) {
1236 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1237 return 1; /* failure */
1244 /* store the original value */
1250 if (value && orig_field) {
1252 *orig_field = value;
1255 free (*orig_field); /* free previous string */
1256 *orig_field = gengetopt_strdup (value);
1266 RNAcofold_cmdline_parser_internal (
1267 int argc, char **argv, struct RNAcofold_args_info *args_info,
1268 struct RNAcofold_cmdline_parser_params *params, const char *additional_error)
1270 int c; /* Character of the parsed option. */
1273 struct RNAcofold_args_info local_args_info;
1278 int check_ambiguity;
1285 package_name = argv[0];
1287 override = params->override;
1288 initialize = params->initialize;
1289 check_required = params->check_required;
1290 check_ambiguity = params->check_ambiguity;
1293 RNAcofold_cmdline_parser_init (args_info);
1295 RNAcofold_cmdline_parser_init (&local_args_info);
1299 opterr = params->print_errors;
1304 int option_index = 0;
1306 static struct option long_options[] = {
1307 { "help", 0, NULL, 'h' },
1308 { "detailed-help", 0, NULL, 0 },
1309 { "full-help", 0, NULL, 0 },
1310 { "version", 0, NULL, 'V' },
1311 { "constraint", 0, NULL, 'C' },
1312 { "noconv", 0, NULL, 0 },
1313 { "noPS", 0, NULL, 0 },
1314 { "partfunc", 2, NULL, 'p' },
1315 { "all_pf", 0, NULL, 'a' },
1316 { "concentrations", 0, NULL, 'c' },
1317 { "concfile", 1, NULL, 'f' },
1318 { "pfScale", 1, NULL, 'S' },
1319 { "bppmThreshold", 1, NULL, 0 },
1320 { "gquad", 0, NULL, 'g' },
1321 { "temp", 1, NULL, 'T' },
1322 { "noTetra", 0, NULL, '4' },
1323 { "dangles", 1, NULL, 'd' },
1324 { "noLP", 0, NULL, 0 },
1325 { "noGU", 0, NULL, 0 },
1326 { "noClosingGU", 0, NULL, 0 },
1327 { "paramFile", 1, NULL, 'P' },
1328 { "nsp", 1, NULL, 0 },
1329 { "energyModel", 1, NULL, 'e' },
1330 { "betaScale", 1, NULL, 0 },
1334 custom_optarg = optarg;
1335 custom_optind = optind;
1336 custom_opterr = opterr;
1337 custom_optopt = optopt;
1339 c = custom_getopt_long (argc, argv, "hVCp::acf:S:gT:4d:P:e:", long_options, &option_index);
1341 optarg = custom_optarg;
1342 optind = custom_optind;
1343 opterr = custom_opterr;
1344 optopt = custom_optopt;
1346 if (c == -1) break; /* Exit from `while (1)' loop. */
1350 case 'h': /* Print help and exit. */
1351 RNAcofold_cmdline_parser_print_help ();
1352 RNAcofold_cmdline_parser_free (&local_args_info);
1353 exit (EXIT_SUCCESS);
1355 case 'V': /* Print version and exit. */
1356 RNAcofold_cmdline_parser_print_version ();
1357 RNAcofold_cmdline_parser_free (&local_args_info);
1358 exit (EXIT_SUCCESS);
1360 case 'C': /* Calculate structures subject to constraints.
1364 if (update_arg((void *)&(args_info->constraint_flag), 0, &(args_info->constraint_given),
1365 &(local_args_info.constraint_given), optarg, 0, 0, ARG_FLAG,
1366 check_ambiguity, override, 1, 0, "constraint", 'C',
1371 case 'p': /* Calculate the partition function and base pairing probability matrix in addition to the mfe structure. Default is calculation of mfe structure only.
1375 if (update_arg( (void *)&(args_info->partfunc_arg),
1376 &(args_info->partfunc_orig), &(args_info->partfunc_given),
1377 &(local_args_info.partfunc_given), optarg, 0, "1", ARG_INT,
1378 check_ambiguity, override, 0, 0,
1384 case 'a': /* Compute the partition function and free energies not only of the hetero-dimer consisting of the two input sequences (the \"AB dimer\"), but also of the homo-dimers AA and BB as well as A and B monomers.
1388 if (update_arg((void *)&(args_info->all_pf_flag), 0, &(args_info->all_pf_given),
1389 &(local_args_info.all_pf_given), optarg, 0, 0, ARG_FLAG,
1390 check_ambiguity, override, 1, 0, "all_pf", 'a',
1395 case 'c': /* In addition to everything listed under the -a option, read in initial monomer concentrations and compute the expected equilibrium concentrations of the 5 possible species (AB, AA, BB, A, B).
1399 if (update_arg((void *)&(args_info->concentrations_flag), 0, &(args_info->concentrations_given),
1400 &(local_args_info.concentrations_given), optarg, 0, 0, ARG_FLAG,
1401 check_ambiguity, override, 1, 0, "concentrations", 'c',
1406 case 'f': /* Specify a file with initial concentrations for the to sequences.. */
1409 if (update_arg( (void *)&(args_info->concfile_arg),
1410 &(args_info->concfile_orig), &(args_info->concfile_given),
1411 &(local_args_info.concfile_given), optarg, 0, 0, ARG_STRING,
1412 check_ambiguity, override, 0, 0,
1418 case 'S': /* In the calculation of the pf use scale*mfe as an estimate for the ensemble free energy (used to avoid overflows).
1422 if (update_arg( (void *)&(args_info->pfScale_arg),
1423 &(args_info->pfScale_orig), &(args_info->pfScale_given),
1424 &(local_args_info.pfScale_given), optarg, 0, 0, ARG_DOUBLE,
1425 check_ambiguity, override, 0, 0,
1431 case 'g': /* Incoorporate G-Quadruplex formation into the structure prediction algorithm
1435 if (update_arg((void *)&(args_info->gquad_flag), 0, &(args_info->gquad_given),
1436 &(local_args_info.gquad_given), optarg, 0, 0, ARG_FLAG,
1437 check_ambiguity, override, 1, 0, "gquad", 'g',
1442 case 'T': /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1447 if (update_arg( (void *)&(args_info->temp_arg),
1448 &(args_info->temp_orig), &(args_info->temp_given),
1449 &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1450 check_ambiguity, override, 0, 0,
1456 case '4': /* Do not include special stabilizing energies for certain tetra-loops. Mostly for testing.
1461 if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1462 &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1463 check_ambiguity, override, 1, 0, "noTetra", '4',
1468 case 'd': /* How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops
1472 if (update_arg( (void *)&(args_info->dangles_arg),
1473 &(args_info->dangles_orig), &(args_info->dangles_given),
1474 &(local_args_info.dangles_given), optarg, 0, "2", ARG_INT,
1475 check_ambiguity, override, 0, 0,
1481 case 'P': /* Read energy parameters from paramfile, instead of using the default parameter set.
1485 if (update_arg( (void *)&(args_info->paramFile_arg),
1486 &(args_info->paramFile_orig), &(args_info->paramFile_given),
1487 &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1488 check_ambiguity, override, 0, 0,
1494 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.
1499 if (update_arg( (void *)&(args_info->energyModel_arg),
1500 &(args_info->energyModel_orig), &(args_info->energyModel_given),
1501 &(local_args_info.energyModel_given), optarg, 0, 0, ARG_INT,
1502 check_ambiguity, override, 0, 0,
1509 case 0: /* Long option with no short option */
1510 if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1511 RNAcofold_cmdline_parser_print_detailed_help ();
1512 RNAcofold_cmdline_parser_free (&local_args_info);
1513 exit (EXIT_SUCCESS);
1516 if (strcmp (long_options[option_index].name, "full-help") == 0) {
1517 RNAcofold_cmdline_parser_print_full_help ();
1518 RNAcofold_cmdline_parser_free (&local_args_info);
1519 exit (EXIT_SUCCESS);
1522 /* Do not automatically substitude nucleotide \"T\" with \"U\"
1525 if (strcmp (long_options[option_index].name, "noconv") == 0)
1529 if (update_arg((void *)&(args_info->noconv_flag), 0, &(args_info->noconv_given),
1530 &(local_args_info.noconv_given), optarg, 0, 0, ARG_FLAG,
1531 check_ambiguity, override, 1, 0, "noconv", '-',
1536 /* Do not produce postscript output
1539 else if (strcmp (long_options[option_index].name, "noPS") == 0)
1543 if (update_arg((void *)&(args_info->noPS_flag), 0, &(args_info->noPS_given),
1544 &(local_args_info.noPS_given), optarg, 0, 0, ARG_FLAG,
1545 check_ambiguity, override, 1, 0, "noPS", '-',
1550 /* Set the threshold for base pair probabilities included in the postscript output
1552 else if (strcmp (long_options[option_index].name, "bppmThreshold") == 0)
1556 if (update_arg( (void *)&(args_info->bppmThreshold_arg),
1557 &(args_info->bppmThreshold_orig), &(args_info->bppmThreshold_given),
1558 &(local_args_info.bppmThreshold_given), optarg, 0, "1e-5", ARG_DOUBLE,
1559 check_ambiguity, override, 0, 0,
1560 "bppmThreshold", '-',
1565 /* Produce structures without lonely pairs (helices of length 1).
1567 else if (strcmp (long_options[option_index].name, "noLP") == 0)
1571 if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1572 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1573 check_ambiguity, override, 1, 0, "noLP", '-',
1578 /* Do not allow GU pairs
1581 else if (strcmp (long_options[option_index].name, "noGU") == 0)
1585 if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1586 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1587 check_ambiguity, override, 1, 0, "noGU", '-',
1592 /* Do not allow GU pairs at the end of helices
1595 else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1599 if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1600 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1601 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1606 /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1608 else if (strcmp (long_options[option_index].name, "nsp") == 0)
1612 if (update_arg( (void *)&(args_info->nsp_arg),
1613 &(args_info->nsp_orig), &(args_info->nsp_given),
1614 &(local_args_info.nsp_given), optarg, 0, 0, ARG_STRING,
1615 check_ambiguity, override, 0, 0,
1621 /* Set the scaling of the Boltzmann factors
1623 else if (strcmp (long_options[option_index].name, "betaScale") == 0)
1627 if (update_arg( (void *)&(args_info->betaScale_arg),
1628 &(args_info->betaScale_orig), &(args_info->betaScale_given),
1629 &(local_args_info.betaScale_given), optarg, 0, "1.", ARG_DOUBLE,
1630 check_ambiguity, override, 0, 0,
1638 case '?': /* Invalid option. */
1639 /* `getopt_long' already printed an error message. */
1642 default: /* bug: option not considered. */
1643 fprintf (stderr, "%s: option unknown: %c%s\n", RNACOFOLD_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1651 RNAcofold_cmdline_parser_release (&local_args_info);
1654 return (EXIT_FAILURE);
1660 RNAcofold_cmdline_parser_release (&local_args_info);
1661 return (EXIT_FAILURE);