ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

PlayTrajectory

Interpolate through coordinate states in a trajectory.

python
from proteinmotion import PlayTrajectory

Constructor

python
PlayTrajectory(
    protein,
    trajectory=None,
    *,
    start=0,
    end=None,
    rate_func=linear,
    state_easing=linear,
)

Parameters

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
trajectoryNoneTrajectory with the same atom identities and order; None uses the protein’s trajectory.
startkeyword only0Starting frame index; may be fractional.
endkeyword onlyNoneEnding frame index; None uses the last frame.
rate_funckeyword onlylinearCallable that maps progress in [0, 1] to a finite value in [0, 1].
state_easingkeyword onlylinearCallable controlling interpolation within each adjacent pair of trajectory frames.

Notes

Trajectory topology must match the protein. rate_func controls progress through the clip; state_easing controls interpolation between each pair of frames. Deposited NMR model order represents structural variation rather than measured time.

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 Scene excerpt
python
loaded = Protein.from_file(DATA / "2k39.cif", chains="A")
core = loaded.select(residues=(1, 70), atoms="CA")
aligned = loaded.trajectory.aligned(indices=core.atom_indices)
p = Protein.from_trajectory(aligned).cartoon().center()
frame(self, p)
self.play(
    PlayTrajectory(p, start=0, end=2, state_easing=smooth),
    run_time=6,
)
self.wait(0.5)
Output Preview · 6.5 s · 60 fps
NMR state playback

PDB 2K39 models 1–3. Interpolation shows structural variation.

Methods and properties

NameDescription
apply()methodEvaluate the animation at eased progress alpha. Called by the timeline.
bind()method · inherited from AnimationCapture starting values when the scene schedules the animation.
targetsproperty · inherited from AnimationObjects whose state this animation changes.
python
PlayTrajectory.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
PlayTrajectory.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 animation.Animation.

python
PlayTrajectory.targets

Objects whose state this animation changes.