IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
membrane.py
1## \example pmi/membrane.py
2"""
3This script shows how to simulate a protein using a
4Membrane restraint. This example shows 3 ideal helices
5that have different segments inside the membrane
6"""
7
8import IMP
9import IMP.atom
10import IMP.rmf
11import IMP.pmi
13import IMP.pmi.dof
14import IMP.pmi.macros
19import sys
20
21IMP.setup_from_argv(sys.argv,
22 "Simulation of a protein using a membrane restraint")
23
24model = IMP.Model()
26st = s.create_state()
27
28# Create molecules and add helix representation
29# this makes a c-alpha chain in approximately the shape of a helix
30mols = []
31
32for i, len_helix in enumerate([20, 40, 80]):
33 mol = st.create_molecule(
34 "helix_%s" % (str(i)), sequence="A" * len_helix, chain_id="A"
35 )
36 mol.add_representation(mol, resolutions=[1], ideal_helix=True)
37 mols.append(mol)
38hier = s.build()
39
41for mol in mols:
42 dof.create_rigid_body(mol,
43 max_trans=3.0,
44 max_rot=0.5)
45##############################
46# Connectivity
47##############################
48output_objects = []
49sample_objects = []
50rmf_restraints = []
51
52crs = []
53for mol in mols:
55 cr.set_label(mol.get_name())
56 cr.add_to_model()
57 output_objects.append(cr)
58 crs.append(cr)
59
60##############################
61# Excluded Volume
62##############################
64 included_objects=mols, resolution=1
65)
66evr1.add_to_model()
67evr1.set_weight(1.0)
68output_objects.append(evr1)
69
70##############################
71# Membrane restraint
72##############################
73
75 hier,
76 objects_inside=["helix_0", (1, 20, "helix_1"), (20, 40, "helix_2")],
77 objects_above=[(21, 40, "helix_1"), (1, 19, "helix_2")],
78 objects_below=[(41, 80, "helix_2")],
79 weight=10,
80)
81
82mr.add_to_model()
83output_objects.append(mr)
84
85# For visualization purposes
86mr.create_membrane_density()
87
88###########################
89# External barrier
90###########################
91eb = IMP.pmi.restraints.basic.ExternalBarrier(hierarchies=hier, radius=50)
92eb.add_to_model()
93
94##############################
95# Shuffle
96##############################
97IMP.pmi.tools.shuffle_configuration(hier, max_translation=300)
98print(dof.get_movers())
99
100##############################
101# Sampling
102##############################
103
104frames = 10 if IMP.get_is_quick_test() else 2000
106 model, root_hier=hier, monte_carlo_sample_objects=dof.get_movers(),
107 replica_exchange_maximum_temperature=3.0,
108 global_output_directory="output/", output_objects=output_objects,
109 monte_carlo_steps=10, number_of_frames=frames,
110 number_of_best_scoring_models=0)
111
112rex.execute_macro()
113exit()
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Simplify creation of constraints and movers for an IMP Hierarchy.
A macro to help setup and run replica exchange.
Definition macros.py:164
Keeps all structures inside a sphere.
Definition basic.py:15
Restrain particles to be above, below, or inside a planar membrane.
Definition basic.py:305
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.
Represent the root node of the global IMP.atom.Hierarchy.
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.
Support for the RMF file format for storing hierarchical molecular data and markup.
bool get_is_quick_test()
Definition flags.h:183
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.