RNAlib-2.1.9
utils.h
Go to the documentation of this file.
1 #ifndef __VIENNA_RNA_PACKAGE_UTILS_H__
2 #define __VIENNA_RNA_PACKAGE_UTILS_H__
3 
12 #define VRNA_INPUT_ERROR 1U
13 
16 #define VRNA_INPUT_QUIT 2U
17 
20 #define VRNA_INPUT_MISC 4U
21 
28 #define VRNA_INPUT_FASTA_HEADER 8U
29 
34 #define VRNA_INPUT_SEQUENCE 16U
35 
40 #define VRNA_INPUT_CONSTRAINT 32U
41 
46 #define VRNA_INPUT_NO_TRUNCATION 256U
47 
51 #define VRNA_INPUT_NO_REST 512U
52 
56 #define VRNA_INPUT_NO_SPAN 1024U
57 
61 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
62 
66 #define VRNA_INPUT_BLANK_LINE 4096U
67 
71 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
72 
76 #define VRNA_INPUT_COMMENT 8192U
77 
78 
79 
80 
84 #define VRNA_CONSTRAINT_PIPE 1U
85 
88 #define VRNA_CONSTRAINT_DOT 2U
89 
92 #define VRNA_CONSTRAINT_X 4U
93 
96 #define VRNA_CONSTRAINT_ANG_BRACK 8U
97 
100 #define VRNA_CONSTRAINT_RND_BRACK 16U
101 
104 #define VRNA_CONSTRAINT_MULTILINE 32U
105 
108 #define VRNA_CONSTRAINT_NO_HEADER 64U
109 
112 #define VRNA_CONSTRAINT_ALL 128U
113 
116 #define VRNA_CONSTRAINT_G 256U
117 
118 
119 
128 #define VRNA_OPTION_MULTILINE 32U
129 
130 
134 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
135 
138 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
139 
142 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
143 
146 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
147 
148 
152 #define XSTR(s) STR(s)
153 
156 #define STR(s) #s
157 
158 #ifndef FILENAME_MAX_LENGTH
159 
165 #define FILENAME_MAX_LENGTH 80
166 
172 #define FILENAME_ID_LENGTH 42
173 #endif
174 
175 
176 #ifdef HAVE_CONFIG_H
177 #include <config.h>
178 #ifndef HAVE_STRDUP
179 char *strdup(const char *s);
180 #endif
181 #endif
182 #ifdef WITH_DMALLOC
183 /* use dmalloc library to check for memory management bugs */
184 #include "dmalloc.h"
185 #define space(S) calloc(1,(S))
186 #else
187 
194 /*@only@*/ /*@notnull@*/
195 void *space(unsigned size) /*@ensures MaxSet(result) == (size-1);@*/;
196 
204 /*@only@*/ /*@notnull@*/
205 void *xrealloc(/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p,
206  unsigned size) /*@modifies *p @*/ /*@ensures MaxSet(result) == (size-1) @*/;
207 #endif
208 
215 /*@exits@*/
216 void nrerror(const char message[]);
217 
225 void warn_user(const char message[]);
226 
230 void init_rand(void);
231 
240 extern unsigned short xsubi[3];
241 
248 double urn(void);
249 
257 int int_urn(int from, int to);
258 
259 void filecopy(FILE *from, FILE *to); /* inefficient `cp' */
260 
269 /*@observer@*/
270 char *time_stamp(void);
271 
279 /*@only@*/ /*@notnull@*/
280 char *random_string(int l, const char symbols[]);
281 
290 int hamming(const char *s1, const char *s2);
291 
301 int hamming_bound(const char *s1, const char *s2, int n);
302 
313 /*@only@*/ /*@null@*/
314 char *get_line(FILE *fp);
315 
316 int skip_comment_lines(char **line);
317 
338 unsigned int get_input_line(char **string,
339  unsigned int options);
340 
341 unsigned int get_multi_input_line(char **string,
342  unsigned int options);
343 
396 unsigned int read_record( char **header,
397  char **sequence,
398  char ***rest,
399  unsigned int options);
400 
401 
402 /* \brief Extract a dot-bracket structure string from (multiline)character array
403  *
404  * This function extracts a dot-bracket structure string from the 'rest' array as
405  * returned by read_record() and returns it. All occurences of comments within the
406  * 'lines' array will be skipped as long as they do not break the structure string.
407  * If no structure could be read, this function returns NULL.
408  *
409  * \see read_record()
410  *
411  * \param lines The (multiline) character array to be parsed
412  * \param length The assumed length of the dot-bracket string (passing a value < 1 results in no length limit)
413  * \param option Some options which may be passed to alter the behavior of the function, use 0 for no options
414  * \return The dot-bracket string read from lines or NULL
415  */
416 char *extract_record_rest_structure(const char **lines,
417  unsigned int length,
418  unsigned int option);
419 
431 char *pack_structure(const char *struc);
432 
442 char *unpack_structure(const char *packed);
443 
453 short *make_pair_table(const char *structure);
454 
455 short *make_pair_table_pk(const char *structure);
456 
463 short *copy_pair_table(const short *pt);
464 
470 short *alimake_pair_table(const char *structure);
471 
477 short *make_pair_table_snoop(const char *structure);
478 
491 int *make_loop_index_pt(short *pt);
492 
493 
494 int bp_distance(const char *str1,
495  const char *str2);
496 
502 void print_tty_input_seq(void);
503 
512 void print_tty_input_seq_str(const char *s);
513 
519 void print_tty_constraint_full(void);
520 
537 void print_tty_constraint(unsigned int option);
538 
546 void str_DNA2RNA(char *sequence);
547 
553 void str_uppercase(char *sequence);
554 
568 int *get_iindx(unsigned int length);
569 
584 int *get_indx(unsigned int length);
585 
586 void getConstraint( char **cstruc,
587  const char **lines,
588  unsigned int option);
589 
601 void constrain_ptypes(const char *constraint,
602  unsigned int length,
603  char *ptype,
604  int *BP,
605  int min_loop_size,
606  unsigned int idx_type);
607 
608 unsigned int *make_referenceBP_array(short *reference_pt,
609  unsigned int turn);
610 
611 unsigned int *compute_BPdifferences( short *pt1,
612  short *pt2,
613  unsigned int turn);
614 
615 #endif