IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
pmi/protein_residue_binding.py
1 ## \example pmi/protein_residue_binding.py
2 """
3 This script shows how to simulate residue-protein
4 binding contacts inferred from mutagenesis studies.
5 This example shows protein A binding to protein B
6 through a set of residues predicted to be required
7 for binding in mutagensis studies.
8 """
9 
10 import IMP
11 import IMP.atom
12 import IMP.rmf
13 import IMP.pmi
14 import IMP.pmi.topology
15 import IMP.pmi.dof
16 import IMP.pmi.macros
17 import IMP.pmi.restraints
20 import tempfile
21 import os
22 import sys
23 
24 IMP.setup_from_argv(sys.argv, "Simulate residue-protein binding contacts")
26  print("This example is too slow to test in debug mode - run without")
27  print("internal tests enabled, or without the --run-quick-test flag")
28  sys.exit(0)
29 
30 topology = '''
31 |molecule_name|color|fasta_fn|fasta_id|pdb_fn|chain|residue_range|pdb_offset|bead_size|em_residues_per_gaussian|rigid_body|super_rigid_body|chain_of_super_rigid_bodies|
32 |Rpb4 |red |1WCM.fasta |1WCM:D |1WCM_fitted.pdb |D|1,END |0 |5|0 |1 | | ||
33 |Rpb7 |gold |1WCM.fasta |1WCM:G |1WCM_fitted.pdb |G|1,END |0 |5|0 |2 | | ||
34 '''
35 
36 # Normally the topology table is kept in a text file but here we just write
37 # it to a temporary one
38 tf = tempfile.NamedTemporaryFile(delete=False, mode='w')
39 tf.write(topology)
40 tf.close()
41 
42 print(IMP.pmi.get_example_path('data/'))
43 
44 # The TopologyReader reads the text file, and the BuildSystem macro
45 # constructs it
46 mdl = IMP.Model()
48  tf.name, pdb_dir=IMP.pmi.get_example_path('data/'),
49  fasta_dir=IMP.pmi.get_example_path('data/'),
50  gmm_dir=IMP.pmi.get_example_path('data/'))
52 # note you can call this multiple times to create a multi-state system
53 bs.add_state(reader)
54 hier, dof = bs.execute_macro()
55 
56 # ################ STEREOCHEMISTRY RESTRAINTS ################
57 
58 output_objects = [] # keep a list of functions that need to be reported
59 
60 # Connectivity keeps things connected along the backbone (ignores if inside
61 # same rigid body)
62 crs = []
63 moldict = bs.get_molecules()[0]
64 mols = []
65 for molname in moldict:
66  for mol in moldict[molname]:
68  cr.add_to_model()
69  output_objects.append(cr)
70  crs.append(cr)
71  mols.append(mol)
72 
73 # Excluded volume - automatically more efficient due to rigid bodies
75  included_objects=mols)
76 evr.add_to_model()
77 output_objects.append(evr)
78 
79 # External barrier- Avoid proteins to drift away
80 eb = IMP.pmi.restraints.basic.ExternalBarrier(hierarchies=hier, radius=500)
81 eb.add_to_model()
82 
83 # ################# PROTEIN-RESIDUE PROXIMITY ################
84 
86  hier, selection=('Rpb7', 38, 44, 'Rpb4'), label='B38_44')
87 
88 br.add_to_model()
89 br.set_weight(5.0)
90 output_objects.append(br)
91 br.get_output()
92 
93 # ##################### SAMPLING #######################
94 
95 # Fix rigid-body
96 
97 part_p1 = IMP.atom.Selection(hier,
98  molecule="Rpb4").get_selected_particles()
99 
100 xyzs, rbs = dof.disable_movers(part_p1,
101  mover_types=[IMP.core.RigidBodyMover])
102 
103 
104 # mix it up so it looks cool
106 
107 # Quickly move all flexible beads into place
108 dof.optimize_flexible_beads(100)
109 
111  mdl,
112  root_hier=hier,
113  monte_carlo_sample_objects=dof.get_movers(),
114  global_output_directory='output/',
115  output_objects=output_objects,
116  monte_carlo_steps=10,
117  number_of_best_scoring_models=0,
118  number_of_frames=500)
119 rex.execute_macro()
120 
121 os.remove(tf.name)