RNAlib-2.2.0RC0
|
Various utility- and helper-functions used throughout the Vienna RNA package. More...
Go to the source code of this file.
Macros | |
#define | VRNA_INPUT_ERROR 1U |
#define | VRNA_INPUT_QUIT 2U |
#define | VRNA_INPUT_MISC 4U |
#define | VRNA_INPUT_FASTA_HEADER 8U |
#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 | VRNA_CONSTRAINT_PIPE 1U |
#define | VRNA_CONSTRAINT_DOT 2U |
#define | VRNA_CONSTRAINT_X 4U |
#define | VRNA_CONSTRAINT_ANG_BRACK 8U |
#define | VRNA_CONSTRAINT_RND_BRACK 16U |
#define | VRNA_CONSTRAINT_MULTILINE 32U |
#define | VRNA_CONSTRAINT_NO_HEADER 64U |
#define | VRNA_CONSTRAINT_ALL 128U |
#define | VRNA_CONSTRAINT_G 256U |
#define | VRNA_OPTION_MULTILINE 32U |
#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))) |
#define | XSTR(s) STR(s) |
#define | STR(s) #s |
#define | FILENAME_MAX_LENGTH 80 |
Maximum length of filenames that are generated by our programs. More... | |
#define | FILENAME_ID_LENGTH 42 |
Maximum length of id taken from fasta header for filename generation. More... | |
Functions | |
void * | space (unsigned size) |
Allocate space safely. More... | |
void * | xrealloc (void *p, unsigned size) |
Reallocate space safely. More... | |
void | nrerror (const char message[]) |
Die with an error message. More... | |
void | warn_user (const char message[]) |
Print a warning message. More... | |
void | init_rand (void) |
Make random number seeds. | |
double | urn (void) |
get a random number from [0..1] More... | |
int | int_urn (int from, int to) |
Generates a pseudo random integer in a specified range. More... | |
char * | time_stamp (void) |
Get a timestamp. More... | |
char * | random_string (int l, const char symbols[]) |
Create a random string using characters from a specified symbol set. More... | |
int | hamming (const char *s1, const char *s2) |
Calculate hamming distance between two sequences. More... | |
int | hamming_bound (const char *s1, const char *s2, int n) |
Calculate hamming distance between two sequences up to a specified length. More... | |
char * | get_line (FILE *fp) |
Read a line of arbitrary length from a stream. More... | |
unsigned int | get_input_line (char **string, unsigned int options) |
void | print_tty_input_seq (void) |
Print a line to stdout that asks for an input sequence. More... | |
void | print_tty_input_seq_str (const char *s) |
Print a line with a user defined string and a ruler to stdout. More... | |
void | str_DNA2RNA (char *sequence) |
Convert a DNA input sequence to RNA alphabet. More... | |
void | str_uppercase (char *sequence) |
Convert an input sequence to uppercase. More... | |
int * | get_iindx (unsigned int length) |
Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function related functions. More... | |
int * | get_indx (unsigned int length) |
Get an index mapper array (indx) for accessing the energy matrices, e.g. in MFE related functions. More... | |
void | fill_pair_matrices (model_detailsT *md) |
Fill the base pair type encodings according to the model details. More... | |
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. | |
char * | vrna_get_ptypes (const short *S, model_detailsT *md) |
Get an array of the numerical encoding for each possible base pair (i,j) More... | |
Variables | |
unsigned short | xsubi [3] |
Current 48 bit random number. More... | |
Various utility- and helper-functions used throughout the Vienna RNA package.
#define VRNA_INPUT_ERROR 1U |
Output flag of get_input_line(): "An ERROR has occured, maybe EOF"
#define VRNA_INPUT_QUIT 2U |
Output flag of get_input_line(): "the user requested quitting the program"
#define VRNA_INPUT_MISC 4U |
Output flag of get_input_line(): "something was read"
#define VRNA_INPUT_FASTA_HEADER 8U |
Input/Output flag of get_input_line():
if used as input option this tells get_input_line() that the data to be read should comply with the FASTA format
the function will return this flag if a fasta header was read
#define VRNA_INPUT_SEQUENCE 16U |
Input flag for get_input_line():
Tell get_input_line() that we assume to read a nucleotide sequence
#define VRNA_INPUT_CONSTRAINT 32U |
Input flag for get_input_line():
Tell get_input_line() that we assume to read a structure constraint
#define VRNA_INPUT_NO_TRUNCATION 256U |
Input switch for get_input_line(): "do not trunkate the line by eliminating white spaces at end of line"
#define VRNA_INPUT_NO_REST 512U |
Input switch for read_record(): "do fill rest array"
#define VRNA_INPUT_NO_SPAN 1024U |
Input switch for read_record(): "never allow data to span more than one line"
#define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U |
Input switch for read_record(): "do not skip empty lines"
#define VRNA_INPUT_BLANK_LINE 4096U |
Output flag for read_record(): "read an empty line"
#define VRNA_INPUT_NOSKIP_COMMENTS 128U |
Input switch for get_input_line(): "do not skip comment lines"
#define VRNA_INPUT_COMMENT 8192U |
Output flag for read_record(): "read a comment"
#define VRNA_CONSTRAINT_PIPE 1U |
pipe sign '|' switch for structure constraints (paired with another base)
#define VRNA_CONSTRAINT_DOT 2U |
dot '.' switch for structure constraints (no constraint at all)
#define VRNA_CONSTRAINT_X 4U |
'x' switch for structure constraint (base must not pair)
#define VRNA_CONSTRAINT_ANG_BRACK 8U |
angle brackets '<', '>' switch for structure constraint (paired downstream/upstream)
#define VRNA_CONSTRAINT_RND_BRACK 16U |
round brackets '(',')' switch for structure constraint (base i pairs base j)
#define VRNA_CONSTRAINT_MULTILINE 32U |
constraint may span over several lines
#define VRNA_CONSTRAINT_NO_HEADER 64U |
do not print the header information line
#define VRNA_CONSTRAINT_ALL 128U |
placeholder for all constraining characters
#define VRNA_CONSTRAINT_G 256U |
'+' switch for structure constraint (base is involved in a gquad)
#define VRNA_OPTION_MULTILINE 32U |
Tell a function that an input is assumed to span several lines if used as input-option A function might also be returning this state telling that it has read data from multiple lines.
#define MIN2 | ( | A, | |
B | |||
) | ((A) < (B) ? (A) : (B)) |
Get the minimum of two comparable values
#define MAX2 | ( | A, | |
B | |||
) | ((A) > (B) ? (A) : (B)) |
Get the maximum of two comparable values
#define XSTR | ( | s | ) | STR(s) |
Stringify a macro after expansion
#define STR | ( | s | ) | #s |
Stringify a macro argument
#define FILENAME_MAX_LENGTH 80 |
Maximum length of filenames that are generated by our programs.
This definition should be used throughout the complete ViennaRNA package wherever a static array holding filenames of output files is declared.
#define FILENAME_ID_LENGTH 42 |
Maximum length of id taken from fasta header for filename generation.
this has to be smaller than FILENAME_MAX_LENGTH since in most cases, some suffix will be appended to the ID
void* space | ( | unsigned | size | ) |
Allocate space safely.
size | The size of the memory to be allocated in bytes |
void* xrealloc | ( | void * | p, |
unsigned | size | ||
) |
Reallocate space safely.
p | A pointer to the memory region to be reallocated |
size | The size of the memory to be allocated in bytes |
void nrerror | ( | const char | message[] | ) |
Die with an error message.
message | The error message to be printed before exiting with 'FAILURE' |
void warn_user | ( | const char | message[] | ) |
Print a warning message.
Print a warning message to stderr
message | The warning message |
double urn | ( | void | ) |
get a random number from [0..1]
int int_urn | ( | int | from, |
int | to | ||
) |
Generates a pseudo random integer in a specified range.
from | The first number in range |
to | The last number in range |
char* time_stamp | ( | void | ) |
Get a timestamp.
Returns a string containing the current date in the format
Fri Mar 19 21:10:57 1993
char* random_string | ( | int | l, |
const char | symbols[] | ||
) |
Create a random string using characters from a specified symbol set.
l | The length of the sequence |
symbols | The symbol set |
int hamming | ( | const char * | s1, |
const char * | s2 | ||
) |
Calculate hamming distance between two sequences.
Calculate the number of positions in which
s1 | The first sequence |
s2 | The second sequence |
int hamming_bound | ( | const char * | s1, |
const char * | s2, | ||
int | n | ||
) |
Calculate hamming distance between two sequences up to a specified length.
This function is similar to hamming() but instead of comparing both sequences up to their actual length only the first 'n' characters are taken into account
s1 | The first sequence |
s2 | The second sequence |
char* get_line | ( | FILE * | fp | ) |
Read a line of arbitrary length from a stream.
Returns a pointer to the resulting string. The necessary memory is allocated and should be released using free() when the string is no longer needed.
fp | A file pointer to the stream where the function should read from |
unsigned int get_input_line | ( | char ** | string, |
unsigned int | options | ||
) |
Retrieve a line from 'stdin' savely while skipping comment characters and other features This function returns the type of input it has read if recognized. An option argument allows to switch between different reading modes.
Currently available options are:
#VRNA_INPUT_NOPRINT_COMMENTS, VRNA_INPUT_NOSKIP_COMMENTS, #VRNA_INPUT_NOELIM_WS_SUFFIX
pass a collection of options as one value like this:
get_input_line(string, option_1 | option_2 | option_n)
If the function recognizes the type of input, it will report it in the return value. It also reports if a user defined 'quit' command (@-sign on 'stdin') was given. Possible return values are:
VRNA_INPUT_FASTA_HEADER, VRNA_INPUT_ERROR, VRNA_INPUT_MISC, VRNA_INPUT_QUIT
string | A pointer to the character array that contains the line read |
options | A collection of options for switching the functions behavior |
void print_tty_input_seq | ( | void | ) |
Print a line to stdout that asks for an input sequence.
There will also be a ruler (scale line) printed that helps orientation of the sequence positions
void print_tty_input_seq_str | ( | const char * | s | ) |
Print a line with a user defined string and a ruler to stdout.
(usually this is used to ask for user input) There will also be a ruler (scale line) printed that helps orientation of the sequence positions
s | A user defined string that will be printed to stdout |
void str_DNA2RNA | ( | char * | sequence | ) |
Convert a DNA input sequence to RNA alphabet.
This function substitudes T and t with U and u, respectively
sequence | The sequence to be converted |
void str_uppercase | ( | char * | sequence | ) |
Convert an input sequence to uppercase.
sequence | The sequence to be converted |
int* get_iindx | ( | unsigned int | length | ) |
Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function related functions.
Access of a position "(i,j)" is then accomplished by using
(i,j) ~ iindx[i]-j
This function is necessary as most of the two-dimensional energy matrices are actually one-dimensional arrays throughout the ViennaRNAPackage
Consult the implemented code to find out about the mapping formula ;)
length | The length of the RNA sequence |
int* get_indx | ( | unsigned int | length | ) |
Get an index mapper array (indx) for accessing the energy matrices, e.g. in MFE related functions.
Access of a position "(i,j)" is then accomplished by using
(i,j) ~ indx[j]+i
This function is necessary as most of the two-dimensional energy matrices are actually one-dimensional arrays throughout the ViennaRNAPackage
Consult the implemented code to find out about the mapping formula ;)
length | The length of the RNA sequence |
void fill_pair_matrices | ( | model_detailsT * | md | ) |
Fill the base pair type encodings according to the model details.
md | The model details datastructure |
char* vrna_get_ptypes | ( | const short * | S, |
model_detailsT * | md | ||
) |
Get an array of the numerical encoding for each possible base pair (i,j)