Draw nucleic acid structures
Project description
NucDraw is a simple Python package inspired by Forgi for the creation of NUCleic acid structures DRAWings. It relies on viennaRNA and matplotlib to convert 1D dot-bracket structures into easily to interpret 2D drawings.
This package is well-suited to generate many structures in an automated way from multiplexed and high-throughput data, and allows to visualize multiple strands without pseudo-knots.
To install simply run from terminal:
- pip install nucdraw
If you use this package for your project, please remember to cite:
- 10.5281/zenodo.15352138
Several functionalities are included to allow the customization of your graphs. See the following examples.
from nucdraw import NucDraw
# Let's generate a simple-to-read graph for a long RNA fold
seq = "CACAAUGUGGCCGAGGACUUUGAUUGCACAUUGUUGUUUUUUUAAUAGUCAUUCCAAAUAUGAGAUGCGUUGUUACAGGAAGUCCCUUGCCAUCCUAAAAGCCACCCCACUUCUCUCUAAGGAGAAUGGCCCAGUCCUCUCCCAAGUCCACACAGGGGAGGUGAUAGCAUUGCUUUCGUGUAAAUUAUGUAAUGCAAAAUUUUUUUAAUCUUCGCCUUAAUACUUUUUUAUUUUGUUUUAUUUUGAAUGAUGAGCCUUCGUGCCCCCCCUUCCCCCUUUUUUGUCCCCCAACUUGAGAUG"
mfe = ".((((((((....((....)).....)))))))).......................................((((..(((............................((((((....))))))...........((((((............))))))............)))..))))......................................................................................................................"
nc = NucDraw(mfe)
nc.generate(degree=90)
nc.plotter(8, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':2, 'c':'red'}, scwargs={'s':10, 'c':'k'})
# Let's focus on one section and increase the details
seq = "CACAAUGUGGCCGAGGACUUUGAUUGCACAUUGUUGUUUUUUUAAUAGUCAUUCCAAAUAUGAGAUGCGUUGUUACAGGAAGUCCCUUGCCAUCCUAAAAGCCACCCCACUUCUCUCUAAGGAGAAUGGCCCAGUCCUCUCCCAAGUCCACACAGGGGAGGUGAUAGCAUUGCUUUCGUGUAAAUUAUGUAAUGCAAAAUUUUUUUAAUCUUCGCCUUAAUACUUUUUUAUUUUGUUUUAUUUUGAAUGAUGAGCCUUCGUGCCCCCCCUUCCCCCUUUUUUGUCCCCCAACUUGAGAUG"
mfe = ".((((((((....((....)).....)))))))).......................................((((..(((............................((((((....))))))...........((((((............))))))............)))..))))......................................................................................................................"
seq = seq[:50]
mfe = mfe[:50]
nc = NucDraw(mfe)
nc.generate(degree=90)
nc.plotter(8, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':2, 'c':'red'}, scwargs={'s':10, 'c':'k'})
nc.plot_circles(circle_size = 4, circle_color='white')
nc.plot_sequence(seq, {'fontsize':8, 'color':'k'})
# Let's annotate with numbers.
# nc.numbering_outside(distance, shape, number spacing, {'fontsize':10, 'color':'k'})
# "distance" determines how far the numbers will be from the structure
# "shape" tunes the direction along which the numbers will move away from the structure
# "number spacing" can either be an integer or a list.
# An integer "i" will cause every "i-th" number to be displayed.
# A list will determine exactly what numbers to be shown.
# We can add a number at a distance=15, with shape=5 and spacing=10
nc.numbering_outside(15, 5, 10, {'fontsize':10, 'color':'k'})
# Let's focus on one section and increase the details
# Let's color-code the nucleobases
seq = "CACAAUGUGGCCGAGGACUUUGAUUGCACAUUGUUGUUUUUUUAAUAGUCAUUCCAAAUAUGAGAUGCGUUGUUACAGGAAGUCCCUUGCCAUCCUAAAAGCCACCCCACUUCUCUCUAAGGAGAAUGGCCCAGUCCUCUCCCAAGUCCACACAGGGGAGGUGAUAGCAUUGCUUUCGUGUAAAUUAUGUAAUGCAAAAUUUUUUUAAUCUUCGCCUUAAUACUUUUUUAUUUUGUUUUAUUUUGAAUGAUGAGCCUUCGUGCCCCCCCUUCCCCCUUUUUUGUCCCCCAACUUGAGAUG"
mfe = ".((((((((....((....)).....)))))))).......................................((((..(((............................((((((....))))))...........((((((............))))))............)))..))))......................................................................................................................"
seq = seq[:50]
mfe = mfe[:50]
nc = NucDraw(mfe)
nc.generate(degree=90)
nc.plotter(8, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':2, 'c':'k'}, scwargs={'s':10, 'c':'k'})
nc.plot_circles(seq, circle_size = 4)
nc.plot_sequence(seq, {'fontsize':8, 'color':'k'})
# Let's draw a 2-strands complex
seq1 = 'UGACGUAAAACUGAC'
seq2 = 'UGUUACCGUA'
seq = "".join([seq1, seq2])
mfe = '..((((..(((....+.))))).)).'
nc = NucDraw(mfe)
nc.generate()
nc.plotter(6, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':3, 'c':'k'}, scwargs={'s':10, 'c':'k'})
nc.plot_circles(seq, circle_size = 3, circle_color='white')
# Let's draw a 3-strands complex and color the strands differently
seq1 = 'UGACGUAAAACUGAC'
seq2 = 'UGUUACCGUAGUACG'
seq3 = 'ACCGUAC'
seq = "".join([seq1, seq2, seq3])
mfe = '..((((..(((....+.))))).)).(((((+..)))))'
nc = NucDraw(mfe)
nc.generate()
nc.plotter(8, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':3, 'c':'k'}, scwargs={'s':10, 'c':'k'})
nc.plot_circles(seq, circle_size = 2, circle_color='white')
nc.multistrand_coloring(clr=['red', 'blue', 'green'], bckwargs={'lw' : 3})
# Let's annotate with numbers.
# nc.numbering_outside(distance, shape, number spacing, {'fontsize':10, 'color':'k'})
# "distance" determines how far the numbers will be from the structure
# "shape" tunes the direction along which the numbers will move away from the structure
# "number spacing" can either be an integer or a list.
# An integer "i" will cause every "i-th" number to be displayed.
# A list will determine exactly what numbers to be shown.
# We can add a number at a distance=10, with shape=2 and spacing=4
nc.numbering_outside(10, 2, 4, {'fontsize':10, 'color':'k'})
# Let's draw a 3-strands complex and color the strands differently
seq1 = 'UGACGUAAAACUGAC'
seq2 = 'UGUUACCGUAGUACG'
seq3 = 'ACCGUAC'
seq = "".join([seq1, seq2, seq3])
mfe = '..((((..(((....+.))))).)).(((((+..)))))'
nc = NucDraw(mfe)
nc.generate()
nc.plotter(8, bckwargs={'lw':2, 'color':'k'}, bpkwargs={'lw':3, 'c':'k'}, scwargs={'s':10, 'c':'k'})
nc.plot_circles(seq, circle_size = 2, circle_color='white')
nc.multistrand_coloring(clr=['red', 'blue', 'green'], bckwargs={'lw' : 3})
# Let's annotate with numbers in custom positions [3, 5, 8, 24].
# nc.numbering_outside(distance, shape, number spacing, {'fontsize':10, 'color':'k'})
# Notice that these positions may exceed the length of your strands, so message is thrown at the user.
nc.numbering_outside(10, 2, [3,5,8,24], {'fontsize':10, 'color':'k'})
24 exceeds the length of the structure # 1 .
8 exceeds the length of the structure # 2 .
24 exceeds the length of the structure # 2 .
Project details
Release history Release notifications | RSS feed
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 nucdraw-0.1.2.tar.gz.
File metadata
- Download URL: nucdraw-0.1.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0df07bab18941f64e06320e85672c2939f536db4c7aa502ee3a4f0f9125d4bb9
|
|
| MD5 |
e2caa3943e4c29d422567558430725d5
|
|
| BLAKE2b-256 |
3f38fd57c26c57eeec54a8ce43e540a7819c5ffa5ab1882bfc0920977dfc9964
|
File details
Details for the file nucdraw-0.1.2-py3-none-any.whl.
File metadata
- Download URL: nucdraw-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ada86d1d4e73b7dbfac58d1ad126608193f6ee53b682284ee6415b6a97cf649
|
|
| MD5 |
0c9c05ec49b7d19290671fde0a78d198
|
|
| BLAKE2b-256 |
dc0bb4e94fb906d5366cc57466dad746d13c4fb43149085163d8a09cc98503c3
|