ProteinMotion
Reference navigation
On this page

TorsionAngles

φ, ψ, ω, and χ1–χ5 in degrees for a set of residues; NaN where a residue lacks a torsion.

python
from proteinmotion import TorsionAngles

Constructor

python
TorsionAngles(protein, residue_indices, values)

Parameters

ParameterDefaultDescription
proteinRequiredProtein that was measured.
residue_indicesRequiredTopology residue indices, one per row.
valuesRequiredArray of shape (residues, 8) in degrees, columns phi, psi, omega, chi1–chi5.

Notes

Use protein.torsions() or region.torsions(). Attributes phi, psi, omega, and chi1–chi5 return one value per residue; angles[23] or angles["A", 23] returns one residue's values.

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
python
"""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
Torsion angles

A 12-residue alanine peptide: ψ of Ala6 turns, then every residue moves to α-helix angles.

Methods and properties

NameDescription
__len__()methodReturn the number of frames with len(trajectory).
residue_idspropertyAuthor identities (chain, residue number, insertion code).
python
TorsionAngles.__len__()

Return the number of frames with len(trajectory).

Returns: int

python
TorsionAngles.residue_ids

Author identities (chain, residue number, insertion code).