IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
pmi/membrane.py
1 ## \example pmi/membrane.py
2 """
3 This script shows how to simulate an a protein using a
4 Membrane restraint. This example show 3 ideal helices
5 that have different segments inside the membrane
6 """
7 
8 import IMP
9 import IMP.atom
10 import IMP.rmf
11 import IMP.pmi
12 import IMP.pmi.topology
13 import IMP.pmi.dof
14 import IMP.pmi.macros
15 import IMP.pmi.restraints
19 import sys
20 
21 IMP.setup_from_argv(sys.argv,
22  "Simulation of a protein using a membrane restraint")
23 
24 model = IMP.Model()
25 s = IMP.pmi.topology.System(model)
26 st = 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
30 mols = []
31 
32 for 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)
38 hier = s.build()
39 
41 for mol in mols:
42  dof.create_rigid_body(mol,
43  max_trans=3.0,
44  max_rot=0.5)
45 ##############################
46 # Connectivity
47 ##############################
48 output_objects = []
49 sample_objects = []
50 rmf_restraints = []
51 
52 crs = []
53 for 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 )
66 evr1.add_to_model()
67 evr1.set_weight(1.0)
68 output_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 
82 mr.add_to_model()
83 output_objects.append(mr)
84 
85 # For visualization purposes
86 mr.create_membrane_density()
87 
88 ###########################
89 # External barrier
90 ###########################
91 eb = IMP.pmi.restraints.basic.ExternalBarrier(hierarchies=hier, radius=50)
92 eb.add_to_model()
93 
94 ##############################
95 # Shuffle
96 ##############################
97 IMP.pmi.tools.shuffle_configuration(hier, max_translation=300)
98 print(dof.get_movers())
99 
100 ##############################
101 # Sampling
102 ##############################
103 
104 frames = 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 
112 rex.execute_macro()
113 exit()