Reference navigation
On this page
SetTorsions
Animate backbone and side-chain torsions to new values in degrees; atoms rotate about bonds, so bond lengths and angles stay fixed.
from proteinmotion import SetTorsionsConstructor
SetTorsions(
target,
*,
phi=None,
psi=None,
omega=None,
chi1=None,
chi2=None,
chi3=None,
chi4=None,
chi5=None,
conformation=None,
anchor='center',
secondary='auto',
path='allowed',
stagger=None,
reverse=False,
easing='smooth',
)Parameters
| Parameter | Default | Description |
|---|---|---|
target | Required | Protein or Region whose amino acids change. |
phikeyword only | None | φ, C(i−1)–N–Cα–C. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
psikeyword only | None | ψ, N–Cα–C–N(i+1). Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
omegakeyword only | None | ω, the peptide bond Cα–C–N(i+1)–Cα(i+1). Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
chi1keyword only | None | χ1 side-chain torsion. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
chi2keyword only | None | χ2 side-chain torsion. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
chi3keyword only | None | χ3 side-chain torsion. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
chi4keyword only | None | χ4 side-chain torsion. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
chi5keyword only | None | χ5 side-chain torsion. Target angle in degrees: one value for every selected residue, one per residue, or a {residue number: angle} dictionary. None leaves it unchanged. |
conformationkeyword only | None | Sets φ and ψ together: helix, alpha, 310, pi, strand, beta, parallel, antiparallel, ppii, extended, or left. |
anchorkeyword only | 'center' | Part that stays still: "center" keeps the middle of each chain in place, "n" or "c" a terminus; a Region is held in place as a whole. |
secondarykeyword only | 'auto' | "auto" blends the cartoon toward the DSSP assignment of the final conformation; "keep" leaves it unchanged. |
pathkeyword only | 'allowed' | "allowed" turns φ and ψ the way that keeps each residue in favored and allowed Ramachandran regions; "shortest" takes the smaller turn. |
staggerkeyword only | None | Fraction of the clip, in [0, 1), used to start residues one after another from N to C. |
reversekeyword only | False | Stagger from C to N. |
easingkeyword only | 'smooth' | Easing of each torsion's change. |
Notes
Torsions in rings, such as proline φ, are skipped and listed by locked. Disulfides and ligands bonded to several residues stretch. The motion illustrates a change of angles, not a folding pathway.
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 |
|---|---|
| lockedproperty | (residue index, torsion) pairs that could not rotate because they lie in rings. |
| 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. |
SetTorsions.locked(residue index, torsion) pairs that could not rotate because they lie in rings.
SetTorsions.bind()Capture starting values when the scene schedules the animation.
Returns: None
Called by ProteinScene.play(). An animation instance can be bound once.
SetTorsions.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.
SetTorsions.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.
SetTorsions.targetsObjects whose state this animation changes.