Reference navigation
On this page
RamachandranPlot
A live φ/ψ plot: one point per residue over favored and allowed regions.
from proteinmotion import RamachandranPlotConstructor
RamachandranPlot(
protein,
*,
region=None,
highlight=None,
labels=True,
color=None,
title='Ramachandran plot',
position=(0.64, 0.1),
size=(0.32, 0.56),
dot_size=5.5,
background='general',
region_labels=True,
paths=True,
highlight_color='#f5d477',
favored_color='#2b4566',
allowed_color='#1a2b42',
)Parameters
| Parameter | Default | Description |
|---|---|---|
protein | Required | Protein whose residues are plotted. |
regionkeyword only | None | Region limiting the plotted residues; None plots every residue with both φ and ψ. |
highlightkeyword only | None | Region whose residues are ringed, enlarged, and labeled. |
labelskeyword only | True | Label highlighted residues with name and number. |
colorkeyword only | None | One color for every point; None uses the residue colors drawn in 3D. |
titlekeyword only | 'Ramachandran plot' | Text displayed above the plot. |
positionkeyword only | (0.64, 0.1) | Image coordinates (x, y), with (0, 0) at the top-left and (1, 1) at the bottom-right. |
sizekeyword only | (0.32, 0.56) | Plot (width, height) as fractions of the viewport. |
dot_sizekeyword only | 5.5 | Point radius in design pixels at 1080p. |
backgroundkeyword only | 'general' | Reference regions: general, glycine, proline, preproline, or None. |
region_labelskeyword only | True | Label the αR, β, and αL regions. |
pathskeyword only | True | During SetTorsions, draw each moving residue's path from its start. |
highlight_colorkeyword only | '#f5d477' | Color marking the selected residues in the plot. |
favored_colorkeyword only | '#2b4566' | Fill of regions containing 98% of reference residues. |
allowed_colorkeyword only | '#1a2b42' | Fill of regions containing 99.8% of reference residues. |
Notes
Glycine is drawn as a triangle and proline as a square. Regions come from one chain per 30% identity cluster of X-ray entries at 1.4 Å or better; scripts/build_ramachandran_reference.py rebuilds them.
Example and output
This excerpt runs inside a scene’s construct() method. The full example file includes imports, structure loading, and camera setup. Run it from a repository checkout.
"""Turn one ψ angle, then wind a whole peptide into an α helix.
A 12-residue alanine peptide is built as an extended β strand. ψ of Ala6 turns to
−45° with its atoms shown over the cartoon; then every residue moves to φ = −57°,
ψ = −47°, starting at the N terminus. DSSP assigns the helix from the final
coordinates, and the cartoon blends from coil to helix as the angles change.
"""
from proteinmotion import (
FadeIn,
Protein,
ProteinScene,
RamachandranPlot,
SetTorsions,
Text,
Unwrite,
Write,
)
class TorsionBasics(ProteinScene):
def construct(self):
peptide = Protein.build("AAAAAAAAAAAA", "strand").cartoon()
middle = peptide.select(residues=6)
middle.show_atoms()
self.add(peptide)
self.camera.frame(peptide, margin=1.0, aspect=self.width / self.height, screen_position=(0.32, 0.55))
self.camera.phi = 0.3
plot = RamachandranPlot(peptide, highlight=middle, position=(0.62, 0.14), size=(0.35, 0.7))
self.add(Text("Torsion angles", font_size=48, font="semibold", position=(0.05, 0.07)))
marker = middle.torsion_marker("psi", radius=1.6)
self.play(FadeIn(plot), Write(marker), run_time=1.5)
self.play(SetTorsions(middle, psi=-45, anchor="n"), run_time=2.5)
self.play(Unwrite(marker), run_time=0.6)
self.play(SetTorsions(peptide, conformation="helix", stagger=0.5), run_time=5)
self.play(self.camera.animate.orbit(0.8), run_time=2.5)A 12-residue alanine peptide: ψ of Ala6 turns, then every residue moves to α-helix angles.
Methods and properties
| Name | Description |
|---|---|
| anglesproperty | Current (φ, ψ) in degrees for each plotted residue. |
| layout()method | Project text and line geometry for the renderer at the current frame. |
| with_panel()method · inherited from _Plot | Draw a rounded card behind the plot so molecules passing behind it stay hidden. |
| snapshot()method · inherited from _Plot | Capture the current state for deterministic timeline evaluation. |
| glyph_countproperty · inherited from _Plot | Number of shaped glyphs used for writing animation. |
| set_opacity()method · inherited from Annotation | Set or animate opacity in [0, 1]. |
| move_to()method · inherited from Annotation | Set or animate text position in normalized image coordinates. |
| shift()method · inherited from Annotation | Translate the object by an offset. |
| restore()method · inherited from Annotation | Restore a state produced by snapshot(). |
| animateproperty · inherited from Annotation | Create a builder for fluent animation calls. Pass the result to scene.play(). |
| text_progressproperty · inherited from Annotation | Current reveal progress for glyphs and annotation lines. |
RamachandranPlot.anglesCurrent (φ, ψ) in degrees for each plotted residue.
RamachandranPlot.layout(camera, width, height)Project text and line geometry for the renderer at the current frame.
| Parameter | Default | Description |
|---|---|---|
camera | Required | Camera used to project or frame objects. |
width | Required | Image width in pixels. |
height | Required | Image height in pixels. |
Returns: AnnotationLayout containing glyph placements and line paths.
Inherited from plots._Plot.
RamachandranPlot.with_panel(color='#0b1220', opacity=1.0, padding=18)Draw a rounded card behind the plot so molecules passing behind it stay hidden.
| Parameter | Default | Description |
|---|---|---|
color | '#0b1220' | Card color. |
opacity | 1.0 | Card opacity in [0, 1]. |
padding | 18 | Margin around the plot in design pixels at 1080p. |
Inherited from plots._Plot.
RamachandranPlot.snapshot()Capture the current state for deterministic timeline evaluation.
Returns: State dictionary.
Inherited from plots._Plot.
RamachandranPlot.glyph_countNumber of shaped glyphs used for writing animation.
Inherited from annotations.Annotation.
RamachandranPlot.set_opacity(opacity)Set or animate opacity in [0, 1].
| Parameter | Default | Description |
|---|---|---|
opacity | Required | Opacity in [0, 1], from transparent to opaque. |
Returns: The object or animation builder.
Inherited from annotations.Annotation.
RamachandranPlot.move_to(position)Set or animate text position in normalized image coordinates.
| Parameter | Default | Description |
|---|---|---|
position | Required | Image coordinates (x, y), with (0, 0) at the top-left and (1, 1) at the bottom-right. |
Returns: The annotation or animation builder.
Inherited from annotations.Annotation.
RamachandranPlot.shift(offset)Translate the object by an offset.
| Parameter | Default | Description |
|---|---|---|
offset | Required | Offset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts. |
Returns: The object or animation builder.
Inherited from annotations.Annotation.
RamachandranPlot.restore(state)Restore a state produced by snapshot().
| Parameter | Default | Description |
|---|---|---|
state | Required | State returned by snapshot(). |
Returns: None
Inherited from annotations.Annotation.
RamachandranPlot.animateCreate a builder for fluent animation calls. Pass the result to scene.play().
Inherited from annotations.Annotation.
RamachandranPlot.text_progressCurrent reveal progress for glyphs and annotation lines.