RNAlib-2.2.7
utils.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_UTILS_H
2 #define VIENNA_RNA_PACKAGE_UTILS_H
3 
4 /* make this interface backward compatible with RNAlib < 2.2.0 */
5 #define VRNA_BACKWARD_COMPAT
6 
7 #ifdef DEPRECATION_WARNINGS
8 # ifdef __GNUC__
9 # define DEPRECATED(func) func __attribute__ ((deprecated))
10 # else
11 # define DEPRECATED(func) func
12 # endif
13 #else
14 # define DEPRECATED(func) func
15 #endif
16 
26 #include <stdio.h>
27 
29 #include <ViennaRNA/string_utils.h>
31 #include <ViennaRNA/alphabet.h>
32 
33 /* two helper macros to indicate whether a function should be exported in
34 the library or stays hidden */
35 #define PUBLIC
36 #define PRIVATE static
37 
41 #define VRNA_INPUT_ERROR 1U
42 
45 #define VRNA_INPUT_QUIT 2U
46 
49 #define VRNA_INPUT_MISC 4U
50 
58 #define VRNA_INPUT_FASTA_HEADER 8U
59 
60 /*
61  * @brief Input flag for get_input_line():\n
62  * Tell get_input_line() that we assume to read a nucleotide sequence
63  *
64  */
65 #define VRNA_INPUT_SEQUENCE 16U
66 
71 #define VRNA_INPUT_CONSTRAINT 32U
72 
77 #define VRNA_INPUT_NO_TRUNCATION 256U
78 
82 #define VRNA_INPUT_NO_REST 512U
83 
87 #define VRNA_INPUT_NO_SPAN 1024U
88 
92 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
93 
97 #define VRNA_INPUT_BLANK_LINE 4096U
98 
102 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
103 
107 #define VRNA_INPUT_COMMENT 8192U
108 
112 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
113 
117 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
118 
122 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
123 
127 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
128 
129 
130 #ifdef WITH_DMALLOC
131 /* use dmalloc library to check for memory management bugs */
132 #include "dmalloc.h"
133 #define vrna_alloc(S) calloc(1,(S))
134 #define vrna_realloc(p, S) xrealloc(p, S)
135 #else
136 
143 void *vrna_alloc(unsigned size);
144 
152 void *vrna_realloc(void *p, unsigned size);
153 
154 #endif
155 
162 void vrna_message_error(const char message[]);
163 
171 void vrna_message_warning(const char message[]);
172 
176 void vrna_init_rand(void);
177 
186 extern unsigned short xsubi[3];
187 
195 double vrna_urn(void);
196 
205 int vrna_int_urn(int from, int to);
206 
210 void vrna_file_copy(FILE *from, FILE *to);
211 
220 char *vrna_time_stamp(void);
221 
232 /*@only@*/ /*@null@*/
233 char *get_line(FILE *fp);
234 
255 unsigned int get_input_line(char **string,
256  unsigned int options);
257 
258 
265 
266 
275 void vrna_message_input_seq(const char *s);
276 
290 int *vrna_idx_row_wise(unsigned int length);
291 
306 int *vrna_idx_col_wise(unsigned int length);
307 
312 #ifdef VRNA_BACKWARD_COMPAT
313 
314 DEPRECATED(int *get_indx(unsigned int length));
315 
316 DEPRECATED(int *get_iindx(unsigned int length));
317 
324 DEPRECATED(void print_tty_input_seq(void));
325 
334 DEPRECATED(void print_tty_input_seq_str(const char *s));
335 
343 DEPRECATED(void warn_user(const char message[]));
344 
350 DEPRECATED(void nrerror(const char message[]));
351 
357 DEPRECATED(void *space(unsigned size));
358 
364 DEPRECATED(void *xrealloc(void *p, unsigned size));
365 
370 DEPRECATED(void init_rand(void));
371 
377 DEPRECATED(double urn(void));
378 
384 DEPRECATED(int int_urn(int from, int to));
385 
391 DEPRECATED(void filecopy(FILE *from, FILE *to));
392 
398 DEPRECATED(char *time_stamp(void));
399 
400 #endif
401 
402 #endif
void * vrna_alloc(unsigned size)
Allocate space safely.
void vrna_message_input_seq(const char *s)
Print a line with a user defined string and a ruler to stdout.
unsigned int get_input_line(char **string, unsigned int options)
void * space(unsigned size)
Allocate space safely.
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
void warn_user(const char message[])
Print a warning message.
void vrna_message_input_seq_simple(void)
Print a line to stdout that asks for an input sequence.
void vrna_message_warning(const char message[])
Print a warning message.
char * time_stamp(void)
Get a timestamp.
Functions to process, convert, and generally handle different nucleotide and/or base pair alphabets...
int * vrna_idx_col_wise(unsigned int length)
Get an index mapper array (indx) for accessing the energy matrices, e.g. in MFE related functions...
int int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
void vrna_file_copy(FILE *from, FILE *to)
Inefficient `cp'.
void filecopy(FILE *from, FILE *to)
Inefficient cp
void vrna_init_rand(void)
Initialize seed for random number generator.
void print_tty_input_seq(void)
Print a line to stdout that asks for an input sequence.
General utility- and helper-functions for RNA sequence and structure strings used throughout the Vien...
int * vrna_idx_row_wise(unsigned int length)
Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function relat...
char * vrna_time_stamp(void)
Get a timestamp.
Various utility- and helper-functions for secondary structure parsing, converting, etc.
void nrerror(const char message[])
Die with an error message.
void * xrealloc(void *p, unsigned size)
Reallocate space safely.
void * vrna_realloc(void *p, unsigned size)
Reallocate space safely.
int vrna_int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
void print_tty_input_seq_str(const char *s)
Print a line with a user defined string and a ruler to stdout.
void vrna_message_error(const char message[])
Die with an error message.
double urn(void)
get a random number from [0..1]
unsigned short xsubi[3]
Current 48 bit random number.
void init_rand(void)
Make random number seeds.
double vrna_urn(void)
get a random number from [0..1]