Reference navigation
On this page
CLASS · v0.9.1
Morph
Interpolate matching atoms to a protein or coordinate array.
from proteinmotion import MorphConstructor
Morph(protein, target, *, align=True, atom_map=None, **kwargs)Parameters
| Parameter | Default | Description |
|---|---|---|
protein | Required | Protein object to read or animate. |
target | Required | Destination Protein or coordinates with the same shape as the source. |
alignkeyword only | True | Align the destination to the source before interpolation. |
atom_mapkeyword only | None | One 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
| Parameter | Default | Description |
|---|---|---|
rate_funckeyword only | smooth | Callable 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.
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)A synthetic stretch followed by a return to the original coordinates.
Methods and properties
| Name | Description |
|---|---|
| bind()method | Capture starting values when the scene schedules the animation. |
| apply()method | Evaluate the animation at eased progress alpha. Called by the timeline. |
| targetsproperty · inherited from Animation | Objects whose state this animation changes. |
Morph.bind()Capture starting values when the scene schedules the animation.
Returns: None
Called by ProteinScene.play(). An animation instance can be bound once.
Morph.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.
Morph.targetsObjects whose state this animation changes.