Quick Visualization Tutorial¶
In [ ]:
Copied!
import mdna
import mdna
The autoreload extension is already loaded. To reload it, use: %reload_ext autoreload
Welcome to the DNA visualization tutorial using the MDNA module. This notebook will demonstrate different ways to visualize DNA structures. You'll learn to:
- Perform basic DNA drawing.
- Customize drawing styles and visual aspects of DNA structures.
- Integrate multiple DNA visualizations in a single plot.
Basic DNA Drawing¶
Start by generating a simple DNA structure and drawing it using default settings.
In [3]:
Copied!
# Basic drawing
dna = mdna.make(n_bp=24)
dna.draw()
# Basic drawing
dna = mdna.make(n_bp=24)
dna.draw()
Advanced Drawing Options¶
Customize the drawing by adjusting styles and adding components like helical axes.
In [4]:
Copied!
# Change styling
dna.draw(backbone=True, triads=False, helical_axis=True, lw=3, markersize=4, color_anti='red', color_lead='blue', color_axis='green')
# Change styling
dna.draw(backbone=True, triads=False, helical_axis=True, lw=3, markersize=4, color_anti='red', color_lead='blue', color_axis='green')
Drawing Mean Reference Frames of Base Pairs¶
Visualize only the reference frames without the backbone for clarity.
In [5]:
Copied!
# Draw mean reference frames of base pairs
dna.draw(backbone=False, triads=True)
# Change styling
dna.draw(backbone=False, triads=True, length=1)
# Draw mean reference frames of base pairs
dna.draw(backbone=False, triads=True)
# Change styling
dna.draw(backbone=False, triads=True, length=1)
Combining Multiple DNA Structures in One Figure¶
Combine multiple DNA structures in a single 3D plot using matplotlib.
In [9]:
Copied!
# Add multiple drawings to the same figure
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
dna1 = mdna.make(n_bp=100, circular=True)
dna1.draw(ax=ax, lw=1, color_anti='blue')
shape = np.array([[15,5,5],[3,3,3],[2,2,2],[0,0,0]])
dna2 = mdna.make(control_points=shape,n_bp=50)
dna2.draw(ax=ax, color_anti='red')
# Add multiple drawings to the same figure
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
dna1 = mdna.make(n_bp=100, circular=True)
dna1.draw(ax=ax, lw=1, color_anti='blue')
shape = np.array([[15,5,5],[3,3,3],[2,2,2],[0,0,0]])
dna2 = mdna.make(control_points=shape,n_bp=50)
dna2.draw(ax=ax, color_anti='red')
Random sequence: TCATGGGATTTCGTTGCATGACTGTCCTAGCATTGATAATCGCGTAAGCGCATAACCATAAACATTGCTGTATACGAGAGATGCCGCAGGTTGTCCGAGG Start rescaling spline based on requested number of base pairs. This requires recomputation of the control points to match the desired number of base pairs. Spline scaled to match the target number of base pairs: 100 Structure is requested to be circular: Excess twist per base to make ends meet: 1.71 degrees New twist angle per base pair: 36.0 Random sequence: AGAAGTTTTATAGACCAACCATTATAATCGTAACGAAACGTTCTATCCAA Start rescaling spline based on requested number of base pairs. This requires recomputation of the control points to match the desired number of base pairs. Spline scaled to match the target number of base pairs: 50
In [ ]:
Copied!