RNAlib-2.5.0
structures.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_STRUCT_UTILS_H
2 #define VIENNA_RNA_PACKAGE_STRUCT_UTILS_H
3 
4 #ifdef VRNA_WARN_DEPRECATED
5 # if defined(__clang__)
6 # define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
7 # elif defined(__GNUC__)
8 # define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
9 # else
10 # define DEPRECATED(func, msg) func
11 # endif
12 #else
13 # define DEPRECATED(func, msg) func
14 #endif
15 
33 typedef struct vrna_hx_s vrna_hx_t;
34 
35 
40 typedef struct vrna_elem_prob_s vrna_ep_t;
41 
42 
73 #define VRNA_BRACKETS_ALPHA 4U
74 
75 
81 #define VRNA_BRACKETS_RND 8U
82 
83 
89 #define VRNA_BRACKETS_CLY 16U
90 
91 
97 #define VRNA_BRACKETS_ANG 32U
98 
99 
105 #define VRNA_BRACKETS_SQR 64U
106 
107 
119 #define VRNA_BRACKETS_DEFAULT \
120  (VRNA_BRACKETS_RND | \
121  VRNA_BRACKETS_CLY | \
122  VRNA_BRACKETS_ANG | \
123  VRNA_BRACKETS_SQR)
124 
125 
132 #define VRNA_BRACKETS_ANY \
133  (VRNA_BRACKETS_RND | \
134  VRNA_BRACKETS_CLY | \
135  VRNA_BRACKETS_ANG | \
136  VRNA_BRACKETS_SQR | \
137  VRNA_BRACKETS_ALPHA)
138 
139 
140 #include <stdio.h>
141 
143 
156 char *
157 vrna_db_pack(const char *struc);
158 
159 
170 char *
171 vrna_db_unpack(const char *packed);
172 
173 
189 void
190 vrna_db_flatten(char *structure,
191  unsigned int options);
192 
193 
213 void
214 vrna_db_flatten_to(char *string,
215  const char target[3],
216  unsigned int options);
217 
218 
225 char *
227 
228 
238 char *
240  unsigned int n);
241 
242 
249 char *
250 vrna_db_to_element_string(const char *structure);
251 
252 
284 char *
285 vrna_db_pk_remove(const char *structure,
286  unsigned int options);
287 
288 /* End dot-bracket interface */
307 short *
308 vrna_ptable(const char *structure);
309 
310 
330 short *
331 vrna_ptable_from_string(const char *string,
332  unsigned int options);
333 
334 
352 short *
353 vrna_pt_pk_get(const char *structure);
354 
355 
362 short *
363 vrna_ptable_copy(const short *pt);
364 
365 
370 short *
371 vrna_pt_ali_get(const char *structure);
372 
373 
381 short *
382 vrna_pt_snoop_get(const char *structure);
383 
384 
401 short *
402 vrna_pt_pk_remove(const short *ptable,
403  unsigned int options);
404 
405 
406 /* End pair table interface */
418 #define VRNA_PLIST_TYPE_BASEPAIR 0
419 
420 
424 #define VRNA_PLIST_TYPE_GQUAD 1
425 
426 
430 #define VRNA_PLIST_TYPE_H_MOTIF 2
431 
432 
436 #define VRNA_PLIST_TYPE_I_MOTIF 3
437 
438 
442 #define VRNA_PLIST_TYPE_UD_MOTIF 4
443 
444 
448 #define VRNA_PLIST_TYPE_STACK 5
449 
450 
460  int i;
461  int j;
462  float p;
463  int type;
464 };
465 
481 vrna_ep_t *vrna_plist(const char *struc,
482  float pr);
483 
484 
502  double cut_off);
503 
504 
505 /* End pair list interface */
573 char *
574 vrna_db_from_WUSS(const char *wuss);
575 
576 
577 /* End WUSS notation interface */
625 char *
626 vrna_abstract_shapes(const char *structure,
627  unsigned int level);
628 
629 
645 char *
646 vrna_abstract_shapes_pt(const short *pt,
647  unsigned int level);
648 
649 
650 /* End abstract shapes interface */
662 struct vrna_hx_s {
663  unsigned int start;
664  unsigned int end;
665  unsigned int length;
666  unsigned int up5;
667  unsigned int up3;
668 };
669 
670 
677 vrna_hx_t *
679 
680 
684 vrna_hx_t *
686  int maxdist);
687 
688 
689 /* End helix list interface */
696 int *
697 vrna_loopidx_from_ptable(const short *pt);
698 
699 
718 int
719 vrna_bp_distance_pt(const short *pt1,
720  const short *pt2);
721 
736 int
737 vrna_bp_distance(const char *str1,
738  const char *str2);
739 
740 
741 double
742 vrna_dist_mountain(const char *str1,
743  const char *str2,
744  unsigned int p);
745 
746 
747 /* End metrics interface */
756 unsigned int *
757 vrna_refBPcnt_matrix(const short *reference_pt,
758  unsigned int turn);
759 
760 
768 unsigned int *
769 vrna_refBPdist_matrix(const short *pt1,
770  const short *pt2,
771  unsigned int turn);
772 
773 
777 char *
779  unsigned int length);
780 
781 
785 char
786 vrna_bpp_symbol(const float *x);
787 
788 
800 char *
802  unsigned int length);
803 
804 
805 void
806 vrna_letter_structure(char *structure,
807  vrna_bp_stack_t *bp,
808  unsigned int length);
809 
810 
896 #define VRNA_STRUCTURE_TREE_HIT 1U
897 
898 
903 #define VRNA_STRUCTURE_TREE_SHAPIRO_SHORT 2U
904 
905 
910 #define VRNA_STRUCTURE_TREE_SHAPIRO 3U
911 
912 
917 #define VRNA_STRUCTURE_TREE_SHAPIRO_EXT 4U
918 
919 
924 #define VRNA_STRUCTURE_TREE_SHAPIRO_WEIGHT 5U
925 
930 #define VRNA_STRUCTURE_TREE_EXPANDED 6U
931 
932 
962 char *
963 vrna_db_to_tree_string(const char *structure,
964  unsigned int type);
965 
966 
978 char *
979 vrna_tree_string_unweight(const char *structure);
980 
981 
993 char *
994 vrna_tree_string_to_db(const char *tree);
995 
996 
997 /* End tree representations */
1000 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
1001 
1002 /*###########################################*/
1003 /*# deprecated functions below #*/
1004 /*###########################################*/
1005 
1025 DEPRECATED(void assign_plist_from_db(vrna_ep_t **pl,
1026  const char *struc,
1027  float pr),
1028  "Use vrna_plist() instead");
1029 
1043 DEPRECATED(char *pack_structure(const char *struc),
1044  "Use vrna_db_pack() instead");
1045 
1057 DEPRECATED(char *unpack_structure(const char *packed),
1058  "Use vrna_db_unpack() instead");
1059 
1072 DEPRECATED(short *make_pair_table(const char *structure),
1073  "Use vrna_ptable() instead");
1074 
1075 DEPRECATED(short *make_pair_table_pk(const char *structure),
1076  "Use vrna_ptable_from_string() instead");
1077 
1087 DEPRECATED(short *copy_pair_table(const short *pt),
1088  "Use vrna_ptable_copy() instead");
1089 
1096 DEPRECATED(short *alimake_pair_table(const char *structure),
1097  "Use vrna_pt_ali_get() instead");
1098 
1106 DEPRECATED(short *make_pair_table_snoop(const char *structure),
1107  "Use vrna_pt_snoop_get() instead");
1108 
1109 DEPRECATED(int *make_loop_index_pt(short *pt),
1110  "Use vrna_loopidx_from_ptable() instead");
1111 
1125 DEPRECATED(int bp_distance(const char *str1,
1126  const char *str2),
1127  "Use vrna_bp_distance() instead");
1128 
1138 DEPRECATED(unsigned int *make_referenceBP_array(short *reference_pt,
1139  unsigned int turn),
1140  "Use vrna_refBPcnt_matrix() instead");
1141 
1151 DEPRECATED(unsigned int *compute_BPdifferences(short *pt1,
1152  short *pt2,
1153  unsigned int turn),
1154  "Use vrna_refBPdist_matrix() instead");
1155 
1176 DEPRECATED(void assign_plist_from_pr(vrna_ep_t **pl,
1177  FLT_OR_DBL *probs,
1178  int length,
1179  double cutoff),
1180  "Use vrna_plist_from_probs() instead");
1181 
1190 DEPRECATED(void parenthesis_structure(char *structure,
1191  vrna_bp_stack_t *bp,
1192  int length),
1193  "Use vrna_parenthesis_structure() instead");
1194 
1204 DEPRECATED(void parenthesis_zuker(char *structure,
1205  vrna_bp_stack_t *bp,
1206  int length),
1207  "Use vrna_parenthesis_zuker() instead");
1208 
1209 DEPRECATED(void letter_structure(char *structure,
1210  vrna_bp_stack_t *bp,
1211  int length),
1212  "Use vrna_letter_structure() instead");
1213 
1219 DEPRECATED(void bppm_to_structure(char *structure,
1220  FLT_OR_DBL *pr,
1221  unsigned int length),
1222  "Use vrna_db_from_probs() instead");
1223 
1229 DEPRECATED(char bppm_symbol(const float *x),
1230  "Use vrna_bpp_symbol() instead");
1231 
1232 #endif
1233 
1238 #endif
Various data structures and pre-processor macros.
FLT_OR_DBL * pr
A pointer to the base pair probability matrix.
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: basic.h:43
Base pair stack element.
Definition: basic.h:143
The most basic data structure required by many functions throughout the RNAlib.
Definition: fold_compound.h:137
void assign_plist_from_pr(vrna_ep_t **pl, FLT_OR_DBL *probs, int length, double cutoff)
Create a vrna_ep_t from a probability matrix.
void assign_plist_from_db(vrna_ep_t **pl, const char *struc, float pr)
Create a vrna_ep_t from a dot-bracket string.
vrna_ep_t * vrna_plist_from_probs(vrna_fold_compound_t *vc, double cut_off)
Create a vrna_ep_t from base pair probability matrix.
char * vrna_abstract_shapes_pt(const short *pt, unsigned int level)
Convert a secondary structure to its abstract shapes representation.
char * vrna_abstract_shapes(const char *structure, unsigned int level)
Convert a secondary structure in dot-bracket notation to its abstract shapes representation.
char * unpack_structure(const char *packed)
Unpack secondary structure previously packed with pack_structure()
void bppm_to_structure(char *structure, FLT_OR_DBL *pr, unsigned int length)
Create a dot-bracket like structure string from base pair probability matrix.
short * alimake_pair_table(const char *structure)
char bppm_symbol(const float *x)
Get a pseudo dot bracket notation for a given probability information.
unsigned int * make_referenceBP_array(short *reference_pt, unsigned int turn)
Make a reference base pair count matrix.
int pairs
contains the number of base pairs in the last parsed structure.
int bp_distance(const char *str1, const char *str2)
Compute the "base pair" distance between two secondary structures s1 and s2.
short * make_pair_table(const char *structure)
Create a pair table of a secondary structure.
short * make_pair_table_snoop(const char *structure)
void parenthesis_zuker(char *structure, vrna_bp_stack_t *bp, int length)
Create a dot-backet/parenthesis structure from backtracking stack obtained by zuker suboptimal calcul...
char * pack_structure(const char *struc)
Pack secondary secondary structure, 5:1 compression using base 3 encoding.
unsigned int * compute_BPdifferences(short *pt1, short *pt2, unsigned int turn)
Make a reference base pair distance matrix.
void parenthesis_structure(char *structure, vrna_bp_stack_t *bp, int length)
Create a dot-backet/parenthesis structure from backtracking stack.
short * copy_pair_table(const short *pt)
Get an exact copy of a pair table.
char * vrna_db_to_element_string(const char *structure)
Convert a secondary structure in dot-bracket notation to a nucleotide annotation of loop contexts.
char * vrna_db_pack(const char *struc)
Pack secondary secondary structure, 5:1 compression using base 3 encoding.
char * vrna_db_unpack(const char *packed)
Unpack secondary structure previously packed with vrna_db_pack()
void vrna_db_flatten_to(char *string, const char target[3], unsigned int options)
Substitute pairs of brackets in a string with another type of pair characters.
char * vrna_db_from_plist(vrna_ep_t *pairs, unsigned int n)
Convert a list of base pairs into dot-bracket notation.
char * vrna_db_pk_remove(const char *structure, unsigned int options)
Remove pseudo-knots from an input structure.
char * vrna_db_from_ptable(short *pt)
Convert a pair table into dot-parenthesis notation.
void vrna_db_flatten(char *structure, unsigned int options)
Substitute pairs of brackets in a string with parenthesis.
vrna_hx_t * vrna_hx_merge(const vrna_hx_t *list, int maxdist)
Create a merged helix list from another helix list.
vrna_hx_t * vrna_hx_from_ptable(short *pt)
Convert a pair table representation of a secondary structure into a helix list.
Data structure representing an entry of a helix list.
Definition: structures.h:662
int vrna_bp_distance(const char *str1, const char *str2)
Compute the "base pair" distance between two secondary structures s1 and s2.
int vrna_bp_distance_pt(const short *pt1, const short *pt2)
Compute the "base pair" distance between two pair tables pt1 and pt2 of secondary structures.
short * vrna_pt_ali_get(const char *structure)
Create a pair table of a secondary structure (snoop align version)
short * vrna_ptable_from_string(const char *string, unsigned int options)
Create a pair table for a secondary structure string.
short * vrna_ptable_copy(const short *pt)
Get an exact copy of a pair table.
short * vrna_ptable(const char *structure)
Create a pair table from a dot-bracket notation of a secondary structure.
short * vrna_pt_pk_get(const char *structure)
Create a pair table of a secondary structure (pseudo-knot version)
short * vrna_pt_pk_remove(const short *ptable, unsigned int options)
Remove pseudo-knots from a pair table.
short * vrna_pt_snoop_get(const char *structure)
Create a pair table of a secondary structure (snoop version)
int i
Start position (usually 5' nucleotide that starts the element, e.g. base pair)
Definition: structures.h:460
int type
Type of the element.
Definition: structures.h:463
float p
Probability of the element.
Definition: structures.h:462
int j
End position (usually 3' nucleotide that ends the element, e.g. base pair)
Definition: structures.h:461
vrna_ep_t * vrna_plist(const char *struc, float pr)
Create a vrna_ep_t from a dot-bracket string.
Data structure representing a single entry of an element probability list (e.g. list of pair probabil...
Definition: structures.h:459
char * vrna_db_to_tree_string(const char *structure, unsigned int type)
Convert a Dot-Bracket structure string into tree string representation.
char * vrna_tree_string_to_db(const char *tree)
Convert a linear tree string representation of a secondary structure back to Dot-Bracket notation.
char * vrna_tree_string_unweight(const char *structure)
Remove weights from a linear string tree representation of a secondary structure.
char * vrna_db_from_WUSS(const char *wuss)
Convert a WUSS annotation string to dot-bracket format.
char vrna_bpp_symbol(const float *x)
Get a pseudo dot bracket notation for a given probability information.
int * vrna_loopidx_from_ptable(const short *pt)
Get a loop index representation of a structure.
char * vrna_db_from_bp_stack(vrna_bp_stack_t *bp, unsigned int length)
Create a dot-backet/parenthesis structure from backtracking stack.
unsigned int * vrna_refBPdist_matrix(const short *pt1, const short *pt2, unsigned int turn)
Make a reference base pair distance matrix.
unsigned int * vrna_refBPcnt_matrix(const short *reference_pt, unsigned int turn)
Make a reference base pair count matrix.
char * vrna_db_from_probs(const FLT_OR_DBL *pr, unsigned int length)
Create a dot-bracket like structure string from base pair probability matrix.