1 #ifndef VIENNA_RNA_PACKAGE_UTILS_H
2 #define VIENNA_RNA_PACKAGE_UTILS_H
5 #define VRNA_BACKWARD_COMPAT
8 #define DEPRECATED(func) func __attribute__ ((deprecated))
10 #define DEPRECATED(func) func
30 #define PRIVATE static
35 #define VRNA_INPUT_ERROR 1U
39 #define VRNA_INPUT_QUIT 2U
43 #define VRNA_INPUT_MISC 4U
52 #define VRNA_INPUT_FASTA_HEADER 8U
59 #define VRNA_INPUT_SEQUENCE 16U
65 #define VRNA_INPUT_CONSTRAINT 32U
71 #define VRNA_INPUT_NO_TRUNCATION 256U
76 #define VRNA_INPUT_NO_REST 512U
81 #define VRNA_INPUT_NO_SPAN 1024U
86 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
91 #define VRNA_INPUT_BLANK_LINE 4096U
96 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
101 #define VRNA_INPUT_COMMENT 8192U
112 #define VRNA_OPTION_MULTILINE 32U
118 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
123 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
128 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
133 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
139 #define XSTR(s) STR(s)
146 #ifndef FILENAME_MAX_LENGTH
154 #define FILENAME_MAX_LENGTH 80
162 #define FILENAME_ID_LENGTH 42
170 char *strdup(
const char *s);
177 #define vrna_alloc(S) calloc(1,(S))
178 #define vrna_realloc(p, S) xrealloc(p, S)
230 extern unsigned short xsubi[3];
329 unsigned int options);
443 void vrna_ali_encode(
const char *sequence,
448 unsigned short **as_p,
466 #ifdef VRNA_BACKWARD_COMPAT
468 DEPRECATED(
char *get_ptypes(
const short *S,
vrna_md_t *md,
unsigned int idx_type));
470 DEPRECATED(
int *get_indx(
unsigned int length));
472 DEPRECATED(
int *get_iindx(
unsigned int length));
512 DEPRECATED(
void warn_user(
const char message[]));
519 DEPRECATED(
void nrerror(
const char message[]));
526 DEPRECATED(
void *
space(
unsigned size));
533 DEPRECATED(
void *
xrealloc(
void *p,
unsigned size));
546 DEPRECATED(
double urn(
void));
553 DEPRECATED(
int int_urn(
int from,
int to));
560 DEPRECATED(
char *
random_string(
int l,
const char symbols[]));
567 DEPRECATED(
void filecopy(FILE *from, FILE *to));
581 DEPRECATED(
int hamming(
const char *s1,
const char *s2));
588 DEPRECATED(
int hamming_bound(
const char *s1,
const char *s2,
int n));
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.
void vrna_seq_toupper(char *sequence)
Convert an input sequence to uppercase.
unsigned int get_input_line(char **string, unsigned int options)
void * space(unsigned size)
Allocate space safely.
int vrna_hamming_distance_bound(const char *s1, const char *s2, int n)
Calculate hamming distance between two sequences up to a specified length.
char * vrna_random_string(int l, const char symbols[])
Create a random string using characters from a specified symbol set.
char * get_line(FILE *fp)
Read a line of arbitrary length from a stream.
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.
void vrna_message_warning(const char message[])
Print a warning message.
char * time_stamp(void)
Get a timestamp.
char vrna_nucleotide_decode(int enc, vrna_md_t *md)
Decode a numerical representation of a nucleotide back into nucleotide alphabet.
int int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
void vrna_file_copy(FILE *from, FILE *to)
Inefficient `cp'.
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.
char * vrna_time_stamp(void)
Get a timestamp.
short * vrna_seq_encode_simple(const char *sequence, vrna_md_t *md)
Get a numerical representation of the nucleotide sequence (simple version)
char * random_string(int l, const char symbols[])
Create a random string using characters from a specified symbol set.
void str_DNA2RNA(char *sequence)
Convert a DNA input sequence to RNA alphabet.
Various utility- and helper-functions for secondary structure parsing, converting, etc.
int * vrna_get_indx(unsigned int length)
Get an index mapper array (indx) for accessing the energy matrices, e.g. in MFE related functions...
int * vrna_get_iindx(unsigned int length)
Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function relat...
short * vrna_seq_encode(const char *sequence, vrna_md_t *md)
Get a numerical representation of the nucleotide sequence.
int hamming_bound(const char *s1, const char *s2, int n)
Calculate hamming distance between two sequences up to a specified length.
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_seq_toRNA(char *sequence)
Convert an input sequence (possibly containing DNA alphabet characters) to RNA alphabet.
int vrna_int_urn(int from, int to)
Generates a pseudo random integer in a specified range.
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:169
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_error(const char message[])
Die with an error message.
double urn(void)
get a random number from [0..1]
unsigned short xsubi[3]
Current 48 bit random number.
int vrna_nucleotide_encode(char c, vrna_md_t *md)
Encode a nucleotide character to numerical value.
void init_rand(void)
Make random number seeds.
char * vrna_get_ptypes(const short *S, vrna_md_t *md)
Get an array of the numerical encoding for each possible base pair (i,j)
double vrna_urn(void)
get a random number from [0..1]
void str_uppercase(char *sequence)
Convert an input sequence to uppercase.
int hamming(const char *s1, const char *s2)
Calculate hamming distance between two sequences.
int vrna_hamming_distance(const char *s1, const char *s2)
Calculate hamming distance between two sequences.