RNAlib-2.2.0
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 
32 /* two helper macros to indicate whether a function should be exported in
33 the library or stays hidden */
34 #define PUBLIC
35 #define PRIVATE static
36 
40 #define VRNA_INPUT_ERROR 1U
41 
44 #define VRNA_INPUT_QUIT 2U
45 
48 #define VRNA_INPUT_MISC 4U
49 
57 #define VRNA_INPUT_FASTA_HEADER 8U
58 
59 /*
60  * @brief Input flag for get_input_line():\n
61  * Tell get_input_line() that we assume to read a nucleotide sequence
62  *
63  */
64 #define VRNA_INPUT_SEQUENCE 16U
65 
70 #define VRNA_INPUT_CONSTRAINT 32U
71 
76 #define VRNA_INPUT_NO_TRUNCATION 256U
77 
81 #define VRNA_INPUT_NO_REST 512U
82 
86 #define VRNA_INPUT_NO_SPAN 1024U
87 
91 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
92 
96 #define VRNA_INPUT_BLANK_LINE 4096U
97 
101 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
102 
106 #define VRNA_INPUT_COMMENT 8192U
107 
117 #define VRNA_OPTION_MULTILINE 32U
118 
119 
123 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
124 
128 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
129 
133 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
134 
138 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
139 
140 
141 #ifdef WITH_DMALLOC
142 /* use dmalloc library to check for memory management bugs */
143 #include "dmalloc.h"
144 #define vrna_alloc(S) calloc(1,(S))
145 #define vrna_realloc(p, S) xrealloc(p, S)
146 #else
147 
154 void *vrna_alloc(unsigned size);
155 
163 void *vrna_realloc(void *p, unsigned size);
164 
165 #endif
166 
173 void vrna_message_error(const char message[]);
174 
182 void vrna_message_warning(const char message[]);
183 
187 void vrna_init_rand(void);
188 
197 extern unsigned short xsubi[3];
198 
206 double vrna_urn(void);
207 
216 int vrna_int_urn(int from, int to);
217 
221 void vrna_file_copy(FILE *from, FILE *to);
222 
231 char *vrna_time_stamp(void);
232 
243 /*@only@*/ /*@null@*/
244 char *get_line(FILE *fp);
245 
266 unsigned int get_input_line(char **string,
267  unsigned int options);
268 
269 
276 
277 
286 void vrna_message_input_seq(const char *s);
287 
301 int *vrna_idx_row_wise(unsigned int length);
302 
317 int *vrna_idx_col_wise(unsigned int length);
318 
328 char *vrna_ptypes( const short *S,
329  vrna_md_t *md);
330 
335 #ifdef VRNA_BACKWARD_COMPAT
336 
337 DEPRECATED(char *get_ptypes(const short *S, vrna_md_t *md, unsigned int idx_type));
338 
339 DEPRECATED(int *get_indx(unsigned int length));
340 
341 DEPRECATED(int *get_iindx(unsigned int length));
342 
349 DEPRECATED(void print_tty_input_seq(void));
350 
359 DEPRECATED(void print_tty_input_seq_str(const char *s));
360 
368 DEPRECATED(void warn_user(const char message[]));
369 
375 DEPRECATED(void nrerror(const char message[]));
376 
382 DEPRECATED(void *space(unsigned size));
383 
389 DEPRECATED(void *xrealloc(void *p, unsigned size));
390 
395 DEPRECATED(void init_rand(void));
396 
402 DEPRECATED(double urn(void));
403 
409 DEPRECATED(int int_urn(int from, int to));
410 
416 DEPRECATED(void filecopy(FILE *from, FILE *to));
417 
423 DEPRECATED(char *time_stamp(void));
424 
425 #endif
426 
427 #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.
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&#39;.
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.
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:187
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.
char * vrna_ptypes(const short *S, vrna_md_t *md)
Get an array of the numerical encoding for each possible base pair (i,j)
void init_rand(void)
Make random number seeds.
double vrna_urn(void)
get a random number from [0..1]