ProteinMotion
Reference navigation
On this page

Morph

Interpolate matching atoms to a protein or coordinate array.

python
from proteinmotion import Morph

Constructor

python
Morph(protein, target, *, align=True, atom_map=None, **kwargs)

Parameters

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
targetRequiredDestination Protein or coordinates with the same shape as the source.
alignkeyword onlyTrueAlign the destination to the source before interpolation.
atom_mapkeyword onlyNoneOne unique target atom index per source atom; used with a Protein destination.
**kwargs—Additional 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

Inputs match atoms by chain, residue number, insertion code, residue name, and atom name. atom_map can supply an explicit one-to-one mapping. Raw arrays use source atom order. Alignment uses Cα for proteins and C1′ for DNA/RNA. Nucleotide alignment requires at least three anchors; use align=False to preserve supplied coordinates.

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()methodEvaluate 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.
python
Morph.bind()

Capture starting values when the scene schedules the animation.

Returns: None

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

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

Objects whose state this animation changes.