import molecularnodes as mn
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
= mn.Canvas() canvas
Rendering
An example of rendering MDAnalysis Trajectories.
Here is an example that uses Canvas
to render images and animations of MDAnalysis Universes.
Add Universe to Blender
= mda.Universe(PSF, DCD)
u = mn.Trajectory(u).add_style("cartoon")
t
# add resid 1 and 129 with spheres style
'spheres', selection="resid 1 129")
t.add_style(# set the sphere geometry to mesh
1].geometry = "mesh" t.styles[
Add annotations to Universe
# add universe info annotation
t.annotations.add_universe_info()
# add COM distance between resid 1 and 129 annotation
t.annotations.add_com_distance(="resid 1", selection2="resid 129", text1="r1", text2="r129"
selection1 )
<molecularnodes.annotations.manager.COMDistance_interface at 0x7867b19ab1d0>
Render Image
# frame the trajectory
canvas.frame_object(t)
# render image of scene at frame 75
=75) canvas.snapshot(frame
Render Animation
# render animation of scene from frame 10 to 50 at 50% sccale
=10, frame_end=50, render_scale=50) canvas.animation(frame_start