2 File autogenerated by gengetopt version 2.22.5
3 generated with the following command:
4 gengetopt -i RNAsnoop.ggo --file-name=RNAsnoop_cmdl --include-getopt --default-optional --func-name=RNAsnoop_cmdline_parser --arg-struct-name=RNAsnoop_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 "RNAsnoop_cmdl.h"
27 const char *RNAsnoop_args_info_purpose = "Find targets of a query H/ACA snoRNA";
29 const char *RNAsnoop_args_info_usage = "Usage: RNAsnoop [options]\n";
31 const char *RNAsnoop_args_info_description = "reads a target RNA sequence and a H/ACA snoRNA sequence\nfrom a target and query file, respectively and computes optimal\nand suboptimal secondary structures for their hybridization. The\ncalculation can be done roughly done in O(nm), where is n the length\nof the target sequence and m is the length of the snoRNA stem, as it\nis specially tailored to the special case of H/ACA snoRNA. For general\npurpose target predictions, please have a look at RNAduplex, RNAup,\nRNAcofold and RNAplex. Accessibility effects can be estimated by\nRNAsnoop if a RNAplfold accessibility profile is provided. \n\nThe computed optimal and suboptimal structure are written to\nstdout, one structure per line. Each line consist\nof: The structure in dot bracket format with a \"&\" separating the\ntwo strands. The '<>' brackets represent snoRNA intramolecular\ninteractions, while the '()' brackets represent intermolecular\ninteractions between the snoRNA and its target.\n\nThe range of the structure in the two sequences in the format\n\"from,to : from,to\"; the energy of duplex structure in\nkcal/mol. If available the opening energy are also returned.\n";
33 const char *RNAsnoop_args_info_detailed_help[] = {
34 " --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",
38 " Below are command line options which alter the general input behavior of \n RNAsnoop\n",
39 " -L, --alignmentLength=INT Limit the extent of the interactions to L \n nucleotides (default=`25')",
40 " -C, --constraint Calculate the stem structure subject to \n constraints.\n (default=off)",
41 " The program reads first the stem sequence, then a string containing \n constraints on 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 " -s, --query=STRING File containing the query sequence.\n",
43 " Input sequences can be given piped to RNAsnoop or given in a query file with \n the -s option. Note that the -s option implies that the -t option is also \n used\n\n",
44 " -t, --target=STRING File containing the target sequence.\n",
45 " Input sequences can be given piped to RNAsnoop or given in a target file with \n the -t optionNote that the -t option implies that the -s option is also used\n\n",
46 " -S, --suffix=STRING Specificy the suffix that was added by RNAup to \n the accessibility files\n\n (default=`_u1_to_30.out')",
47 " -P, --from-RNAplfold=STRING Specify the directory where accessibility \n profile generated by RNAplfold are found\n\n",
49 " Options which alter the computing behaviour of RNAplex.\n Please note that the options allowing to filter out snoRNA-RNA\n duplexes expect the energy to be given in decacal/mol instead of\n kcal/mol. A threshold of -2.8(kcal/mol) should be given as -280(decacal/mol)\n",
50 " -A, --alignment-mode Specify if RNAsnoop gets alignments or single \n sequences as input\n\n (default=off)",
51 " -f, --fast-folding=INT Speedup of the target search (default=`1')",
52 " This option allows to decide if the backtracking has to be\n done (-f 1) or not (-f 0). For -f 1 the structure is computed based\n on the standard energy model. This is the slowest mode of RNAsnoop. -f\n 0 is the fastest mode, as no structure are recomputed and only the\n interaction energy is returned\n\n",
53 " -c, --extension-cost=INT Cost to add to each nucleotide in a duplex \n (default=`0')",
54 " Cost of extending a duplex by one nucleotide. Allows to find\n compact duplexes, having few/small bulges or interior loops. Only\n useful when no accessibility profiles are available. This option is\n disabled if accessibility profiles are used (-P option)\n\n",
55 " -o, --minimal-right-duplex=INT\n Minimal Right Duplex Energy\n\n (default=`-270')",
56 " -l, --minimal-loop-energy=INT Minimal Right Duplex Energy\n (default=`-280')",
57 " Minimal Stem Loop Energy of the snoRNA. The energy should be\n given in decacalories, i.e. a minimal stem-loop energy of -2.8\n kcal/mol corresponds to -280 decacal/mol\n\n",
58 " -p, --minimal-left-duplex=INT Minimal Left Duplex Energy\n\n (default=`-170')",
59 " -q, --minimal-duplex=INT Minimal Duplex Energy\n\n (default=`-1090')",
60 " -d, --duplex-distance=INT Distance between target 3' ends of two \n consecutive duplexes\n (default=`2')",
61 " Distance between the target 3'ends of two consecutive\n duplexes. Should be set to the maximal length of interaction to get\n good results. Smaller d leads to larger overlaps between consecutive\n duplexes\n\n",
62 " -h, --minimal-stem-length=INT Minimal snoRNA stem length\n\n (default=`5')",
63 " -i, --maximal-stem-length=INT Maximal snoRNA stem length\n\n (default=`120')",
64 " -j, --minimal-duplex-box-length=INT\n Minimal distance between the duplex end and the \n H/ACA box\n\n (default=`11')",
65 " -k, --maximal-duplex-box-length=INT\n Maximal distance between the duplex end and the \n H/ACA box\n\n (default=`16')",
66 " -m, --minimal-snoRNA-stem-loop-length=INT\n Minimal number of nucleotides between the \n beginning of stem loop and\n beginning of the snoRNA sequence\n\n (default=`1')",
67 " -n, --maximal-snoRNA-stem-loop-length=INT\n Maximal number of nucleotides between the \n beginning of stem loop and\n beginning of the snoRNA sequence\n\n (default=`100000')",
68 " -v, --minimal-snoRNA-duplex-length=INT\n Minimal distance between duplex start and \n snoRNA\n\n (default=`0')",
69 " -w, --maximal-snoRNA-duplex-length=INT\n Maximal distance between duplex start and \n snoRNA\n\n (default=`0')",
70 " -x, --minimal-duplex-stem-energy=INT\n Minimal duplex stem energy\n\n (default=`-1370')",
71 " -y, --minimal-total-energy=INT\n Minimal total energy\n\n (default=`100000')",
72 " -a, --maximal-stem-asymmetry=INT\n Maximal snoRNA stem asymmetry\n\n (default=`30')",
73 " -b, --minimal-lower-stem-energy=INT\n Minimal lower stem energy\n\n (default=`100000')",
75 " Options that modifies the output\n\n",
76 " -e, --energy-threshold=DOUBLE Maximal energy difference between the mfe and \n the desired suboptimal\n (default=`-1')",
77 " Energy range for a duplex to be returned. The threshold is set on the total \n energy of interaction, i.e. the hybridizationenergy corrected for opening \n energy if -a is set or the energy corrected by -c. If unset, only the mfe \n will be returned\n\n",
78 " -I, --produce-ps Draw annotated 2D structures for a list of \n dot-bracket structures\n (default=off)",
79 " This option allows to produce interaction figures in PS-format with \n conservation/accessibility annotation, if available\n\n",
80 " -O, --output_directory=STRING Set where the generated figures should be \n stored\n\n (default=`./')",
81 " -N, --direct-redraw Outputs 2D interactions concurrently with the \n interaction calculation for each suboptimal \n interaction. The -I option should be \n preferred.\n\n (default=off)",
82 " -U, --from-RNAup=STRING Specify the directory where accessibility \n profiles generated by RNAup are found\n\n",
83 "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
90 RNAsnoop_args_info_help[0] = RNAsnoop_args_info_detailed_help[0];
91 RNAsnoop_args_info_help[1] = RNAsnoop_args_info_detailed_help[1];
92 RNAsnoop_args_info_help[2] = RNAsnoop_args_info_detailed_help[2];
93 RNAsnoop_args_info_help[3] = RNAsnoop_args_info_detailed_help[3];
94 RNAsnoop_args_info_help[4] = RNAsnoop_args_info_detailed_help[4];
95 RNAsnoop_args_info_help[5] = RNAsnoop_args_info_detailed_help[5];
96 RNAsnoop_args_info_help[6] = RNAsnoop_args_info_detailed_help[6];
97 RNAsnoop_args_info_help[7] = RNAsnoop_args_info_detailed_help[8];
98 RNAsnoop_args_info_help[8] = RNAsnoop_args_info_detailed_help[10];
99 RNAsnoop_args_info_help[9] = RNAsnoop_args_info_detailed_help[12];
100 RNAsnoop_args_info_help[10] = RNAsnoop_args_info_detailed_help[13];
101 RNAsnoop_args_info_help[11] = RNAsnoop_args_info_detailed_help[14];
102 RNAsnoop_args_info_help[12] = RNAsnoop_args_info_detailed_help[15];
103 RNAsnoop_args_info_help[13] = RNAsnoop_args_info_detailed_help[16];
104 RNAsnoop_args_info_help[14] = RNAsnoop_args_info_detailed_help[17];
105 RNAsnoop_args_info_help[15] = RNAsnoop_args_info_detailed_help[19];
106 RNAsnoop_args_info_help[16] = RNAsnoop_args_info_detailed_help[21];
107 RNAsnoop_args_info_help[17] = RNAsnoop_args_info_detailed_help[22];
108 RNAsnoop_args_info_help[18] = RNAsnoop_args_info_detailed_help[24];
109 RNAsnoop_args_info_help[19] = RNAsnoop_args_info_detailed_help[25];
110 RNAsnoop_args_info_help[20] = RNAsnoop_args_info_detailed_help[26];
111 RNAsnoop_args_info_help[21] = RNAsnoop_args_info_detailed_help[28];
112 RNAsnoop_args_info_help[22] = RNAsnoop_args_info_detailed_help[29];
113 RNAsnoop_args_info_help[23] = RNAsnoop_args_info_detailed_help[30];
114 RNAsnoop_args_info_help[24] = RNAsnoop_args_info_detailed_help[31];
115 RNAsnoop_args_info_help[25] = RNAsnoop_args_info_detailed_help[32];
116 RNAsnoop_args_info_help[26] = RNAsnoop_args_info_detailed_help[33];
117 RNAsnoop_args_info_help[27] = RNAsnoop_args_info_detailed_help[34];
118 RNAsnoop_args_info_help[28] = RNAsnoop_args_info_detailed_help[35];
119 RNAsnoop_args_info_help[29] = RNAsnoop_args_info_detailed_help[36];
120 RNAsnoop_args_info_help[30] = RNAsnoop_args_info_detailed_help[37];
121 RNAsnoop_args_info_help[31] = RNAsnoop_args_info_detailed_help[38];
122 RNAsnoop_args_info_help[32] = RNAsnoop_args_info_detailed_help[39];
123 RNAsnoop_args_info_help[33] = RNAsnoop_args_info_detailed_help[40];
124 RNAsnoop_args_info_help[34] = RNAsnoop_args_info_detailed_help[41];
125 RNAsnoop_args_info_help[35] = RNAsnoop_args_info_detailed_help[42];
126 RNAsnoop_args_info_help[36] = RNAsnoop_args_info_detailed_help[44];
127 RNAsnoop_args_info_help[37] = RNAsnoop_args_info_detailed_help[46];
128 RNAsnoop_args_info_help[38] = RNAsnoop_args_info_detailed_help[47];
129 RNAsnoop_args_info_help[39] = RNAsnoop_args_info_detailed_help[48];
130 RNAsnoop_args_info_help[40] = RNAsnoop_args_info_detailed_help[49];
131 RNAsnoop_args_info_help[41] = 0;
135 const char *RNAsnoop_args_info_help[42];
142 } RNAsnoop_cmdline_parser_arg_type;
145 void clear_given (struct RNAsnoop_args_info *args_info);
147 void clear_args (struct RNAsnoop_args_info *args_info);
150 RNAsnoop_cmdline_parser_internal (int argc, char **argv, struct RNAsnoop_args_info *args_info,
151 struct RNAsnoop_cmdline_parser_params *params, const char *additional_error);
155 gengetopt_strdup (const char *s);
158 void clear_given (struct RNAsnoop_args_info *args_info)
160 args_info->help_given = 0 ;
161 args_info->detailed_help_given = 0 ;
162 args_info->version_given = 0 ;
163 args_info->alignmentLength_given = 0 ;
164 args_info->constraint_given = 0 ;
165 args_info->query_given = 0 ;
166 args_info->target_given = 0 ;
167 args_info->suffix_given = 0 ;
168 args_info->from_RNAplfold_given = 0 ;
169 args_info->alignment_mode_given = 0 ;
170 args_info->fast_folding_given = 0 ;
171 args_info->extension_cost_given = 0 ;
172 args_info->minimal_right_duplex_given = 0 ;
173 args_info->minimal_loop_energy_given = 0 ;
174 args_info->minimal_left_duplex_given = 0 ;
175 args_info->minimal_duplex_given = 0 ;
176 args_info->duplex_distance_given = 0 ;
177 args_info->minimal_stem_length_given = 0 ;
178 args_info->maximal_stem_length_given = 0 ;
179 args_info->minimal_duplex_box_length_given = 0 ;
180 args_info->maximal_duplex_box_length_given = 0 ;
181 args_info->minimal_snoRNA_stem_loop_length_given = 0 ;
182 args_info->maximal_snoRNA_stem_loop_length_given = 0 ;
183 args_info->minimal_snoRNA_duplex_length_given = 0 ;
184 args_info->maximal_snoRNA_duplex_length_given = 0 ;
185 args_info->minimal_duplex_stem_energy_given = 0 ;
186 args_info->minimal_total_energy_given = 0 ;
187 args_info->maximal_stem_asymmetry_given = 0 ;
188 args_info->minimal_lower_stem_energy_given = 0 ;
189 args_info->energy_threshold_given = 0 ;
190 args_info->produce_ps_given = 0 ;
191 args_info->output_directory_given = 0 ;
192 args_info->direct_redraw_given = 0 ;
193 args_info->from_RNAup_given = 0 ;
197 void clear_args (struct RNAsnoop_args_info *args_info)
199 FIX_UNUSED (args_info);
200 args_info->alignmentLength_arg = 25;
201 args_info->alignmentLength_orig = NULL;
202 args_info->constraint_flag = 0;
203 args_info->query_arg = NULL;
204 args_info->query_orig = NULL;
205 args_info->target_arg = NULL;
206 args_info->target_orig = NULL;
207 args_info->suffix_arg = gengetopt_strdup ("_u1_to_30.out");
208 args_info->suffix_orig = NULL;
209 args_info->from_RNAplfold_arg = NULL;
210 args_info->from_RNAplfold_orig = NULL;
211 args_info->alignment_mode_flag = 0;
212 args_info->fast_folding_arg = 1;
213 args_info->fast_folding_orig = NULL;
214 args_info->extension_cost_arg = 0;
215 args_info->extension_cost_orig = NULL;
216 args_info->minimal_right_duplex_arg = -270;
217 args_info->minimal_right_duplex_orig = NULL;
218 args_info->minimal_loop_energy_arg = -280;
219 args_info->minimal_loop_energy_orig = NULL;
220 args_info->minimal_left_duplex_arg = -170;
221 args_info->minimal_left_duplex_orig = NULL;
222 args_info->minimal_duplex_arg = -1090;
223 args_info->minimal_duplex_orig = NULL;
224 args_info->duplex_distance_arg = 2;
225 args_info->duplex_distance_orig = NULL;
226 args_info->minimal_stem_length_arg = 5;
227 args_info->minimal_stem_length_orig = NULL;
228 args_info->maximal_stem_length_arg = 120;
229 args_info->maximal_stem_length_orig = NULL;
230 args_info->minimal_duplex_box_length_arg = 11;
231 args_info->minimal_duplex_box_length_orig = NULL;
232 args_info->maximal_duplex_box_length_arg = 16;
233 args_info->maximal_duplex_box_length_orig = NULL;
234 args_info->minimal_snoRNA_stem_loop_length_arg = 1;
235 args_info->minimal_snoRNA_stem_loop_length_orig = NULL;
236 args_info->maximal_snoRNA_stem_loop_length_arg = 100000;
237 args_info->maximal_snoRNA_stem_loop_length_orig = NULL;
238 args_info->minimal_snoRNA_duplex_length_arg = 0;
239 args_info->minimal_snoRNA_duplex_length_orig = NULL;
240 args_info->maximal_snoRNA_duplex_length_arg = 0;
241 args_info->maximal_snoRNA_duplex_length_orig = NULL;
242 args_info->minimal_duplex_stem_energy_arg = -1370;
243 args_info->minimal_duplex_stem_energy_orig = NULL;
244 args_info->minimal_total_energy_arg = 100000;
245 args_info->minimal_total_energy_orig = NULL;
246 args_info->maximal_stem_asymmetry_arg = 30;
247 args_info->maximal_stem_asymmetry_orig = NULL;
248 args_info->minimal_lower_stem_energy_arg = 100000;
249 args_info->minimal_lower_stem_energy_orig = NULL;
250 args_info->energy_threshold_arg = -1;
251 args_info->energy_threshold_orig = NULL;
252 args_info->produce_ps_flag = 0;
253 args_info->output_directory_arg = gengetopt_strdup ("./");
254 args_info->output_directory_orig = NULL;
255 args_info->direct_redraw_flag = 0;
256 args_info->from_RNAup_arg = NULL;
257 args_info->from_RNAup_orig = NULL;
262 void init_args_info(struct RNAsnoop_args_info *args_info)
266 args_info->help_help = RNAsnoop_args_info_detailed_help[0] ;
267 args_info->detailed_help_help = RNAsnoop_args_info_detailed_help[1] ;
268 args_info->version_help = RNAsnoop_args_info_detailed_help[2] ;
269 args_info->alignmentLength_help = RNAsnoop_args_info_detailed_help[5] ;
270 args_info->constraint_help = RNAsnoop_args_info_detailed_help[6] ;
271 args_info->query_help = RNAsnoop_args_info_detailed_help[8] ;
272 args_info->target_help = RNAsnoop_args_info_detailed_help[10] ;
273 args_info->suffix_help = RNAsnoop_args_info_detailed_help[12] ;
274 args_info->from_RNAplfold_help = RNAsnoop_args_info_detailed_help[13] ;
275 args_info->alignment_mode_help = RNAsnoop_args_info_detailed_help[16] ;
276 args_info->fast_folding_help = RNAsnoop_args_info_detailed_help[17] ;
277 args_info->extension_cost_help = RNAsnoop_args_info_detailed_help[19] ;
278 args_info->minimal_right_duplex_help = RNAsnoop_args_info_detailed_help[21] ;
279 args_info->minimal_loop_energy_help = RNAsnoop_args_info_detailed_help[22] ;
280 args_info->minimal_left_duplex_help = RNAsnoop_args_info_detailed_help[24] ;
281 args_info->minimal_duplex_help = RNAsnoop_args_info_detailed_help[25] ;
282 args_info->duplex_distance_help = RNAsnoop_args_info_detailed_help[26] ;
283 args_info->minimal_stem_length_help = RNAsnoop_args_info_detailed_help[28] ;
284 args_info->maximal_stem_length_help = RNAsnoop_args_info_detailed_help[29] ;
285 args_info->minimal_duplex_box_length_help = RNAsnoop_args_info_detailed_help[30] ;
286 args_info->maximal_duplex_box_length_help = RNAsnoop_args_info_detailed_help[31] ;
287 args_info->minimal_snoRNA_stem_loop_length_help = RNAsnoop_args_info_detailed_help[32] ;
288 args_info->maximal_snoRNA_stem_loop_length_help = RNAsnoop_args_info_detailed_help[33] ;
289 args_info->minimal_snoRNA_duplex_length_help = RNAsnoop_args_info_detailed_help[34] ;
290 args_info->maximal_snoRNA_duplex_length_help = RNAsnoop_args_info_detailed_help[35] ;
291 args_info->minimal_duplex_stem_energy_help = RNAsnoop_args_info_detailed_help[36] ;
292 args_info->minimal_total_energy_help = RNAsnoop_args_info_detailed_help[37] ;
293 args_info->maximal_stem_asymmetry_help = RNAsnoop_args_info_detailed_help[38] ;
294 args_info->minimal_lower_stem_energy_help = RNAsnoop_args_info_detailed_help[39] ;
295 args_info->energy_threshold_help = RNAsnoop_args_info_detailed_help[42] ;
296 args_info->produce_ps_help = RNAsnoop_args_info_detailed_help[44] ;
297 args_info->output_directory_help = RNAsnoop_args_info_detailed_help[46] ;
298 args_info->direct_redraw_help = RNAsnoop_args_info_detailed_help[47] ;
299 args_info->from_RNAup_help = RNAsnoop_args_info_detailed_help[48] ;
304 RNAsnoop_cmdline_parser_print_version (void)
307 (strlen(RNASNOOP_CMDLINE_PARSER_PACKAGE_NAME) ? RNASNOOP_CMDLINE_PARSER_PACKAGE_NAME : RNASNOOP_CMDLINE_PARSER_PACKAGE),
308 RNASNOOP_CMDLINE_PARSER_VERSION);
311 static void print_help_common(void) {
312 RNAsnoop_cmdline_parser_print_version ();
314 if (strlen(RNAsnoop_args_info_purpose) > 0)
315 printf("\n%s\n", RNAsnoop_args_info_purpose);
317 if (strlen(RNAsnoop_args_info_usage) > 0)
318 printf("\n%s\n", RNAsnoop_args_info_usage);
322 if (strlen(RNAsnoop_args_info_description) > 0)
323 printf("%s\n\n", RNAsnoop_args_info_description);
327 RNAsnoop_cmdline_parser_print_help (void)
331 while (RNAsnoop_args_info_help[i])
332 printf("%s\n", RNAsnoop_args_info_help[i++]);
336 RNAsnoop_cmdline_parser_print_detailed_help (void)
340 while (RNAsnoop_args_info_detailed_help[i])
341 printf("%s\n", RNAsnoop_args_info_detailed_help[i++]);
345 RNAsnoop_cmdline_parser_init (struct RNAsnoop_args_info *args_info)
347 clear_given (args_info);
348 clear_args (args_info);
349 init_args_info (args_info);
353 RNAsnoop_cmdline_parser_params_init(struct RNAsnoop_cmdline_parser_params *params)
357 params->override = 0;
358 params->initialize = 1;
359 params->check_required = 1;
360 params->check_ambiguity = 0;
361 params->print_errors = 1;
365 struct RNAsnoop_cmdline_parser_params *
366 RNAsnoop_cmdline_parser_params_create(void)
368 struct RNAsnoop_cmdline_parser_params *params =
369 (struct RNAsnoop_cmdline_parser_params *)malloc(sizeof(struct RNAsnoop_cmdline_parser_params));
370 RNAsnoop_cmdline_parser_params_init(params);
375 free_string_field (char **s)
386 RNAsnoop_cmdline_parser_release (struct RNAsnoop_args_info *args_info)
389 free_string_field (&(args_info->alignmentLength_orig));
390 free_string_field (&(args_info->query_arg));
391 free_string_field (&(args_info->query_orig));
392 free_string_field (&(args_info->target_arg));
393 free_string_field (&(args_info->target_orig));
394 free_string_field (&(args_info->suffix_arg));
395 free_string_field (&(args_info->suffix_orig));
396 free_string_field (&(args_info->from_RNAplfold_arg));
397 free_string_field (&(args_info->from_RNAplfold_orig));
398 free_string_field (&(args_info->fast_folding_orig));
399 free_string_field (&(args_info->extension_cost_orig));
400 free_string_field (&(args_info->minimal_right_duplex_orig));
401 free_string_field (&(args_info->minimal_loop_energy_orig));
402 free_string_field (&(args_info->minimal_left_duplex_orig));
403 free_string_field (&(args_info->minimal_duplex_orig));
404 free_string_field (&(args_info->duplex_distance_orig));
405 free_string_field (&(args_info->minimal_stem_length_orig));
406 free_string_field (&(args_info->maximal_stem_length_orig));
407 free_string_field (&(args_info->minimal_duplex_box_length_orig));
408 free_string_field (&(args_info->maximal_duplex_box_length_orig));
409 free_string_field (&(args_info->minimal_snoRNA_stem_loop_length_orig));
410 free_string_field (&(args_info->maximal_snoRNA_stem_loop_length_orig));
411 free_string_field (&(args_info->minimal_snoRNA_duplex_length_orig));
412 free_string_field (&(args_info->maximal_snoRNA_duplex_length_orig));
413 free_string_field (&(args_info->minimal_duplex_stem_energy_orig));
414 free_string_field (&(args_info->minimal_total_energy_orig));
415 free_string_field (&(args_info->maximal_stem_asymmetry_orig));
416 free_string_field (&(args_info->minimal_lower_stem_energy_orig));
417 free_string_field (&(args_info->energy_threshold_orig));
418 free_string_field (&(args_info->output_directory_arg));
419 free_string_field (&(args_info->output_directory_orig));
420 free_string_field (&(args_info->from_RNAup_arg));
421 free_string_field (&(args_info->from_RNAup_orig));
425 clear_given (args_info);
430 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
434 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
436 fprintf(outfile, "%s\n", opt);
442 RNAsnoop_cmdline_parser_dump(FILE *outfile, struct RNAsnoop_args_info *args_info)
448 fprintf (stderr, "%s: cannot dump options to stream\n", RNASNOOP_CMDLINE_PARSER_PACKAGE);
452 if (args_info->help_given)
453 write_into_file(outfile, "help", 0, 0 );
454 if (args_info->detailed_help_given)
455 write_into_file(outfile, "detailed-help", 0, 0 );
456 if (args_info->version_given)
457 write_into_file(outfile, "version", 0, 0 );
458 if (args_info->alignmentLength_given)
459 write_into_file(outfile, "alignmentLength", args_info->alignmentLength_orig, 0);
460 if (args_info->constraint_given)
461 write_into_file(outfile, "constraint", 0, 0 );
462 if (args_info->query_given)
463 write_into_file(outfile, "query", args_info->query_orig, 0);
464 if (args_info->target_given)
465 write_into_file(outfile, "target", args_info->target_orig, 0);
466 if (args_info->suffix_given)
467 write_into_file(outfile, "suffix", args_info->suffix_orig, 0);
468 if (args_info->from_RNAplfold_given)
469 write_into_file(outfile, "from-RNAplfold", args_info->from_RNAplfold_orig, 0);
470 if (args_info->alignment_mode_given)
471 write_into_file(outfile, "alignment-mode", 0, 0 );
472 if (args_info->fast_folding_given)
473 write_into_file(outfile, "fast-folding", args_info->fast_folding_orig, 0);
474 if (args_info->extension_cost_given)
475 write_into_file(outfile, "extension-cost", args_info->extension_cost_orig, 0);
476 if (args_info->minimal_right_duplex_given)
477 write_into_file(outfile, "minimal-right-duplex", args_info->minimal_right_duplex_orig, 0);
478 if (args_info->minimal_loop_energy_given)
479 write_into_file(outfile, "minimal-loop-energy", args_info->minimal_loop_energy_orig, 0);
480 if (args_info->minimal_left_duplex_given)
481 write_into_file(outfile, "minimal-left-duplex", args_info->minimal_left_duplex_orig, 0);
482 if (args_info->minimal_duplex_given)
483 write_into_file(outfile, "minimal-duplex", args_info->minimal_duplex_orig, 0);
484 if (args_info->duplex_distance_given)
485 write_into_file(outfile, "duplex-distance", args_info->duplex_distance_orig, 0);
486 if (args_info->minimal_stem_length_given)
487 write_into_file(outfile, "minimal-stem-length", args_info->minimal_stem_length_orig, 0);
488 if (args_info->maximal_stem_length_given)
489 write_into_file(outfile, "maximal-stem-length", args_info->maximal_stem_length_orig, 0);
490 if (args_info->minimal_duplex_box_length_given)
491 write_into_file(outfile, "minimal-duplex-box-length", args_info->minimal_duplex_box_length_orig, 0);
492 if (args_info->maximal_duplex_box_length_given)
493 write_into_file(outfile, "maximal-duplex-box-length", args_info->maximal_duplex_box_length_orig, 0);
494 if (args_info->minimal_snoRNA_stem_loop_length_given)
495 write_into_file(outfile, "minimal-snoRNA-stem-loop-length", args_info->minimal_snoRNA_stem_loop_length_orig, 0);
496 if (args_info->maximal_snoRNA_stem_loop_length_given)
497 write_into_file(outfile, "maximal-snoRNA-stem-loop-length", args_info->maximal_snoRNA_stem_loop_length_orig, 0);
498 if (args_info->minimal_snoRNA_duplex_length_given)
499 write_into_file(outfile, "minimal-snoRNA-duplex-length", args_info->minimal_snoRNA_duplex_length_orig, 0);
500 if (args_info->maximal_snoRNA_duplex_length_given)
501 write_into_file(outfile, "maximal-snoRNA-duplex-length", args_info->maximal_snoRNA_duplex_length_orig, 0);
502 if (args_info->minimal_duplex_stem_energy_given)
503 write_into_file(outfile, "minimal-duplex-stem-energy", args_info->minimal_duplex_stem_energy_orig, 0);
504 if (args_info->minimal_total_energy_given)
505 write_into_file(outfile, "minimal-total-energy", args_info->minimal_total_energy_orig, 0);
506 if (args_info->maximal_stem_asymmetry_given)
507 write_into_file(outfile, "maximal-stem-asymmetry", args_info->maximal_stem_asymmetry_orig, 0);
508 if (args_info->minimal_lower_stem_energy_given)
509 write_into_file(outfile, "minimal-lower-stem-energy", args_info->minimal_lower_stem_energy_orig, 0);
510 if (args_info->energy_threshold_given)
511 write_into_file(outfile, "energy-threshold", args_info->energy_threshold_orig, 0);
512 if (args_info->produce_ps_given)
513 write_into_file(outfile, "produce-ps", 0, 0 );
514 if (args_info->output_directory_given)
515 write_into_file(outfile, "output_directory", args_info->output_directory_orig, 0);
516 if (args_info->direct_redraw_given)
517 write_into_file(outfile, "direct-redraw", 0, 0 );
518 if (args_info->from_RNAup_given)
519 write_into_file(outfile, "from-RNAup", args_info->from_RNAup_orig, 0);
527 RNAsnoop_cmdline_parser_file_save(const char *filename, struct RNAsnoop_args_info *args_info)
532 outfile = fopen(filename, "w");
536 fprintf (stderr, "%s: cannot open file for writing: %s\n", RNASNOOP_CMDLINE_PARSER_PACKAGE, filename);
540 i = RNAsnoop_cmdline_parser_dump(outfile, args_info);
547 RNAsnoop_cmdline_parser_free (struct RNAsnoop_args_info *args_info)
549 RNAsnoop_cmdline_parser_release (args_info);
552 /** @brief replacement of strdup, which is not standard */
554 gengetopt_strdup (const char *s)
560 result = (char*)malloc(strlen(s) + 1);
561 if (result == (char*)0)
568 RNAsnoop_cmdline_parser (int argc, char **argv, struct RNAsnoop_args_info *args_info)
570 return RNAsnoop_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
574 RNAsnoop_cmdline_parser_ext (int argc, char **argv, struct RNAsnoop_args_info *args_info,
575 struct RNAsnoop_cmdline_parser_params *params)
578 result = RNAsnoop_cmdline_parser_internal (argc, argv, args_info, params, 0);
580 if (result == EXIT_FAILURE)
582 RNAsnoop_cmdline_parser_free (args_info);
590 RNAsnoop_cmdline_parser2 (int argc, char **argv, struct RNAsnoop_args_info *args_info, int override, int initialize, int check_required)
593 struct RNAsnoop_cmdline_parser_params params;
595 params.override = override;
596 params.initialize = initialize;
597 params.check_required = check_required;
598 params.check_ambiguity = 0;
599 params.print_errors = 1;
601 result = RNAsnoop_cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
603 if (result == EXIT_FAILURE)
605 RNAsnoop_cmdline_parser_free (args_info);
613 RNAsnoop_cmdline_parser_required (struct RNAsnoop_args_info *args_info, const char *prog_name)
615 FIX_UNUSED (args_info);
616 FIX_UNUSED (prog_name);
621 * Extracted from the glibc source tree, version 2.3.6
623 * Licensed under the GPL as per the whole glibc source tree.
625 * This file was modified so that getopt_long can be called
626 * many times without risking previous memory to be spoiled.
628 * Modified by Andre Noll and Lorenzo Bettini for use in
629 * GNU gengetopt generated files.
634 * we must include anything we need since this file is not thought to be
635 * inserted in a file already using getopt.h
643 /* has_arg can't be an enum because some compilers complain about
644 type mismatches in all the code that assumes it is an int. */
650 /* This version of `getopt' appears to the caller like standard Unix `getopt'
651 but it behaves differently for the user, since it allows the user
652 to intersperse the options with the other arguments.
654 As `getopt' works, it permutes the elements of ARGV so that,
655 when it is done, all the options precede everything else. Thus
656 all application programs are extended to handle flexible argument order.
659 If the field `flag' is not NULL, it points to a variable that is set
660 to the value given in the field `val' when the option is found, but
661 left unchanged if the option is not found.
663 To have a long-named option do something other than set an `int' to
664 a compiled-in constant, such as set a value from `custom_optarg', set the
665 option's `flag' field to zero and its `val' field to a nonzero
666 value (the equivalent single-letter option character, if there is
667 one). For long options that have a zero `flag' field, `getopt'
668 returns the contents of the `val' field. */
670 /* Names for the values of the `has_arg' field of `struct option'. */
672 #define no_argument 0
675 #ifndef required_argument
676 #define required_argument 1
679 #ifndef optional_argument
680 #define optional_argument 2
683 struct custom_getopt_data {
685 * These have exactly the same meaning as the corresponding global variables,
686 * except that they are used for the reentrant versions of getopt.
693 /* True if the internal members have been initialized. */
697 * The next char to be scanned in the option-element in which the last option
698 * character we returned was found. This allows us to pick up the scan where
699 * we left off. If this is zero, or a null string, it means resume the scan by
700 * advancing to the next ARGV-element.
705 * Describe the part of ARGV that contains non-options that have been skipped.
706 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
707 * the index after the last of them.
714 * the variables optarg, optind, opterr and optopt are renamed with
715 * the custom_ prefix so that they don't interfere with getopt ones.
717 * Moreover they're static so they are visible only from within the
718 * file where this very file will be included.
722 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
723 * option that takes an argument, the argument value is returned here.
725 static char *custom_optarg;
728 * Index in ARGV of the next element to be scanned. This is used for
729 * communication to and from the caller and for communication between
730 * successive calls to `custom_getopt'.
732 * On entry to `custom_getopt', 1 means this is the first call; initialize.
734 * When `custom_getopt' returns -1, this is the index of the first of the non-option
735 * elements that the caller should itself scan.
737 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
738 * has been scanned so far.
740 * 1003.2 says this must be 1 before any call.
742 static int custom_optind = 1;
745 * Callers store zero here to inhibit the error message for unrecognized
748 static int custom_opterr = 1;
751 * Set to an option character which was unrecognized. This must be initialized
752 * on some systems to avoid linking in the system's own getopt implementation.
754 static int custom_optopt = '?';
757 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
758 * [first_nonopt,last_nonopt) which contains all the non-options that have been
759 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
760 * all the options processed since those non-options were skipped.
761 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
762 * indices of the non-options in ARGV after they are moved.
764 static void exchange(char **argv, struct custom_getopt_data *d)
766 int bottom = d->first_nonopt;
767 int middle = d->last_nonopt;
768 int top = d->custom_optind;
772 * Exchange the shorter segment with the far end of the longer segment.
773 * That puts the shorter segment into the right place. It leaves the
774 * longer segment in the right place overall, but it consists of two
775 * parts that need to be swapped next.
777 while (top > middle && middle > bottom) {
778 if (top - middle > middle - bottom) {
779 /* Bottom segment is the short one. */
780 int len = middle - bottom;
783 /* Swap it with the top part of the top segment. */
784 for (i = 0; i < len; i++) {
785 tem = argv[bottom + i];
787 argv[top - (middle - bottom) + i];
788 argv[top - (middle - bottom) + i] = tem;
790 /* Exclude the moved bottom segment from further swapping. */
793 /* Top segment is the short one. */
794 int len = top - middle;
797 /* Swap it with the bottom part of the bottom segment. */
798 for (i = 0; i < len; i++) {
799 tem = argv[bottom + i];
800 argv[bottom + i] = argv[middle + i];
801 argv[middle + i] = tem;
803 /* Exclude the moved top segment from further swapping. */
807 /* Update records for the slots the non-options now occupy. */
808 d->first_nonopt += (d->custom_optind - d->last_nonopt);
809 d->last_nonopt = d->custom_optind;
812 /* Initialize the internal data when the first call is made. */
813 static void custom_getopt_initialize(struct custom_getopt_data *d)
816 * Start processing options with ARGV-element 1 (since ARGV-element 0
817 * is the program name); the sequence of previously skipped non-option
818 * ARGV-elements is empty.
820 d->first_nonopt = d->last_nonopt = d->custom_optind;
825 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
827 /* return: zero: continue, nonzero: return given value to user */
828 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
829 struct custom_getopt_data *d)
832 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
833 * moved back by the user (who may also have changed the arguments).
835 if (d->last_nonopt > d->custom_optind)
836 d->last_nonopt = d->custom_optind;
837 if (d->first_nonopt > d->custom_optind)
838 d->first_nonopt = d->custom_optind;
840 * If we have just processed some options following some
841 * non-options, exchange them so that the options come first.
843 if (d->first_nonopt != d->last_nonopt &&
844 d->last_nonopt != d->custom_optind)
845 exchange((char **) argv, d);
846 else if (d->last_nonopt != d->custom_optind)
847 d->first_nonopt = d->custom_optind;
849 * Skip any additional non-options and extend the range of
850 * non-options previously skipped.
852 while (d->custom_optind < argc && NONOPTION_P)
854 d->last_nonopt = d->custom_optind;
856 * The special ARGV-element `--' means premature end of options. Skip
857 * it like a null option, then exchange with previous non-options as if
858 * it were an option, then skip everything else like a non-option.
860 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
862 if (d->first_nonopt != d->last_nonopt
863 && d->last_nonopt != d->custom_optind)
864 exchange((char **) argv, d);
865 else if (d->first_nonopt == d->last_nonopt)
866 d->first_nonopt = d->custom_optind;
867 d->last_nonopt = argc;
868 d->custom_optind = argc;
871 * If we have done all the ARGV-elements, stop the scan and back over
872 * any non-options that we skipped and permuted.
874 if (d->custom_optind == argc) {
876 * Set the next-arg-index to point at the non-options that we
877 * previously skipped, so the caller will digest them.
879 if (d->first_nonopt != d->last_nonopt)
880 d->custom_optind = d->first_nonopt;
884 * If we have come to a non-option and did not permute it, either stop
885 * the scan or describe it to the caller and pass it by.
888 d->custom_optarg = argv[d->custom_optind++];
892 * We have found another option-ARGV-element. Skip the initial
895 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
900 * Check whether the ARGV-element is a long option.
902 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
903 * that an abbreviation of the long option, just like "--fu", and not "-f" with
906 * This distinction seems to be the most useful approach.
909 static int check_long_opt(int argc, char *const *argv, const char *optstring,
910 const struct option *longopts, int *longind,
911 int print_errors, struct custom_getopt_data *d)
914 const struct option *p;
915 const struct option *pfound = NULL;
921 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
924 /* Test all long options for either exact match or abbreviated matches */
925 for (p = longopts, option_index = 0; p->name; p++, option_index++)
926 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
927 if ((unsigned int) (nameend - d->nextchar)
928 == (unsigned int) strlen(p->name)) {
929 /* Exact match found. */
931 indfound = option_index;
934 } else if (pfound == NULL) {
935 /* First nonexact match found. */
937 indfound = option_index;
938 } else if (pfound->has_arg != p->has_arg
939 || pfound->flag != p->flag
940 || pfound->val != p->val)
941 /* Second or later nonexact match found. */
944 if (ambig && !exact) {
947 "%s: option `%s' is ambiguous\n",
948 argv[0], argv[d->custom_optind]);
950 d->nextchar += strlen(d->nextchar);
952 d->custom_optopt = 0;
956 option_index = indfound;
959 if (pfound->has_arg != no_argument)
960 d->custom_optarg = nameend + 1;
963 if (argv[d->custom_optind - 1][1] == '-') {
965 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
966 argv[0], pfound->name);
968 /* +option or -option */
969 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
970 argv[0], argv[d->custom_optind - 1][0], pfound->name);
974 d->nextchar += strlen(d->nextchar);
975 d->custom_optopt = pfound->val;
978 } else if (pfound->has_arg == required_argument) {
979 if (d->custom_optind < argc)
980 d->custom_optarg = argv[d->custom_optind++];
984 "%s: option `%s' requires an argument\n",
986 argv[d->custom_optind - 1]);
988 d->nextchar += strlen(d->nextchar);
989 d->custom_optopt = pfound->val;
990 return optstring[0] == ':' ? ':' : '?';
993 d->nextchar += strlen(d->nextchar);
995 *longind = option_index;
997 *(pfound->flag) = pfound->val;
1003 * Can't find it as a long option. If this is not getopt_long_only, or
1004 * the option starts with '--' or is not a valid short option, then
1005 * it's an error. Otherwise interpret it as a short option.
1008 if (argv[d->custom_optind][1] == '-') {
1011 "%s: unrecognized option `--%s'\n",
1012 argv[0], d->nextchar);
1014 /* +option or -option */
1016 "%s: unrecognized option `%c%s'\n",
1017 argv[0], argv[d->custom_optind][0],
1021 d->nextchar = (char *) "";
1023 d->custom_optopt = 0;
1027 static int check_short_opt(int argc, char *const *argv, const char *optstring,
1028 int print_errors, struct custom_getopt_data *d)
1030 char c = *d->nextchar++;
1031 const char *temp = strchr(optstring, c);
1033 /* Increment `custom_optind' when we start to process its last character. */
1034 if (*d->nextchar == '\0')
1036 if (!temp || c == ':') {
1038 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
1040 d->custom_optopt = c;
1043 if (temp[1] == ':') {
1044 if (temp[2] == ':') {
1045 /* This is an option that accepts an argument optionally. */
1046 if (*d->nextchar != '\0') {
1047 d->custom_optarg = d->nextchar;
1050 d->custom_optarg = NULL;
1053 /* This is an option that requires an argument. */
1054 if (*d->nextchar != '\0') {
1055 d->custom_optarg = d->nextchar;
1057 * If we end this ARGV-element by taking the
1058 * rest as an arg, we must advance to the next
1062 } else if (d->custom_optind == argc) {
1065 "%s: option requires an argument -- %c\n",
1068 d->custom_optopt = c;
1069 if (optstring[0] == ':')
1075 * We already incremented `custom_optind' once;
1076 * increment it again when taking next ARGV-elt
1079 d->custom_optarg = argv[d->custom_optind++];
1087 * Scan elements of ARGV for option characters given in OPTSTRING.
1089 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
1090 * then it is an option element. The characters of this element
1091 * (aside from the initial '-') are option characters. If `getopt'
1092 * is called repeatedly, it returns successively each of the option characters
1093 * from each of the option elements.
1095 * If `getopt' finds another option character, it returns that character,
1096 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
1097 * resume the scan with the following option character or ARGV-element.
1099 * If there are no more option characters, `getopt' returns -1.
1100 * Then `custom_optind' is the index in ARGV of the first ARGV-element
1101 * that is not an option. (The ARGV-elements have been permuted
1102 * so that those that are not options now come last.)
1104 * OPTSTRING is a string containing the legitimate option characters.
1105 * If an option character is seen that is not listed in OPTSTRING,
1106 * return '?' after printing an error message. If you set `custom_opterr' to
1107 * zero, the error message is suppressed but we still return '?'.
1109 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
1110 * so the following text in the same ARGV-element, or the text of the following
1111 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
1112 * wants an optional arg; if there is text in the current ARGV-element,
1113 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
1115 * If OPTSTRING starts with `-' or `+', it requests different methods of
1116 * handling the non-option ARGV-elements.
1117 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
1119 * Long-named options begin with `--' instead of `-'.
1120 * Their names may be abbreviated as long as the abbreviation is unique
1121 * or is an exact match for some defined option. If they have an
1122 * argument, it follows the option name in the same ARGV-element, separated
1123 * from the option name by a `=', or else the in next ARGV-element.
1124 * When `getopt' finds a long-named option, it returns 0 if that option's
1125 * `flag' field is nonzero, the value of the option's `val' field
1126 * if the `flag' field is zero.
1128 * The elements of ARGV aren't really const, because we permute them.
1129 * But we pretend they're const in the prototype to be compatible
1130 * with other systems.
1132 * LONGOPTS is a vector of `struct option' terminated by an
1133 * element containing a name which is zero.
1135 * LONGIND returns the index in LONGOPT of the long-named option found.
1136 * It is only valid when a long-named option has been found by the most
1139 * Return the option character from OPTS just read. Return -1 when there are
1140 * no more options. For unrecognized options, or options missing arguments,
1141 * `custom_optopt' is set to the option letter, and '?' is returned.
1143 * The OPTS string is a list of characters which are recognized option letters,
1144 * optionally followed by colons, specifying that that letter takes an
1145 * argument, to be placed in `custom_optarg'.
1147 * If a letter in OPTS is followed by two colons, its argument is optional.
1148 * This behavior is specific to the GNU `getopt'.
1150 * The argument `--' causes premature termination of argument scanning,
1151 * explicitly telling `getopt' that there are no more options. If OPTS begins
1152 * with `--', then non-option arguments are treated as arguments to the option
1153 * '\0'. This behavior is specific to the GNU `getopt'.
1156 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
1157 const struct option *longopts, int *longind,
1158 struct custom_getopt_data *d)
1160 int ret, print_errors = d->custom_opterr;
1162 if (optstring[0] == ':')
1166 d->custom_optarg = NULL;
1169 * This is a big difference with GNU getopt, since optind == 0
1170 * means initialization while here 1 means first call.
1172 if (d->custom_optind == 0 || !d->initialized) {
1173 if (d->custom_optind == 0)
1174 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
1175 custom_getopt_initialize(d);
1177 if (d->nextchar == NULL || *d->nextchar == '\0') {
1178 ret = shuffle_argv(argc, argv, longopts, d);
1182 if (longopts && (argv[d->custom_optind][1] == '-' ))
1183 return check_long_opt(argc, argv, optstring, longopts,
1184 longind, print_errors, d);
1185 return check_short_opt(argc, argv, optstring, print_errors, d);
1188 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1189 const struct option *longopts, int *longind)
1192 /* Keep a global copy of all internal members of d */
1193 static struct custom_getopt_data d;
1195 d.custom_optind = custom_optind;
1196 d.custom_opterr = custom_opterr;
1197 result = getopt_internal_r(argc, argv, optstring, longopts,
1199 custom_optind = d.custom_optind;
1200 custom_optarg = d.custom_optarg;
1201 custom_optopt = d.custom_optopt;
1205 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1206 const struct option *long_options, int *opt_index)
1208 return custom_getopt_internal(argc, argv, options, long_options,
1213 static char *package_name = 0;
1216 * @brief updates an option
1217 * @param field the generic pointer to the field to update
1218 * @param orig_field the pointer to the orig field
1219 * @param field_given the pointer to the number of occurrence of this option
1220 * @param prev_given the pointer to the number of occurrence already seen
1221 * @param value the argument for this option (if null no arg was specified)
1222 * @param possible_values the possible values for this option (if specified)
1223 * @param default_value the default value (in case the option only accepts fixed values)
1224 * @param arg_type the type of this option
1225 * @param check_ambiguity @see RNAsnoop_cmdline_parser_params.check_ambiguity
1226 * @param override @see RNAsnoop_cmdline_parser_params.override
1227 * @param no_free whether to free a possible previous value
1228 * @param multiple_option whether this is a multiple option
1229 * @param long_opt the corresponding long option
1230 * @param short_opt the corresponding short option (or '-' if none)
1231 * @param additional_error possible further error specification
1234 int update_arg(void *field, char **orig_field,
1235 unsigned int *field_given, unsigned int *prev_given,
1236 char *value, const char *possible_values[],
1237 const char *default_value,
1238 RNAsnoop_cmdline_parser_arg_type arg_type,
1239 int check_ambiguity, int override,
1240 int no_free, int multiple_option,
1241 const char *long_opt, char short_opt,
1242 const char *additional_error)
1244 char *stop_char = 0;
1245 const char *val = value;
1247 char **string_field;
1253 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1255 if (short_opt != '-')
1256 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1257 package_name, long_opt, short_opt,
1258 (additional_error ? additional_error : ""));
1260 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1261 package_name, long_opt,
1262 (additional_error ? additional_error : ""));
1263 return 1; /* failure */
1266 FIX_UNUSED (default_value);
1268 if (field_given && *field_given && ! override)
1274 if (possible_values)
1275 val = possible_values[found];
1279 *((int *)field) = !*((int *)field);
1282 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1285 if (val) *((double *)field) = strtod (val, &stop_char);
1289 string_field = (char **)field;
1290 if (!no_free && *string_field)
1291 free (*string_field); /* free previous string */
1292 *string_field = gengetopt_strdup (val);
1299 /* check numeric conversion */
1303 if (val && !(stop_char && *stop_char == '\0')) {
1304 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1305 return 1; /* failure */
1312 /* store the original value */
1318 if (value && orig_field) {
1320 *orig_field = value;
1323 free (*orig_field); /* free previous string */
1324 *orig_field = gengetopt_strdup (value);
1334 RNAsnoop_cmdline_parser_internal (
1335 int argc, char **argv, struct RNAsnoop_args_info *args_info,
1336 struct RNAsnoop_cmdline_parser_params *params, const char *additional_error)
1338 int c; /* Character of the parsed option. */
1341 struct RNAsnoop_args_info local_args_info;
1346 int check_ambiguity;
1353 package_name = argv[0];
1355 override = params->override;
1356 initialize = params->initialize;
1357 check_required = params->check_required;
1358 check_ambiguity = params->check_ambiguity;
1361 RNAsnoop_cmdline_parser_init (args_info);
1363 RNAsnoop_cmdline_parser_init (&local_args_info);
1367 opterr = params->print_errors;
1372 int option_index = 0;
1374 static struct option long_options[] = {
1375 { "help", 0, NULL, 0 },
1376 { "detailed-help", 0, NULL, 0 },
1377 { "version", 0, NULL, 'V' },
1378 { "alignmentLength", 1, NULL, 'L' },
1379 { "constraint", 0, NULL, 'C' },
1380 { "query", 1, NULL, 's' },
1381 { "target", 1, NULL, 't' },
1382 { "suffix", 1, NULL, 'S' },
1383 { "from-RNAplfold", 1, NULL, 'P' },
1384 { "alignment-mode", 0, NULL, 'A' },
1385 { "fast-folding", 1, NULL, 'f' },
1386 { "extension-cost", 1, NULL, 'c' },
1387 { "minimal-right-duplex", 1, NULL, 'o' },
1388 { "minimal-loop-energy", 1, NULL, 'l' },
1389 { "minimal-left-duplex", 1, NULL, 'p' },
1390 { "minimal-duplex", 1, NULL, 'q' },
1391 { "duplex-distance", 1, NULL, 'd' },
1392 { "minimal-stem-length", 1, NULL, 'h' },
1393 { "maximal-stem-length", 1, NULL, 'i' },
1394 { "minimal-duplex-box-length", 1, NULL, 'j' },
1395 { "maximal-duplex-box-length", 1, NULL, 'k' },
1396 { "minimal-snoRNA-stem-loop-length", 1, NULL, 'm' },
1397 { "maximal-snoRNA-stem-loop-length", 1, NULL, 'n' },
1398 { "minimal-snoRNA-duplex-length", 1, NULL, 'v' },
1399 { "maximal-snoRNA-duplex-length", 1, NULL, 'w' },
1400 { "minimal-duplex-stem-energy", 1, NULL, 'x' },
1401 { "minimal-total-energy", 1, NULL, 'y' },
1402 { "maximal-stem-asymmetry", 1, NULL, 'a' },
1403 { "minimal-lower-stem-energy", 1, NULL, 'b' },
1404 { "energy-threshold", 1, NULL, 'e' },
1405 { "produce-ps", 0, NULL, 'I' },
1406 { "output_directory", 1, NULL, 'O' },
1407 { "direct-redraw", 0, NULL, 'N' },
1408 { "from-RNAup", 1, NULL, 'U' },
1412 custom_optarg = optarg;
1413 custom_optind = optind;
1414 custom_opterr = opterr;
1415 custom_optopt = optopt;
1417 c = custom_getopt_long (argc, argv, "VL:Cs:t:S:P:Af:c:o:l:p:q:d:h:i:j:k:m:n:v:w:x:y:a:b:e:IO:NU:", long_options, &option_index);
1419 optarg = custom_optarg;
1420 optind = custom_optind;
1421 opterr = custom_opterr;
1422 optopt = custom_optopt;
1424 if (c == -1) break; /* Exit from `while (1)' loop. */
1428 case 'V': /* Print version and exit. */
1429 RNAsnoop_cmdline_parser_print_version ();
1430 RNAsnoop_cmdline_parser_free (&local_args_info);
1431 exit (EXIT_SUCCESS);
1433 case 'L': /* Limit the extent of the interactions to L nucleotides. */
1436 if (update_arg( (void *)&(args_info->alignmentLength_arg),
1437 &(args_info->alignmentLength_orig), &(args_info->alignmentLength_given),
1438 &(local_args_info.alignmentLength_given), optarg, 0, "25", ARG_INT,
1439 check_ambiguity, override, 0, 0,
1440 "alignmentLength", 'L',
1445 case 'C': /* Calculate the stem structure subject to constraints.
1449 if (update_arg((void *)&(args_info->constraint_flag), 0, &(args_info->constraint_given),
1450 &(local_args_info.constraint_given), optarg, 0, 0, ARG_FLAG,
1451 check_ambiguity, override, 1, 0, "constraint", 'C',
1456 case 's': /* File containing the query sequence.
1460 if (update_arg( (void *)&(args_info->query_arg),
1461 &(args_info->query_orig), &(args_info->query_given),
1462 &(local_args_info.query_given), optarg, 0, 0, ARG_STRING,
1463 check_ambiguity, override, 0, 0,
1469 case 't': /* File containing the target sequence.
1473 if (update_arg( (void *)&(args_info->target_arg),
1474 &(args_info->target_orig), &(args_info->target_given),
1475 &(local_args_info.target_given), optarg, 0, 0, ARG_STRING,
1476 check_ambiguity, override, 0, 0,
1482 case 'S': /* Specificy the suffix that was added by RNAup to the accessibility files
1487 if (update_arg( (void *)&(args_info->suffix_arg),
1488 &(args_info->suffix_orig), &(args_info->suffix_given),
1489 &(local_args_info.suffix_given), optarg, 0, "_u1_to_30.out", ARG_STRING,
1490 check_ambiguity, override, 0, 0,
1496 case 'P': /* Specify the directory where accessibility profile generated by RNAplfold are found
1501 if (update_arg( (void *)&(args_info->from_RNAplfold_arg),
1502 &(args_info->from_RNAplfold_orig), &(args_info->from_RNAplfold_given),
1503 &(local_args_info.from_RNAplfold_given), optarg, 0, 0, ARG_STRING,
1504 check_ambiguity, override, 0, 0,
1505 "from-RNAplfold", 'P',
1510 case 'A': /* Specify if RNAsnoop gets alignments or single sequences as input
1515 if (update_arg((void *)&(args_info->alignment_mode_flag), 0, &(args_info->alignment_mode_given),
1516 &(local_args_info.alignment_mode_given), optarg, 0, 0, ARG_FLAG,
1517 check_ambiguity, override, 1, 0, "alignment-mode", 'A',
1522 case 'f': /* Speedup of the target search. */
1525 if (update_arg( (void *)&(args_info->fast_folding_arg),
1526 &(args_info->fast_folding_orig), &(args_info->fast_folding_given),
1527 &(local_args_info.fast_folding_given), optarg, 0, "1", ARG_INT,
1528 check_ambiguity, override, 0, 0,
1529 "fast-folding", 'f',
1534 case 'c': /* Cost to add to each nucleotide in a duplex. */
1537 if (update_arg( (void *)&(args_info->extension_cost_arg),
1538 &(args_info->extension_cost_orig), &(args_info->extension_cost_given),
1539 &(local_args_info.extension_cost_given), optarg, 0, "0", ARG_INT,
1540 check_ambiguity, override, 0, 0,
1541 "extension-cost", 'c',
1546 case 'o': /* Minimal Right Duplex Energy
1551 if (update_arg( (void *)&(args_info->minimal_right_duplex_arg),
1552 &(args_info->minimal_right_duplex_orig), &(args_info->minimal_right_duplex_given),
1553 &(local_args_info.minimal_right_duplex_given), optarg, 0, "-270", ARG_INT,
1554 check_ambiguity, override, 0, 0,
1555 "minimal-right-duplex", 'o',
1560 case 'l': /* Minimal Right Duplex Energy
1564 if (update_arg( (void *)&(args_info->minimal_loop_energy_arg),
1565 &(args_info->minimal_loop_energy_orig), &(args_info->minimal_loop_energy_given),
1566 &(local_args_info.minimal_loop_energy_given), optarg, 0, "-280", ARG_INT,
1567 check_ambiguity, override, 0, 0,
1568 "minimal-loop-energy", 'l',
1573 case 'p': /* Minimal Left Duplex Energy
1578 if (update_arg( (void *)&(args_info->minimal_left_duplex_arg),
1579 &(args_info->minimal_left_duplex_orig), &(args_info->minimal_left_duplex_given),
1580 &(local_args_info.minimal_left_duplex_given), optarg, 0, "-170", ARG_INT,
1581 check_ambiguity, override, 0, 0,
1582 "minimal-left-duplex", 'p',
1587 case 'q': /* Minimal Duplex Energy
1592 if (update_arg( (void *)&(args_info->minimal_duplex_arg),
1593 &(args_info->minimal_duplex_orig), &(args_info->minimal_duplex_given),
1594 &(local_args_info.minimal_duplex_given), optarg, 0, "-1090", ARG_INT,
1595 check_ambiguity, override, 0, 0,
1596 "minimal-duplex", 'q',
1601 case 'd': /* Distance between target 3' ends of two consecutive duplexes
1605 if (update_arg( (void *)&(args_info->duplex_distance_arg),
1606 &(args_info->duplex_distance_orig), &(args_info->duplex_distance_given),
1607 &(local_args_info.duplex_distance_given), optarg, 0, "2", ARG_INT,
1608 check_ambiguity, override, 0, 0,
1609 "duplex-distance", 'd',
1614 case 'h': /* Minimal snoRNA stem length
1619 if (update_arg( (void *)&(args_info->minimal_stem_length_arg),
1620 &(args_info->minimal_stem_length_orig), &(args_info->minimal_stem_length_given),
1621 &(local_args_info.minimal_stem_length_given), optarg, 0, "5", ARG_INT,
1622 check_ambiguity, override, 0, 0,
1623 "minimal-stem-length", 'h',
1628 case 'i': /* Maximal snoRNA stem length
1633 if (update_arg( (void *)&(args_info->maximal_stem_length_arg),
1634 &(args_info->maximal_stem_length_orig), &(args_info->maximal_stem_length_given),
1635 &(local_args_info.maximal_stem_length_given), optarg, 0, "120", ARG_INT,
1636 check_ambiguity, override, 0, 0,
1637 "maximal-stem-length", 'i',
1642 case 'j': /* Minimal distance between the duplex end and the H/ACA box
1647 if (update_arg( (void *)&(args_info->minimal_duplex_box_length_arg),
1648 &(args_info->minimal_duplex_box_length_orig), &(args_info->minimal_duplex_box_length_given),
1649 &(local_args_info.minimal_duplex_box_length_given), optarg, 0, "11", ARG_INT,
1650 check_ambiguity, override, 0, 0,
1651 "minimal-duplex-box-length", 'j',
1656 case 'k': /* Maximal distance between the duplex end and the H/ACA box
1661 if (update_arg( (void *)&(args_info->maximal_duplex_box_length_arg),
1662 &(args_info->maximal_duplex_box_length_orig), &(args_info->maximal_duplex_box_length_given),
1663 &(local_args_info.maximal_duplex_box_length_given), optarg, 0, "16", ARG_INT,
1664 check_ambiguity, override, 0, 0,
1665 "maximal-duplex-box-length", 'k',
1670 case 'm': /* Minimal number of nucleotides between the beginning of stem loop and
1671 beginning of the snoRNA sequence
1676 if (update_arg( (void *)&(args_info->minimal_snoRNA_stem_loop_length_arg),
1677 &(args_info->minimal_snoRNA_stem_loop_length_orig), &(args_info->minimal_snoRNA_stem_loop_length_given),
1678 &(local_args_info.minimal_snoRNA_stem_loop_length_given), optarg, 0, "1", ARG_INT,
1679 check_ambiguity, override, 0, 0,
1680 "minimal-snoRNA-stem-loop-length", 'm',
1685 case 'n': /* Maximal number of nucleotides between the beginning of stem loop and
1686 beginning of the snoRNA sequence
1691 if (update_arg( (void *)&(args_info->maximal_snoRNA_stem_loop_length_arg),
1692 &(args_info->maximal_snoRNA_stem_loop_length_orig), &(args_info->maximal_snoRNA_stem_loop_length_given),
1693 &(local_args_info.maximal_snoRNA_stem_loop_length_given), optarg, 0, "100000", ARG_INT,
1694 check_ambiguity, override, 0, 0,
1695 "maximal-snoRNA-stem-loop-length", 'n',
1700 case 'v': /* Minimal distance between duplex start and snoRNA
1705 if (update_arg( (void *)&(args_info->minimal_snoRNA_duplex_length_arg),
1706 &(args_info->minimal_snoRNA_duplex_length_orig), &(args_info->minimal_snoRNA_duplex_length_given),
1707 &(local_args_info.minimal_snoRNA_duplex_length_given), optarg, 0, "0", ARG_INT,
1708 check_ambiguity, override, 0, 0,
1709 "minimal-snoRNA-duplex-length", 'v',
1714 case 'w': /* Maximal distance between duplex start and snoRNA
1719 if (update_arg( (void *)&(args_info->maximal_snoRNA_duplex_length_arg),
1720 &(args_info->maximal_snoRNA_duplex_length_orig), &(args_info->maximal_snoRNA_duplex_length_given),
1721 &(local_args_info.maximal_snoRNA_duplex_length_given), optarg, 0, "0", ARG_INT,
1722 check_ambiguity, override, 0, 0,
1723 "maximal-snoRNA-duplex-length", 'w',
1728 case 'x': /* Minimal duplex stem energy
1733 if (update_arg( (void *)&(args_info->minimal_duplex_stem_energy_arg),
1734 &(args_info->minimal_duplex_stem_energy_orig), &(args_info->minimal_duplex_stem_energy_given),
1735 &(local_args_info.minimal_duplex_stem_energy_given), optarg, 0, "-1370", ARG_INT,
1736 check_ambiguity, override, 0, 0,
1737 "minimal-duplex-stem-energy", 'x',
1742 case 'y': /* Minimal total energy
1747 if (update_arg( (void *)&(args_info->minimal_total_energy_arg),
1748 &(args_info->minimal_total_energy_orig), &(args_info->minimal_total_energy_given),
1749 &(local_args_info.minimal_total_energy_given), optarg, 0, "100000", ARG_INT,
1750 check_ambiguity, override, 0, 0,
1751 "minimal-total-energy", 'y',
1756 case 'a': /* Maximal snoRNA stem asymmetry
1761 if (update_arg( (void *)&(args_info->maximal_stem_asymmetry_arg),
1762 &(args_info->maximal_stem_asymmetry_orig), &(args_info->maximal_stem_asymmetry_given),
1763 &(local_args_info.maximal_stem_asymmetry_given), optarg, 0, "30", ARG_INT,
1764 check_ambiguity, override, 0, 0,
1765 "maximal-stem-asymmetry", 'a',
1770 case 'b': /* Minimal lower stem energy
1775 if (update_arg( (void *)&(args_info->minimal_lower_stem_energy_arg),
1776 &(args_info->minimal_lower_stem_energy_orig), &(args_info->minimal_lower_stem_energy_given),
1777 &(local_args_info.minimal_lower_stem_energy_given), optarg, 0, "100000", ARG_INT,
1778 check_ambiguity, override, 0, 0,
1779 "minimal-lower-stem-energy", 'b',
1784 case 'e': /* Maximal energy difference between the mfe and the desired suboptimal
1788 if (update_arg( (void *)&(args_info->energy_threshold_arg),
1789 &(args_info->energy_threshold_orig), &(args_info->energy_threshold_given),
1790 &(local_args_info.energy_threshold_given), optarg, 0, "-1", ARG_DOUBLE,
1791 check_ambiguity, override, 0, 0,
1792 "energy-threshold", 'e',
1797 case 'I': /* Draw annotated 2D structures for a list of dot-bracket structures
1801 if (update_arg((void *)&(args_info->produce_ps_flag), 0, &(args_info->produce_ps_given),
1802 &(local_args_info.produce_ps_given), optarg, 0, 0, ARG_FLAG,
1803 check_ambiguity, override, 1, 0, "produce-ps", 'I',
1808 case 'O': /* Set where the generated figures should be stored
1813 if (update_arg( (void *)&(args_info->output_directory_arg),
1814 &(args_info->output_directory_orig), &(args_info->output_directory_given),
1815 &(local_args_info.output_directory_given), optarg, 0, "./", ARG_STRING,
1816 check_ambiguity, override, 0, 0,
1817 "output_directory", 'O',
1822 case 'N': /* Outputs 2D interactions concurrently with the interaction calculation for each suboptimal interaction. The -I option should be preferred.
1827 if (update_arg((void *)&(args_info->direct_redraw_flag), 0, &(args_info->direct_redraw_given),
1828 &(local_args_info.direct_redraw_given), optarg, 0, 0, ARG_FLAG,
1829 check_ambiguity, override, 1, 0, "direct-redraw", 'N',
1834 case 'U': /* Specify the directory where accessibility profiles generated by RNAup are found
1839 if (update_arg( (void *)&(args_info->from_RNAup_arg),
1840 &(args_info->from_RNAup_orig), &(args_info->from_RNAup_given),
1841 &(local_args_info.from_RNAup_given), optarg, 0, 0, ARG_STRING,
1842 check_ambiguity, override, 0, 0,
1849 case 0: /* Long option with no short option */
1850 if (strcmp (long_options[option_index].name, "help") == 0) {
1851 RNAsnoop_cmdline_parser_print_help ();
1852 RNAsnoop_cmdline_parser_free (&local_args_info);
1853 exit (EXIT_SUCCESS);
1856 if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1857 RNAsnoop_cmdline_parser_print_detailed_help ();
1858 RNAsnoop_cmdline_parser_free (&local_args_info);
1859 exit (EXIT_SUCCESS);
1862 case '?': /* Invalid option. */
1863 /* `getopt_long' already printed an error message. */
1866 default: /* bug: option not considered. */
1867 fprintf (stderr, "%s: option unknown: %c%s\n", RNASNOOP_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1875 RNAsnoop_cmdline_parser_release (&local_args_info);
1878 return (EXIT_FAILURE);
1884 RNAsnoop_cmdline_parser_release (&local_args_info);
1885 return (EXIT_FAILURE);