Utilities — ViennaRNA Package

# Utilities

Specialized Modules:

- Utilities to deal with Nucleotide Alphabets
- (Nucleic Acid Sequence) String Utilitites
- Secondary Structure Utilities
- Multiple Sequence Alignment Utilities
- Files and I/O
- Plotting
- Data Handling and Manipulation
- Search Algorithms
- Mathematical Functions
- Combinatorics Algorithms
- (Abstract) Data Structures
- Messages
- Log Messages
- Unit Conversion

  Defines

  PUBLIC

        #include <ViennaRNA/utils/basic.h>

  PRIVATE

        #include <ViennaRNA/utils/basic.h>

  VRNA_UNUSED

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_ERROR

    Output flag of get_input_line(): “An ERROR has occured, maybe EOF”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_QUIT

    Output flag of get_input_line(): “the user requested quitting the program”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_MISC

    Output flag of get_input_line(): “something was read”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_FASTA_HEADER

    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.

        #include <ViennaRNA/utils/basic.h>

    the function will return this flag if a fasta header was read

  VRNA_INPUT_SEQUENCE

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_CONSTRAINT

    Input flag for get_input_line()

    :

    Tell

    get_input_line() that we assume to read a structure constraint.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_NO_TRUNCATION

    Input switch for get_input_line(): “do not trunkate the line by eliminating white spaces at end of line”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_NO_REST

    Input switch for vrna_file_fasta_read_record(): “do fill rest array”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_NO_SPAN

    Input switch for vrna_file_fasta_read_record(): “never allow data to span more than one line”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_NOSKIP_BLANK_LINES

    Input switch for vrna_file_fasta_read_record(): “do not skip empty lines”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_BLANK_LINE

    Output flag for vrna_file_fasta_read_record(): “read an empty line”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_NOSKIP_COMMENTS

    Input switch for get_input_line(): “do not skip comment lines”.

        #include <ViennaRNA/utils/basic.h>

  VRNA_INPUT_COMMENT

    Output flag for vrna_file_fasta_read_record(): “read a comment”.

        #include <ViennaRNA/utils/basic.h>

  MIN2(A, B)

    Get the minimum of two comparable values.

        #include <ViennaRNA/utils/basic.h>

  MAX2(A, B)

    Get the maximum of two comparable values.

        #include <ViennaRNA/utils/basic.h>

  MIN3(A, B, C)

    Get the minimum of three comparable values.

        #include <ViennaRNA/utils/basic.h>

  MAX3(A, B, C)

    Get the maximum of three comparable values.

        #include <ViennaRNA/utils/basic.h>

  Functions

  void *vrna_alloc(size_t size)

    Allocate space safely.

        #include <ViennaRNA/utils/basic.h>

    Parameters:

      - size – The size of the memory to be allocated in bytes

    Returns:

      A pointer to the allocated memory

  void *vrna_realloc(void *p, size_t size)

    Reallocate space safely.

        #include <ViennaRNA/utils/basic.h>

    Parameters:

      - p – A pointer to the memory region to be reallocated

      - size – The size of the memory to be allocated in bytes

    Returns:

      A pointer to the newly allocated memory

  void vrna_init_rand(void)

    Initialize seed for random number generator.

        #include <ViennaRNA/utils/basic.h>

    See also

    vrna_init_rand_seed(), vrna_urn()

  void vrna_init_rand_seed(unsigned int seed)

    Initialize the random number generator with a pre-defined seed.

        #include <ViennaRNA/utils/basic.h>

    SWIG Wrapper Notes:

      This function is available as an overloaded function init_rand() where the argument `seed` is optional. See, e.g. `RNA.init_rand()` in the Python API.

    See also

    vrna_init_rand(), vrna_urn()

    Parameters:

      - seed – The seed for the random number generator

  double vrna_urn(void)

    get a random number from [0..1]

        #include <ViennaRNA/utils/basic.h>

    See also

    vrna_int_urn(), vrna_init_rand(), vrna_init_rand_seed()

    Note

    Usually implemented by calling erand48().

    Returns:

      A random number in range [0..1]

  int vrna_int_urn(int from, int to)

    Generates a pseudo random integer in a specified range.

        #include <ViennaRNA/utils/basic.h>

    See also

    vrna_urn(), vrna_init_rand()

    Parameters:

      - from – The first number in range

      - to – The last number in range

    Returns:

      A pseudo random number in range [from, to]

  char *vrna_time_stamp(void)

    Get a timestamp.

        #include <ViennaRNA/utils/basic.h>

    Returns a string containing the current date in the format

        Fri Mar 19 21:10:57 1993

    Returns:

      A string containing the timestamp

  unsigned int get_input_line(char **string, unsigned int options)

        #include <ViennaRNA/utils/basic.h>

    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 one to switch between different reading modes.

    Currently available options are:

    VRNA_INPUT_COMMENT, VRNA_INPUT_NOSKIP_COMMENTS, VRNA_INPUT_NO_TRUNCATION

    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

    Parameters:

      - string – A pointer to the character array that contains the line read

      - options – A collection of options for switching the functions behavior

    Returns:

      A flag with information about what has been read

  int *vrna_idx_row_wise(unsigned int length)

    Get an index mapper array (iindx) for accessing the energy matrices, e.g. in partition function related functions.

        #include <ViennaRNA/utils/basic.h>

    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 ViennaRNA Package

    Consult the implemented code to find out about the mapping formula ;)

    See also

    vrna_idx_col_wise()

    Parameters:

      - length – The length of the RNA sequence

    Returns:

      The mapper array

  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.

        #include <ViennaRNA/utils/basic.h>

    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 ;)

    See also

    vrna_idx_row_wise()

    Parameters:

      - length – The length of the RNA sequence

    Returns:

      The mapper array

  Variables

  unsigned short xsubi[3]

    Current 48 bit random number.

        #include <ViennaRNA/utils/basic.h>

    This variable is used by vrna_urn(). These should be set to some random number seeds before the first call to vrna_urn().

    See also

    vrna_urn()