RNAlib-2.2.0RC0
utils.h
Go to the documentation of this file.
1 #ifndef __VIENNA_RNA_PACKAGE_UTILS_H__
2 #define __VIENNA_RNA_PACKAGE_UTILS_H__
3 
9 #include <stdio.h>
10 
13 
14 /* two helper macros to indicate whether a function should be exported in
15 the library or stays hidden */
16 #define PUBLIC
17 #define PRIVATE static
18 
19 #ifdef __GNUC__
20 #define DEPRECATED(func) func __attribute__ ((deprecated))
21 #else
22 #define DEPRECATED(func) func
23 #endif
24 
28 #define VRNA_INPUT_ERROR 1U
29 
32 #define VRNA_INPUT_QUIT 2U
33 
36 #define VRNA_INPUT_MISC 4U
37 
44 #define VRNA_INPUT_FASTA_HEADER 8U
45 
50 #define VRNA_INPUT_SEQUENCE 16U
51 
56 #define VRNA_INPUT_CONSTRAINT 32U
57 
62 #define VRNA_INPUT_NO_TRUNCATION 256U
63 
67 #define VRNA_INPUT_NO_REST 512U
68 
72 #define VRNA_INPUT_NO_SPAN 1024U
73 
77 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U
78 
82 #define VRNA_INPUT_BLANK_LINE 4096U
83 
87 #define VRNA_INPUT_NOSKIP_COMMENTS 128U
88 
92 #define VRNA_INPUT_COMMENT 8192U
93 
94 
95 
96 
100 #define VRNA_CONSTRAINT_PIPE 1U
101 
104 #define VRNA_CONSTRAINT_DOT 2U
105 
108 #define VRNA_CONSTRAINT_X 4U
109 
112 #define VRNA_CONSTRAINT_ANG_BRACK 8U
113 
116 #define VRNA_CONSTRAINT_RND_BRACK 16U
117 
120 #define VRNA_CONSTRAINT_MULTILINE 32U
121 
124 #define VRNA_CONSTRAINT_NO_HEADER 64U
125 
128 #define VRNA_CONSTRAINT_ALL 128U
129 
132 #define VRNA_CONSTRAINT_G 256U
133 
134 
135 
144 #define VRNA_OPTION_MULTILINE 32U
145 
146 
150 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
151 
154 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
155 
158 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C)))
159 
162 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C)))
163 
164 
168 #define XSTR(s) STR(s)
169 
172 #define STR(s) #s
173 
174 #ifndef FILENAME_MAX_LENGTH
175 
181 #define FILENAME_MAX_LENGTH 80
182 
188 #define FILENAME_ID_LENGTH 42
189 #endif
190 
191 
192 #ifdef HAVE_CONFIG_H
193 #include <config.h>
194 #ifndef HAVE_STRDUP
195 char *strdup(const char *s);
196 #endif
197 #endif
198 #ifdef WITH_DMALLOC
199 /* use dmalloc library to check for memory management bugs */
200 #include "dmalloc.h"
201 #define space(S) calloc(1,(S))
202 #else
203 
210 /*@only@*/ /*@notnull@*/
211 void *space(unsigned size) /*@ensures MaxSet(result) == (size-1);@*/;
212 
220 /*@only@*/ /*@notnull@*/
221 void *xrealloc(/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p,
222  unsigned size) /*@modifies *p @*/ /*@ensures MaxSet(result) == (size-1) @*/;
223 #endif
224 
231 /*@exits@*/
232 void nrerror(const char message[]);
233 
241 void warn_user(const char message[]);
242 
246 void init_rand(void);
247 
256 extern unsigned short xsubi[3];
257 
264 double urn(void);
265 
273 int int_urn(int from, int to);
274 
275 void filecopy(FILE *from, FILE *to); /* inefficient `cp' */
276 
285 /*@observer@*/
286 char *time_stamp(void);
287 
295 /*@only@*/ /*@notnull@*/
296 char *random_string(int l, const char symbols[]);
297 
306 int hamming(const char *s1, const char *s2);
307 
317 int hamming_bound(const char *s1, const char *s2, int n);
318 
329 /*@only@*/ /*@null@*/
330 char *get_line(FILE *fp);
331 
352 unsigned int get_input_line(char **string,
353  unsigned int options);
354 
355 
356 
362 void print_tty_input_seq(void);
363 
372 void print_tty_input_seq_str(const char *s);
373 
381 void str_DNA2RNA(char *sequence);
382 
388 void str_uppercase(char *sequence);
389 
403 int *get_iindx(unsigned int length);
404 
419 int *get_indx(unsigned int length);
420 
421 
428 
433 short *vrna_seq_encode(const char *sequence, model_detailsT *md);
434 
435 short *vrna_seq_encode_simple(const char *sequence, model_detailsT *md);
436 
437 
438 char get_encoded_char(int enc, model_detailsT *md);
439 
440 void vrna_ali_encode(const char *sequence,
441  short **S_p,
442  short **s5_p,
443  short **s3_p,
444  char **ss_p,
445  unsigned short **as_p,
446  model_detailsT *md);
447 
456 char *vrna_get_ptypes( const short *S,
457  model_detailsT *md);
458 
459 DEPRECATED(char *get_ptypes(const short *S,
460  model_detailsT *md,
461  unsigned int idx_type));
462 
463 int *get_pscores( const short *const* S,
464  const char **AS,
465  int n_seq,
466  float **distance_matrix,
467  model_detailsT *md);
468 
469 #endif
void * space(unsigned size)
Allocate space safely.
char * vrna_get_ptypes(const short *S, model_detailsT *md)
Get an array of the numerical encoding for each possible base pair (i,j)
short * vrna_seq_encode(const char *sequence, model_detailsT *md)
Get the integer encoding of the sequence according to the model details and encoding type...
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.
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.
unsigned int get_input_line(char **string, unsigned int options)
char * random_string(int l, const char symbols[])
Create a random string using characters from a specified symbol set.
All datastructures and typedefs shared among the Vienna RNA Package can be found here.
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 * get_indx(unsigned int length)
Get an index mapper array (indx) for accessing the energy matrices, e.g. in MFE related functions...
int hamming_bound(const char *s1, const char *s2, int n)
Calculate hamming distance between two sequences up to a specified length.
void fill_pair_matrices(model_detailsT *md)
Fill the base pair type encodings according to the model details.
void nrerror(const char message[])
Die with an error message.
int * get_iindx(unsigned int length)
Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function relat...
void * xrealloc(void *p, unsigned size)
Reallocate space safely.
void print_tty_input_seq_str(const char *s)
Print a line with a user defined string and a ruler to stdout.
The data structure that contains the complete model details used throughout the calculations.
Definition: model.h:206
double urn(void)
get a random number from [0..1]
void init_rand(void)
Make random number seeds.
unsigned short xsubi[3]
Current 48 bit random number.
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.