Reference navigation
On this page
CLASS · v0.9.1
PlayTrajectory
Interpolate through coordinate states in a trajectory.
from proteinmotion import PlayTrajectoryConstructor
PlayTrajectory(
protein,
trajectory=None,
*,
start=0,
end=None,
rate_func=linear,
state_easing=linear,
)Parameters
| Parameter | Default | Description |
|---|---|---|
protein | Required | Protein object to read or animate. |
trajectory | None | Trajectory with the same atom identities and order; None uses the protein’s trajectory. |
startkeyword only | 0 | Starting frame index; may be fractional. |
endkeyword only | None | Ending frame index; None uses the last frame. |
rate_funckeyword only | linear | Callable that maps progress in [0, 1] to a finite value in [0, 1]. |
state_easingkeyword only | linear | Callable 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.
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)PDB 2K39 models 1–3. Interpolation shows structural variation.
Methods and properties
| Name | Description |
|---|---|
| apply()method | Evaluate the animation at eased progress alpha. Called by the timeline. |
| bind()method · inherited from Animation | Capture starting values when the scene schedules the animation. |
| targetsproperty · inherited from Animation | Objects whose state this animation changes. |
PlayTrajectory.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.
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.
PlayTrajectory.targetsObjects whose state this animation changes.