ProteinMotion
Reference navigation
On this page

ShowAtoms

Grow atoms in as ball-and-stick detail over a cartoon, ribbon, or surface.

python
from proteinmotion import ShowAtoms

Constructor

python
ShowAtoms(target, **kwargs)

Parameters

ParameterDefaultDescription
targetRequiredProtein or Region whose atoms to show.
**kwargs—Additional keyword options described below or in the linked constructor.

Additional keyword arguments

ParameterDefaultDescription
residue_delaykeyword only0Delay in seconds between successive residue starts.
delay_secondskeyword onlyNoneDelay between successive residue, chain, or glyph starts, in seconds. Choose one delay option.
staggerkeyword onlyNoneTotal fraction of the clip reserved for residue starts, in [0, 1).
reversekeyword onlyFalseReverse residue or glyph order.
easingkeyword only'smooth'Named easing (smooth, linear, ease_in_out_sine, there_and_back) or callable mapping [0, 1] to [0, 1]. Per-item easing preserves stagger timing.

Notes

Detail atoms use the protein's atom_scale and bond_radius, element colors, and carbons in the structure palette. A bond appears once both of its atoms are visible. Residue staggering and run_time limits match SetOpacity.

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
"""Show 1CLL Ca²⁺ ions on the cartoon and grow the side chains that coordinate them."""

from pathlib import Path

from proteinmotion import Protein, ProteinScene, ShowSideChains, Unwrite, Write

DATA = Path(__file__).parent / "data"


class LigandsAndSideChains(ProteinScene):
    def construct(self):
        # Ions and ligands outside the traced chain draw as ball-and-stick detail.
        p = Protein.from_file(DATA / "1cll.cif").cartoon().center()
        self.add(p)
        self.camera.frame(p, margin=1.0, aspect=self.width / self.height)
        self.camera.theta, self.camera.phi = 0.4, 0.15
        self.camera.depth_cue = 0.3
        self.play(self.camera.animate.orbit(0.4), run_time=1.5)

        # Whole residues with an atom within 3 Å of the first Ca²⁺ ion.
        ion = p.select(ions=True, residues=149)
        site = p.select(within=3.0, of=ion)
        self.focus(site | ion, margin=1.3, run_time=1.5)
        self.play(ShowSideChains(site, residue_delay=0.2), run_time=1.8)
        labels = p.label_residues(
            residues=[20, 22, 24, 26, 31],
            font_size=30,
            color="#f2ba67",
            offsets={20: (-260, 90), 22: (-300, -40), 24: (-120, -170), 26: (260, -130), 31: (300, 70)},
        )
        self.play(Write(labels, lag_ratio=0.1), run_time=1.2)
        self.play(self.camera.animate.orbit(0.5), run_time=2.5)
        self.play(Unwrite(labels), run_time=0.6)

        # Every residue within 3 Å of any of the four ions, staggered N to C.
        self.focus(p, margin=1.0, run_time=1.5)
        self.play(
            ShowSideChains(p.select(within=3.0, of=p.select(ions=True)), residue_delay=0.04),
            self.camera.animate.orbit(0.5),
            run_time=2.5,
        )
Output Preview · 13.1 s · 60 fps
Ions and coordinating side chains

1CLL Ca²⁺ ions on the cartoon, and the side chains within 3 Å of each ion.

Methods and properties

NameDescription
bind()method · inherited from _AppearanceAnimationCapture starting values when the scene schedules the animation.
apply()method · inherited from _AppearanceAnimationEvaluate the animation at eased progress alpha. Called by the timeline.
during()method · inherited from AnimationSet this animation duration and start delay in seconds.
targetsproperty · inherited from AnimationObjects whose state this animation changes.

Inherited from styling._AppearanceAnimation.

python
ShowAtoms.bind()

Capture starting values when the scene schedules the animation.

Returns: None

Called by ProteinScene.play(). An animation instance can be bound once.

Inherited from styling._AppearanceAnimation.

python
ShowAtoms.apply(alpha)

Evaluate the animation at eased progress alpha. Called by the timeline.

ParameterDefaultDescription
alphaRequiredEased animation progress in [0, 1].

Returns: None

Inherited from animation.Animation.

python
ShowAtoms.during(seconds, *, delay=0)

Set this animation duration and start delay in seconds.

ParameterDefaultDescription
secondsRequiredPositive animation duration in seconds.
delaykeyword only0Nonnegative animation start delay in seconds.

Inherited from animation.Animation.

python
ShowAtoms.targets

Objects whose state this animation changes.