ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

InteractionHighlight

Draw selected hydrogen-bond or electrostatic contact lines.

python
from proteinmotion import InteractionHighlight

Constructor

python
InteractionHighlight(
    analysis,
    *,
    mode='3d',
    color=None,
    attractive_color='#58b8fa',
    repulsive_color='#ef7484',
    show_distances=False,
    max_pairs=100,
    region=None,
    endpoints='donor_acceptor',
    **line_options,
)

Parameters

ParameterDefaultDescription
analysisRequiredHydrogenBonds or Electrostatics analysis.
modekeyword only'3d'"3d" draws lines within the model; "2d" draws lines over the image.
colorkeyword onlyNoneFixed line color, or None to use the interaction-specific colors.
attractive_colorkeyword only'#58b8fa'Color for negative electrostatic pair energy.
repulsive_colorkeyword only'#ef7484'Color for positive electrostatic pair energy.
show_distanceskeyword onlyFalseDisplay distance labels on interaction lines.
max_pairskeyword only100Maximum number of interaction lines displayed, from 1 to 2000.
regionkeyword onlyNoneOptional Region that filters pairs touching the selection.
endpointskeyword only'donor_acceptor'"donor_acceptor" or "hydrogen_acceptor" for hydrogen-bond line endpoints.
**line_optionsAdditional Distance style options.

Notes

Hydrogen-bond labels use donor–acceptor distance by default. endpoints="hydrogen_acceptor" uses H···acceptor positions and distances. Electrostatic contacts use different colors for attraction and repulsion. Additional line options go to Distance.

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 = helix_view(self)
hb = HydrogenBonds(
    p,
    donors=p.select(residues=(23, 34), atoms="N"),
    max_distance=3.5,
    min_angle=150,
    hydrogens="backbone",
)
lines = hb.highlight(
    mode="3d",
    color="#f2ba67",
    radius=0.07,
    dash_count=5,
    show_distances=False,
)
self.play(Write(lines), run_time=2)
self.play(self.camera.animate.orbit(0.6), run_time=3)
self.wait(1)
Output Preview · 6.0 s · 60 fps
Hydrogen bonds

Geometry-based N···O contacts with inferred backbone H.

Methods and properties

NameDescription
glyph_countpropertyNumber of shaped glyphs used for writing animation.
text_progresspropertyCurrent reveal progress for glyphs and annotation lines.
layout()methodProject text and line geometry for the renderer at the current frame.
set_opacity()method · inherited from AnnotationSet or animate opacity in [0, 1].
move_to()method · inherited from AnnotationSet or animate text position in normalized image coordinates.
shift()method · inherited from AnnotationTranslate the object by an offset.
snapshot()method · inherited from AnnotationCapture the current state for deterministic timeline evaluation.
restore()method · inherited from AnnotationRestore a state produced by snapshot().
animateproperty · inherited from AnnotationCreate a builder for fluent animation calls. Pass the result to scene.play().
python
InteractionHighlight.glyph_count

Number of shaped glyphs used for writing animation.

python
InteractionHighlight.text_progress

Current reveal progress for glyphs and annotation lines.

python
InteractionHighlight.layout(camera, width, height)

Project text and line geometry for the renderer at the current frame.

ParameterDefaultDescription
cameraRequiredCamera used to project or frame objects.
widthRequiredImage width in pixels.
heightRequiredImage height in pixels.

Returns: AnnotationLayout containing glyph placements and line paths.

Inherited from annotations.Annotation.

python
InteractionHighlight.set_opacity(opacity)

Set or animate opacity in [0, 1].

ParameterDefaultDescription
opacityRequiredOpacity in [0, 1], from transparent to opaque.

Returns: The object or animation builder.

Inherited from annotations.Annotation.

python
InteractionHighlight.move_to(position)

Set or animate text position in normalized image coordinates.

ParameterDefaultDescription
positionRequiredImage coordinates (x, y), with (0, 0) at the top-left and (1, 1) at the bottom-right.

Returns: The annotation or animation builder.

Inherited from annotations.Annotation.

python
InteractionHighlight.shift(offset)

Translate the object by an offset.

ParameterDefaultDescription
offsetRequiredOffset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts.

Returns: The object or animation builder.

Inherited from annotations.Annotation.

python
InteractionHighlight.snapshot()

Capture the current state for deterministic timeline evaluation.

Returns: State dictionary.

Inherited from annotations.Annotation.

python
InteractionHighlight.restore(state)

Restore a state produced by snapshot().

ParameterDefaultDescription
stateRequiredState returned by snapshot().

Returns: None

Inherited from annotations.Annotation.

python
InteractionHighlight.animate

Create a builder for fluent animation calls. Pass the result to scene.play().