ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

Region

A selection of atoms that follows its parent protein’s coordinates.

python
from proteinmotion import Region

Constructor

python
Region(protein, atom_indices)

Parameters

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
atom_indicesRequiredNonempty collection of zero-based atom indices.

Notes

Create selections with protein.select(). Combine regions from the same protein with the | operator. Residue numbers in select() use PDB author numbering; atom_indices are zero-based.

Attributes

NameDescription
proteinParent Protein object.
atom_indicesRead-only, sorted atom indices.
residue_indicesRead-only topology residue indices represented in the selection.

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)
helix = p.select(chain="A", residues=(23, 34))
marker = helix.highlight(
    style="box",
    color="#f2ba67",
    padding=1.5,
)
self.play(FadeIn(marker), run_time=0.6)
self.focus(helix, margin=1.6, run_time=1.5)
self.play(self.camera.animate.orbit(0.4), run_time=2)
self.play(FadeOut(marker), run_time=0.6)
self.focus(p, run_time=1.5)
Output Preview · 6.2 s · 60 fps
Camera focus

Ubiquitin residues 23–34.

Methods and properties

NameDescription
select()class methodSelect atoms by author chain, residue number, and atom name.
positionspropertyCurrent atom coordinates in the protein’s local coordinate frame.
model_matrixpropertyCurrent 4 × 4 transform from local to world coordinates.
positionpropertyTranslation of the parent protein in world coordinates.
world_positionspropertySelected atom coordinates after the parent’s display transform.
__or__()methodCombine selections from the same protein with region_a | region_b.
highlight()methodCreate a sphere, box, or atom highlight around the selection.
set_color()methodApply a tint across all representations. None restores the base palette.
set_opacity()methodSet or animate opacity in [0, 1].
animatepropertyCreate a builder for residue color and opacity animations.
distance_to()methodCreate a ruler to another region. Extra options go to Distance.
callout()methodCreate a label connected by a line to this region. Extra options go to Callout.
label()methodCreate one amino-acid label. Extra options go to ResidueLabel.
python
Region.select(protein, *, chain=None, residues=None, atoms=None)

Select atoms by author chain, residue number, and atom name.

ParameterDefaultDescription
proteinRequiredProtein object to read or animate.
chainkeyword onlyNoneAuthor chain ID or a collection of IDs; None selects all chains.
residueskeyword onlyNoneAuthor residue number, inclusive (first, last) tuple, or list of individual numbers.
atomskeyword onlyNoneAtom 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.

python
Region.positions

Current atom coordinates in the protein’s local coordinate frame.

Returns: Array with shape (selected atoms, 3), in ångströms.

python
Region.model_matrix

Current 4 × 4 transform from local to world coordinates.

python
Region.position

Translation of the parent protein in world coordinates.

python
Region.world_positions

Selected atom coordinates after the parent’s display transform.

python
Region.__or__(other)

Combine selections from the same protein with region_a | region_b.

ParameterDefaultDescription
otherRequiredAnother Region from the same protein for a union, or an endpoint Region for a distance.

Returns: Region

python
Region.highlight(
    *,
    style='sphere',
    color='#f2ba67',
    opacity=None,
    padding=None,
    line_width=0.12,
)

Create a sphere, box, or atom highlight around the selection.

ParameterDefaultDescription
stylekeyword only'sphere'Highlight shape or line style; allowed values are specified by the constructor.
colorkeyword only'#f2ba67'Hex color or RGB values. For tint setters, None restores the representation’s base palette.
opacitykeyword onlyNoneOpacity in [0, 1], from transparent to opaque.
paddingkeyword onlyNoneExtra highlight size in ångströms. None selects a default for the highlight style.
line_widthkeyword only0.12Line width in design pixels at 1080p for overlays; ångströms for 3D highlight boxes.

Returns: RegionHighlight

python
Region.set_color(color)

Apply a tint across all representations. None restores the base palette.

ParameterDefaultDescription
colorRequiredHex color or RGB values. For tint setters, None restores the representation’s base palette.

Returns: The object or a Colorize animation.

python
Region.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.

python
Region.animate

Create a builder for residue color and opacity animations.

Returns: RegionAnimate

python
Region.distance_to(other, **kwargs)

Create a ruler to another region. Extra options go to Distance.

ParameterDefaultDescription
otherRequiredAnother Region from the same protein for a union, or an endpoint Region for a distance.
**kwargsAdditional keyword options described below or in the linked constructor.

Returns: Distance

python
Region.callout(text, **kwargs)

Create a label connected by a line to this region. Extra options go to Callout.

ParameterDefaultDescription
textRequiredText to display.
**kwargsAdditional keyword options described below or in the linked constructor.

Returns: Callout

python
Region.label(text=None, **kwargs)

Create one amino-acid label. Extra options go to ResidueLabel.

ParameterDefaultDescription
textNoneText to display.
**kwargsAdditional keyword options described below or in the linked constructor.

Returns: ResidueLabel