Reference navigation
On this page
CLASS · v0.9.1
InteractionHighlight
Draw selected hydrogen-bond or electrostatic contact lines.
from proteinmotion import InteractionHighlightConstructor
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
| Parameter | Default | Description |
|---|---|---|
analysis | Required | HydrogenBonds or Electrostatics analysis. |
modekeyword only | '3d' | "3d" draws lines within the model; "2d" draws lines over the image. |
colorkeyword only | None | Fixed 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 only | False | Display distance labels on interaction lines. |
max_pairskeyword only | 100 | Maximum number of interaction lines displayed, from 1 to 2000. |
regionkeyword only | None | Optional Region that filters pairs touching the selection. |
endpointskeyword only | 'donor_acceptor' | "donor_acceptor" or "hydrogen_acceptor" for hydrogen-bond line endpoints. |
**line_options | — | Additional 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.
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)Geometry-based N···O contacts with inferred backbone H.
Methods and properties
| Name | Description |
|---|---|
| glyph_countproperty | Number of shaped glyphs used for writing animation. |
| text_progressproperty | Current reveal progress for glyphs and annotation lines. |
| layout()method | Project text and line geometry for the renderer at the current frame. |
| set_opacity()method · inherited from Annotation | Set or animate opacity in [0, 1]. |
| move_to()method · inherited from Annotation | Set or animate text position in normalized image coordinates. |
| shift()method · inherited from Annotation | Translate the object by an offset. |
| snapshot()method · inherited from Annotation | Capture the current state for deterministic timeline evaluation. |
| restore()method · inherited from Annotation | Restore a state produced by snapshot(). |
| animateproperty · inherited from Annotation | Create a builder for fluent animation calls. Pass the result to scene.play(). |
InteractionHighlight.glyph_countNumber of shaped glyphs used for writing animation.
InteractionHighlight.text_progressCurrent reveal progress for glyphs and annotation lines.
InteractionHighlight.layout(camera, width, height)Project text and line geometry for the renderer at the current frame.
| Parameter | Default | Description |
|---|---|---|
camera | Required | Camera used to project or frame objects. |
width | Required | Image width in pixels. |
height | Required | Image height in pixels. |
Returns: AnnotationLayout containing glyph placements and line paths.
Inherited from annotations.Annotation.
InteractionHighlight.set_opacity(opacity)Set or animate opacity in [0, 1].
| Parameter | Default | Description |
|---|---|---|
opacity | Required | Opacity in [0, 1], from transparent to opaque. |
Returns: The object or animation builder.
Inherited from annotations.Annotation.
InteractionHighlight.move_to(position)Set or animate text position in normalized image coordinates.
| Parameter | Default | Description |
|---|---|---|
position | Required | Image 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.
InteractionHighlight.shift(offset)Translate the object by an offset.
| Parameter | Default | Description |
|---|---|---|
offset | Required | Offset (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.
InteractionHighlight.snapshot()Capture the current state for deterministic timeline evaluation.
Returns: State dictionary.
Inherited from annotations.Annotation.
InteractionHighlight.restore(state)Restore a state produced by snapshot().
| Parameter | Default | Description |
|---|---|---|
state | Required | State returned by snapshot(). |
Returns: None
Inherited from annotations.Annotation.
InteractionHighlight.animateCreate a builder for fluent animation calls. Pass the result to scene.play().