This Tool creates a visualization for any working inter- and intramolecular structure and sequence involving one or two molecules, using FornaC.
Example for two distinctly colored molecules, with their intermolecular region highlighted:

./rna_to_img.py -u=".<<<....>>>.(((.<<<<<....>>>>>.(((..<<..>>..&..<<....>>..)))...)))." -e="NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN&NNNNNNNNNNNNNNNNNNNNNN" -c=distinct -o=example.svg
We need to install
- playwright (tested and developed with v1.57.0)
- chromium browser (install via playwright)
# install dependencies
python3 -m pip install playwright==1.57.0
python3 -m playwright install chromium
# check version
python3 -m playwright --version
-u/ --structure Specifies the RNA secondary structure in dot-bracket notation.
| Notation |
Meaning |
( ) |
Base pair |
[ ] |
Alternative bracket pair (pseudoknot region 1) |
< > |
Alternative bracket pair (pseudoknot region 2) |
{ } |
Alternative bracket pair (pseudoknot region 3) |
. |
Unpaired nucleotide |
& |
Separator between two molecules (intermolecular interaction) |
intramolecular:
rna_to_img.py \
-u="((...))...." \
-e="NNNNNNNNNNN"
|
|
intermolecular:
rna_to_img.py \
-u="((...))..<<..&...>>.." \
-e="NNNNNNNNNNNNN&NNNNNNN"
|
|
Hybrid Input Format (Advanced)
The hybrid input format provides a convenient way to specify intermolecular base pairing interactions using position indices instead of dot-bracket notation.
Format:
<start_pos_1><pipes_and_dots>&<start_pos_2><pipes_and_dots>
Where:
<start_pos>: Starting position (index, can be negative, can not be 0)
|: Represents a base pair in the intermolecular interaction
.: Represents an unpaired position within the interaction region
How it works:
- Both molecules must have the same number of
| characters (representing the same number of base pairs)
- Interaction positions are defined relative to your sequence start Index
- The tool automatically converts hybrid input to standard dot-bracket notation
Example (simple interaction):
Two sequences with interaction starting at position 5 (seq1) and position 3 (seq2) and each has 3 intermolecular base pairs
./rna_to_img.py \
-u="5|||..&3|||.." \
-e="NNNNNNNNNNNNN&NNNNNNN"
|
|
Example (with custom start Index)
Start indexing from position 10 (seq1) and 100 (seq2)
Interaction starts at position 15 (seq1) and 102 (seq2)
rna_to_img.py \
-u="15|||..&102|||.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-i1=10 \
-i2=100
|
|
Example (negative positions):
start indexing form -10 (seq1) and 1 (seq2)
Interaction starts at position -5 (seq1) and 3 (seq2)
rna_to_img.py \
-u="-5|||..&3|||.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-i1=-10 \
-i2=1
|
|
Hybrid vs. Dot-Bracket Comparison:
These two commands are equivalent:
Hybrid format:
rna_to_img.py \
-u="5|||..&3|||" \
-e="NNNNNNNNNNNNNN&NNNNN"
|
|
Equivalent dot-bracket format:
rna_to_img.py \
-u="....(((......&..))).." \
-e="NNNNNNNNNNNNN&NNNNNNN"
|
|
-e/ --sequence Specifies the RNA sequence using IUPAC nucleotide codes
| Code |
Nucleotide |
Code |
Nucleotide |
A |
Adenosine |
N |
Any nucleotide |
C |
Cytidine |
W |
Adenosine or Uridine |
G |
Guanosine |
S |
Cytidine or Guanosine |
U |
Uridine |
K |
Guanosine or Uridine |
|
|
& |
Separator between two molecules |
Example:
rna_to_img.py -u="((...))." -e="ACGAGUGA"
|
|
-o/ --output Specifies the output file name and format
| Value |
Description |
STDOUT (default) |
Print SVG to standard output |
filename |
Save as SVG with given name |
filename.png |
Save as PNG with given name |
Examples:
# Output to stdout
rna_to_img.py -u="((...))." -e="ACGAGUGA" > output.svg
# Save as SVG file
rna_to_img.py -u="((...))." -e="ACGAGUGA" -o=structure
# Save as PNG file
rna_to_img.py -u="((...))." -e="ACGAGUGA" -o=structure.png
-c/ --coloring Defines how nucleotides should be colored
| Option |
Description |
Example |
default (default) |
Standard fornac coloring scheme |
|
distinct |
Each molecule receives its own color |
 |
Example:
rna_to_img.py \
-u="((...))..<<..&...>>.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-c=distinct
|
|
-i/ --highlighting Specifies which elements should be highlighted in intermolecular structures
|
Option
|
Example Image
|
nothing: no sepcial highlighting
rna_to_img.py \
-u="((...))..<<....<<..&..>>...>>.." \
-e="NNNNNNNNNNNNNNNNNNN&NNNNNNNNNNN" \
-i=nothing
|
|
basepairs: Highlights only individual intermolecular base pairs
rna_to_img.py \
-u="((...))..<<....<<..&..>>...>>.." \
-e="NNNNNNNNNNNNNNNNNNN&NNNNNNNNNNN" \
-i=basepairs
|
|
region(default): Highlights entire intermolecular interaction region
rna_to_img.py \
-u="((...))..<<....<<..&..>>...>>.." \
-e="NNNNNNNNNNNNNNNNNNN&NNNNNNNNNNN" \
-i=region
|
|
-i1/ --startIndex1 Sets the starting index for the first molecule's nucleotide numbering
| Parameter |
Constraint |
| Default |
1 |
| Restriction |
Cannot be 0 |
Example (start numbering at 10):
rna_to_img.py \
-u="((...))." \
-e="ACGAGUGA" \
-i1=10
|
|
-i2/ --startIndex2 Sets the starting index for the second molecule's nucleotide numbering (only relevant for intermolecular structures)
| Parameter |
Constraint |
| Default |
1 |
| Restriction |
Cannot be 0 |
Example:
rna_to_img.py \
-u="((...))..<<..&...>>.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-i1=5 \
-i2=100
|
|
-v/ --verbose
Enables detailed logging output for debugging and troubleshooting
./rna_to_img.py -u="((...))." -e="ACGAGUGA" -v
Simple Intramolecular Structure
Visualization of a single RNA molecule with one hairpin loop:
rna_to_img.py -u="((...))." -e="ACGAGUGA" > hairpin.svg
|
|
Intermolecular Interaction with Distinct Coloring
Two molecules interacting with distinct colors:
rna_to_img.py \
-u="((...))..<<..&...>>.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-c=distinct \
-o=interaction.svg
|
|
Custom Indexing
Start numbering from different positions for each molecule:
rna_to_img.py \
-u="((...))..<<..&...>>.." \
-e="NNNNNNNNNNNNN&NNNNNNN" \
-i1=5 -i2=100 \
-o=custom_index.svg
|
|
Pseudoknot Structure (Simple)
A basic pseudoknot involving two interacting molecules:
rna_to_img.py \
-u="<<<..((..>>>&<<<..))..>>>" \
-e="NNNNNNNNNNN&NNNNNNNNNNNN" \
-c=distinct \
-o=pseudoknot_simple.svg
|
|
Pseudoknot Structure (Complex - Kissing Hairpins)
Two molecules forming a complex kissing hairpin interaction:
rna_to_img.py \
-u="<<<..(((..>>>...<<<..(((..>>>..&<<<..)))..>>>...<<<..)))..>>>.." \
-e="NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN&NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN" \
-c=distinct \
-o=kissing_hairpins.svg
|
|