ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

ResidueLabel

Label one amino acid at its projected Cα position.

python
from proteinmotion import ResidueLabel

Constructor

python
ResidueLabel(
    region,
    text=None,
    *,
    offset=(24, -36),
    format='three_letter',
    include_chain=True,
    font_size=26,
    **kwargs,
)

Parameters

ParameterDefaultDescription
regionRequiredRegion selection attached to a protein.
textNoneCustom text, or None to use the residue name and author number.
offsetkeyword only(24, -36)Offset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts.
formatkeyword only'three_letter'Automatic residue name style: "three_letter" or "one_letter".
include_chainkeyword onlyTrueInclude the chain identifier in automatic residue names.
font_sizekeyword only26Font size in pixels at a 1080-pixel image height.
**kwargsAdditional keyword options described below or in the linked constructor.

Additional keyword arguments

ParameterDefaultDescription
subtitlekeyword onlyNoneOptional second line of text.
fontkeyword only'semibold'Bundled "regular" or "semibold", or a path to a TTF/OTF font.
colorkeyword only'#edf3fc'Hex color or RGB values. For tint setters, None restores the representation’s base palette.
subtitle_colorkeyword only'#a3b3c7'Subtitle color.
line_colorkeyword onlyNoneCallout line color; None uses the main text color.
line_widthkeyword only1.5Line width in design pixels at 1080p for overlays; ångströms for 3D highlight boxes.
tipkeyword only'dot'Callout endpoint marker: "dot", "arrow", or "none".
clampkeyword onlyTrueKeep callout text inside the image bounds.
follow_opacitykeyword onlyTrueMultiply annotation opacity by its selected atom opacity.
opacitykeyword only1.0Opacity in [0, 1], from transparent to opaque.

Notes

If the residue has no Cα, the label uses the selected atoms’ centroid. The selection must contain exactly one residue. Additional style options go to Callout.

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)
labels = p.label_residues(
    chain="A",
    residues=[8, 44, 70],
    font_size=40,
    color="#f2ba67",
    offsets={8: (-270, -90), 44: (440, -100), 70: (380, 150)},
)
self.play(Write(labels, lag_ratio=0.08), run_time=2)
self.play(self.camera.animate.orbit(0.35), run_time=2)
self.wait(1)
Output Preview · 5.0 s · 60 fps
Amino acid labels

Ubiquitin residues 8, 44, and 70.

Methods and properties

NameDescription
set_offset()methodSet or animate a residue label’s offset from its projected atom.
glyph_countproperty · inherited from CalloutNumber of shaped glyphs used for writing animation.
text_progressproperty · inherited from CalloutCurrent reveal progress for glyphs and annotation lines.
layout()method · inherited from CalloutProject 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 AnnotationThis inherited method raises ValueError because residue labels follow their atoms. Set label offsets to change placement.
shift()method · inherited from AnnotationThis inherited method raises ValueError because residue labels follow their atoms. Set label offsets to change placement.
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
ResidueLabel.set_offset(offset)

Set or animate a residue label’s offset from its projected atom.

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

Returns: The label or animation builder.

Inherited from annotations.Callout.

python
ResidueLabel.glyph_count

Number of shaped glyphs used for writing animation.

Inherited from annotations.Callout.

python
ResidueLabel.text_progress

Current reveal progress for glyphs and annotation lines.

Inherited from annotations.Callout.

python
ResidueLabel.layout(camera, width, height, *, offset=None, progress=None)

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.
offsetkeyword onlyNoneOffset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts.
progresskeyword onlyNoneOptional reveal progress in [0, 1]; None uses the annotation’s current progress.

Returns: AnnotationLayout containing glyph placements and line paths.

Inherited from annotations.Annotation.

python
ResidueLabel.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
ResidueLabel.move_to(position)

This inherited method raises ValueError because residue labels follow their atoms. Set label offsets to change placement.

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

Inherited from annotations.Annotation.

python
ResidueLabel.shift(offset)

This inherited method raises ValueError because residue labels follow their atoms. Set label offsets to change placement.

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

Inherited from annotations.Annotation.

python
ResidueLabel.snapshot()

Capture the current state for deterministic timeline evaluation.

Returns: State dictionary.

Inherited from annotations.Annotation.

python
ResidueLabel.restore(state)

Restore a state produced by snapshot().

ParameterDefaultDescription
stateRequiredState returned by snapshot().

Returns: None

Inherited from annotations.Annotation.

python
ResidueLabel.animate

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