Skip to main content

Python Class for VARNA

Project description

VARNA API is a Python interface for VARNA, a Java lightweight component and applet for drawing the RNA secondary structure. VARNA allows users to produce drawing in a non-iteractive way via command line. However, the command line might be massive and complicate in some use cases. VARNA API aims to simplify such process.

NOTE: The VARNA API is 0-indexed unlike VARNA, which is 1-indexed.

Example

The command below highlights region 11-21 and adds a non-canonical base pair at position (14,20) on secondary structure ((((((.((((((........)))))).((((((.......))))))..)))))).

java -cp VARNAv3-93.jar fr.orsay.lri.varna.applications.VARNAcmd -sequenceDBN "                                                       " -structureDBN "((((((.((((((........)))))).((((((.......))))))..))))))" -o example.png -algorithm radiate -auxBPs "(14,20):color=#FF00FF,thickness=1.0,edge5=s,edge3=wc,stericity=cis" -highlightRegion "11-21:radius=15.0,fill=#9999FF,outline=#3333FF"

The equivalence in python is

from varnaapi import VARNA
v = VARNA(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
v.add_highlight_region(10,20)
v.add_aux_BP(13, 19, edge5="s", color="#FF00FF")
v.savefig("example.png")

Installation

python3 -m pip install varnaapi

Usage

Here, we show the basic usage of varnaapi. Please refer the API page for more details. The first thing after importing varnaapi is to setup the location of VARNA used. The default is VARNAv3-93.jar in the current folder.

import varnaapi
varnaapi.set_VARNA(path_to_VARNA)

Each drawing in VARNA is an object called VARNA created from given secondary structure or/and RNA sequence.

ss = "((((((.((((((........)))))).((((((.......))))))..))))))"
v = varnaapi.VARNA(structure=ss)

Then we can add operations on drawing by calling object functions, such as VARNA.set_algorithm() to choose a drawing algorithm, VARNA.add_highlight_region() to highlight a region etc.

v.set_algorithm('line')
v.add_highlight_region(0, 5, radius=20)

Finally, we can draw the secondary structure

v.savefig(path_to_store)

Credits

Please kindly cite VARNA supporting manuscript if you use VARNA API in your research. Download bibtex format.

Darty, K., Denise, A., & Ponty, Y. (2009). VARNA: Interactive drawing and editing of the RNA secondary structure. Bioinformatics, 25(15), 1974.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for varnaapi, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size varnaapi-0.1.0-py3-none-any.whl (23.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size varnaapi-0.1.0.tar.gz (673.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page