Scripting Language interface(s)

# Introduction

For an easy integration into scripting languages, we provide an automatically generated interface to the RNAlib C-library, generated with swig.

## Function renaming scheme

The main difference when using a scripting language interface compared to direct calls of RNAlib C functions is, that the prefix 'vrna_' is dropped. For instance, when calling the vrna_fold() function, corresponding calls in perl or python are RNA::fold(), and RNA.fold(), respectively.

Functions that are dedicated to work on specific data structures only, e.g. the vrna_fold_compound_t, are usually not exported at all. Instead, they are attached as object methods of a corresponding class (see Object oriented Interface for data structures for detailed information).

## Object oriented Interface for data structures

For data structures, typedefs, and enumerations the 'vrna_' prefixes are dropped as well, together with their suffixes '_s', '_t', and '_e', respectively. Furthermore, data structures are usually transformed into classes and relevant functions of the C-library are attached as methods.

# Examples

## Perl Examples

### Using the Flat Interface

Example 1: "Simple MFE prediction"

#!/usr/bin/perl
use warnings;
use strict;
use RNA;
my $seq1 = "CGCAGGGAUACCCGCG";
# compute minimum free energy (mfe) and corresponding structure
my ($ss, $mfe) = RNA::fold($seq1);
# print output
printf "%s [ %6.2f ]\n", $ss, $mfe;

### Using the Object Oriented (OO) Interface

The 'fold_compound' class that serves as an object oriented interface for vrna_fold_compound_t

Example 1: "Simple MFE prediction"

#!/usr/bin/perl
use warnings;
use strict;
use RNA;
my $seq1 = "CGCAGGGAUACCCGCG";
# create new fold_compound object
my $fc = new RNA::fold_compound($seq1);
# compute minimum free energy (mfe) and corresponding structure
my ($ss, $mfe) = $fc->mfe();
# print output
printf "%s [ %6.2f ]\n", $ss, $mfe;

## Python Examples