#ifndef VIENNA_RNA_PACKAGE_STRUCT_UTILS_H #define VIENNA_RNA_PACKAGE_STRUCT_UTILS_H /* make this interface backward compatible with RNAlib < 2.2.0 */ #define VRNA_BACKWARD_COMPAT #ifdef DEPRECATION_WARNINGS # ifdef __GNUC__ # define DEPRECATED(func) func __attribute__ ((deprecated)) # else # define DEPRECATED(func) func # endif #else # define DEPRECATED(func) func #endif /** * @file structure_utils.h * @ingroup utils * @brief Various utility- and helper-functions for secondary structure parsing, converting, etc. */ /** * @{ * @ingroup struct_utils */ /** * @brief Convenience typedef for data structure #vrna_hx_s */ typedef struct vrna_hx_s vrna_hx_t; #include #include /** * @brief Data structure representing an entry of a helix list */ struct vrna_hx_s { unsigned int start; unsigned int end; unsigned int length; unsigned int up5; unsigned int up3; }; /** * @brief Pack secondary secondary structure, 5:1 compression using base 3 encoding * * Returns a binary string encoding of the secondary structure using * a 5:1 compression scheme. The string is NULL terminated and can * therefore be used with standard string functions such as strcmp(). * Useful for programs that need to keep many structures in memory. * * @see vrna_db_unpack() * @param struc The secondary structure in dot-bracket notation * @return The binary encoded structure */ char *vrna_db_pack(const char *struc); /** * @brief Unpack secondary structure previously packed with vrna_db_pack() * * Translate a compressed binary string produced by vrna_db_pack() back into * the familiar dot-bracket notation. * * @see vrna_db_pack() * @param packed The binary encoded packed secondary structure * @return The unpacked secondary structure in dot-bracket notation */ char *vrna_db_unpack(const char *packed); /** * @brief Create a pair table of a secondary structure * * Returns a newly allocated table, such that table[i]=j if (i.j) pair * or 0 if i is unpaired, table[0] contains the length of the structure. * * @param structure The secondary structure in dot-bracket notation * @return A pointer to the created pair_table */ short *vrna_ptable(const char *structure); /** * @brief Create a pair table of a secondary structure (pseudo-knot version) * * Returns a newly allocated table, such that table[i]=j if (i.j) pair * or 0 if i is unpaired, table[0] contains the length of the structure. * * In contrast to vrna_ptable() this function also recognizes the base pairs * denoted by '[' and ']' brackets. * * @param structure The secondary structure in (extended) dot-bracket notation * @return A pointer to the created pair_table */ short *vrna_pt_pk_get(const char *structure); /** * @brief Get an exact copy of a pair table * * @param pt The pair table to be copied * @return A pointer to the copy of 'pt' */ short *vrna_ptable_copy(const short *pt); /** * @brief Create a pair table of a secondary structure (snoop align version) * */ short *vrna_pt_ali_get(const char *structure); /** * @brief Create a pair table of a secondary structure (snoop version) * * returns a newly allocated table, such that: table[i]=j if (i.j) pair or * 0 if i is unpaired, table[0] contains the length of the structure. * The special pseudoknotted H/ACA-mRNA structure is taken into account. */ short *vrna_pt_snoop_get(const char *structure); /** * @brief Get a loop index representation of a structure */ int *vrna_loopidx_from_ptable(const short *pt); /** * @brief Convert a pair table into dot-parenthesis notation * * @param pt The pair table to be copied * @return A char pointer to the dot-bracket string */ char *vrna_db_from_ptable(short *pt); /** * @brief Compute the "base pair" distance between two secondary structures s1 and s2. * * The sequences should have the same length. * dist = number of base pairs in one structure but not in the other * same as edit distance with open-pair close-pair as move-set * * @param str1 First structure in dot-bracket notation * @param str2 Second structure in dot-bracket notation * @return The base pair distance between str1 and str2 */ int vrna_bp_distance( const char *str1, const char *str2); /** * @brief Make a reference base pair count matrix * * Get an upper triangular matrix containing the number of basepairs of a reference * structure for each interval [i,j] with i