IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
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 import IMP.em
7 import IMP.core
8 import IMP.atom
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "fit restraint")
12 
13 IMP.set_log_level(IMP.SILENT)
14 m = IMP.Model()
15 # 1. setup the input protein
16 # 1.1 select a selector.
18 # 1.2 read the protein
19 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
20 ps = IMP.core.get_leaves(mh)
22 # 2. read the density map
23 resolution = 8.
24 voxel_size = 1.5
25 dmap = IMP.em.read_map(
27 dmap.get_header_writable().set_resolution(resolution)
28 # 3. calculate the cross correlation between the density and the map
29 print("The cross-correlation score is:",
30  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))