ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

Deform

Interpolate coordinates toward the result of a user-supplied function.

python
from proteinmotion import Deform

Constructor

python
Deform(protein, function, **kwargs)

Parameters

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
functionRequiredCallable receiving a copy of the coordinates and returning an array of the same shape.
**kwargsAdditional keyword options described below or in the linked constructor.

Additional keyword arguments

ParameterDefaultDescription
rate_funckeyword onlysmoothCallable that maps progress in [0, 1] to a finite value in [0, 1].

Notes

The function runs when the animation is scheduled. It must return finite coordinates with the original shape. This operation creates an illustrative shape change.

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
p = ubiquitin()
frame(self, p, margin=1.05)
rest = p.positions.copy()

def stretch(xyz):
    center = xyz.mean(axis=0)
    return center + (xyz - center) * [1.4, 1, 1]

self.play(Deform(p, stretch), run_time=2)
self.wait(0.5)
self.play(Morph(p, rest, align=False), run_time=2)
self.wait(0.5)
Output Preview · 5.0 s · 60 fps
Deformation and morph

A synthetic stretch followed by a return to the original coordinates.

Methods and properties

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

python
Deform.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
Deform.targets

Objects whose state this animation changes.