VARNA API is a Python interface for VARNA (v3-93), 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. The online documentation is available.
!!! danger "Starting from v1.1.0, VARNA API uses 1-indexed to count RNA bases. The change aims to better align with VARNA and ViennaRNA."
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 -auxBPs "(14,20):color=#ff00ff" -highlightRegion "11-21"
The equivalence using VARNA API would be
from varnaapi import Structure
v = Structure(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
v.add_highlight_region(11,21)
v.add_aux_BP(14, 20, edge5="s", color="#FF00FF")
v.savefig("example.png")
Installation
python3 -m pip install varnaapi
Usage
Here, we show the basic usage of varnaapi.
The first thing after importing varnaapi is to setup the location of VARNA to use.
!!! note "By default, the library assumes the VARNA v3-93 in the current folder is used (./VARNAv3-93.jar)"
import varnaapi
varnaapi.set_VARNA(path_to_VARNA)
Each drawing in VARNA is an object of class inherited from [BasicDraw][varnaapi.BasicDraw]. The standard class to draw from given secondary structure or/and RNA sequence is [Structure][varnaapi.Structure].
ss = "((((((.((((((........)))))).((((((.......))))))..))))))"
v = varnaapi.Structure(structure=ss)
One can call the member function #!python BasicDraw.savefig() with given file name to save the drawing. The format is either png or svg, that VARNA will determine from the file name.
v.savefig("my_drawing.png")
While using jupyter notebook, one can also set the option show to #!python True to show the drawing in the notebook
v.savefig("my_drawing.png", show=True)
or simply use the member function #!python BasicDraw.show().
v.show()
The later one creates a temporary file in png format for drawing.
Configuration
In VARNA, one can chose the structure drawing algorithm, change the style for base pair, or hide backbone in drawing etc.
The full list of parameters with default value can be found here.
In library, the easiest way to modify these parameters is through the member function #!python BasicDraw.update().
Some parameters, such as algorithm, can be set up via specific function. The rest will be supported in future update.
v.update(algorithm='naview', bpStyle='none', drawBackbone=False, bp='#006400')
!!! note "Color parameters" Value for all color parameters in VARNA API should be readable by the object colour.Color, such as human color name, hex, RGB etc.
Save configuration
The library offers function to save the parameters setting in YAML format for the further use.
v.dump_param('config.yml')
Load configuration
There are two ways to load the saved configuration.
The first one is using the member function of BasicDraw.
v.load_param('config.yml')
The second way is loading the configuration as a global setting in the opened session.
varnaapi.load_config('config.yml')
!!! note "Parameter value priority order" VARNA API uses parameter values in the following order, i.e. if the value in the current order is undefined, then the next one is used
- Value set by `varnaapi.BasicDraw.update()` or similar functions
- Object Value loaded using `varnaapi.BasicDraw.load_param()`
- Global values loaded using `varnaapi.load_cofig()`
- Default parameter values.
Operations
VARNA allows different operations on drawing, such as highlighting a region, adding auxiliary base pairs. This can be achieved by using the proper functions. We invite users to read API for more details.
v.add_highlight_region(1, 6, radius=20)
v.add_aux_bp(1, 10, color='red')
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.
Metadata
Release files for varnaapi 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| varnaapi-1.2.0.tar.gz | 35.8 kB | Without provenance | Details for varnaapi-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| varnaapi-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for varnaapi-1.2.0-py3-none-any.whl |
Total release size: 71.0 kB
Release files / varnaapi-1.2.0.tar.gz
| Download URL | varnaapi-1.2.0.tar.gz |
|---|---|
| Size | 35.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe826b8d34b07069d1e036a5ded7ce8bfe8b8d77ec68947fe30904ed5eea94cc
|
|
BLAKE2b-256 checksum How to use checksums |
bb01371699393ce80ac0f9a2ea87e928a9095014b53e302efbf41ec70366c8b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.13
|
Release files / varnaapi-1.2.0-py3-none-any.whl
| Download URL | varnaapi-1.2.0-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a30c8ac92364da54747e5f3877fa77e1be68e12f3844fe73d8c3a1a8add78f00
|
|
BLAKE2b-256 checksum How to use checksums |
8bd77cbaf43f21235fab83a6e749e2ac47aa6c835f462f5af66190ee7a3ea565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.13
|
Security for varnaapi 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.