ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

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.
**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

Protein 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 their given atom order. Alignment uses matching Cα atoms when at least three exist.

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

Objects whose state this animation changes.