RNAlib-2.3.1
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 
28 #include <stdio.h>
29 
31 #include <ViennaRNA/string_utils.h>
33 #include <ViennaRNA/file_utils.h>
34 #include <ViennaRNA/alphabet.h>
35 
36 /* two helper macros to indicate whether a function should be exported in
37 the library or stays hidden */
38 #define PUBLIC
39 #define PRIVATE static
40 
44 #define VRNA_INPUT_ERROR 1U
45 
48 #define VRNA_INPUT_QUIT 2U
49 
52 #define VRNA_INPUT_MISC 4U
53 
61 #define VRNA_INPUT_FASTA_HEADER 8U
62 
63 /*
64  * @brief Input flag for get_input_line():\n
65  * Tell get_input_line() that we assume to read a nucleotide sequence
66  *
67  */
68 #define VRNA_INPUT_SEQUENCE 16U
69 
74 #define VRNA_INPUT_CONSTRAINT 32U
75 
80 #define VRNA_INPUT_NO_TRUNCATION 256U
81 
85 #define VRNA_INPUT_NO_REST 512U
86 
90 #define VRNA_INPUT_NO_SPAN 1024U
91 
95 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
96 
100 #define VRNA_INPUT_BLANK_LINE 4096U
101 
105 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
106 
110 #define VRNA_INPUT_COMMENT 8192U
111 
115 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
116 
120 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
121 
125 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
126 
130 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
131 
132 
133 #ifdef WITH_DMALLOC
134 /* use dmalloc library to check for memory management bugs */
135 #include "dmalloc.h"
136 #define vrna_alloc(S) calloc(1,(S))
137 #define vrna_realloc(p, S) xrealloc(p, S)
138 #else
139 
146 void *vrna_alloc(unsigned size);
147 
155 void *vrna_realloc(void *p, unsigned size);
156 
157 #endif
158 
171 void vrna_message_error(const char *format, ...);
172 
173 
186 void vrna_message_verror(const char *format, va_list args);
187 
188 
200 void vrna_message_warning(const char *format, ...);
201 
202 
214 void vrna_message_vwarning(const char *format, va_list args);
215 
216 
228 void vrna_message_info(FILE *fp, const char *format, ...);
229 
230 
242 void vrna_message_vinfo(FILE *fp, const char *format, va_list args);
243 
244 
248 void vrna_init_rand(void);
249 
258 extern unsigned short xsubi[3];
259 
267 double vrna_urn(void);
268 
277 int vrna_int_urn(int from, int to);
278 
287 char *vrna_time_stamp(void);
288 
309 unsigned int get_input_line(char **string,
310  unsigned int options);
311 
312 
319 
320 
329 void vrna_message_input_seq(const char *s);
330 
344 int *vrna_idx_row_wise(unsigned int length);
345 
360 int *vrna_idx_col_wise(unsigned int length);
361 
366 #ifdef VRNA_BACKWARD_COMPAT
367 
368 DEPRECATED(int *get_indx(unsigned int length));
369 
370 DEPRECATED(int *get_iindx(unsigned int length));
371 
384 DEPRECATED(char *get_line(FILE *fp));
385 
392 DEPRECATED(void print_tty_input_seq(void));
393 
402 DEPRECATED(void print_tty_input_seq_str(const char *s));
403 
411 DEPRECATED(void warn_user(const char message[]));
412 
418 DEPRECATED(void nrerror(const char message[]));
419 
425 DEPRECATED(void *space(unsigned size));
426 
432 DEPRECATED(void *xrealloc(void *p, unsigned size));
433 
438 DEPRECATED(void init_rand(void));
439 
445 DEPRECATED(double urn(void));
446 
452 DEPRECATED(int int_urn(int from, int to));
453 
459 DEPRECATED(void filecopy(FILE *from, FILE *to));
460 
466 DEPRECATED(char *time_stamp(void));
467 
468 #endif
469 
470 #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.
void vrna_message_error(const char *format,...)
Print an error message and die.
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.
char * time_stamp(void)
Get a timestamp.
Functions to process, convert, and generally handle different nucleotide and/or base pair alphabets...
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
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...
void vrna_message_info(FILE *fp, const char *format,...)
Print an info message.
int int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
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...
void vrna_message_vinfo(FILE *fp, const char *format, va_list args)
Print an info message.
char * vrna_time_stamp(void)
Get a timestamp.
Various data structures and pre-processor macros.
Various utility- and helper-functions for secondary structure parsing, converting, etc.
Several utilities for file handling.
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.
void vrna_message_warning(const char *format,...)
Print a warning message.
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_verror(const char *format, va_list args)
Print an error message and die.
double urn(void)
get a random number from [0..1]
unsigned short xsubi[3]
Current 48 bit random number.
void vrna_message_vwarning(const char *format, va_list args)
Print a warning message.
void init_rand(void)
Make random number seeds.
double vrna_urn(void)
get a random number from [0..1]