ProteinMotion
Reference navigation
On this page

Representation

Transition between cartoon, ribbon, ball-and-stick and surface, with optional nucleotide base styles.

python
from proteinmotion import Representation

Constructor

python
Representation(
    protein,
    representation,
    *,
    bases=None,
    rate_func=smooth,
    easing=None,
    **options,
)

Parameters

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
representationRequired"cartoon", "ribbon", "ball_and_stick", or "surface".
baseskeyword onlyNoneNucleotide base style: slabs, rings, sticks, ladder, or none. None in Representation preserves the current style.
rate_funckeyword onlysmoothCallable that maps progress in [0, 1] to a finite value in [0, 1].
easingkeyword onlyNoneNamed easing (smooth, linear, ease_in_out_sine, there_and_back) or callable mapping [0, 1] to [0, 1]. Per-item easing preserves stagger timing.
**options—Representation options such as kind, grid_spacing, atom_scale, bond_radius, color, or width. These are applied when the transition begins.

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().surface(resolution=0.7).cartoon()
frame(self, p)
self.wait(1)
for name in ("ribbon", "ball_and_stick", "surface"):
    self.play(Representation(p, name), run_time=1.2)
    self.play(Rotate(p, 0.45), run_time=1.5)
Output Preview · 9.1 s · 60 fps
Representation changes

Cartoon, ribbon, ball-and-stick, and SES surface.

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
Representation.bind()

Capture starting values when the scene schedules the animation.

Returns: None

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

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

Objects whose state this animation changes.