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.
- Note
- This program uses the old API of RNAlib, which is in part already marked deprecated. Please consult the RNAlib API v3.0 page for details of what changes are necessary to port your implementation to the new API.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void main()
{
char *seq1="CGCAGGGAUACCCGCG", *seq2="GCGCCCAUAGGGACGC",
*struct1,* struct2,* xstruc;
float e1, e2, tree_dist, string_dist, profile_dist, kT;
float *pf1, *pf2;
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(xstruc);
free(xstruc);
free(S1); free(S2);
printf("%s mfe=%5.2f\n%s mfe=%5.2f dist=%3.2f\n",
printf("%s free energy=%5.2f\n%s free energy=%5.2f dist=%3.2f\n",
}
In a typical Unix environment you would compile this program using:
cc ${OPENMP_CFLAGS} -c example.c -I${hpath}
and link using
cc ${OPENMP_CFLAGS} -o example -L${lpath} -lRNA -lm
where ${hpath} and ${lpath} point to the location of the header files and library, respectively.
- Note
- As default, the RNAlib is compiled with build-in OpenMP multithreading support. Thus, when linking your own object files to the library you have to pass the compiler specific ${OPENMP_CFLAGS} (e.g. '-fopenmp' for gcc) even if your code does not use openmp specific code. However, in that case the OpenMP flags may be ommited when compiling example.c