# G-Quadruplexes

## Introduction

## Energy Evaluation

  Functions

  int vrna_E_gquad(unsigned int L, unsigned int l[3], vrna_param_t *P)
    #include <ViennaRNA/eval/gquad.h>
  FLT_OR_DBL vrna_exp_E_gquad(unsigned int L, unsigned int l[3], vrna_exp_param_t *pf)
    #include <ViennaRNA/eval/gquad.h>
  void vrna_E_consensus_gquad(unsigned int L, unsigned int l[3], unsigned int position, unsigned int length, unsigned int n_seq, const short **S, const unsigned int **a2s, vrna_param_t *P, int en[2])
    #include <ViennaRNA/eval/gquad.h>
  FLT_OR_DBL vrna_exp_E_consensus_gquad(unsigned int L, unsigned int l[3], vrna_exp_param_t *pf, unsigned int position, unsigned int length, unsigned int n_seq, const short **S, const unsigned int **a2s)
    #include <ViennaRNA/eval/gquad.h>
  int vrna_mfe_gquad_internal_loop( vrna_fold_compound_t *fc, unsigned int i, unsigned int j)
    #include <ViennaRNA/mfe/gquad.h>
  FLT_OR_DBL vrna_gq_int_loop_pf( vrna_fold_compound_t *fc, unsigned int i, unsigned int j)
    #include <ViennaRNA/partfunc/gquad.h>
  vrna_array (int) vrna_gq_int_loop_subopt(vrna_fold_compound_t *fc
    #include <ViennaRNA/subopt/gquad.h>
  unsigned int unsigned int vrna_array (unsigned int) *p_p
    #include <ViennaRNA/subopt/gquad.h>
  void get_gquad_pattern_exhaustive(short *S, unsigned int i, unsigned int j, vrna_param_t *P, unsigned int *L, unsigned int *l, int threshold)
    #include <ViennaRNA/subopt/gquad.h>
  unsigned int get_gquad_count(short *S, unsigned int i, unsigned int j)
    #include <ViennaRNA/subopt/gquad.h>

  Variables

  unsigned int i
  unsigned int unsigned int j
  unsigned int unsigned int int threshold

## Dynamic Programming Matrices

  Functions

  vrna_smx_csr_FLT_OR_DBL_t *vrna_gq_pos_pf( vrna_fold_compound_t *fc)
    #include <ViennaRNA/partfunc/gquad.h>

## Backtracking

  Functions

  int vrna_bt_gquad( vrna_fold_compound_t *fc, unsigned int i, unsigned int j, unsigned int *L, unsigned int l[3])
    #include <ViennaRNA/backtrack/gquad.h>
  int vrna_bt_gquad_mfe( vrna_fold_compound_t *fc, unsigned int i, unsigned int j, vrna_bps_t bp_stack)
    #include <ViennaRNA/backtrack/gquad.h>
  int vrna_bt_gquad_internal( vrna_fold_compound_t *fc, unsigned int i, unsigned int j, int en, vrna_bps_t bp_stack, vrna_bts_t bt_stack)
    #include <ViennaRNA/backtrack/gquad.h>

## Parsing

  Functions

  void get_gquad_pattern_pf(short *S, int i, int j, vrna_exp_param_t *pf, int *L, int l[3])
    #include <ViennaRNA/partfunc/gquad.h>
  void vrna_get_gquad_pattern_pf( vrna_fold_compound_t *fc, unsigned int i, unsigned int j, unsigned int *L, unsigned int[3])
    #include <ViennaRNA/partfunc/gquad.h>
  unsigned int vrna_gq_parse(const char *db_string, unsigned int *L, unsigned int l[3])
    #include <ViennaRNA/structures/dotbracket.h>

    Parse a G-Quadruplex from a dot-bracket structure string.

    Given a dot-bracket structure (possibly) containing gquads encoded by ‘+’ signs (and an optional ‘~’ end sign, find first gquad, return end position (1-based) or 0 if none found. Upon return L and l[] contain the number of stacked layers, as well as the lengths of the linker regions.

    To parse a string with many gquads, call vrna_gq_parse() repeatedly e.g.

        end1 = vrna_gq_parse(struc, &L, l); ... ;
        end2 = vrna_gq_parse(struc+end1, &L, l); end2+=end1; ... ;
        end3 = vrna_gq_parse(struc+end2, &L, l); end3+=end2; ... ;

    Note

    For circular RNAs and G-Quadruplexes spanning the n,1-junction the sum of linkers and g-runs is lower than the end position. This condition can be used to check whether or not to accept a G-Quadruplex parsed from the dot-bracket string. Also note, that such n,1-junction spanning G-Quadruplexes must end with a `~` sign, to be unambigous.

    Parameters:

      - db_string – The input structure in dot-bracket notation

      - L – A pointer to an unsigned integer to store the layer (stack) size

      - l – An array of three values to store the respective linker lenghts

    Returns:

      The end position of the G-Quadruplex (1-based) or 0 if not found

  void vrna_db_insert_gq(char *db, unsigned int i, unsigned int L, unsigned int l[3], unsigned int n)
    #include <ViennaRNA/structures/dotbracket.h>
  plist *get_plist_gquad_from_db(const char *structure, float pr)
    #include <ViennaRNA/structures/problist.h>

## Other

  Functions

  plist * get_plist_gquad_from_pr (short *S, int gi, int gj, vrna_smx_csr(FLT_OR_DBL) *q_gq, FLT_OR_DBL *probs, FLT_OR_DBL *scale, vrna_exp_param_t *pf)
    #include <ViennaRNA/partfunc/gquad.h>
  vrna_ep_t *vrna_plist_gquad_from_pr( vrna_fold_compound_t *fc, int gi, int gj)
    #include <ViennaRNA/partfunc/gquad.h>
  plist * get_plist_gquad_from_pr_max (short *S, int gi, int gj, vrna_smx_csr(FLT_OR_DBL) *q_gq, FLT_OR_DBL *probs, FLT_OR_DBL *scale, int *L, int l[3], vrna_exp_param_t *pf)
    #include <ViennaRNA/partfunc/gquad.h>
  vrna_ep_t *vrna_plist_gquad_from_pr_max( vrna_fold_compound_t *fc, unsigned int gi, unsigned int gj, unsigned int *Lmax, unsigned int lmax[3])
    #include <ViennaRNA/partfunc/gquad.h>

## Deprecated

  Functions

  int vrna_BT_gquad_mfe( vrna_fold_compound_t *fc, int i, int j, vrna_bp_stack_t *bp_stack, unsigned int *stack_count)
    #include <ViennaRNA/backtrack/gquad.h>
  int vrna_BT_gquad_int( vrna_fold_compound_t *fc, int i, int j, int en, vrna_bp_stack_t *bp_stack, unsigned int *stack_count)
    #include <ViennaRNA/backtrack/gquad.h>
  int backtrack_GQuad_IntLoop_L(int c, int i, int j, int type, short *S, int **ggg, int maxdist, int *p, int *q, vrna_param_t *P)
    #include <ViennaRNA/backtrack/gquad.h>

    backtrack an internal loop like enclosed g-quadruplex with closing pair (i,j) with underlying Lfold matrix

    Parameters:

      - c – The total contribution the loop should resemble

      - i – position i of enclosing pair

      - j – position j of enclosing pair

      - type – base pair type of enclosing pair (must be reverse type)

      - S – integer encoded sequence

      - ggg – triangular matrix containing g-quadruplex contributions

      - p – here the 5’ position of the gquad is stored

      - q – here the 3’ position of the gquad is stored

      - P – the datastructure containing the precalculated contibutions

    Returns:

      1 on success, 0 if no gquad found

  int backtrack_GQuad_IntLoop_L_comparative(int c, int i, int j, unsigned int *type, short *S_cons, short **S5, short **S3, unsigned int **a2s, int **ggg, int *p, int *q, int n_seq, vrna_param_t *P)
    #include <ViennaRNA/backtrack/gquad.h>
  int E_gquad(int L, int l[3], vrna_param_t *P)
    #include <ViennaRNA/eval/gquad.h>
  FLT_OR_DBL exp_E_gquad(int L, int l[3], vrna_exp_param_t *pf)
    #include <ViennaRNA/eval/gquad.h>
  void E_gquad_ali_en(int i, int L, int l[3], const short **S, unsigned int **a2s, unsigned int n_seq, vrna_param_t *P, int en[2])
    #include <ViennaRNA/eval/gquad.h>
  FLT_OR_DBL exp_E_gquad_ali(int i, int L, int l[3], short **S, unsigned int **a2s, int n_seq, vrna_exp_param_t *pf)
    #include <ViennaRNA/eval/gquad.h>
  DEPRECATED (FLT_OR_DBL *get_gquad_pf_matrix(short *S, FLT_OR_DBL *scale, vrna_exp_param_t *pf), "Use vrna_gq_pos_pf() instead")
    #include <ViennaRNA/partfunc/gquad.h>
  DEPRECATED (FLT_OR_DBL *get_gquad_pf_matrix_comparative(unsigned int n, short *S_cons, short **S, unsigned int **a2s, FLT_OR_DBL *scale, unsigned int n_seq, vrna_exp_param_t *pf), "Use vrna_gq_pos_pf() instead")
    #include <ViennaRNA/partfunc/gquad.h>
  int parse_gquad(const char *struc, int *L, int l[3])
    #include <ViennaRNA/structures/dotbracket.h>

    Parse a G-Quadruplex from a dot-bracket structure string.

    Given a dot-bracket structure (possibly) containing gquads encoded by ‘+’ signs, find first gquad, return end position or 0 if none found Upon return L and l[] contain the number of stacked layers, as well as the lengths of the linker regions. To parse a string with many gquads, call parse_gquad repeatedly e.g. end1 = parse_gquad(struc, &L, l); … ; end2 = parse_gquad(struc+end1, &L, l); end2+=end1; … ; end3 = parse_gquad(struc+end2, &L, l); end3+=end2; … ;