Add missing binaty and statis library
[jabaws.git] / binaries / src / ViennaRNA / Progs / RNAaliduplex_cmdl.c
1 /*
2   File autogenerated by gengetopt version 2.22.5
3   generated with the following command:
4   gengetopt -i RNAaliduplex.ggo --file-name=RNAaliduplex_cmdl --include-getopt --default-optional --unamed-opts --func-name=RNAaliduplex_cmdline_parser --arg-struct-name=RNAaliduplex_args_info
5
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.
9 */
10
11 /* If we use autoconf.  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 #ifndef FIX_UNUSED
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22 #endif
23
24
25 #include "RNAaliduplex_cmdl.h"
26
27 const char *RNAaliduplex_args_info_purpose = "Predict conserved RNA-RNA interactions between two alignments";
28
29 const char *RNAaliduplex_args_info_usage = "Usage: RNAaliduplex [options] <file1.aln> <file2.aln>";
30
31 const char *RNAaliduplex_args_info_description = "The program reads two alignments of RNA sequences in CLUSTAL format and \npredicts optimal and suboptimal binding sites, hybridization energies and the \ncorresponding structures. The calculation takes only inter-molecular base pairs \ninto account, for the general case use RNAcofold. The use of alignments allows \nto focus on binding sites that are evolutionary conserved. Note, that the two \ninput alignments need to have equal number of sequences and the same order, \ni.e. the 1st sequence in file1 will be hybridized to the 1st in file2 etc.\n\nThe computed binding sites, energies, and structures are written to stdout, one \nstructure per line. Each line consist of: The structure in dot bracket format \nwith a \"&\" separating the two strands. The range of the structure in the two \nsequences in the format  \"from,to : from,to\"; the energy of duplex structure \nin kcal/mol.\nThe format is especially useful for computing the hybrid structure between a \nsmall probe sequence and a long target sequence.\n\n";
32
33 const char *RNAaliduplex_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   "  -V, --version              Print version and exit",
37   "\nGeneral Options:",
38   "  Below are command line options which alter the general behavior of this \n  program\n",
39   "  -e, --deltaEnergy=range    Compute suboptimal structures with energy in a \n                               certain range of the optimum (kcal/mol). Default \n                               is calculation of mfe structure only.\n\n",
40   "  -s, --sorted               print output sorted by free energy\n\n                                 (default=off)",
41   "\nModel Details:",
42   "  -T, --temp=DOUBLE          Rescale energy parameters to a temperature of temp \n                               C. Default is 37C.\n\n",
43   "  -4, --noTetra              Do not include special tabulated stabilizing \n                               energies for tri-, tetra- and hexaloop hairpins. \n                               Mostly for testing.\n\n                                 (default=off)",
44   "  -d, --dangles=INT          How to treat \"dangling end\" energies for bases \n                               adjacent to helices in free ends and multi-loops\n                                 (default=`2')",
45   "  \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",
46   "      --noLP                 Produce structures without lonely pairs (helices \n                               of length 1).\n                                 (default=off)",
47   "  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",
48   "      --noGU                 Do not allow GU pairs\n\n                                 (default=off)",
49   "      --noClosingGU          Do not allow GU pairs at the end of helices\n\n                                 (default=off)",
50   "      --noconv               Do not automatically substitude nucleotide \"T\" \n                               with \"U\"\n\n                                 (default=off)",
51   "      --nsp=STRING           Allow other pairs in addition to the usual \n                               AU,GC,and GU pairs.\n",
52   "  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",
53   "  -P, --paramFile=paramfile  Read energy parameters from paramfile, instead of \n                               using the default parameter set.\n",
54   "  A sample parameter file should accompany your distribution.\n  See the RNAlib documentation for details on the file format.\n\n",
55   "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at\n",
56     0
57 };
58
59 static void
60 init_help_array(void)
61 {
62   RNAaliduplex_args_info_help[0] = RNAaliduplex_args_info_detailed_help[0];
63   RNAaliduplex_args_info_help[1] = RNAaliduplex_args_info_detailed_help[1];
64   RNAaliduplex_args_info_help[2] = RNAaliduplex_args_info_detailed_help[2];
65   RNAaliduplex_args_info_help[3] = RNAaliduplex_args_info_detailed_help[3];
66   RNAaliduplex_args_info_help[4] = RNAaliduplex_args_info_detailed_help[4];
67   RNAaliduplex_args_info_help[5] = RNAaliduplex_args_info_detailed_help[5];
68   RNAaliduplex_args_info_help[6] = RNAaliduplex_args_info_detailed_help[6];
69   RNAaliduplex_args_info_help[7] = RNAaliduplex_args_info_detailed_help[7];
70   RNAaliduplex_args_info_help[8] = RNAaliduplex_args_info_detailed_help[8];
71   RNAaliduplex_args_info_help[9] = RNAaliduplex_args_info_detailed_help[9];
72   RNAaliduplex_args_info_help[10] = RNAaliduplex_args_info_detailed_help[10];
73   RNAaliduplex_args_info_help[11] = RNAaliduplex_args_info_detailed_help[12];
74   RNAaliduplex_args_info_help[12] = RNAaliduplex_args_info_detailed_help[14];
75   RNAaliduplex_args_info_help[13] = RNAaliduplex_args_info_detailed_help[15];
76   RNAaliduplex_args_info_help[14] = RNAaliduplex_args_info_detailed_help[16];
77   RNAaliduplex_args_info_help[15] = RNAaliduplex_args_info_detailed_help[17];
78   RNAaliduplex_args_info_help[16] = RNAaliduplex_args_info_detailed_help[19];
79   RNAaliduplex_args_info_help[17] = RNAaliduplex_args_info_detailed_help[21];
80   RNAaliduplex_args_info_help[18] = 0; 
81   
82 }
83
84 const char *RNAaliduplex_args_info_help[19];
85
86 typedef enum {ARG_NO
87   , ARG_FLAG
88   , ARG_STRING
89   , ARG_INT
90   , ARG_FLOAT
91   , ARG_DOUBLE
92 } RNAaliduplex_cmdline_parser_arg_type;
93
94 static
95 void clear_given (struct RNAaliduplex_args_info *args_info);
96 static
97 void clear_args (struct RNAaliduplex_args_info *args_info);
98
99 static int
100 RNAaliduplex_cmdline_parser_internal (int argc, char **argv, struct RNAaliduplex_args_info *args_info,
101                         struct RNAaliduplex_cmdline_parser_params *params, const char *additional_error);
102
103
104 static char *
105 gengetopt_strdup (const char *s);
106
107 static
108 void clear_given (struct RNAaliduplex_args_info *args_info)
109 {
110   args_info->help_given = 0 ;
111   args_info->detailed_help_given = 0 ;
112   args_info->version_given = 0 ;
113   args_info->deltaEnergy_given = 0 ;
114   args_info->sorted_given = 0 ;
115   args_info->temp_given = 0 ;
116   args_info->noTetra_given = 0 ;
117   args_info->dangles_given = 0 ;
118   args_info->noLP_given = 0 ;
119   args_info->noGU_given = 0 ;
120   args_info->noClosingGU_given = 0 ;
121   args_info->noconv_given = 0 ;
122   args_info->nsp_given = 0 ;
123   args_info->paramFile_given = 0 ;
124 }
125
126 static
127 void clear_args (struct RNAaliduplex_args_info *args_info)
128 {
129   FIX_UNUSED (args_info);
130   args_info->deltaEnergy_orig = NULL;
131   args_info->sorted_flag = 0;
132   args_info->temp_orig = NULL;
133   args_info->noTetra_flag = 0;
134   args_info->dangles_arg = 2;
135   args_info->dangles_orig = NULL;
136   args_info->noLP_flag = 0;
137   args_info->noGU_flag = 0;
138   args_info->noClosingGU_flag = 0;
139   args_info->noconv_flag = 0;
140   args_info->nsp_arg = NULL;
141   args_info->nsp_orig = NULL;
142   args_info->paramFile_arg = NULL;
143   args_info->paramFile_orig = NULL;
144   
145 }
146
147 static
148 void init_args_info(struct RNAaliduplex_args_info *args_info)
149 {
150
151   init_help_array(); 
152   args_info->help_help = RNAaliduplex_args_info_detailed_help[0] ;
153   args_info->detailed_help_help = RNAaliduplex_args_info_detailed_help[1] ;
154   args_info->version_help = RNAaliduplex_args_info_detailed_help[2] ;
155   args_info->deltaEnergy_help = RNAaliduplex_args_info_detailed_help[5] ;
156   args_info->sorted_help = RNAaliduplex_args_info_detailed_help[6] ;
157   args_info->temp_help = RNAaliduplex_args_info_detailed_help[8] ;
158   args_info->noTetra_help = RNAaliduplex_args_info_detailed_help[9] ;
159   args_info->dangles_help = RNAaliduplex_args_info_detailed_help[10] ;
160   args_info->noLP_help = RNAaliduplex_args_info_detailed_help[12] ;
161   args_info->noGU_help = RNAaliduplex_args_info_detailed_help[14] ;
162   args_info->noClosingGU_help = RNAaliduplex_args_info_detailed_help[15] ;
163   args_info->noconv_help = RNAaliduplex_args_info_detailed_help[16] ;
164   args_info->nsp_help = RNAaliduplex_args_info_detailed_help[17] ;
165   args_info->paramFile_help = RNAaliduplex_args_info_detailed_help[19] ;
166   
167 }
168
169 void
170 RNAaliduplex_cmdline_parser_print_version (void)
171 {
172   printf ("%s %s\n",
173      (strlen(RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE_NAME) ? RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE_NAME : RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE),
174      RNAALIDUPLEX_CMDLINE_PARSER_VERSION);
175 }
176
177 static void print_help_common(void) {
178   RNAaliduplex_cmdline_parser_print_version ();
179
180   if (strlen(RNAaliduplex_args_info_purpose) > 0)
181     printf("\n%s\n", RNAaliduplex_args_info_purpose);
182
183   if (strlen(RNAaliduplex_args_info_usage) > 0)
184     printf("\n%s\n", RNAaliduplex_args_info_usage);
185
186   printf("\n");
187
188   if (strlen(RNAaliduplex_args_info_description) > 0)
189     printf("%s\n\n", RNAaliduplex_args_info_description);
190 }
191
192 void
193 RNAaliduplex_cmdline_parser_print_help (void)
194 {
195   int i = 0;
196   print_help_common();
197   while (RNAaliduplex_args_info_help[i])
198     printf("%s\n", RNAaliduplex_args_info_help[i++]);
199 }
200
201 void
202 RNAaliduplex_cmdline_parser_print_detailed_help (void)
203 {
204   int i = 0;
205   print_help_common();
206   while (RNAaliduplex_args_info_detailed_help[i])
207     printf("%s\n", RNAaliduplex_args_info_detailed_help[i++]);
208 }
209
210 void
211 RNAaliduplex_cmdline_parser_init (struct RNAaliduplex_args_info *args_info)
212 {
213   clear_given (args_info);
214   clear_args (args_info);
215   init_args_info (args_info);
216
217   args_info->inputs = 0;
218   args_info->inputs_num = 0;
219 }
220
221 void
222 RNAaliduplex_cmdline_parser_params_init(struct RNAaliduplex_cmdline_parser_params *params)
223 {
224   if (params)
225     { 
226       params->override = 0;
227       params->initialize = 1;
228       params->check_required = 1;
229       params->check_ambiguity = 0;
230       params->print_errors = 1;
231     }
232 }
233
234 struct RNAaliduplex_cmdline_parser_params *
235 RNAaliduplex_cmdline_parser_params_create(void)
236 {
237   struct RNAaliduplex_cmdline_parser_params *params = 
238     (struct RNAaliduplex_cmdline_parser_params *)malloc(sizeof(struct RNAaliduplex_cmdline_parser_params));
239   RNAaliduplex_cmdline_parser_params_init(params);  
240   return params;
241 }
242
243 static void
244 free_string_field (char **s)
245 {
246   if (*s)
247     {
248       free (*s);
249       *s = 0;
250     }
251 }
252
253
254 static void
255 RNAaliduplex_cmdline_parser_release (struct RNAaliduplex_args_info *args_info)
256 {
257   unsigned int i;
258   free_string_field (&(args_info->deltaEnergy_orig));
259   free_string_field (&(args_info->temp_orig));
260   free_string_field (&(args_info->dangles_orig));
261   free_string_field (&(args_info->nsp_arg));
262   free_string_field (&(args_info->nsp_orig));
263   free_string_field (&(args_info->paramFile_arg));
264   free_string_field (&(args_info->paramFile_orig));
265   
266   
267   for (i = 0; i < args_info->inputs_num; ++i)
268     free (args_info->inputs [i]);
269
270   if (args_info->inputs_num)
271     free (args_info->inputs);
272
273   clear_given (args_info);
274 }
275
276
277 static void
278 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
279 {
280   FIX_UNUSED (values);
281   if (arg) {
282     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
283   } else {
284     fprintf(outfile, "%s\n", opt);
285   }
286 }
287
288
289 int
290 RNAaliduplex_cmdline_parser_dump(FILE *outfile, struct RNAaliduplex_args_info *args_info)
291 {
292   int i = 0;
293
294   if (!outfile)
295     {
296       fprintf (stderr, "%s: cannot dump options to stream\n", RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE);
297       return EXIT_FAILURE;
298     }
299
300   if (args_info->help_given)
301     write_into_file(outfile, "help", 0, 0 );
302   if (args_info->detailed_help_given)
303     write_into_file(outfile, "detailed-help", 0, 0 );
304   if (args_info->version_given)
305     write_into_file(outfile, "version", 0, 0 );
306   if (args_info->deltaEnergy_given)
307     write_into_file(outfile, "deltaEnergy", args_info->deltaEnergy_orig, 0);
308   if (args_info->sorted_given)
309     write_into_file(outfile, "sorted", 0, 0 );
310   if (args_info->temp_given)
311     write_into_file(outfile, "temp", args_info->temp_orig, 0);
312   if (args_info->noTetra_given)
313     write_into_file(outfile, "noTetra", 0, 0 );
314   if (args_info->dangles_given)
315     write_into_file(outfile, "dangles", args_info->dangles_orig, 0);
316   if (args_info->noLP_given)
317     write_into_file(outfile, "noLP", 0, 0 );
318   if (args_info->noGU_given)
319     write_into_file(outfile, "noGU", 0, 0 );
320   if (args_info->noClosingGU_given)
321     write_into_file(outfile, "noClosingGU", 0, 0 );
322   if (args_info->noconv_given)
323     write_into_file(outfile, "noconv", 0, 0 );
324   if (args_info->nsp_given)
325     write_into_file(outfile, "nsp", args_info->nsp_orig, 0);
326   if (args_info->paramFile_given)
327     write_into_file(outfile, "paramFile", args_info->paramFile_orig, 0);
328   
329
330   i = EXIT_SUCCESS;
331   return i;
332 }
333
334 int
335 RNAaliduplex_cmdline_parser_file_save(const char *filename, struct RNAaliduplex_args_info *args_info)
336 {
337   FILE *outfile;
338   int i = 0;
339
340   outfile = fopen(filename, "w");
341
342   if (!outfile)
343     {
344       fprintf (stderr, "%s: cannot open file for writing: %s\n", RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE, filename);
345       return EXIT_FAILURE;
346     }
347
348   i = RNAaliduplex_cmdline_parser_dump(outfile, args_info);
349   fclose (outfile);
350
351   return i;
352 }
353
354 void
355 RNAaliduplex_cmdline_parser_free (struct RNAaliduplex_args_info *args_info)
356 {
357   RNAaliduplex_cmdline_parser_release (args_info);
358 }
359
360 /** @brief replacement of strdup, which is not standard */
361 char *
362 gengetopt_strdup (const char *s)
363 {
364   char *result = 0;
365   if (!s)
366     return result;
367
368   result = (char*)malloc(strlen(s) + 1);
369   if (result == (char*)0)
370     return (char*)0;
371   strcpy(result, s);
372   return result;
373 }
374
375 int
376 RNAaliduplex_cmdline_parser (int argc, char **argv, struct RNAaliduplex_args_info *args_info)
377 {
378   return RNAaliduplex_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
379 }
380
381 int
382 RNAaliduplex_cmdline_parser_ext (int argc, char **argv, struct RNAaliduplex_args_info *args_info,
383                    struct RNAaliduplex_cmdline_parser_params *params)
384 {
385   int result;
386   result = RNAaliduplex_cmdline_parser_internal (argc, argv, args_info, params, 0);
387
388   if (result == EXIT_FAILURE)
389     {
390       RNAaliduplex_cmdline_parser_free (args_info);
391       exit (EXIT_FAILURE);
392     }
393   
394   return result;
395 }
396
397 int
398 RNAaliduplex_cmdline_parser2 (int argc, char **argv, struct RNAaliduplex_args_info *args_info, int override, int initialize, int check_required)
399 {
400   int result;
401   struct RNAaliduplex_cmdline_parser_params params;
402   
403   params.override = override;
404   params.initialize = initialize;
405   params.check_required = check_required;
406   params.check_ambiguity = 0;
407   params.print_errors = 1;
408
409   result = RNAaliduplex_cmdline_parser_internal (argc, argv, args_info, &params, 0);
410
411   if (result == EXIT_FAILURE)
412     {
413       RNAaliduplex_cmdline_parser_free (args_info);
414       exit (EXIT_FAILURE);
415     }
416   
417   return result;
418 }
419
420 int
421 RNAaliduplex_cmdline_parser_required (struct RNAaliduplex_args_info *args_info, const char *prog_name)
422 {
423   FIX_UNUSED (args_info);
424   FIX_UNUSED (prog_name);
425   return EXIT_SUCCESS;
426 }
427
428 /*
429  * Extracted from the glibc source tree, version 2.3.6
430  *
431  * Licensed under the GPL as per the whole glibc source tree.
432  *
433  * This file was modified so that getopt_long can be called
434  * many times without risking previous memory to be spoiled.
435  *
436  * Modified by Andre Noll and Lorenzo Bettini for use in
437  * GNU gengetopt generated files.
438  *
439  */
440
441 /* 
442  * we must include anything we need since this file is not thought to be
443  * inserted in a file already using getopt.h
444  *
445  * Lorenzo
446  */
447
448 struct option
449 {
450   const char *name;
451   /* has_arg can't be an enum because some compilers complain about
452      type mismatches in all the code that assumes it is an int.  */
453   int has_arg;
454   int *flag;
455   int val;
456 };
457
458 /* This version of `getopt' appears to the caller like standard Unix `getopt'
459    but it behaves differently for the user, since it allows the user
460    to intersperse the options with the other arguments.
461
462    As `getopt' works, it permutes the elements of ARGV so that,
463    when it is done, all the options precede everything else.  Thus
464    all application programs are extended to handle flexible argument order.
465 */
466 /*
467    If the field `flag' is not NULL, it points to a variable that is set
468    to the value given in the field `val' when the option is found, but
469    left unchanged if the option is not found.
470
471    To have a long-named option do something other than set an `int' to
472    a compiled-in constant, such as set a value from `custom_optarg', set the
473    option's `flag' field to zero and its `val' field to a nonzero
474    value (the equivalent single-letter option character, if there is
475    one).  For long options that have a zero `flag' field, `getopt'
476    returns the contents of the `val' field.  */
477
478 /* Names for the values of the `has_arg' field of `struct option'.  */
479 #ifndef no_argument
480 #define no_argument             0
481 #endif
482
483 #ifndef required_argument
484 #define required_argument       1
485 #endif
486
487 #ifndef optional_argument
488 #define optional_argument       2
489 #endif
490
491 struct custom_getopt_data {
492         /*
493          * These have exactly the same meaning as the corresponding global variables,
494          * except that they are used for the reentrant versions of getopt.
495          */
496         int custom_optind;
497         int custom_opterr;
498         int custom_optopt;
499         char *custom_optarg;
500
501         /* True if the internal members have been initialized.  */
502         int initialized;
503
504         /*
505          * The next char to be scanned in the option-element in which the last option
506          * character we returned was found.  This allows us to pick up the scan where
507          * we left off.  If this is zero, or a null string, it means resume the scan by
508          * advancing to the next ARGV-element.
509          */
510         char *nextchar;
511
512         /*
513          * Describe the part of ARGV that contains non-options that have been skipped.
514          * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
515          * the index after the last of them.
516          */
517         int first_nonopt;
518         int last_nonopt;
519 };
520
521 /*
522  * the variables optarg, optind, opterr and optopt are renamed with
523  * the custom_ prefix so that they don't interfere with getopt ones.
524  *
525  * Moreover they're static so they are visible only from within the
526  * file where this very file will be included.
527  */
528
529 /*
530  * For communication from `custom_getopt' to the caller.  When `custom_getopt' finds an
531  * option that takes an argument, the argument value is returned here.
532  */
533 static char *custom_optarg;
534
535 /*
536  * Index in ARGV of the next element to be scanned.  This is used for
537  * communication to and from the caller and for communication between
538  * successive calls to `custom_getopt'.
539  *
540  * On entry to `custom_getopt', 1 means this is the first call; initialize.
541  *
542  * When `custom_getopt' returns -1, this is the index of the first of the non-option
543  * elements that the caller should itself scan.
544  *
545  * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
546  * has been scanned so far.
547  *
548  * 1003.2 says this must be 1 before any call.
549  */
550 static int custom_optind = 1;
551
552 /*
553  * Callers store zero here to inhibit the error message for unrecognized
554  * options.
555  */
556 static int custom_opterr = 1;
557
558 /*
559  * Set to an option character which was unrecognized.  This must be initialized
560  * on some systems to avoid linking in the system's own getopt implementation.
561  */
562 static int custom_optopt = '?';
563
564 /*
565  * Exchange two adjacent subsequences of ARGV.  One subsequence is elements
566  * [first_nonopt,last_nonopt) which contains all the non-options that have been
567  * skipped so far.  The other is elements [last_nonopt,custom_optind), which contains
568  * all the options processed since those non-options were skipped.
569  * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
570  * indices of the non-options in ARGV after they are moved.
571  */
572 static void exchange(char **argv, struct custom_getopt_data *d)
573 {
574         int bottom = d->first_nonopt;
575         int middle = d->last_nonopt;
576         int top = d->custom_optind;
577         char *tem;
578
579         /*
580          * Exchange the shorter segment with the far end of the longer segment.
581          * That puts the shorter segment into the right place.  It leaves the
582          * longer segment in the right place overall, but it consists of two
583          * parts that need to be swapped next.
584          */
585         while (top > middle && middle > bottom) {
586                 if (top - middle > middle - bottom) {
587                         /* Bottom segment is the short one.  */
588                         int len = middle - bottom;
589                         int i;
590
591                         /* Swap it with the top part of the top segment.  */
592                         for (i = 0; i < len; i++) {
593                                 tem = argv[bottom + i];
594                                 argv[bottom + i] =
595                                         argv[top - (middle - bottom) + i];
596                                 argv[top - (middle - bottom) + i] = tem;
597                         }
598                         /* Exclude the moved bottom segment from further swapping.  */
599                         top -= len;
600                 } else {
601                         /* Top segment is the short one.  */
602                         int len = top - middle;
603                         int i;
604
605                         /* Swap it with the bottom part of the bottom segment.  */
606                         for (i = 0; i < len; i++) {
607                                 tem = argv[bottom + i];
608                                 argv[bottom + i] = argv[middle + i];
609                                 argv[middle + i] = tem;
610                         }
611                         /* Exclude the moved top segment from further swapping.  */
612                         bottom += len;
613                 }
614         }
615         /* Update records for the slots the non-options now occupy.  */
616         d->first_nonopt += (d->custom_optind - d->last_nonopt);
617         d->last_nonopt = d->custom_optind;
618 }
619
620 /* Initialize the internal data when the first call is made.  */
621 static void custom_getopt_initialize(struct custom_getopt_data *d)
622 {
623         /*
624          * Start processing options with ARGV-element 1 (since ARGV-element 0
625          * is the program name); the sequence of previously skipped non-option
626          * ARGV-elements is empty.
627          */
628         d->first_nonopt = d->last_nonopt = d->custom_optind;
629         d->nextchar = NULL;
630         d->initialized = 1;
631 }
632
633 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
634
635 /* return: zero: continue, nonzero: return given value to user */
636 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
637         struct custom_getopt_data *d)
638 {
639         /*
640          * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
641          * moved back by the user (who may also have changed the arguments).
642          */
643         if (d->last_nonopt > d->custom_optind)
644                 d->last_nonopt = d->custom_optind;
645         if (d->first_nonopt > d->custom_optind)
646                 d->first_nonopt = d->custom_optind;
647         /*
648          * If we have just processed some options following some
649          * non-options, exchange them so that the options come first.
650          */
651         if (d->first_nonopt != d->last_nonopt &&
652                         d->last_nonopt != d->custom_optind)
653                 exchange((char **) argv, d);
654         else if (d->last_nonopt != d->custom_optind)
655                 d->first_nonopt = d->custom_optind;
656         /*
657          * Skip any additional non-options and extend the range of
658          * non-options previously skipped.
659          */
660         while (d->custom_optind < argc && NONOPTION_P)
661                 d->custom_optind++;
662         d->last_nonopt = d->custom_optind;
663         /*
664          * The special ARGV-element `--' means premature end of options.  Skip
665          * it like a null option, then exchange with previous non-options as if
666          * it were an option, then skip everything else like a non-option.
667          */
668         if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
669                 d->custom_optind++;
670                 if (d->first_nonopt != d->last_nonopt
671                                 && d->last_nonopt != d->custom_optind)
672                         exchange((char **) argv, d);
673                 else if (d->first_nonopt == d->last_nonopt)
674                         d->first_nonopt = d->custom_optind;
675                 d->last_nonopt = argc;
676                 d->custom_optind = argc;
677         }
678         /*
679          * If we have done all the ARGV-elements, stop the scan and back over
680          * any non-options that we skipped and permuted.
681          */
682         if (d->custom_optind == argc) {
683                 /*
684                  * Set the next-arg-index to point at the non-options that we
685                  * previously skipped, so the caller will digest them.
686                  */
687                 if (d->first_nonopt != d->last_nonopt)
688                         d->custom_optind = d->first_nonopt;
689                 return -1;
690         }
691         /*
692          * If we have come to a non-option and did not permute it, either stop
693          * the scan or describe it to the caller and pass it by.
694          */
695         if (NONOPTION_P) {
696                 d->custom_optarg = argv[d->custom_optind++];
697                 return 1;
698         }
699         /*
700          * We have found another option-ARGV-element. Skip the initial
701          * punctuation.
702          */
703         d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
704         return 0;
705 }
706
707 /*
708  * Check whether the ARGV-element is a long option.
709  *
710  * If there's a long option "fubar" and the ARGV-element is "-fu", consider
711  * that an abbreviation of the long option, just like "--fu", and not "-f" with
712  * arg "u".
713  *
714  * This distinction seems to be the most useful approach.
715  *
716  */
717 static int check_long_opt(int argc, char *const *argv, const char *optstring,
718                 const struct option *longopts, int *longind,
719                 int print_errors, struct custom_getopt_data *d)
720 {
721         char *nameend;
722         const struct option *p;
723         const struct option *pfound = NULL;
724         int exact = 0;
725         int ambig = 0;
726         int indfound = -1;
727         int option_index;
728
729         for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
730                 /* Do nothing.  */ ;
731
732         /* Test all long options for either exact match or abbreviated matches */
733         for (p = longopts, option_index = 0; p->name; p++, option_index++)
734                 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
735                         if ((unsigned int) (nameend - d->nextchar)
736                                         == (unsigned int) strlen(p->name)) {
737                                 /* Exact match found.  */
738                                 pfound = p;
739                                 indfound = option_index;
740                                 exact = 1;
741                                 break;
742                         } else if (pfound == NULL) {
743                                 /* First nonexact match found.  */
744                                 pfound = p;
745                                 indfound = option_index;
746                         } else if (pfound->has_arg != p->has_arg
747                                         || pfound->flag != p->flag
748                                         || pfound->val != p->val)
749                                 /* Second or later nonexact match found.  */
750                                 ambig = 1;
751                 }
752         if (ambig && !exact) {
753                 if (print_errors) {
754                         fprintf(stderr,
755                                 "%s: option `%s' is ambiguous\n",
756                                 argv[0], argv[d->custom_optind]);
757                 }
758                 d->nextchar += strlen(d->nextchar);
759                 d->custom_optind++;
760                 d->custom_optopt = 0;
761                 return '?';
762         }
763         if (pfound) {
764                 option_index = indfound;
765                 d->custom_optind++;
766                 if (*nameend) {
767                         if (pfound->has_arg != no_argument)
768                                 d->custom_optarg = nameend + 1;
769                         else {
770                                 if (print_errors) {
771                                         if (argv[d->custom_optind - 1][1] == '-') {
772                                                 /* --option */
773                                                 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
774                                                         argv[0], pfound->name);
775                                         } else {
776                                                 /* +option or -option */
777                                                 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
778                                                         argv[0], argv[d->custom_optind - 1][0], pfound->name);
779                                         }
780
781                                 }
782                                 d->nextchar += strlen(d->nextchar);
783                                 d->custom_optopt = pfound->val;
784                                 return '?';
785                         }
786                 } else if (pfound->has_arg == required_argument) {
787                         if (d->custom_optind < argc)
788                                 d->custom_optarg = argv[d->custom_optind++];
789                         else {
790                                 if (print_errors) {
791                                         fprintf(stderr,
792                                                 "%s: option `%s' requires an argument\n",
793                                                 argv[0],
794                                                 argv[d->custom_optind - 1]);
795                                 }
796                                 d->nextchar += strlen(d->nextchar);
797                                 d->custom_optopt = pfound->val;
798                                 return optstring[0] == ':' ? ':' : '?';
799                         }
800                 }
801                 d->nextchar += strlen(d->nextchar);
802                 if (longind != NULL)
803                         *longind = option_index;
804                 if (pfound->flag) {
805                         *(pfound->flag) = pfound->val;
806                         return 0;
807                 }
808                 return pfound->val;
809         }
810         /*
811          * Can't find it as a long option.  If this is not getopt_long_only, or
812          * the option starts with '--' or is not a valid short option, then
813          * it's an error.  Otherwise interpret it as a short option.
814          */
815         if (print_errors) {
816                 if (argv[d->custom_optind][1] == '-') {
817                         /* --option */
818                         fprintf(stderr,
819                                 "%s: unrecognized option `--%s'\n",
820                                 argv[0], d->nextchar);
821                 } else {
822                         /* +option or -option */
823                         fprintf(stderr,
824                                 "%s: unrecognized option `%c%s'\n",
825                                 argv[0], argv[d->custom_optind][0],
826                                 d->nextchar);
827                 }
828         }
829         d->nextchar = (char *) "";
830         d->custom_optind++;
831         d->custom_optopt = 0;
832         return '?';
833 }
834
835 static int check_short_opt(int argc, char *const *argv, const char *optstring,
836                 int print_errors, struct custom_getopt_data *d)
837 {
838         char c = *d->nextchar++;
839         const char *temp = strchr(optstring, c);
840
841         /* Increment `custom_optind' when we start to process its last character.  */
842         if (*d->nextchar == '\0')
843                 ++d->custom_optind;
844         if (!temp || c == ':') {
845                 if (print_errors)
846                         fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
847
848                 d->custom_optopt = c;
849                 return '?';
850         }
851         if (temp[1] == ':') {
852                 if (temp[2] == ':') {
853                         /* This is an option that accepts an argument optionally.  */
854                         if (*d->nextchar != '\0') {
855                                 d->custom_optarg = d->nextchar;
856                                 d->custom_optind++;
857                         } else
858                                 d->custom_optarg = NULL;
859                         d->nextchar = NULL;
860                 } else {
861                         /* This is an option that requires an argument.  */
862                         if (*d->nextchar != '\0') {
863                                 d->custom_optarg = d->nextchar;
864                                 /*
865                                  * If we end this ARGV-element by taking the
866                                  * rest as an arg, we must advance to the next
867                                  * element now.
868                                  */
869                                 d->custom_optind++;
870                         } else if (d->custom_optind == argc) {
871                                 if (print_errors) {
872                                         fprintf(stderr,
873                                                 "%s: option requires an argument -- %c\n",
874                                                 argv[0], c);
875                                 }
876                                 d->custom_optopt = c;
877                                 if (optstring[0] == ':')
878                                         c = ':';
879                                 else
880                                         c = '?';
881                         } else
882                                 /*
883                                  * We already incremented `custom_optind' once;
884                                  * increment it again when taking next ARGV-elt
885                                  * as argument.
886                                  */
887                                 d->custom_optarg = argv[d->custom_optind++];
888                         d->nextchar = NULL;
889                 }
890         }
891         return c;
892 }
893
894 /*
895  * Scan elements of ARGV for option characters given in OPTSTRING.
896  *
897  * If an element of ARGV starts with '-', and is not exactly "-" or "--",
898  * then it is an option element.  The characters of this element
899  * (aside from the initial '-') are option characters.  If `getopt'
900  * is called repeatedly, it returns successively each of the option characters
901  * from each of the option elements.
902  *
903  * If `getopt' finds another option character, it returns that character,
904  * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
905  * resume the scan with the following option character or ARGV-element.
906  *
907  * If there are no more option characters, `getopt' returns -1.
908  * Then `custom_optind' is the index in ARGV of the first ARGV-element
909  * that is not an option.  (The ARGV-elements have been permuted
910  * so that those that are not options now come last.)
911  *
912  * OPTSTRING is a string containing the legitimate option characters.
913  * If an option character is seen that is not listed in OPTSTRING,
914  * return '?' after printing an error message.  If you set `custom_opterr' to
915  * zero, the error message is suppressed but we still return '?'.
916  *
917  * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
918  * so the following text in the same ARGV-element, or the text of the following
919  * ARGV-element, is returned in `custom_optarg'.  Two colons mean an option that
920  * wants an optional arg; if there is text in the current ARGV-element,
921  * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
922  *
923  * If OPTSTRING starts with `-' or `+', it requests different methods of
924  * handling the non-option ARGV-elements.
925  * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
926  *
927  * Long-named options begin with `--' instead of `-'.
928  * Their names may be abbreviated as long as the abbreviation is unique
929  * or is an exact match for some defined option.  If they have an
930  * argument, it follows the option name in the same ARGV-element, separated
931  * from the option name by a `=', or else the in next ARGV-element.
932  * When `getopt' finds a long-named option, it returns 0 if that option's
933  * `flag' field is nonzero, the value of the option's `val' field
934  * if the `flag' field is zero.
935  *
936  * The elements of ARGV aren't really const, because we permute them.
937  * But we pretend they're const in the prototype to be compatible
938  * with other systems.
939  *
940  * LONGOPTS is a vector of `struct option' terminated by an
941  * element containing a name which is zero.
942  *
943  * LONGIND returns the index in LONGOPT of the long-named option found.
944  * It is only valid when a long-named option has been found by the most
945  * recent call.
946  *
947  * Return the option character from OPTS just read.  Return -1 when there are
948  * no more options.  For unrecognized options, or options missing arguments,
949  * `custom_optopt' is set to the option letter, and '?' is returned.
950  *
951  * The OPTS string is a list of characters which are recognized option letters,
952  * optionally followed by colons, specifying that that letter takes an
953  * argument, to be placed in `custom_optarg'.
954  *
955  * If a letter in OPTS is followed by two colons, its argument is optional.
956  * This behavior is specific to the GNU `getopt'.
957  *
958  * The argument `--' causes premature termination of argument scanning,
959  * explicitly telling `getopt' that there are no more options.  If OPTS begins
960  * with `--', then non-option arguments are treated as arguments to the option
961  * '\0'.  This behavior is specific to the GNU `getopt'.
962  */
963
964 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
965                 const struct option *longopts, int *longind,
966                 struct custom_getopt_data *d)
967 {
968         int ret, print_errors = d->custom_opterr;
969
970         if (optstring[0] == ':')
971                 print_errors = 0;
972         if (argc < 1)
973                 return -1;
974         d->custom_optarg = NULL;
975
976         /* 
977          * This is a big difference with GNU getopt, since optind == 0
978          * means initialization while here 1 means first call.
979          */
980         if (d->custom_optind == 0 || !d->initialized) {
981                 if (d->custom_optind == 0)
982                         d->custom_optind = 1;   /* Don't scan ARGV[0], the program name.  */
983                 custom_getopt_initialize(d);
984         }
985         if (d->nextchar == NULL || *d->nextchar == '\0') {
986                 ret = shuffle_argv(argc, argv, longopts, d);
987                 if (ret)
988                         return ret;
989         }
990         if (longopts && (argv[d->custom_optind][1] == '-' ))
991                 return check_long_opt(argc, argv, optstring, longopts,
992                         longind, print_errors, d);
993         return check_short_opt(argc, argv, optstring, print_errors, d);
994 }
995
996 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
997         const struct option *longopts, int *longind)
998 {
999         int result;
1000         /* Keep a global copy of all internal members of d */
1001         static struct custom_getopt_data d;
1002
1003         d.custom_optind = custom_optind;
1004         d.custom_opterr = custom_opterr;
1005         result = getopt_internal_r(argc, argv, optstring, longopts,
1006                 longind, &d);
1007         custom_optind = d.custom_optind;
1008         custom_optarg = d.custom_optarg;
1009         custom_optopt = d.custom_optopt;
1010         return result;
1011 }
1012
1013 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1014         const struct option *long_options, int *opt_index)
1015 {
1016         return custom_getopt_internal(argc, argv, options, long_options,
1017                 opt_index);
1018 }
1019
1020
1021 static char *package_name = 0;
1022
1023 /**
1024  * @brief updates an option
1025  * @param field the generic pointer to the field to update
1026  * @param orig_field the pointer to the orig field
1027  * @param field_given the pointer to the number of occurrence of this option
1028  * @param prev_given the pointer to the number of occurrence already seen
1029  * @param value the argument for this option (if null no arg was specified)
1030  * @param possible_values the possible values for this option (if specified)
1031  * @param default_value the default value (in case the option only accepts fixed values)
1032  * @param arg_type the type of this option
1033  * @param check_ambiguity @see RNAaliduplex_cmdline_parser_params.check_ambiguity
1034  * @param override @see RNAaliduplex_cmdline_parser_params.override
1035  * @param no_free whether to free a possible previous value
1036  * @param multiple_option whether this is a multiple option
1037  * @param long_opt the corresponding long option
1038  * @param short_opt the corresponding short option (or '-' if none)
1039  * @param additional_error possible further error specification
1040  */
1041 static
1042 int update_arg(void *field, char **orig_field,
1043                unsigned int *field_given, unsigned int *prev_given, 
1044                char *value, const char *possible_values[],
1045                const char *default_value,
1046                RNAaliduplex_cmdline_parser_arg_type arg_type,
1047                int check_ambiguity, int override,
1048                int no_free, int multiple_option,
1049                const char *long_opt, char short_opt,
1050                const char *additional_error)
1051 {
1052   char *stop_char = 0;
1053   const char *val = value;
1054   int found;
1055   char **string_field;
1056   FIX_UNUSED (field);
1057
1058   stop_char = 0;
1059   found = 0;
1060
1061   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1062     {
1063       if (short_opt != '-')
1064         fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
1065                package_name, long_opt, short_opt,
1066                (additional_error ? additional_error : ""));
1067       else
1068         fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
1069                package_name, long_opt,
1070                (additional_error ? additional_error : ""));
1071       return 1; /* failure */
1072     }
1073
1074   FIX_UNUSED (default_value);
1075     
1076   if (field_given && *field_given && ! override)
1077     return 0;
1078   if (prev_given)
1079     (*prev_given)++;
1080   if (field_given)
1081     (*field_given)++;
1082   if (possible_values)
1083     val = possible_values[found];
1084
1085   switch(arg_type) {
1086   case ARG_FLAG:
1087     *((int *)field) = !*((int *)field);
1088     break;
1089   case ARG_INT:
1090     if (val) *((int *)field) = strtol (val, &stop_char, 0);
1091     break;
1092   case ARG_FLOAT:
1093     if (val) *((float *)field) = (float)strtod (val, &stop_char);
1094     break;
1095   case ARG_DOUBLE:
1096     if (val) *((double *)field) = strtod (val, &stop_char);
1097     break;
1098   case ARG_STRING:
1099     if (val) {
1100       string_field = (char **)field;
1101       if (!no_free && *string_field)
1102         free (*string_field); /* free previous string */
1103       *string_field = gengetopt_strdup (val);
1104     }
1105     break;
1106   default:
1107     break;
1108   };
1109
1110   /* check numeric conversion */
1111   switch(arg_type) {
1112   case ARG_INT:
1113   case ARG_FLOAT:
1114   case ARG_DOUBLE:
1115     if (val && !(stop_char && *stop_char == '\0')) {
1116       fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1117       return 1; /* failure */
1118     }
1119     break;
1120   default:
1121     ;
1122   };
1123
1124   /* store the original value */
1125   switch(arg_type) {
1126   case ARG_NO:
1127   case ARG_FLAG:
1128     break;
1129   default:
1130     if (value && orig_field) {
1131       if (no_free) {
1132         *orig_field = value;
1133       } else {
1134         if (*orig_field)
1135           free (*orig_field); /* free previous string */
1136         *orig_field = gengetopt_strdup (value);
1137       }
1138     }
1139   };
1140
1141   return 0; /* OK */
1142 }
1143
1144
1145 int
1146 RNAaliduplex_cmdline_parser_internal (
1147   int argc, char **argv, struct RNAaliduplex_args_info *args_info,
1148                         struct RNAaliduplex_cmdline_parser_params *params, const char *additional_error)
1149 {
1150   int c;        /* Character of the parsed option.  */
1151
1152   int error = 0;
1153   struct RNAaliduplex_args_info local_args_info;
1154   
1155   int override;
1156   int initialize;
1157   int check_required;
1158   int check_ambiguity;
1159
1160   char *optarg;
1161   int optind;
1162   int opterr;
1163   int optopt;
1164   
1165   package_name = argv[0];
1166   
1167   override = params->override;
1168   initialize = params->initialize;
1169   check_required = params->check_required;
1170   check_ambiguity = params->check_ambiguity;
1171
1172   if (initialize)
1173     RNAaliduplex_cmdline_parser_init (args_info);
1174
1175   RNAaliduplex_cmdline_parser_init (&local_args_info);
1176
1177   optarg = 0;
1178   optind = 0;
1179   opterr = params->print_errors;
1180   optopt = '?';
1181
1182   while (1)
1183     {
1184       int option_index = 0;
1185
1186       static struct option long_options[] = {
1187         { "help",       0, NULL, 'h' },
1188         { "detailed-help",      0, NULL, 0 },
1189         { "version",    0, NULL, 'V' },
1190         { "deltaEnergy",        1, NULL, 'e' },
1191         { "sorted",     0, NULL, 's' },
1192         { "temp",       1, NULL, 'T' },
1193         { "noTetra",    0, NULL, '4' },
1194         { "dangles",    1, NULL, 'd' },
1195         { "noLP",       0, NULL, 0 },
1196         { "noGU",       0, NULL, 0 },
1197         { "noClosingGU",        0, NULL, 0 },
1198         { "noconv",     0, NULL, 0 },
1199         { "nsp",        1, NULL, 0 },
1200         { "paramFile",  1, NULL, 'P' },
1201         { 0,  0, 0, 0 }
1202       };
1203
1204       custom_optarg = optarg;
1205       custom_optind = optind;
1206       custom_opterr = opterr;
1207       custom_optopt = optopt;
1208
1209       c = custom_getopt_long (argc, argv, "hVe:sT:4d:P:", long_options, &option_index);
1210
1211       optarg = custom_optarg;
1212       optind = custom_optind;
1213       opterr = custom_opterr;
1214       optopt = custom_optopt;
1215
1216       if (c == -1) break;       /* Exit from `while (1)' loop.  */
1217
1218       switch (c)
1219         {
1220         case 'h':       /* Print help and exit.  */
1221           RNAaliduplex_cmdline_parser_print_help ();
1222           RNAaliduplex_cmdline_parser_free (&local_args_info);
1223           exit (EXIT_SUCCESS);
1224
1225         case 'V':       /* Print version and exit.  */
1226           RNAaliduplex_cmdline_parser_print_version ();
1227           RNAaliduplex_cmdline_parser_free (&local_args_info);
1228           exit (EXIT_SUCCESS);
1229
1230         case 'e':       /* Compute suboptimal structures with energy in a certain range of the optimum (kcal/mol). Default is calculation of mfe structure only.
1231         
1232 .  */
1233         
1234         
1235           if (update_arg( (void *)&(args_info->deltaEnergy_arg), 
1236                &(args_info->deltaEnergy_orig), &(args_info->deltaEnergy_given),
1237               &(local_args_info.deltaEnergy_given), optarg, 0, 0, ARG_FLOAT,
1238               check_ambiguity, override, 0, 0,
1239               "deltaEnergy", 'e',
1240               additional_error))
1241             goto failure;
1242         
1243           break;
1244         case 's':       /* print output sorted by free energy
1245         
1246 .  */
1247         
1248         
1249           if (update_arg((void *)&(args_info->sorted_flag), 0, &(args_info->sorted_given),
1250               &(local_args_info.sorted_given), optarg, 0, 0, ARG_FLAG,
1251               check_ambiguity, override, 1, 0, "sorted", 's',
1252               additional_error))
1253             goto failure;
1254         
1255           break;
1256         case 'T':       /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1257         
1258 .  */
1259         
1260         
1261           if (update_arg( (void *)&(args_info->temp_arg), 
1262                &(args_info->temp_orig), &(args_info->temp_given),
1263               &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1264               check_ambiguity, override, 0, 0,
1265               "temp", 'T',
1266               additional_error))
1267             goto failure;
1268         
1269           break;
1270         case '4':       /* Do not include special tabulated stabilizing energies for tri-, tetra- and hexaloop hairpins. Mostly for testing.
1271         
1272 .  */
1273         
1274         
1275           if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1276               &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1277               check_ambiguity, override, 1, 0, "noTetra", '4',
1278               additional_error))
1279             goto failure;
1280         
1281           break;
1282         case 'd':       /* How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops
1283 .  */
1284         
1285         
1286           if (update_arg( (void *)&(args_info->dangles_arg), 
1287                &(args_info->dangles_orig), &(args_info->dangles_given),
1288               &(local_args_info.dangles_given), optarg, 0, "2", ARG_INT,
1289               check_ambiguity, override, 0, 0,
1290               "dangles", 'd',
1291               additional_error))
1292             goto failure;
1293         
1294           break;
1295         case 'P':       /* Read energy parameters from paramfile, instead of using the default parameter set.
1296 .  */
1297         
1298         
1299           if (update_arg( (void *)&(args_info->paramFile_arg), 
1300                &(args_info->paramFile_orig), &(args_info->paramFile_given),
1301               &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1302               check_ambiguity, override, 0, 0,
1303               "paramFile", 'P',
1304               additional_error))
1305             goto failure;
1306         
1307           break;
1308
1309         case 0: /* Long option with no short option */
1310           if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1311             RNAaliduplex_cmdline_parser_print_detailed_help ();
1312             RNAaliduplex_cmdline_parser_free (&local_args_info);
1313             exit (EXIT_SUCCESS);
1314           }
1315
1316           /* Produce structures without lonely pairs (helices of length 1).
1317 .  */
1318           if (strcmp (long_options[option_index].name, "noLP") == 0)
1319           {
1320           
1321           
1322             if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1323                 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1324                 check_ambiguity, override, 1, 0, "noLP", '-',
1325                 additional_error))
1326               goto failure;
1327           
1328           }
1329           /* Do not allow GU pairs
1330           
1331 .  */
1332           else if (strcmp (long_options[option_index].name, "noGU") == 0)
1333           {
1334           
1335           
1336             if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1337                 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1338                 check_ambiguity, override, 1, 0, "noGU", '-',
1339                 additional_error))
1340               goto failure;
1341           
1342           }
1343           /* Do not allow GU pairs at the end of helices
1344           
1345 .  */
1346           else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1347           {
1348           
1349           
1350             if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1351                 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1352                 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1353                 additional_error))
1354               goto failure;
1355           
1356           }
1357           /* Do not automatically substitude nucleotide \"T\" with \"U\"
1358           
1359 .  */
1360           else if (strcmp (long_options[option_index].name, "noconv") == 0)
1361           {
1362           
1363           
1364             if (update_arg((void *)&(args_info->noconv_flag), 0, &(args_info->noconv_given),
1365                 &(local_args_info.noconv_given), optarg, 0, 0, ARG_FLAG,
1366                 check_ambiguity, override, 1, 0, "noconv", '-',
1367                 additional_error))
1368               goto failure;
1369           
1370           }
1371           /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1372 .  */
1373           else if (strcmp (long_options[option_index].name, "nsp") == 0)
1374           {
1375           
1376           
1377             if (update_arg( (void *)&(args_info->nsp_arg), 
1378                  &(args_info->nsp_orig), &(args_info->nsp_given),
1379                 &(local_args_info.nsp_given), optarg, 0, 0, ARG_STRING,
1380                 check_ambiguity, override, 0, 0,
1381                 "nsp", '-',
1382                 additional_error))
1383               goto failure;
1384           
1385           }
1386           
1387           break;
1388         case '?':       /* Invalid option.  */
1389           /* `getopt_long' already printed an error message.  */
1390           goto failure;
1391
1392         default:        /* bug: option not considered.  */
1393           fprintf (stderr, "%s: option unknown: %c%s\n", RNAALIDUPLEX_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1394           abort ();
1395         } /* switch */
1396     } /* while */
1397
1398
1399
1400
1401   RNAaliduplex_cmdline_parser_release (&local_args_info);
1402
1403   if ( error )
1404     return (EXIT_FAILURE);
1405
1406   if (optind < argc)
1407     {
1408       int i = 0 ;
1409       int found_prog_name = 0;
1410       /* whether program name, i.e., argv[0], is in the remaining args
1411          (this may happen with some implementations of getopt,
1412           but surely not with the one included by gengetopt) */
1413
1414
1415       args_info->inputs_num = argc - optind - found_prog_name;
1416       args_info->inputs =
1417         (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1418       while (optind < argc)
1419         args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
1420     }
1421
1422   return 0;
1423
1424 failure:
1425   
1426   RNAaliduplex_cmdline_parser_release (&local_args_info);
1427   return (EXIT_FAILURE);
1428 }