RNAstructure logo

RNAstructure Python Interfaces
Quick Start Guide

 

To compile the python library, run this shell command in the RNAstructure/RNA_class directory
> make python_interface

The library will be built in RNAstructure/RNAstructure_python_interface. Make sure this directory is on your PATH or PYTHONPATH
Once compiled, the RNAstructure module is loaded as usual:
> import RNAstructure

To access the in-line documentation:
>help(RNAstructure)

The following RNAstructure classes have python bindings:
RNA
ProbScan
Dynalign_object
Multilign_object
Oligowalk_object

Each class and method has in-line documentation
> help(RNAstructure.RNA)
> help(RNAstructure.RNA.FoldSingleStrand())
> help(RNAstructure.ProbScan.probability_of_multibranch_loop)

Each class can be instantiated with its fromString and fromFile methods
> p = RNAstructure.RNA.fromString("GGGGAAACCCC")
> q = RNAstructure.RNA.fromFile("../tests/time/ivslsu.seq")
> m = RNAstructure.Dynalign_object.fromString("CGCGCGUUCGGCGCGC","GCGCGCUUCAGCGCGC")

The classes have structure calculation methods identically to the C++ classes
> p.FoldSingleStrand()
> p.PartitionFunction()
> m.Dynalign()

The multiple-sequence classes such as dynalign have multiple RNA objects that can be accessed
> m.GetRNA2() # returns an RNA

They have IO methods to write structures to disc
> p.WriteCt("foo.ct")
> m.GetRNA2.WriteCt("bar.ct")

RNA and ProbScan objects are iterable. To iterate over the sequence:
> for nuc in p: print nuc

Or over the nucleotide indices:
> for i in p.iterIndices(): print GetNucleotide(i) #identical behavior

It's also possible to get the pairing information to manipulate it within python
> pairs = [(i,p.GetPair(i)) for i in p.iterIndices()]

Or pair probabilities
> p.GetPairProbability(1,10) #0.437

If you have any trouble, feel free to contact Michael Sloma at michael_sloma@urmc.rochester.edu.