Skip to main content

Draw RNA secondary structures in Python

Project description

draw_rna

Generate quick secondary structures of nucleic acids via jupyter notebook or command line.

A communal and continuing effort by the Das Lab, Eterna Players, M. Wu, H. Wayment-Steele.

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:DasLab/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:


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 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.)

NOTE ON render_rna and render_rna_flip:

'render_rna_flip.py' is what is currently called in the main routine and where major edits have been made. render_rna.py renders 3' -> 5'. TODO: handle 3' -> 5' drawing better.

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

draw_rna-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

draw_rna-0.1.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file draw_rna-0.1.1.tar.gz.

File metadata

  • Download URL: draw_rna-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for draw_rna-0.1.1.tar.gz
Algorithm Hash digest
SHA256 64b2a4e6d4255e01ad776788e6727beeb85dcb34a59c5cf5015bfdf7fec60766
MD5 f84348f0ce37527d9f776c0d5691ede3
BLAKE2b-256 ab12749d2a25e50b4b99109cb1720a7233a4db5a836fca11ef23262d2772101c

See more details on using hashes here.

File details

Details for the file draw_rna-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: draw_rna-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for draw_rna-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a118cd282dd1f458a310596f73b01a052e7613cd5647c423cb2f211da1f93a29
MD5 17dcea093dd62c3947a07eecd8839a0e
BLAKE2b-256 d890a9ef8908bb6c819837541fb8bd6c96fcbc1f491e24e37f718d5a3a26de16

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page