IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
protein_residue_binding.py
1## \example pmi/protein_residue_binding.py
2"""
3This script shows how to simulate residue-protein
4binding contacts inferred from mutagenesis studies.
5This example shows protein A binding to protein B
6through a set of residues predicted to be required
7for binding in mutagenesis studies.
8"""
9
10import IMP
11import IMP.atom
12import IMP.rmf
13import IMP.pmi
15import IMP.pmi.dof
16import IMP.pmi.macros
20import tempfile
21import os
22import sys
23
24IMP.setup_from_argv(sys.argv, "Simulate residue-protein binding contacts")
25if IMP.get_check_level() >= IMP.USAGE_AND_INTERNAL:
26 print("This example is too slow to test in debug mode - run without")
27 print("internal tests enabled")
28 sys.exit(0)
29
30topology = '''
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
38tf = tempfile.NamedTemporaryFile(delete=False, mode='w')
39tf.write(topology)
40tf.close()
41
42print(IMP.pmi.get_example_path('data/'))
43
44# The TopologyReader reads the text file, and the BuildSystem macro
45# constructs it
46mdl = 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
53bs.add_state(reader)
54hier, dof = bs.execute_macro()
55
56# ################ STEREOCHEMISTRY RESTRAINTS ################
57
58output_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)
62crs = []
63moldict = bs.get_molecules()[0]
64mols = []
65for 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)
76evr.add_to_model()
77output_objects.append(evr)
78
79# External barrier- Avoid proteins to drift away
80eb = IMP.pmi.restraints.basic.ExternalBarrier(hierarchies=hier, radius=500)
81eb.add_to_model()
82
83# ################# PROTEIN-RESIDUE PROXIMITY ################
84
86 hier, selection=('Rpb7', 38, 44, 'Rpb4'), label='B38_44')
87
88br.add_to_model()
89br.set_weight(5.0)
90output_objects.append(br)
91br.get_output()
92
93# ##################### SAMPLING #######################
94
95# Fix rigid-body
96
97part_p1 = IMP.atom.Selection(hier,
98 molecule="Rpb4").get_selected_particles()
99
100xyzs, 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
108dof.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)
119rex.execute_macro()
120
121os.remove(tf.name)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Select hierarchy particles identified by the biological name.
Definition Selection.h:76
Modify the transformation of a rigid body.
A macro to build a IMP.pmi.topology.System based on a TopologyReader object.
Definition macros.py:840
A macro to help setup and run replica exchange.
Definition macros.py:164
Keeps all structures inside a sphere.
Definition basic.py:15
Restrain residue/residues to bind to unknown location in a target.
Definition basic.py:470
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object.
A class to create an excluded volume restraint for a set of particles at a given resolution.
Automatically setup System and Degrees of Freedom with a formatted text file.
Functionality for loading, creating, manipulating and scoring atomic structures.
Create movers and set up constraints for PMI objects.
Protocols for sampling structures and analyzing them.
Definition macros.py:1
Some miscellaneous simple restraints.
Definition basic.py:1
Restraints for keeping correct stereochemistry.
Classes to handle different kinds of restraints.
shuffle_configuration(objects, max_translation=300.0, max_rotation=2.0 *math.pi, avoidcollision_rb=True, avoidcollision_fb=False, cutoff=10.0, niterations=100, bounding_box=None, excluded_rigid_bodies=[], hierarchies_excluded_from_collision=[], hierarchies_included_in_collision=[], verbose=False, return_debug=False)
Shuffle particles.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
Python classes to represent, score, sample and analyze models.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Support for the RMF file format for storing hierarchical molecular data and markup.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
CheckLevel get_check_level()
Get the current audit mode.
Definition exception.h:80