IMP logo
IMP Reference Guide  2.6.2
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 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.
3 #
4 # The same code also works (more efficiently in fact) if the protein is made into a rigid body.
5 #
6 
7 import IMP.atom
8 import IMP.display
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "markers")
12 
13 m = IMP.Model()
14 h = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"),
15  m)
16 # residues 100 and 153 are two residues that are close together
17 # spatially, create a marker for the volume around them
18 s = IMP.atom.Selection(h, residue_indexes=[100, 153])
19 marker = IMP.atom.create_cover(s, "my marker")
20 m.update()
21 
22 # if we now move the protein, marker will move along with it
25 IMP.atom.transform(h, tr)
26 m.update()
27 
28 # display it to a file
29 w = IMP.display.PymolWriter("marker.pym")
30 g = IMP.core.XYZRGeometry(marker)
31 g.set_color(IMP.display.Color(0, 1, 0))
34 gs.set_color(IMP.display.Color(1, 0, 0))
35 w.add_geometry(g)
36 w.add_geometry(gp)
37 w.add_geometry(gs)