RNAlib-2.4.11
basic.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_UTILS_H
2 #define VIENNA_RNA_PACKAGE_UTILS_H
3 
4 #ifdef VRNA_WARN_DEPRECATED
5 # if defined(__clang__)
6 # define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
7 # elif defined(__GNUC__)
8 # define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
9 # else
10 # define DEPRECATED(func, msg) func
11 # endif
12 #else
13 # define DEPRECATED(func, msg) func
14 #endif
15 
27 #include <stdio.h>
28 #include <stdarg.h>
29 
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 
111 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
112 
116 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
117 
121 #define MIN3(A, B, C) (MIN2((MIN2((A), (B))), (C)))
122 
126 #define MAX3(A, B, C) (MAX2((MAX2((A), (B))), (C)))
127 
128 
129 #ifdef WITH_DMALLOC
130 /* use dmalloc library to check for memory management bugs */
131 #include "dmalloc.h"
132 #define vrna_alloc(S) calloc(1, (S))
133 #define vrna_realloc(p, S) xrealloc(p, S)
134 #else
135 
142 void *vrna_alloc(unsigned size);
143 
144 
152 void *vrna_realloc(void *p,
153  unsigned size);
154 
155 
156 #endif
157 
161 void vrna_init_rand(void);
162 
163 
172 extern unsigned short xsubi[3];
173 
181 double vrna_urn(void);
182 
183 
192 int vrna_int_urn(int from,
193  int to);
194 
195 
204 char *vrna_time_stamp(void);
205 
206 
227 unsigned int get_input_line(char **string,
228  unsigned int options);
229 
230 
244 int *vrna_idx_row_wise(unsigned int length);
245 
246 
261 int *vrna_idx_col_wise(unsigned int length);
262 
263 
286 void vrna_message_error(const char *format,
287  ...);
288 
289 
302 void vrna_message_verror(const char *format,
303  va_list args);
304 
305 
317 void vrna_message_warning(const char *format,
318  ...);
319 
320 
332 void vrna_message_vwarning(const char *format,
333  va_list args);
334 
335 
347 void vrna_message_info(FILE *fp,
348  const char *format,
349  ...);
350 
351 
363 void vrna_message_vinfo(FILE *fp,
364  const char *format,
365  va_list args);
366 
367 
374 
375 
384 void vrna_message_input_seq(const char *s);
385 
386 
387 void vrna_message_input_msa(const char *s);
388 
389 
394 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
395 
396 DEPRECATED(int *get_indx(unsigned int length), "Use vrna_idx_col_wise() instead");
397 
398 DEPRECATED(int *get_iindx(unsigned int length), "Use vrna_idx_row_wise() instead");
399 
412 DEPRECATED(char *get_line(FILE *fp), "Use vrna_read_line() instead");
413 
420 DEPRECATED(void print_tty_input_seq(void), "Use vrna_message_input_seq_simple() instead");
421 
430 DEPRECATED(void print_tty_input_seq_str(const char *s), "Use vrna_message_input_seq() instead");
431 
439 DEPRECATED(void warn_user(const char message[]), "Use vrna_message_warning() instead");
440 
446 DEPRECATED(void nrerror(const char message[]), "Use vrna_message_error() instead()");
447 
453 DEPRECATED(void *space(unsigned size), "Use vrna_alloc() instead");
454 
460 DEPRECATED(void *xrealloc(void *p,
461  unsigned size), "Use vrna_realloc() instead");
462 
467 DEPRECATED(void init_rand(void), "Use vrna_init_rand() instead");
468 
474 DEPRECATED(double urn(void), "Use vrna_urn() instead");
475 
481 DEPRECATED(int int_urn(int from,
482  int to), "Use vrna_int_urn() instead()");
483 
489 DEPRECATED(void filecopy(FILE *from,
490  FILE *to), "Use vrna_file_copy() instead");
491 
497 DEPRECATED(char *time_stamp(void), "Use vrna_time_stamp() instead");
498 
499 #endif
500 
501 #endif
void * vrna_alloc(unsigned size)
Allocate space safely.
unsigned int get_input_line(char **string, unsigned int options)
void vrna_message_warning(const char *format,...)
Print a warning message.
void * xrealloc(void *p, unsigned size)
Reallocate space safely.
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_vinfo(FILE *fp, const char *format, va_list args)
Print an info message.
void vrna_init_rand(void)
Initialize seed for random number generator.
double urn(void)
get a random number from [0..1]
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 data structures and pre-processor macros.
void vrna_message_vwarning(const char *format, va_list args)
Print a warning message.
void vrna_message_info(FILE *fp, const char *format,...)
Print an info message.
void vrna_message_verror(const char *format, va_list args)
Print an error message and die.
void vrna_message_input_seq_simple(void)
Print a line to stdout that asks for an input sequence.
void warn_user(const char message[])
Print a warning message.
char * time_stamp(void)
Get a timestamp.
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
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 vrna_message_error(const char *format,...)
Print an error message and die.
void print_tty_input_seq(void)
Print a line to stdout that asks for an input sequence.
void * space(unsigned size)
Allocate space safely.
void print_tty_input_seq_str(const char *s)
Print a line with a user defined string and a ruler to stdout.
void nrerror(const char message[])
Die with an error message.
unsigned short xsubi[3]
Current 48 bit random number.
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 init_rand(void)
Make random number seeds.
double vrna_urn(void)
get a random number from [0..1]
void vrna_message_input_seq(const char *s)
Print a line with a user defined string and a ruler to stdout.