mainpage.h
/*
#############################################################
# The next comment is used to order the modules correctly #
#############################################################
*/
/*
#############################################################
# Now the mainpage text is following #
#############################################################
*/
{ 0, 2, 2, 2, 2, 1, 1}, /* Null replaced */
{ 2, 0, 2, 2, 2, INF, INF}, /* H replaced */
{ 2, 2, 0, 1, 2, INF, INF}, /* B replaced */
{ 2, 2, 1, 0, 2, INF, INF}, /* I replaced */
{ 2, 2, 2, 2, 0, INF, INF}, /* M replaced */
{ 1, INF, INF, INF, INF, 0, INF}, /* S replaced */
{ 1, INF, INF, INF, INF, INF, 0}, /* E replaced */
/* Null, H, B, I, M, S, E */
{ 0, 100, 5, 5, 75, 5, 5}, /* Null replaced */
{ 100, 0, 8, 8, 8, INF, INF}, /* H replaced */
{ 5, 8, 0, 3, 8, INF, INF}, /* B replaced */
{ 5, 8, 3, 0, 8, INF, INF}, /* I replaced */
{ 75, 8, 8, 8, 0, INF, INF}, /* M replaced */
{ 5, INF, INF, INF, INF, 0, INF}, /* S replaced */
{ 5, INF, INF, INF, INF, INF, 0}, /* E replaced */
\endverbatim
The lower matrix uses the costs given in \cite shapiro:1990.
All distance functions use the following global variables:
\verbatim
int cost_matrix;
\endverbatim
\copybrief cost_matrix
\verbatim
int edit_backtrack;
\endverbatim
\copybrief edit_backtrack
\verbatim
char *aligned_line[4];
\endverbatim
\copybrief aligned_line
\see utils.h, dist_vars.h and stringdist.h for more details
<h3>Functions for Tree Edit Distances</h3>
\verbatim
Tree *make_tree (char *struc)
\endverbatim
\copybrief make_tree()
\verbatim
float tree_edit_distance (Tree *T1,
Tree *T2)
\endverbatim
\copybrief tree_edit_distance()
\verbatim
void free_tree(Tree *t)
\endverbatim
\copybrief free_tree()
\see dist_vars.h and treedist.h for prototypes and more detailed descriptions
<h3>Functions for String Alignment</h3>
\verbatim
swString *Make_swString (char *string)
\endverbatim
\copybrief Make_swString()
\verbatim
float string_edit_distance (swString *T1,
swString *T2)
\endverbatim
\copybrief string_edit_distance()
\see dist_vars.h and stringdist.h for prototypes and more detailed descriptions
<h3>Functions for Comparison of Base Pair Probabilities</h3>
For comparison of base pair probability matrices, the matrices are first
condensed into probability profiles which are the compared by alignment.
\verbatim
float *Make_bp_profile_bppm ( double *bppm,
int length)
\endverbatim
\copybrief Make_bp_profile_bppm()
\verbatim
float profile_edit_distance ( const float *T1,
const float *T2)
\endverbatim
\copybrief profile_edit_distance()
\see ProfileDist.h for prototypes and more details of the above functions
\ref mp_utils "Next Page: Utilities"
\page mp_utils Utilities - Odds and Ends
\anchor toc
<h3>Table of Contents</h3>
<hr>
\li \ref utils_ss
\li \ref utils_dot
\li \ref utils_aln
\li \ref utils_seq
\li \ref utils_struc
\li \ref utils_misc
<hr>
\section utils_ss Producing secondary structure graphs
\verbatim
int PS_rna_plot ( char *string,
char *structure,
char *file)
\endverbatim
\copybrief PS_rna_plot()
\verbatim
int PS_rna_plot_a (
char *string,
char *structure,
char *file,
char *pre,
char *post)
\endverbatim
\copybrief PS_rna_plot_a()
\verbatim
int gmlRNA (char *string,
char *structure,
char *ssfile,
char option)
\endverbatim
\copybrief gmlRNA()
\verbatim
int ssv_rna_plot (char *string,
char *structure,
char *ssfile)
\endverbatim
\copybrief ssv_rna_plot()
\verbatim
int svg_rna_plot (char *string,
char *structure,
char *ssfile)
\endverbatim
\copybrief svg_rna_plot()
\verbatim
int xrna_plot ( char *string,
char *structure,
char *ssfile)
\endverbatim
\copybrief xrna_plot()
\verbatim
int rna_plot_type
\endverbatim
\copybrief rna_plot_type
Two low-level functions provide direct access to the graph lauyouting
algorithms:
\verbatim
int simple_xy_coordinates ( short *pair_table,
float *X,
float *Y)
\endverbatim
\copybrief simple_xy_coordinates()
\verbatim
int naview_xy_coordinates ( short *pair_table,
float *X,
float *Y)
\endverbatim
\copybrief naview_xy_coordinates()
\see PS_dot.h and naview.h for more detailed descriptions.
\htmlonly
<hr>
<a href="#toc">Table of Contents</a>
<hr>
\endhtmlonly
\section utils_dot Producing (colored) dot plots for base pair probabilities
\verbatim
int PS_color_dot_plot ( char *string,
cpair *pi,
char *filename)
\endverbatim
\copybrief PS_color_dot_plot()
\verbatim
int PS_color_dot_plot_turn (char *seq,
cpair *pi,
char *filename,
int winSize)
\endverbatim
\copybrief PS_color_dot_plot_turn()
\verbatim
int PS_dot_plot_list (char *seq,
char *filename,
plist *pl,
plist *mf,
char *comment)
\endverbatim
\copybrief PS_dot_plot_list()
\verbatim
int PS_dot_plot_turn (char *seq,
struct plist *pl,
char *filename,
int winSize)
\endverbatim
\copybrief PS_dot_plot_turn()
\see PS_dot.h for more detailed descriptions.
\section utils_aln Producing (colored) alignments
\verbatim
int PS_color_aln (
const char *structure,
const char *filename,
const char *seqs[],
const char *names[])
\endverbatim
\copybrief PS_color_aln()
\htmlonly
<hr>
<a href="#toc">Table of Contents</a>
<hr>
\endhtmlonly
\section utils_seq RNA sequence related utilities
Several functions provide useful applications to RNA sequences
\verbatim
char *random_string (int l,
const char symbols[])
\endverbatim
\copybrief random_string()
\verbatim
int hamming ( const char *s1,
const char *s2)
\endverbatim
\copybrief hamming()
\verbatim
void str_DNA2RNA(char *sequence);
\endverbatim
\copybrief str_DNA2RNA()
\verbatim
void str_uppercase(char *sequence);
\endverbatim
\copybrief str_uppercase()
\htmlonly
<hr>
<a href="#toc">Table of Contents</a>
<hr>
\endhtmlonly
\section utils_struc RNA secondary structure related utilities
\verbatim
char *pack_structure (const char *struc)
\endverbatim
\copybrief pack_structure()
\verbatim
char *unpack_structure (const char *packed)
\endverbatim
\copybrief unpack_structure()
\verbatim
short *make_pair_table (const char *structure)
\endverbatim
\copybrief make_pair_table()
\verbatim
short *copy_pair_table (const short *pt)
\endverbatim
\copybrief copy_pair_table()
\htmlonly
<hr>
<a href="#toc">Table of Contents</a>
<hr>
\endhtmlonly
\section utils_misc Miscellaneous Utilities
\verbatim
void print_tty_input_seq (void)
\endverbatim
\copybrief print_tty_input_seq()
\verbatim
void print_tty_constraint_full (void)
\endverbatim
\copybrief print_tty_constraint_full()
\verbatim
void print_tty_constraint (unsigned int option)
\endverbatim
\copybrief print_tty_constraint()
\verbatim
int *get_iindx (unsigned int length)
\endverbatim
\copybrief get_iindx()
\verbatim
int *get_indx (unsigned int length)
\endverbatim
\copybrief get_indx()
\verbatim
void constrain_ptypes (
const char *constraint,
unsigned int length,
char *ptype,
int *BP,
int min_loop_size,
unsigned int idx_type)
\endverbatim
\copybrief constrain_ptypes()
\verbatim
char *get_line(FILE *fp);
\endverbatim
\copybrief get_line()
\verbatim
unsigned int read_record(
char **header,
char **sequence,
char ***rest,
unsigned int options);
\endverbatim
\copybrief read_record()
\verbatim
char *time_stamp (void)
\endverbatim
\copybrief time_stamp()
\verbatim
void warn_user (const char message[])
\endverbatim
\copybrief warn_user()
\verbatim
void nrerror (const char message[])
\endverbatim
\copybrief nrerror()
\verbatim
void init_rand (void)
\endverbatim
\copybrief init_rand()
\verbatim
unsigned short xsubi[3];
\endverbatim
\copybrief xsubi
\verbatim
double urn (void)
\endverbatim
\copybrief urn()
\verbatim
int int_urn (int from, int to)
\endverbatim
\copybrief int_urn()
\verbatim
void *space (unsigned size)
\endverbatim
\copybrief space()
\verbatim
void *xrealloc ( void *p,
unsigned size)
\endverbatim
\copybrief xrealloc()
\see utils.h for a complete overview and detailed description of the utility functions
\htmlonly
<hr>
<a href="#toc">Table of Contents</a>
<hr>
\endhtmlonly
\ref mp_example "Next Page: Examples"
\page mp_example Example - A Small Example Program
The following program exercises most commonly used functions of the library.
The program folds two sequences using both the mfe and partition function
algorithms and calculates the tree edit and profile distance of the
resulting structures and base pairing probabilities.
\code{.c}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "utils.h"
#include "fold_vars.h"
#include "fold.h"
#include "part_func.h"
#include "inverse.h"
#include "RNAstruct.h"
#include "treedist.h"
#include "stringdist.h"
#include "profiledist.h"
void main()
{
char *seq1="CGCAGGGAUACCCGCG", *seq2="GCGCCCAUAGGGACGC",
*struct1,* struct2,* xstruc;
float e1, e2, tree_dist, string_dist, profile_dist, kT;
Tree *T1, *T2;
swString *S1, *S2;
float *pf1, *pf2;
FLT_OR_DBL *bppm;
/* fold at 30C instead of the default 37C */
temperature = 30.; /* must be set *before* initializing */
/* allocate memory for structure and fold */
struct1 = (char* ) space(sizeof(char)*(strlen(seq1)+1));
e1 = fold(seq1, struct1);
struct2 = (char* ) space(sizeof(char)*(strlen(seq2)+1));
e2 = fold(seq2, struct2);
free_arrays(); /* free arrays used in fold() */
/* produce tree and string representations for comparison */
xstruc = expand_Full(struct1);
T1 = make_tree(xstruc);
S1 = Make_swString(xstruc);
free(xstruc);
xstruc = expand_Full(struct2);
T2 = make_tree(xstruc);
S2 = Make_swString(xstruc);
free(xstruc);
/* calculate tree edit distance and aligned structures with gaps */
edit_backtrack = 1;
tree_dist = tree_edit_distance(T1, T2);
free_tree(T1); free_tree(T2);
unexpand_aligned_F(aligned_line);
printf("%s\n%s %3.2f\n", aligned_line[0], aligned_line[1], tree_dist);
/* same thing using string edit (alignment) distance */
string_dist = string_edit_distance(S1, S2);
free(S1); free(S2);
printf("%s mfe=%5.2f\n%s mfe=%5.2f dist=%3.2f\n",
aligned_line[0], e1, aligned_line[1], e2, string_dist);
/* for longer sequences one should also set a scaling factor for
partition function folding, e.g: */
kT = (temperature+273.15)*1.98717/1000.; /* kT in kcal/mol */
pf_scale = exp(-e1/kT/strlen(seq1));
/* calculate partition function and base pair probabilities */
e1 = pf_fold(seq1, struct1);
/* get the base pair probability matrix for the previous run of pf_fold() */
bppm = export_bppm();
pf1 = Make_bp_profile_bppm(bppm, strlen(seq1));
e2 = pf_fold(seq2, struct2);
/* get the base pair probability matrix for the previous run of pf_fold() */
bppm = export_bppm();
pf2 = Make_bp_profile_bppm(bppm, strlen(seq2));
free_pf_arrays(); /* free space allocated for pf_fold() */
profile_dist = profile_edit_distance(pf1, pf2);
printf("%s free energy=%5.2f\n%s free energy=%5.2f dist=%3.2f\n",
aligned_line[0], e1, aligned_line[1], e2, profile_dist);
free_profile(pf1); free_profile(pf2);
}
\endcode
In a typical Unix environment you would compile this program using:
\verbatim
cc ${OPENMP_CFLAGS} -c example.c -I${hpath}
\endverbatim
and link using
\verbatim
cc ${OPENMP_CFLAGS} -o example -L${lpath} -lRNA -lm
\endverbatim
where \e ${hpath} and \e ${lpath} point to the location of the header
files and library, respectively.
\note As default, the RNAlib is compiled with build-in \e OpenMP multithreading
support. Thus, when linking your own object files to the library you have to pass
the compiler specific \e ${OPENMP_CFLAGS} (e.g. '-fopenmp' for \b gcc) even if your code does not
use openmp specific code. However, in that case the \e OpenMP flags may be ommited when compiling
example.c
**/