IMP logo
IMP Reference Guide  2.11.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 rigid bodies.
6 
7 Preliminary step: you should convert your EM map to a GMM file
8 with the command line utility create_gmm.py (located in isd/pyext/src/create_gmm.py):
9 python create_gmm.py emd_1883.mrc 50 emd_1883.gmm50.txt -m emd_1883.gmm50.mrc
10 """
11 
12 import IMP
13 import IMP.atom
14 import IMP.algebra
15 import IMP.rmf
16 import IMP.pmi
17 import IMP.pmi.topology
18 import IMP.pmi.dof
19 import IMP.pmi.macros
21 import sys
22 
23 IMP.setup_from_argv(sys.argv, "Set up the EM restraint")
24 
25 ###################### SYSTEM SETUP #####################
26 # Preliminaries
27 mdl = IMP.Model()
29 
30 # Setup just one molecule
32 st = s.create_state()
33 mol = st.create_molecule("Rpn4",sequence=seqs["1WCM:D"],chain_id="D")
34 atomic_res = mol.add_structure(IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
35  chain_id="D",
36  offset=0)
37 
38 # Below we create a GMM approximation for this moleucle
39 # This "DENSITY" representation is used in the GaussianEMRestraint (and others in the future)
40 # For structure regions we "fit" GMM components to all atom centers
41 mol.add_representation(atomic_res,
42  resolutions=[1,10],
43  density_residues_per_component=10, #how much to coarsen this representation
44  density_prefix="Rpn4_gmm", # will write a .txt and .mrc file forcomponent
45  density_force_compute=False, # set True if you want to overwrite
46  density_voxel_size=3.0) # set to 0 if you don't care about writing the map
47  # if rasterizing takes too long, increase this value
48 
49 # for the unstructured regions, we simply decorate each bead AS a gaussian, so no fitting is necessary
50 mol.add_representation(mol.get_non_atomic_residues(),
51  resolutions=[10],
52  setup_particles_as_densities=True) # just set this flag, nothing is written
53 
54 hier = s.build()
55 
56 # You can always check the representations with:
58 
59 ###################### RESTRAINTS #####################
60 output_objects = []
61 
62 # To add the GaussianEMRestraint, first select all densities
63 densities = IMP.atom.Selection(hier,representation_type=IMP.atom.DENSITIES).get_selected_particles()
65  densities,
66  target_fn=IMP.pmi.get_example_path('data/emd_1883.gmm50.txt'), # created by user, see top of file
67  slope=0.01, # a small number, helps drag bits into map
68  scale_target_to_mass=False, # if the model is the same size as map, usually set to True
69  target_mass_scale=100000, # manually set the mass of the target map (remove if you set above to True)
70  weight=100.0) # the data weight
71 emr.add_to_model()
72 output_objects.append(emr)
73 mdl.update()
74 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
This class initializes the root node of the global IMP.atom.Hierarchy.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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:66
Support for the RMF file format for storing hierarchical molecular data and markup.