# (Abstract) Data Structures

All datastructures and typedefs shared among the ViennaRNA Package can be found here.

Specialized Modules:

- The Fold Compound
- The Dynamic Programming Matrices
- Hash Tables
- Heaps
- Arrays
- Strings
- Buffers

## Common Data Structures

  Typedefs

  typedef struct vrna_elem_prob_s vrna_plist_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for the base pair list repesenting data structure vrna_elem_prob_s.

  typedef struct vrna_cpair_s vrna_cpair_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for data structure vrna_cpair_s.

  typedef struct vrna_data_linear_s vrna_data_lin_t
    #include <ViennaRNA/datastructures/basic.h>
  typedef struct vrna_color_s vrna_color_t
    #include <ViennaRNA/datastructures/basic.h>
  typedef double FLT_OR_DBL
    #include <ViennaRNA/datastructures/basic.h>

    Typename for floating point number in partition function computations.

  typedef struct vrna_basepair_s PAIR
    #include <ViennaRNA/datastructures/basic.h>

    Old typename of vrna_basepair_s.

    Deprecated:

      Use vrna_basepair_t instead!

  typedef struct vrna_elem_prob_s plist
    #include <ViennaRNA/datastructures/basic.h>

    Old typename of vrna_elem_prob_s.

    Deprecated:

      Use vrna_ep_t or vrna_elem_prob_s instead!

  typedef struct vrna_cpair_s cpair
    #include <ViennaRNA/datastructures/basic.h>

    Old typename of vrna_cpair_s.

    Deprecated:

      Use vrna_cpair_t instead!

  typedef struct vrna_sect_s sect
    #include <ViennaRNA/datastructures/basic.h>

    Old typename of vrna_sect_s.

    Deprecated:

      Use vrna_sect_t instead!

  typedef vrna_bp_stack_t bondT
    #include <ViennaRNA/datastructures/basic.h>

    Old typename of #vrna_bp_stack_s.

    Deprecated:

      Use vrna_bp_stack_t instead!

  typedef struct pu_contrib pu_contrib
    #include <ViennaRNA/datastructures/basic.h>

    contributions to p_u

  typedef struct interact interact
    #include <ViennaRNA/datastructures/basic.h>

    interaction data structure for RNAup

  typedef struct pu_out pu_out
    #include <ViennaRNA/datastructures/basic.h>

    Collection of all free_energy of beeing unpaired values for output.

  typedef struct constrain constrain
    #include <ViennaRNA/datastructures/basic.h>

    constraints for cofolding

  typedef struct node folden
    #include <ViennaRNA/datastructures/basic.h>

    Data structure for RNAsnoop (fold energy list)

  typedef struct dupVar dupVar
    #include <ViennaRNA/datastructures/basic.h>

    Data structure used in RNApkplex.

  struct vrna_basepair_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for base pair element.

    Deprecated:

      Use vrna_bp_t instead!

    Public Members

    int i
    int j
  struct vrna_bp_stack_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for the base pair stack element.

    Public Members

    unsigned int i
    unsigned int j
  struct pu_contrib
    #include <ViennaRNA/datastructures/basic.h>

    contributions to p_u

    Public Members

    double **H

      hairpin loops

    double **I

      internal loops

    double **M

      multi loops

    double **E

      exterior loop

    int length

      length of the input sequence

    int w

      longest unpaired region

  struct interact
    #include <ViennaRNA/datastructures/basic.h>

    interaction data structure for RNAup

    Public Members

    double *Pi

      probabilities of interaction

    double *Gi

      free energies of interaction

    double Gikjl

      full free energy for interaction between [k,i] k<i in longer seq and [j,l] j<l in shorter seq

    double Gikjl_wo

      Gikjl without contributions for prob_unpaired.

    int i

      k<i in longer seq

    int k

      k<i in longer seq

    int j

      j<l in shorter seq

    int l

      j<l in shorter seq

    int length

      length of longer sequence

  struct pu_out
    #include <ViennaRNA/datastructures/basic.h>

    Collection of all free_energy of beeing unpaired values for output.

    Public Members

    int len

      sequence length

    int u_vals

      number of different -u values

    int contribs

      [-c “SHIME”]

    char **header

      header line

    double **u_values

      (the -u values * [-c “SHIME”]) * seq len

  struct constrain
    #include <ViennaRNA/datastructures/basic.h>

    constraints for cofolding

    Public Members

    int *indx
    char *ptype
  struct duplexT
    #include <ViennaRNA/datastructures/basic.h>

    Data structure for RNAduplex.

    Public Members

    int i
    int j
    int end
    char *structure
    double energy
    double energy_backtrack
    double opening_backtrack_x
    double opening_backtrack_y
    int offset
    double dG1
    double dG2
    double ddG
    int tb
    int te
    int qb
    int qe
  struct node
    #include <ViennaRNA/datastructures/basic.h>

    Data structure for RNAsnoop (fold energy list)

    Public Members

    int k
    int energy
    struct node *next
  struct snoopT
    #include <ViennaRNA/datastructures/basic.h>

    Data structure for RNAsnoop.

    Public Members

    int i
    int j
    int u
    char *structure
    float energy
    float Duplex_El
    float Duplex_Er
    float Loop_E
    float Loop_D
    float pscd
    float psct
    float pscg
    float Duplex_Ol
    float Duplex_Or
    float Duplex_Ot
    float fullStemEnergy
  struct dupVar
    #include <ViennaRNA/datastructures/basic.h>

    Data structure used in RNApkplex.

    Public Members

    int i
    int j
    int end
    char *pk_helix
    char *structure
    double energy
    int offset
    double dG1
    double dG2
    double ddG
    int tb
    int te
    int qb
    int qe
    int inactive
    int processed

## Backtracking Related Data Structures

  Typedefs

  typedef struct vrna_bt_stack_s *vrna_bts_t
    #include <ViennaRNA/datastructures/basic.h>

    The backtrack stack data structure.

    See also

    vrna_bts_init(), vrna_bts_free(), vrna_bts_push(), vrna_bts_top(), vrna_bts_pop()

  typedef struct vrna_bp_stack_s *vrna_bps_t
    #include <ViennaRNA/datastructures/basic.h>

    The basepair stack data structure.

    See also

    vrna_bps_init(), vrna_bps_free(), vrna_bps_push(), vrna_bps_top(), vrna_bps_pop(), vrna_bps_at()

  typedef struct vrna_basepair_s vrna_bp_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for the base pair repesenting data structure vrna_basepair_s.

  typedef struct vrna_sect_s vrna_sect_t
    #include <ViennaRNA/datastructures/basic.h>

    Typename for stack of partial structures vrna_sect_s.

  Functions

  vrna_bts_t vrna_bts_init(size_t n)
    #include <ViennaRNA/datastructures/basic.h>

    Get an initialized backtrack stack.

    This function yields an initialized backtracking stack that holds all elements that need to be further evaluated. The individual elements stored in the stack are of type vrna_sect_t and store the sequence delimiters and corresponding backtrack DP matrix flag.

    See also

    vrna_bts_t, vrna_bts_free(), vrna_bts_push(), vrna_bts_top(),vrna_bts_pop(), vrna_bts_size(),

    Note

    Memory for the stack must be released via the vrna_bts_free() function.

    Parameters:

      - n – The initial size of the backtrack stack

    Returns:

      An initialized backtrack stack, ready for usage in backtracking functions

  void vrna_bts_free(vrna_bts_t bts)
    #include <ViennaRNA/datastructures/basic.h>

    Release memory occupied by a backtrack stack.

    Parameters:

      - bts – The backtrack stack that should be free’d

  size_t vrna_bts_push(vrna_bts_t bts, vrna_sect_t element)
    #include <ViennaRNA/datastructures/basic.h>

    Push a new interval onto the backtrack stack.

    This function pushes a new sequence interval for backtracking onto the backstracking stack `bts`.

    Parameters:

      - bts – The backtrack stack

      - element – The sequence interval and corresponding DP matrix flag

    Returns:

      The size of the backtrack stack after pushing the new interval

  vrna_sect_t vrna_bts_top(vrna_bts_t bts)
    #include <ViennaRNA/datastructures/basic.h>

    Retrieve the top element of the backtrack stack.

    Retrieves the last element put onto the stack, or a zero’d out vrna_sect_t structure. The latter is returned on error or when topping an empty stack.

    Parameters:

      - bts – The backtrack stack

    Returns:

      The top element of the backtrack stack, or a zero’d out vrna_sect_t

  vrna_sect_t vrna_bts_pop(vrna_bts_t bts)
    #include <ViennaRNA/datastructures/basic.h>

    Pop last element of from backtrack stack.

    Retrieves and removes the last element put onto the stack, or a zero’d out vrna_sect_t structure. The latter is returned on error or when topping an empty stack.

    Parameters:

      - bts – The backtrack stack

    Returns:

      The top element of the backtrack stack, or a zero’d out vrna_sect_t

  size_t vrna_bts_size(vrna_bts_t bts)
    #include <ViennaRNA/datastructures/basic.h>

    Get the size of the backtrack stack.

    Parameters:

      - bts – The backtrack stack

    Returns:

      The size of the backtracking stack

  vrna_bps_t vrna_bps_init(size_t n)
    #include <ViennaRNA/datastructures/basic.h>

    Get an initialized base pair stack.

    Base pair stacks are used in the backtracking procedure to store all base pairs and structural elements that have been identified so far. Thos function returns an initialized backtracking stack with initial size `n`. Individual elements stored in this stack are of type vrna_bp_t.

    Note

    Memory for the stack must be released via the vrna_bps_free() function.

    Parameters:

      - n – The initial size of the base pair stack

    Returns:

      An initialized base pair stack

  void vrna_bps_free(vrna_bps_t bps)
    #include <ViennaRNA/datastructures/basic.h>

    Release memory of a base pair stack.

    Parameters:

      - bps – The base pair stack to be free’d

  size_t vrna_bps_push(vrna_bps_t bps, vrna_bp_t pair)
    #include <ViennaRNA/datastructures/basic.h>

    Put a new base pair element on top of the stack.

    Parameters:

      - bps – The base pair stack

      - pair – The base pair to be put onto the stack

    Returns:

      The size of the base pair stack after pushing the base pair

  vrna_bp_t vrna_bps_top(vrna_bps_t bps)
    #include <ViennaRNA/datastructures/basic.h>

    Retrieve the top element of the base pair stack.

    Retrieves the last element put onto the stack, or a zero’d out vrna_bp_t structure. The latter is returned on error or when topping an empty stack.

    Parameters:

      - bps – The base pair stack

    Returns:

      The top element of the base pair stack, or a zero’d out vrna_bp_t

  vrna_bp_t vrna_bps_pop(vrna_bps_t bps)
    #include <ViennaRNA/datastructures/basic.h>

    Pop last element of from base pair stack.

    Retrieves and removes the last element put onto the stack, or a zero’d out vrna_bp_t structure. The latter is returned on error or when topping an empty stack.

    Parameters:

      - bps – The base pair stack

    Returns:

      The top element of the backtrack stack, or a zero’d out vrna_bp_t

  vrna_bp_t vrna_bps_at(vrna_bps_t bps, size_t n)
    #include <ViennaRNA/datastructures/basic.h>

    Retrieve the n’th element of the base pair stack.

    Retrieves the n’th element counted from the bottom of the stack (0-based), or a zero’d out vrna_bp_t structure. The latter is returned on error or when `n` is outside the size of the stack.

    Parameters:

      - bps – The base pair stack

      - n – The position within the stack

    Returns:

      The n’th element of the base pair stack, or a zero’d out vrna_bp_t

  size_t vrna_bps_size(vrna_bps_t bps)
    #include <ViennaRNA/datastructures/basic.h>

    Get the size of the base pair stack.

    Parameters:

      - bps – The base pair stack

    Returns:

      The size of the base pair stack

  struct vrna_sect_s
    #include <ViennaRNA/datastructures/basic.h>

    Stack of partial structures for backtracking.

    Public Members

    int i
    int j
    unsigned int ml
  struct vrna_basepair_s
    #include <ViennaRNA/datastructures/basic.h>

    Base pair data structure used in subopt.c.

    Public Members

    unsigned int i
    unsigned int j
    unsigned int L
    unsigned int l[3]