Reference navigation
On this page
CLASS · v0.9.1
RegionHighlight
Draw a sphere, wire box, or atom halos around a region.
from proteinmotion import RegionHighlightConstructor
RegionHighlight(
region,
*,
style='sphere',
color='#f2ba67',
opacity=None,
padding=None,
line_width=0.12,
)Parameters
| Parameter | Default | Description |
|---|---|---|
region | Required | Region selection attached to a protein. |
stylekeyword only | 'sphere' | "sphere", "box", or "atoms". |
colorkeyword only | '#f2ba67' | Hex color or RGB values. For tint setters, None restores the representation’s base palette. |
opacitykeyword only | None | Opacity in [0, 1]. None uses 0.9 for a box and 0.18 otherwise. |
paddingkeyword only | None | Extra size in ångströms. None uses 0.3 for atoms and 2.0 otherwise. |
line_widthkeyword only | 0.12 | Box edge radius in ångströms. |
Notes
The highlight follows the region’s coordinates and parent transform. Animate its opacity; apply movement to the parent protein. Highlight geometry describes a region boundary.
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)
helix = p.select(residues=(23, 34))
for style in ("sphere", "box", "atoms"):
marker = helix.highlight(
style=style,
color="#f2ba67",
padding=1.0,
opacity=0.3,
)
self.play(FadeIn(marker), run_time=0.6)
self.wait(1.2)
self.play(FadeOut(marker), run_time=0.6)Sphere, box, and atom highlights on the same helix.
Methods and properties
| Name | Description |
|---|---|
| copy()method | Create another region.highlight() for independent styling. Calling copy() raises ValueError. |
| select()method · inherited from Protein | Select atoms by author chain, residue number, and atom name. |
| label_residues()method · inherited from Protein | Create labels for the selected residues. Extra options go to ResidueLabels. |
| hydrogen_bonds()method · inherited from Protein | Create a hydrogen-bond analysis. Options go to HydrogenBonds. |
| electrostatics()method · inherited from Protein | Create a screened Coulomb analysis. Options go to Electrostatics. |
| from_file()class method · inherited from Protein | Load PDB or mmCIF coordinates and retain all models with matching atom identities. |
| from_trajectory()class method · inherited from Protein | Create a protein from the trajectory’s topology and first frame. |
| positionsproperty · inherited from Protein | Current atom coordinates in the protein’s local coordinate frame. |
| atom_progressproperty · inherited from Protein | Current interpolation fraction for each atom. |
| atom_opacitiesproperty · inherited from Protein | Current per-atom opacity, including global opacity and residue fades. |
| set_positions()method · inherited from Protein | Replace coordinates while preserving atom identities and topology. |
| center()method · inherited from Protein | Move the molecular centroid to the world origin. |
| shift()method · inherited from Protein | Translate the object by an offset. |
| rotate()method · inherited from Protein | Rotate around the molecular centroid. |
| scale()method · inherited from Protein | Scale around the molecular centroid. |
| set_opacity()method · inherited from Protein | Set or animate opacity in [0, 1]. |
| set_color()method · inherited from Protein | Apply a tint across all representations. None restores the base palette. |
| color_by()method · inherited from Protein | Apply residue property colors and optional cartoon thickness before adding the protein to a scene. |
| color_residues()method · inherited from Protein | Apply a tint to the selected residues in every representation. |
| set_residue_opacity()method · inherited from Protein | Set opacity on the selected residues. |
| surface()method · inherited from Protein | Show a van der Waals, solvent-accessible, or voxel solvent-excluded surface. |
| cartoon()method · inherited from Protein | Show helices, sheet arrows, and coils as a cartoon. |
| ribbon()method · inherited from Protein | Show a continuous backbone ribbon. |
| ball_and_stick()method · inherited from Protein | Show element-colored atom spheres and covalent bond cylinders. |
| with_secondary_structure()method · inherited from Protein | Assign helix, sheet, and coil labels before adding the protein to a scene. |
| animateproperty · inherited from Protein | Create a builder for protein transforms, opacity, and color animation. |
| model_matrixproperty · inherited from Protein | Current 4 × 4 transform from local to world coordinates. |
| snapshot()method · inherited from Protein | Capture the current state for deterministic timeline evaluation. |
| restore()method · inherited from Protein | Restore a state produced by snapshot(). |
RegionHighlight.copy()Create another region.highlight() for independent styling. Calling copy() raises ValueError.
Inherited from protein.Protein.
RegionHighlight.select(*, chain=None, residues=None, atoms=None)Select atoms by author chain, residue number, and atom name.
| Parameter | Default | Description |
|---|---|---|
chainkeyword only | None | Author chain ID or a collection of IDs; None selects all chains. |
residueskeyword only | None | Author residue number, inclusive (first, last) tuple, or list of individual numbers. |
atomskeyword only | None | Atom name or list of names, such as "CA"; None selects all atom names. |
Returns: Region
A residue tuple is an inclusive range. A list selects individual numbers. Empty selections raise ValueError.
Inherited from protein.Protein.
RegionHighlight.label_residues(*, chain=None, residues=None, **kwargs)Create labels for the selected residues. Extra options go to ResidueLabels.
| Parameter | Default | Description |
|---|---|---|
chainkeyword only | None | Author chain ID or a collection of IDs; None selects all chains. |
residueskeyword only | None | Author residue number, inclusive (first, last) tuple, or list of individual numbers. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Returns: ResidueLabels
Inherited from protein.Protein.
RegionHighlight.hydrogen_bonds(**kwargs)Create a hydrogen-bond analysis. Options go to HydrogenBonds.
| Parameter | Default | Description |
|---|---|---|
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Returns: HydrogenBonds
Inherited from protein.Protein.
RegionHighlight.electrostatics(charges='formal', **kwargs)Create a screened Coulomb analysis. Options go to Electrostatics.
| Parameter | Default | Description |
|---|---|---|
charges | 'formal' | "formal" side-chain templates or one charge per atom, in elementary charge units. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Returns: Electrostatics
Inherited from protein.Protein.
RegionHighlight.from_file(path, **kwargs)Load PDB or mmCIF coordinates and retain all models with matching atom identities.
| Parameter | Default | Description |
|---|---|---|
path | Required | Input or output file path, as specified by the operation. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Returns: Protein
Keyword options: chains=None, include_water=False, include_hydrogens=False. Other hetero atoms are retained.
Inherited from protein.Protein.
RegionHighlight.from_trajectory(trajectory)Create a protein from the trajectory’s topology and first frame.
| Parameter | Default | Description |
|---|---|---|
trajectory | Required | Trajectory with the same atom identities and order; None uses the protein’s trajectory. |
Returns: Protein
Inherited from protein.Protein.
RegionHighlight.positionsCurrent atom coordinates in the protein’s local coordinate frame.
Returns: Array with shape (selected atoms, 3), in ångströms.
Inherited from protein.Protein.
RegionHighlight.atom_progressCurrent interpolation fraction for each atom.
Inherited from protein.Protein.
RegionHighlight.atom_opacitiesCurrent per-atom opacity, including global opacity and residue fades.
Inherited from protein.Protein.
RegionHighlight.set_positions(xyz)Replace coordinates while preserving atom identities and topology.
| Parameter | Default | Description |
|---|---|---|
xyz | Required | Finite coordinates with shape (atoms, 3), in ångströms. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.center()Move the molecular centroid to the world origin.
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.shift(vector)Translate the object by an offset.
| Parameter | Default | Description |
|---|---|---|
vector | Required | Finite 3D translation vector in ångströms. |
Returns: The object or animation builder.
Inherited from protein.Protein.
RegionHighlight.rotate(angle, axis=(0, 1, 0))Rotate around the molecular centroid.
| Parameter | Default | Description |
|---|---|---|
angle | Required | Rotation angle in radians. |
axis | (0, 1, 0) | Nonzero 3D rotation axis; it is normalized internally. |
Returns: The protein or animation builder.
Inherited from protein.Protein.
RegionHighlight.scale(factor)Scale around the molecular centroid.
| Parameter | Default | Description |
|---|---|---|
factor | Required | Positive scale or zoom factor. |
Returns: The protein or animation builder.
Inherited from protein.Protein.
RegionHighlight.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 protein.Protein.
RegionHighlight.set_color(color)Apply a tint across all representations. None restores the base palette.
| Parameter | Default | Description |
|---|---|---|
color | Required | Hex color or RGB values. For tint setters, None restores the representation’s base palette. |
Returns: The object or a Colorize animation.
Inherited from protein.Protein.
RegionHighlight.color_by(values, *, scale=None, thickness=None)Apply residue property colors and optional cartoon thickness before adding the protein to a scene.
| Parameter | Default | Description |
|---|---|---|
values | Required | Numerical input values; see the shape and missing-value rules for this object. |
scalekeyword only | None | ColorScale shared by the structure, plots, and legend. None derives limits from finite values. |
thicknesskeyword only | None | Optional (minimum, maximum) positive cartoon cross-section scale factors. Missing values use 1. |
Inherited from protein.Protein.
RegionHighlight.color_residues(color, *, chain=None, residues=None)Apply a tint to the selected residues in every representation.
| Parameter | Default | Description |
|---|---|---|
color | Required | Hex color or RGB values. For tint setters, None restores the representation’s base palette. |
chainkeyword only | None | Author chain ID or a collection of IDs; None selects all chains. |
residueskeyword only | None | Author residue number, inclusive (first, last) tuple, or list of individual numbers. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.set_residue_opacity(opacity, *, chain=None, residues=None)Set opacity on the selected residues.
| Parameter | Default | Description |
|---|---|---|
opacity | Required | Opacity in [0, 1], from transparent to opaque. |
chainkeyword only | None | Author chain ID or a collection of IDs; None selects all chains. |
residueskeyword only | None | Author residue number, inclusive (first, last) tuple, or list of individual numbers. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.surface(
*,
kind='ses',
probe_radius=1.4,
resolution=0.7,
color='secondary',
update='rebuild',
**kwargs,
)Show a van der Waals, solvent-accessible, or voxel solvent-excluded surface.
| Parameter | Default | Description |
|---|---|---|
kindkeyword only | 'ses' | Surface type: "vdw", "sas", or "ses". |
probe_radiuskeyword only | 1.4 | Solvent probe radius in ångströms. |
resolutionkeyword only | 0.7 | Surface grid spacing in ångströms; smaller values increase detail and cost. |
colorkeyword only | 'secondary' | Base palette: "secondary", "rainbow", "chain", or a fixed color. |
updatekeyword only | 'rebuild' | "rebuild" recalculates the surface as coordinates change; "deform" moves the reference mesh. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Returns: The protein.
Additional option: max_voxels=8000000 limits the grid size. Configure surface settings before the first play() call. The ses surface is a voxel approximation.
Inherited from protein.Protein.
RegionHighlight.cartoon(*, color='secondary')Show helices, sheet arrows, and coils as a cartoon.
| Parameter | Default | Description |
|---|---|---|
colorkeyword only | 'secondary' | Base palette: "secondary", "rainbow", "chain", or a fixed color. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.ribbon(*, color='rainbow', width=1.05)Show a continuous backbone ribbon.
| Parameter | Default | Description |
|---|---|---|
colorkeyword only | 'rainbow' | Base palette: "secondary", "rainbow", "chain", or a fixed color. |
widthkeyword only | 1.05 | Ribbon width in ångströms. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.ball_and_stick(*, atom_scale=0.3, bond_radius=0.14)Show element-colored atom spheres and covalent bond cylinders.
| Parameter | Default | Description |
|---|---|---|
atom_scalekeyword only | 0.3 | Multiplier applied to element van der Waals radii for ball-and-stick atoms. |
bond_radiuskeyword only | 0.14 | Covalent bond cylinder radius in ångströms. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.with_secondary_structure(assignments)Assign helix, sheet, and coil labels before adding the protein to a scene.
| Parameter | Default | Description |
|---|---|---|
assignments | Required | One "H", "E", or "C" code per topology residue for helix, sheet, or coil. |
Returns: The protein.
Inherited from protein.Protein.
RegionHighlight.animateCreate a builder for protein transforms, opacity, and color animation.
Returns: Animate
Inherited from protein.Protein.
RegionHighlight.model_matrixCurrent 4 × 4 transform from local to world coordinates.
Inherited from protein.Protein.
RegionHighlight.snapshot()Capture the current state for deterministic timeline evaluation.
Returns: State dictionary.
Inherited from protein.Protein.
RegionHighlight.restore(s)Restore a state produced by snapshot().
| Parameter | Default | Description |
|---|---|---|
s | Required | State returned by snapshot(). |
Returns: None