IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
pmi/multiscale.py
1 ## \example pmi/multiscale.py
2 """This script shows how to represent a system at multiple scales and do
3  basic sampling.
4 """
5 
6 import IMP
7 import IMP.atom
8 import IMP.rmf
9 import IMP.pmi
10 import IMP.pmi.topology
11 import IMP.pmi.dof
12 import IMP.pmi.macros
13 import IMP.pmi.restraints
15 import sys
16 
17 IMP.setup_from_argv(sys.argv, "Representation at multiple scales")
19  print("This example is too slow to test in debug mode - run without")
20  print("internal tests enabled, or without the --run-quick-test flag")
21  sys.exit(0)
22 
23 # ##################### SYSTEM SETUP #####################
24 # Read sequences etc
26 components = ["Rpb1", "Rpb2", "Rpb3", "Rpb4"]
27 colors = ['medium purple', 'goldenrod', 'orchid', 'olive drab']
28 chains = "ABCD"
29 beadsize = 10
30 
31 # Setup System and add a State
32 mdl = IMP.Model()
34 st = s.create_state()
35 
36 # Add Molecules for each component as well as representations
37 mols = []
38 for n in range(len(components)):
39  print('PMI: setting up', components[n], '1WCM:'+chains[n])
40  mol = st.create_molecule( # create molecule
41  components[n],
42  sequence=seqs['1WCM:'+chains[n]],
43  chain_id=chains[n])
44  atomic = mol.add_structure(
45  IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
46  chain_id=chains[n], offset=0)
47  mol.add_representation(atomic, # res 1,10 for structured regions
48  resolutions=[1, 10],
49  color=colors[n])
50  mol.add_representation(mol[:]-atomic, # res 10 for unstructured regions
51  resolutions=[beadsize],
52  color=colors[n])
53  mols.append(mol)
54 
55 # calling System.build() creates all States and Molecules (and their
56 # representations)
57 # Once you call build(), anything without representation is destroyed.
58 # You can still use handles like molecule[a:b], molecule.get_atomic_residues()
59 # or molecule.get_non_atomic_residues()
60 # However these functions will only return BUILT representations
61 root_hier = s.build()
62 
63 # Uncomment this for verbose output of the representation
64 # IMP.atom.show_with_representations(root_hier)
65 
66 # Setup degrees of freedom
67 # The DOF functions automatically select all resolutions
68 # Objects passed to nonrigid_parts move with the frame but also have
69 # their own independent movers.
71 for mol in mols:
72  dof.create_rigid_body(mol,
73  nonrigid_parts=mol.get_non_atomic_residues(),
74  max_trans=0.1,
75  max_rot=0.78,
76  nonrigid_max_trans=0.1)
77  # display the bonds between consecutive fragments,
78  # so that they are shown in the psf
80 
81 
82 # ##################### RESTRAINTS #####################
83 output_objects = [] # keep a list of functions that need to be reported
84 
85 # Connectivity keeps things connected along the backbone (ignores if inside
86 # same rigid body)
87 crs = []
88 for mol in mols:
90  cr.add_to_model()
91  output_objects.append(cr)
92  crs.append(cr)
93 
94 # Excluded volume - automatically more efficient due to rigid bodies
96  included_objects=mols)
97 evr.add_to_model()
98 output_objects.append(evr)
99 
100 
101 # ##################### SAMPLING #####################
102 # First shuffle the system
103 IMP.pmi.tools.shuffle_configuration(root_hier, max_translation=30)
104 
105 # Quickly move all flexible beads into place
106 dof.optimize_flexible_beads(100)
107 
108 # Run replica exchange Monte Carlo sampling
110  mdl,
111  # pass the root hierarchy
112  root_hier=root_hier,
113  # pass MC movers
114  monte_carlo_sample_objects=dof.get_movers(),
115  global_output_directory='multiscale_output/',
116  output_objects=output_objects,
117  monte_carlo_steps=10,
118  # set >0 to store best PDB files (but this is slow to do online)
119  number_of_best_scoring_models=0,
120  # increase number of frames to get better results!
121  number_of_frames=1)
122 rex.execute_macro()
Simplify creation of constraints and movers for an IMP Hierarchy.
Restraints for keeping correct stereochemistry.
def display_bonds
Decorate the sequence-consecutive particles from a PMI2 molecule with a bond, so that they appear con...
Definition: tools.py:1033
bool get_is_quick_test()
Definition: flags.h:183
def shuffle_configuration
Shuffle particles.
Definition: tools.py:1242
A macro to help setup and run replica exchange.
Definition: macros.py:65
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
Classes to handle different kinds of restraints.
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object...
Create movers and set up constraints for PMI objects.
A class to create an excluded volume restraint for a set of particles at a given resolution.
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.
Support for the RMF file format for storing hierarchical molecular data and markup.