IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
doc/examples/pmi/em.py
1 ## \example pmi/em.py
2 """This script shows how to create DENSITY representations.
3 and set up the Gaussian EM restraint.
4 
5 These representations are useful when you are doing EM fitting with
6 rigid bodies.
7 
8 Preliminary step: you should convert your EM map to a GMM file
9 with the command line utility create_gmm.py
10 (located in isd/pyext/src/create_gmm.py):
11 python create_gmm.py emd_1883.mrc 50 emd_1883.gmm50.txt -m emd_1883.gmm50.mrc
12 """
13 
14 import IMP
15 import IMP.atom
16 import IMP.algebra
17 import IMP.rmf
18 import IMP.pmi
19 import IMP.pmi.topology
20 import IMP.pmi.dof
21 import IMP.pmi.macros
23 import sys
24 
25 IMP.setup_from_argv(sys.argv, "Set up the EM restraint")
26 
27 # ##################### SYSTEM SETUP #####################
28 # Preliminaries
29 mdl = IMP.Model()
31 
32 # Setup just one molecule
34 st = s.create_state()
35 mol = st.create_molecule("Rpn4", sequence=seqs["1WCM:D"], chain_id="D")
36 atomic_res = mol.add_structure(
37  IMP.pmi.get_example_path('data/1WCM_fitted.pdb'), chain_id="D", offset=0)
38 
39 # Below we create a GMM approximation for this moleucle
40 # This "DENSITY" representation is used in the GaussianEMRestraint (and others
41 # in the future)
42 # For structure regions we "fit" GMM components to all atom centers
43 mol.add_representation(
44  atomic_res,
45  resolutions=[1, 10],
46  # how much to coarsen this representation
47  density_residues_per_component=10,
48  # will write a .txt and .mrc file forcomponent
49  density_prefix="Rpn4_gmm",
50  # set True if you want to overwrite
51  density_force_compute=False,
52  # set to 0 if you don't care about writing the map
53  # if rasterizing takes too long, increase this value
54  density_voxel_size=3.0)
55 
56 # for the unstructured regions, we simply decorate each bead AS a Gaussian,
57 # so no fitting is necessary
58 mol.add_representation(mol.get_non_atomic_residues(),
59  resolutions=[10],
60  # just set this flag, nothing is written
61  setup_particles_as_densities=True)
62 
63 hier = s.build()
64 
65 # You can always check the representations with:
67 
68 # ##################### RESTRAINTS #####################
69 output_objects = []
70 
71 # To add the GaussianEMRestraint, first select all densities
72 densities = IMP.atom.Selection(
73  hier, representation_type=IMP.atom.DENSITIES).get_selected_particles()
75  densities,
76  # created by user, see top of file
77  target_fn=IMP.pmi.get_example_path('data/emd_1883.gmm50.txt'),
78  # a small number, helps drag bits into map
79  slope=0.01,
80  # if the model is the same size as map, usually set to True
81  scale_target_to_mass=False,
82  # manually set the mass of the target map (remove if you set above to True)
83  target_mass_scale=100000,
84  # the data weight
85  weight=100.0)
86 emr.add_to_model()
87 output_objects.append(emr)
88 mdl.update()
89 print(emr.evaluate())
Fit Gaussian-decorated particles to an EM map (also represented with a set of Gaussians) ...
void show_with_representations(Hierarchy h, std::ostream &out=std::cout)
Traverse through the tree and show atom info, including representations.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Protocols for sampling structures and analyzing them.
Definition: macros.py:1
Represent the root node of the global IMP.atom.Hierarchy.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Restraints for handling electron microscopy maps.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Create movers and set up constraints for PMI objects.
Python classes to represent, score, sample and analyze models.
A dictionary-like wrapper for reading and storing sequence data.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Definition: Selection.h:70
Support for the RMF file format for storing hierarchical molecular data and markup.