IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
markers.py
1## \example atom/markers.py
2# It is often useful to be able to add extra particles to a model to act as
3# markers for particular features. Examples include creating a bounding sphere
4# for some part of a molecule and using the bounding sphere particle in a
5# distance restraint. The IMP.atom.create_cover() is such a function, creating
6# a particle whose IMP.core.XYZR sphere contains the passed IMP.atom.Selection
7# at all times.
8#
9# The same code also works (more efficiently in fact) if the protein is made
10# into a rigid body.
11#
12
13import IMP.atom
14import IMP.display
15import sys
16
17IMP.setup_from_argv(sys.argv, "markers")
18
19m = IMP.Model()
20h = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"),
21 m)
22# residues 100 and 153 are two residues that are close together
23# spatially, create a marker for the volume around them
24s = IMP.atom.Selection(h, residue_indexes=[100, 153])
25marker = IMP.atom.create_cover(s, "my marker")
26m.update()
27
28# if we now move the protein, marker will move along with it
32m.update()
33
34# display it to a file
35w = IMP.display.PymolWriter("marker.pym")
36g = IMP.core.XYZRGeometry(marker)
37g.set_color(IMP.display.Color(0, 1, 0))
40gs.set_color(IMP.display.Color(1, 0, 0))
41w.add_geometry(g)
42w.add_geometry(gp)
43w.add_geometry(gs)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Simple 3D transformation class.
Display an IMP::atom::Hierarchy particle as balls.
Display a Selection.
Definition Selection.h:352
Select hierarchy particles identified by the biological name.
Definition Selection.h:76
Display an IMP::core::XYZR particle as a ball.
Definition XYZR.h:151
Represent an RGB color.
Definition Color.h:25
Write a CGO file with the geometry.
Definition PymolWriter.h:34
Rotation3D get_random_rotation_3d()
Pick a rotation at random from all possible rotations.
VectorD< 3 > Vector3D
Definition VectorD.h:407
Functionality for loading, creating, manipulating and scoring atomic structures.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
core::XYZR create_cover(const Selection &s, std::string name=std::string())
Output IMP model data in various file formats.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.