Reference navigation
On this page
SecondaryStructure
Blend the cartoon to new helix, strand, and coil states.
from proteinmotion import SecondaryStructureConstructor
SecondaryStructure(protein, assignments='dssp', **kwargs)Parameters
| Parameter | Default | Description |
|---|---|---|
protein | Required | Protein whose cartoon changes. |
assignments | 'dssp' | "dssp" assigns states from the coordinates when the clip starts; otherwise one H, E, or C per topology residue. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
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.
Code Full script
"""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)Output Preview · 12.1 s · 60 fps
A 12-residue alanine peptide: ψ of Ala6 turns, then every residue moves to α-helix angles.
Methods and properties
| Name | Description |
|---|---|
| bind()method | Capture starting values when the scene schedules the animation. |
| apply()method | Evaluate the animation at eased progress alpha. Called by the timeline. |
| during()method · inherited from Animation | Set this animation duration and start delay in seconds. |
| targetsproperty · inherited from Animation | Objects whose state this animation changes. |
SecondaryStructure.bind()Capture starting values when the scene schedules the animation.
Returns: None
Called by ProteinScene.play(). An animation instance can be bound once.
SecondaryStructure.apply(alpha)Evaluate the animation at eased progress alpha. Called by the timeline.
| Parameter | Default | Description |
|---|---|---|
alpha | Required | Eased animation progress in [0, 1]. |
Returns: None
Inherited from animation.Animation.
SecondaryStructure.during(seconds, *, delay=0)Set this animation duration and start delay in seconds.
| Parameter | Default | Description |
|---|---|---|
seconds | Required | Positive animation duration in seconds. |
delaykeyword only | 0 | Nonnegative animation start delay in seconds. |
Inherited from animation.Animation.
SecondaryStructure.targetsObjects whose state this animation changes.