IMP logo
IMP Reference Guide  2.6.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 basic sampling.
3 """
4 
5 import IMP
6 import RMF
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 
16 ###################### SYSTEM SETUP #####################
17 # Read sequences etc
19 components = ["Rpb1","Rpb2","Rpb3","Rpb4"]
20 colors = [0.1,0.9,0.5,0.8]
21 chains = "ABCD"
22 beadsize = 10
23 
24 # Setup System and add a State
25 mdl = IMP.Model()
27 st = s.create_state()
28 
29 # Add Molecules for each component as well as representations
30 mols = []
31 for n in range(len(components)):
32  print('PMI: setting up',components[n],'1WCM:'+chains[n])
33  mol = st.create_molecule( # create molecule
34  components[n],
35  sequence=seqs['1WCM:'+chains[n]],
36  chain_id=chains[n])
37  atomic = mol.add_structure(IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
38  chain_id=chains[n],
39  offset=0)
40  mol.add_representation(atomic, # res 1,10 for structured regions
41  resolutions=[1,10],
42  color=colors[n])
43  mol.add_representation(mol[:]-atomic, # res 10 for unstructured regions
44  resolutions=[beadsize],
45  color=colors[n])
46  mols.append(mol)
47 
48 # calling System.build() creates all States and Molecules (and their representations)
49 # Once you call build(), anything without representation is destroyed.
50 # You can still use handles like molecule[a:b], molecule.get_atomic_residues() or molecule.get_non_atomic_residues()
51 # However these functions will only return BUILT representations
52 root_hier = s.build()
53 
54 # Uncomment this for verbose output of the representation
55 #IMP.atom.show_with_representations(root_hier)
56 
57 # Setup degrees of freedom
58 # The DOF functions automatically select all resolutions
59 # Objects passed to nonrigid_parts move with the frame but also have their own independent movers.
61 for mol in mols:
62  dof.create_rigid_body(mol,
63  nonrigid_parts=mol.get_non_atomic_residues(),
64  max_trans=0.1,
65  max_rot=0.78,
66  nonrigid_max_trans=0.1)
67 
68 
69 ###################### RESTRAINTS #####################
70 output_objects = [] # keep a list of functions that need to be reported
71 
72 # Connectivity keeps things connected along the backbone (ignores if inside same rigid body)
73 crs = []
74 for mol in mols:
76  cr.add_to_model()
77  output_objects.append(cr)
78  crs.append(cr)
79 
80 # Excluded volume - automatically more efficient due to rigid bodies
82 evr.add_to_model()
83 output_objects.append(evr)
84 
85 
86 ###################### SAMPLING #####################
87 # First shuffle the system
89  max_translation=30)
90 
91 # Quickly move all flexible beads into place
92 dof.optimize_flexible_beads(100)
93 
94 # Run replica exchange Monte Carlo sampling
96  root_hier=root_hier, # pass the root hierarchy
97  crosslink_restraints=crs, # will display like XLs
98  monte_carlo_sample_objects=dof.get_movers(), # pass MC movers
99  global_output_directory='multiscale_output/',
100  output_objects=output_objects,
101  monte_carlo_steps=10,
102  number_of_best_scoring_models=0, # set >0 to store best PDB files (but this is slow to do online)
103  number_of_frames=1) # increase number of frames to get better results!
104 rex.execute_macro()