RNAlib-2.6.3
 
Loading...
Searching...
No Matches
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/* two helper macros to indicate whether a function should be exported in
28 * the library or stays hidden */
29#define PUBLIC
30#define PRIVATE static
31
35#define VRNA_INPUT_ERROR 1U
39#define VRNA_INPUT_QUIT 2U
43#define VRNA_INPUT_MISC 4U
44
52#define VRNA_INPUT_FASTA_HEADER 8U
53
54/*
55 * @brief Input flag for get_input_line():\n
56 * Tell get_input_line() that we assume to read a nucleotide sequence
57 *
58 */
59#define VRNA_INPUT_SEQUENCE 16U
60
65#define VRNA_INPUT_CONSTRAINT 32U
66
71#define VRNA_INPUT_NO_TRUNCATION 256U
72
76#define VRNA_INPUT_NO_REST 512U
77
81#define VRNA_INPUT_NO_SPAN 1024U
82
86#define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
87
91#define VRNA_INPUT_BLANK_LINE 4096U
92
96#define VRNA_INPUT_NOSKIP_COMMENTS 128U
97
101#define VRNA_INPUT_COMMENT 8192U
102
106#define MIN2(A, B) ((A) < (B) ? (A) : (B))
107
111#define MAX2(A, B) ((A) > (B) ? (A) : (B))
112
116#define MIN3(A, B, C) (MIN2((MIN2((A), (B))), (C)))
117
121#define MAX3(A, B, C) (MAX2((MAX2((A), (B))), (C)))
122
123#include <stdio.h>
124#include <stdarg.h>
125
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
142void *
143vrna_alloc(unsigned size);
144
145
153void *
155 unsigned size);
156
157
158#endif
159
165void
167
168
176void
177vrna_init_rand_seed(unsigned int seed);
178
179
188extern unsigned short xsubi[3];
189
199double
201
202
212int
214 int to);
215
216
225char *
227
228
249unsigned int
250get_input_line(char **string,
251 unsigned int options);
252
253
268int *
269vrna_idx_row_wise(unsigned int length);
270
271
287int *
288vrna_idx_col_wise(unsigned int length);
289
290
313void
314vrna_message_error(const char *format,
315 ...);
316
317
330void
331vrna_message_verror(const char *format,
332 va_list args);
333
334
346void
347vrna_message_warning(const char *format,
348 ...);
349
350
362void
363vrna_message_vwarning(const char *format,
364 va_list args);
365
366
378void
380 const char *format,
381 ...);
382
383
395void
397 const char *format,
398 va_list args);
399
400
406void
408
409
418void
420
421
422void
423vrna_message_input_msa(const char *s);
424
425
430#ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
431
432DEPRECATED(int *get_indx(unsigned int length), "Use vrna_idx_col_wise() instead");
433
434DEPRECATED(int *get_iindx(unsigned int length), "Use vrna_idx_row_wise() instead");
435
448DEPRECATED(char *get_line(FILE *fp), "Use vrna_read_line() instead");
449
456DEPRECATED(void print_tty_input_seq(void), "Use vrna_message_input_seq_simple() instead");
457
466DEPRECATED(void print_tty_input_seq_str(const char *s), "Use vrna_message_input_seq() instead");
467
475DEPRECATED(void warn_user(const char message[]), "Use vrna_message_warning() instead");
476
482DEPRECATED(void nrerror(const char message[]), "Use vrna_message_error() instead()");
483
489DEPRECATED(void *space(unsigned size), "Use vrna_alloc() instead");
490
496DEPRECATED(void *xrealloc(void *p,
497 unsigned size), "Use vrna_realloc() instead");
498
503DEPRECATED(void init_rand(void), "Use vrna_init_rand() instead");
504
510DEPRECATED(double urn(void), "Use vrna_urn() instead");
511
517DEPRECATED(int int_urn(int from,
518 int to), "Use vrna_int_urn() instead()");
519
525DEPRECATED(void filecopy(FILE *from,
526 FILE *to), "Use vrna_file_copy() instead");
527
533DEPRECATED(char *time_stamp(void), "Use vrna_time_stamp() instead");
534
535#endif
536
537#endif
Various data structures and pre-processor macros.
void vrna_message_info(FILE *fp, const char *format,...)
Print an info message.
void vrna_message_error(const char *format,...)
Print an error message and die.
void vrna_message_vwarning(const char *format, va_list args)
Print a warning message.
void vrna_message_warning(const char *format,...)
Print a warning message.
void vrna_message_verror(const char *format, va_list args)
Print an error message and die.
void vrna_message_vinfo(FILE *fp, const char *format, va_list args)
Print an info message.
void vrna_message_input_seq_simple(void)
Print a line to stdout that asks for an input sequence.
void vrna_message_input_seq(const char *s)
Print a line with a user defined string and a ruler to stdout.
void vrna_init_rand(void)
Initialize seed for random number generator.
char * vrna_time_stamp(void)
Get a timestamp.
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...
double vrna_urn(void)
get a random number from [0..1]
int vrna_int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
unsigned int get_input_line(char **string, unsigned int options)
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_init_rand_seed(unsigned int seed)
Initialize the random number generator with a pre-defined seed.
void * vrna_realloc(void *p, unsigned size)
Reallocate space safely.
unsigned short xsubi[3]
Current 48 bit random number.
void * vrna_alloc(unsigned size)
Allocate space safely.
void nrerror(const char message[])
Die with an error message.
char * time_stamp(void)
Get a timestamp.
int int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
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 * xrealloc(void *p, unsigned size)
Reallocate space safely.
void init_rand(void)
Make random number seeds.
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
double urn(void)
get a random number from [0..1]
void filecopy(FILE *from, FILE *to)
Inefficient cp
void print_tty_input_seq_str(const char *s)
Print a line with a user defined string and a ruler to stdout.
void warn_user(const char message[])
Print a warning message.