IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
atom/markers.py

It is often useful to be able to add extra particles to a model to act as markers for particular features. Examples include creating a bounding sphere for some part of a molecule and using the bounding sphere particle in a distance restraint. The IMP.atom.create_cover() is such a function, creating a particle whose IMP.core.XYZR sphere contains the passed IMP.atom.Selection at all times.

The same code also works (more efficiently in fact) if the protein is made into a rigid body.

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 
13 import IMP.atom
14 import IMP.display
15 import sys
16 
17 IMP.setup_from_argv(sys.argv, "markers")
18 
19 m = IMP.Model()
20 h = 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
24 s = IMP.atom.Selection(h, residue_indexes=[100, 153])
25 marker = IMP.atom.create_cover(s, "my marker")
26 m.update()
27 
28 # if we now move the protein, marker will move along with it
31 IMP.atom.transform(h, tr)
32 m.update()
33 
34 # display it to a file
35 w = IMP.display.PymolWriter("marker.pym")
36 g = IMP.core.XYZRGeometry(marker)
37 g.set_color(IMP.display.Color(0, 1, 0))
40 gs.set_color(IMP.display.Color(1, 0, 0))
41 w.add_geometry(g)
42 w.add_geometry(gp)
43 w.add_geometry(gs)