Perl5 Examples

Hello World Examples

Using the flat interface

  • MFE prediction

    use RNA;
    
    # The RNA sequence
    my $seq = "GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA";
    
    # compute minimum free energy (MFE) and corresponding structure
    my ($ss, $mfe) = RNA::fold($seq);
    
    # print output
    printf "%s\n%s [ %6.2f ]\n", $seq, $ss, $mfe;
    

Using the object oriented interface

  • 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;
    

Changing the Model Settings

Using the flat interface

  • MFE prediction at different temperature and dangle model

    use RNA;
    
    # The RNA sequence
    my $seq = "GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA";
    
    # create a new model details structure
    my $md = new RNA::md();
    
    # change temperature and dangle model
    $md->{temperature} = 20.0; # 20 Deg Celcius
    $md->{dangles}     = 1;    # Dangle Model 1
    
    # create a fold compound
    my $fc = new RNA::fold_compound($seq, $md);
    
    # predict Minmum Free Energy and corresponding secondary structure
    my ($ss, $mfe) = $fc->mfe();
    
    # print sequence, structure and MFE
    printf "%s\n%s [ %6.2f ]\n", $seq, $ss, $mfe;
    

Using the object oriented interface

  • MFE prediction at different temperature and dangle model