RNAlib-2.3.2
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 #include <stdarg.h>
30 
32 #include <ViennaRNA/string_utils.h>
34 #include <ViennaRNA/file_utils.h>
35 #include <ViennaRNA/alphabet.h>
36 
37 /* two helper macros to indicate whether a function should be exported in
38 the library or stays hidden */
39 #define PUBLIC
40 #define PRIVATE static
41 
45 #define VRNA_INPUT_ERROR 1U
46 
49 #define VRNA_INPUT_QUIT 2U
50 
53 #define VRNA_INPUT_MISC 4U
54 
62 #define VRNA_INPUT_FASTA_HEADER 8U
63 
64 /*
65  * @brief Input flag for get_input_line():\n
66  * Tell get_input_line() that we assume to read a nucleotide sequence
67  *
68  */
69 #define VRNA_INPUT_SEQUENCE 16U
70 
75 #define VRNA_INPUT_CONSTRAINT 32U
76 
81 #define VRNA_INPUT_NO_TRUNCATION 256U
82 
86 #define VRNA_INPUT_NO_REST 512U
87 
91 #define VRNA_INPUT_NO_SPAN 1024U
92 
96 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
97 
101 #define VRNA_INPUT_BLANK_LINE 4096U
102 
106 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
107 
111 #define VRNA_INPUT_COMMENT 8192U
112 
116 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
117 
121 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
122 
126 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
127 
131 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
132 
133 
134 #ifdef WITH_DMALLOC
135 /* use dmalloc library to check for memory management bugs */
136 #include "dmalloc.h"
137 #define vrna_alloc(S) calloc(1,(S))
138 #define vrna_realloc(p, S) xrealloc(p, S)
139 #else
140 
147 void *vrna_alloc(unsigned size);
148 
156 void *vrna_realloc(void *p, unsigned size);
157 
158 #endif
159 
172 void vrna_message_error(const char *format, ...);
173 
174 
187 void vrna_message_verror(const char *format, va_list args);
188 
189 
201 void vrna_message_warning(const char *format, ...);
202 
203 
215 void vrna_message_vwarning(const char *format, va_list args);
216 
217 
229 void vrna_message_info(FILE *fp, const char *format, ...);
230 
231 
243 void vrna_message_vinfo(FILE *fp, const char *format, va_list args);
244 
245 
249 void vrna_init_rand(void);
250 
259 extern unsigned short xsubi[3];
260 
268 double vrna_urn(void);
269 
278 int vrna_int_urn(int from, int to);
279 
288 char *vrna_time_stamp(void);
289 
310 unsigned int get_input_line(char **string,
311  unsigned int options);
312 
313 
320 
321 
330 void vrna_message_input_seq(const char *s);
331 
345 int *vrna_idx_row_wise(unsigned int length);
346 
361 int *vrna_idx_col_wise(unsigned int length);
362 
367 #ifdef VRNA_BACKWARD_COMPAT
368 
369 DEPRECATED(int *get_indx(unsigned int length));
370 
371 DEPRECATED(int *get_iindx(unsigned int length));
372 
385 DEPRECATED(char *get_line(FILE *fp));
386 
393 DEPRECATED(void print_tty_input_seq(void));
394 
403 DEPRECATED(void print_tty_input_seq_str(const char *s));
404 
412 DEPRECATED(void warn_user(const char message[]));
413 
419 DEPRECATED(void nrerror(const char message[]));
420 
426 DEPRECATED(void *space(unsigned size));
427 
433 DEPRECATED(void *xrealloc(void *p, unsigned size));
434 
439 DEPRECATED(void init_rand(void));
440 
446 DEPRECATED(double urn(void));
447 
453 DEPRECATED(int int_urn(int from, int to));
454 
460 DEPRECATED(void filecopy(FILE *from, FILE *to));
461 
467 DEPRECATED(char *time_stamp(void));
468 
469 #endif
470 
471 #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]