Below, you'll find some more or less simple C programs showing first steps into using RNAlib. A complete list of example C programs can be found in the C Examples section.
Simple MFE prediction for a given sequence
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
main()
{
char *seq = "GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA";
char *structure = (
char *)
vrna_alloc(
sizeof(
char) * (strlen(seq) + 1));
printf("%s\n%s [ %6.2f ]\n", seq, structure, mfe);
free(structure);
return 0;
}
- See also
examples/helloworld_mfe.c
in the source code tarball
Simple MFE prediction for a multiple sequence alignment
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
main()
{
const char *sequences[] = {
"CUGCCUCACAACGUUUGUGCCUCAGUUACCCGUAGAUGUAGUGAGGGU",
"CUGCCUCACAACAUUUGUGCCUCAGUUACUCAUAGAUGUAGUGAGGGU",
"---CUCGACACCACU---GCCUCGGUUACCCAUCGGUGCAGUGCGGGU",
NULL
};
char *cons = consensus(sequences);
char *structure = (
char *)
vrna_alloc(
sizeof(
char) * (strlen(sequences[0]) + 1));
printf("%s\n%s [ %6.2f ]\n", cons, structure, mfe);
free(cons);
free(structure);
return 0;
}
- See also
examples/helloworld_mfe_comparative.c
in the source code tarball
Simple Base Pair Probability computation
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
main()
{
char *seq = "GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA";
char *propensity = (
char *)
vrna_alloc(
sizeof(
char) * (strlen(seq) + 1));
float en =
vrna_pf_fold(seq, propensity, &pair_probabilities);
printf("%s\n%s [ %6.2f ]\n", seq, propensity, en);
for (ptr = pair_probabilities; ptr->
i != 0; ptr++)
printf(
"p(%d, %d) = %g\n", ptr->
i, ptr->
j, ptr->
p);
free(pair_probabilities);
free(propensity);
return 0;
}
- See also
examples/helloworld_probabilities.c
in the source code tarball
Deviating from the Default Model
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
main()
{
char *structure = (
char *)
vrna_alloc(
sizeof(
char) * (strlen(seq) + 1));
printf("%s\n%s [ %6.2f ]\n", seq, structure, mfe);
free(structure);
return 0;
}
- See also
examples/fold_compound_md.c
in the source code tarball