IMP logo
IMP Reference Guide  2.12.0
The Integrative Modeling Platform
em/fit_restraint.py

A simple example showing how to set up a fit restraint. The number of spheres and resolution are randomly chosen and so should not be considered significant.

1 ## \example em/fit_restraint.py
2 # A simple example showing how to set up a fit restraint. The number of
3 # spheres and resolution are randomly chosen and so should not be
4 # considered significant.
5 
6 from __future__ import print_function
7 import IMP.em
8 import IMP.core
9 import IMP.atom
10 import sys
11 
12 IMP.setup_from_argv(sys.argv, "fit restraint")
13 
14 IMP.set_log_level(IMP.SILENT)
15 m = IMP.Model()
16 # 1. setup the input protein
17 # 1.1 select a selector.
19 # 1.2 read the protein
20 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
21 ps = IMP.core.get_leaves(mh)
23 # 2. read the density map
24 resolution = 8.
25 voxel_size = 1.5
26 dmap = IMP.em.read_map(
28 dmap.get_header_writable().set_resolution(resolution)
29 # 3. calculate the cross correlation between the density and the map
30 print("The cross-correlation score is:", 1. - IMP.em.compute_fitting_score(ps, dmap))
31 # 4. add a fitting restraint
32 r = IMP.em.FitRestraint(ps, dmap)
33 print("The fit of the particles in the density is:", r.evaluate(False))