utils.h
Go to the documentation of this file.
#ifndef VIENNA_RNA_PACKAGE_UTILS_H
#define VIENNA_RNA_PACKAGE_UTILS_H
/* make this interface backward compatible with RNAlib < 2.2.0 */
#define VRNA_BACKWARD_COMPAT
#ifdef DEPRECATION_WARNINGS
# ifdef __GNUC__
# define DEPRECATED(func) func __attribute__ ((deprecated))
# else
# define DEPRECATED(func) func
# endif
#else
# define DEPRECATED(func) func
#endif
#include <stdio.h>
#include <ViennaRNA/data_structures.h>
#include <ViennaRNA/string_utils.h>
#include <ViennaRNA/structure_utils.h>
#include <ViennaRNA/alphabet.h>
/* two helper macros to indicate whether a function should be exported in
the library or stays hidden */
#define PUBLIC
#define PRIVATE static
#define VRNA_INPUT_ERROR 1U
#define VRNA_INPUT_QUIT 2U
#define VRNA_INPUT_MISC 4U
#define VRNA_INPUT_FASTA_HEADER 8U
/*
* @brief Input flag for get_input_line():\n
* Tell get_input_line() that we assume to read a nucleotide sequence
*
*/
#define VRNA_INPUT_SEQUENCE 16U
#define VRNA_INPUT_CONSTRAINT 32U
#define VRNA_INPUT_NO_TRUNCATION 256U
#define VRNA_INPUT_NO_REST 512U
#define VRNA_INPUT_NO_SPAN 1024U
#define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
#define VRNA_INPUT_BLANK_LINE 4096U
#define VRNA_INPUT_NOSKIP_COMMENTS 128U
#define VRNA_INPUT_COMMENT 8192U
#define MIN2(A, B) ((A) < (B) ? (A) : (B))
#define MAX2(A, B) ((A) > (B) ? (A) : (B))
#define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
#define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
#ifdef WITH_DMALLOC
/* use dmalloc library to check for memory management bugs */
#include "dmalloc.h"
#define vrna_alloc(S) calloc(1,(S))
#define vrna_realloc(p, S) xrealloc(p, S)
#else
void *vrna_alloc(unsigned size);
void *vrna_realloc(void *p, unsigned size);
#endif
void vrna_message_error(const char message[]);
void vrna_message_warning(const char message[]);
void vrna_init_rand(void);
extern unsigned short xsubi[3];
double vrna_urn(void);
int vrna_int_urn(int from, int to);
void vrna_file_copy(FILE *from, FILE *to);
char *vrna_time_stamp(void);
/*@only@*/ /*@null@*/
char *get_line(FILE *fp);
unsigned int get_input_line(char **string,
unsigned int options);
void vrna_message_input_seq_simple(void);
void vrna_message_input_seq(const char *s);
int *vrna_idx_row_wise(unsigned int length);
int *vrna_idx_col_wise(unsigned int length);
#ifdef VRNA_BACKWARD_COMPAT
DEPRECATED(int *get_indx(unsigned int length));
DEPRECATED(int *get_iindx(unsigned int length));
DEPRECATED(void print_tty_input_seq(void));
DEPRECATED(void print_tty_input_seq_str(const char *s));
DEPRECATED(void warn_user(const char message[]));
DEPRECATED(void nrerror(const char message[]));
DEPRECATED(void *space(unsigned size));
DEPRECATED(void *xrealloc(void *p, unsigned size));
DEPRECATED(void init_rand(void));
DEPRECATED(double urn(void));
DEPRECATED(int int_urn(int from, int to));
DEPRECATED(void filecopy(FILE *from, FILE *to));
DEPRECATED(char *time_stamp(void));
#endif
#endif
vrna_alloc
void * vrna_alloc(unsigned size)
Allocate space safely.
vrna_message_input_seq
void vrna_message_input_seq(const char *s)
Print a line with a user defined string and a ruler to stdout.
get_input_line
unsigned int get_input_line(char **string, unsigned int options)
space
void * space(unsigned size)
Allocate space safely.
get_line
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
warn_user
void warn_user(const char message[])
Print a warning message.
vrna_message_input_seq_simple
void vrna_message_input_seq_simple(void)
Print a line to stdout that asks for an input sequence.
vrna_message_warning
void vrna_message_warning(const char message[])
Print a warning message.
time_stamp
char * time_stamp(void)
Get a timestamp.
alphabet.h
Functions to process, convert, and generally handle different nucleotide and/or base pair alphabets...
vrna_idx_col_wise
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_urn
int int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
vrna_file_copy
void vrna_file_copy(FILE *from, FILE *to)
Inefficient `cp'.
filecopy
void filecopy(FILE *from, FILE *to)
Inefficient cp
vrna_init_rand
void vrna_init_rand(void)
Initialize seed for random number generator.
print_tty_input_seq
void print_tty_input_seq(void)
Print a line to stdout that asks for an input sequence.
string_utils.h
General utility- and helper-functions for RNA sequence and structure strings used throughout the Vien...
vrna_idx_row_wise
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...
vrna_time_stamp
char * vrna_time_stamp(void)
Get a timestamp.
data_structures.h
structure_utils.h
Various utility- and helper-functions for secondary structure parsing, converting, etc.
nrerror
void nrerror(const char message[])
Die with an error message.
xrealloc
void * xrealloc(void *p, unsigned size)
Reallocate space safely.
vrna_realloc
void * vrna_realloc(void *p, unsigned size)
Reallocate space safely.
vrna_int_urn
int vrna_int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
print_tty_input_seq_str
void print_tty_input_seq_str(const char *s)
Print a line with a user defined string and a ruler to stdout.
vrna_message_error
void vrna_message_error(const char message[])
Die with an error message.
urn
double urn(void)
get a random number from [0..1]
xsubi
unsigned short xsubi[3]
Current 48 bit random number.
init_rand
void init_rand(void)
Make random number seeds.
vrna_urn
double vrna_urn(void)
get a random number from [0..1]