Draw RNA secondary structures in Python
Project description
draw_rna
Generate quick secondary structures of nucleic acids via jupyter notebook or command line.
Dependencies
The default behavior is to output the secondary structure visualization to both svg and png. The png requires Inkscape, whose directory must be set by environmental variable INKSCAPEDIR.
Install
draw_rna is available on PyPI.
pip install draw_rna
Alternatively, clone the Github repository to your hard drive as follows:
git clone git@github.com:eternagame/draw_rna.git
Warning if you see errors in using the repository, it may be due to your draw_rna directory sitting in a folder like src/ which already is in your Python Path. in that case, rename draw_rna to draw_rna_directory and/or move it to another spot in your system.
Basic Usage
Jupyter notebook
See example_files/demo.ipynb for more. In brief:
from draw_rna.ipynb_draw import draw_struct
draw_struct('GGGGAAAACCCC', '((((....))))')
Input file
An input file is used to specify the sequence, secondary structure, and coloring of the desired drawing. The format is as follows
filename # image will be written to filename.svg
GTGANNNNNTCAC # nucleic acid sequence
((((.....)))) # nucleic acid secondary structure in dot-bracket notation
rrrrbbbbbgggg # optional: coloring of each base (e.g. r for red, g for green, b for blue)
Multiple sequences can be specified in one file as in example_input.txt.
Execution
The draw script can be run with
python src/draw_rna/draw_all.py example_files/command_line/example_input.txt
You'll get files example_contours.svg, example_sequence_colors.svg, example_specific_colors.svg. Example output available in example_files/command_line/.
Sample secondary structure diagrams:
Notes on usage
Multistrand drawing
At the moment, current practice is to include blanks between strands such as:
filename
GTGANN NNTCAC
((((.....))))
rrrrbbwbbgggg
And then remove nucleotides corresponding to blanks afterwards. (This would be a quick fix.)
Extended options
Draw a large thing with linear exterior loop and with a custom color vector:
python draw_all.py covid19_5primeUTR.txt --large_mode --color_values perc_conserved_5UTR.txt --png
If you use --color_values with an input file with multiple structures, the same colors will be applied to all the structures.
Draw from RDAT file containing reactivity
Requires RDATkit to be in working python path. Example command:
python src/draw_rna/draw_from_rdat.py ETERNA_R69_0000.rdat 297 --png
Movie mode
More coming eventually. For now, if you generate a bunch of stills, say from a cotranscriptional simulation, can string them together with ImageMagick:
convert -delay 25 my_stills_*.png my_great_trajectory.gif
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file draw_rna-0.4.3.tar.gz.
File metadata
- Download URL: draw_rna-0.4.3.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fccadcc1d98ad71db1410cc0e5bc23f435a923ababc826cfaa482e63e814eded
|
|
| MD5 |
809613d63aa39c399982713cc25097e4
|
|
| BLAKE2b-256 |
9acf0e8448cd2aff50c2ee181582b23652ea5631378fc1f88f10661704c8dc17
|
Provenance
The following attestation bundles were made for draw_rna-0.4.3.tar.gz:
Publisher:
release.yml on eternagame/draw_rna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
draw_rna-0.4.3.tar.gz -
Subject digest:
fccadcc1d98ad71db1410cc0e5bc23f435a923ababc826cfaa482e63e814eded - Sigstore transparency entry: 248797421
- Sigstore integration time:
-
Permalink:
eternagame/draw_rna@9e79bd4de78cdc1e412493eaac757ca7b435a33d -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/eternagame
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9e79bd4de78cdc1e412493eaac757ca7b435a33d -
Trigger Event:
push
-
Statement type:
File details
Details for the file draw_rna-0.4.3-py3-none-any.whl.
File metadata
- Download URL: draw_rna-0.4.3-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb7d31ffab85cad0c23d08ed43995dddcd8f307ab90265b0e9e7c8e0c7b1c97
|
|
| MD5 |
11c37a97f8ec60436c80064e081f4a91
|
|
| BLAKE2b-256 |
dfde0426ca34925fb4daeaa7ff89ceb16b62ee5fb582f687b9ee52b1d93b9d24
|
Provenance
The following attestation bundles were made for draw_rna-0.4.3-py3-none-any.whl:
Publisher:
release.yml on eternagame/draw_rna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
draw_rna-0.4.3-py3-none-any.whl -
Subject digest:
1eb7d31ffab85cad0c23d08ed43995dddcd8f307ab90265b0e9e7c8e0c7b1c97 - Sigstore transparency entry: 248797423
- Sigstore integration time:
-
Permalink:
eternagame/draw_rna@9e79bd4de78cdc1e412493eaac757ca7b435a33d -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/eternagame
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9e79bd4de78cdc1e412493eaac757ca7b435a33d -
Trigger Event:
push
-
Statement type: