Modify solve for a Nup84-like structure using a mix of rigid bodies and coarse grained models using crosslinking data. In addition, show how to visualize restraints and visualize the rejected conformations. Both are useful things to do when trying to figure out why optimization is not converging.
8 from __future__
import print_function
38 number_of_sampling_attempts = 1
39 number_of_mc_steps = 10000
44 def add_protein_from_length(model, name, residues, parent, restraints,
45 excluded_volume_particles, optimized_particles):
52 optimized_particles.extend(leaves)
53 excluded_volume_particles.extend(leaves)
57 for c
in h.get_children()], k,
63 r.set_maximum_score(k)
68 def add_protein_from_pdb(model, name, file, parent, restraints,
69 excluded_volume_particles, optimized_particles):
74 IMP.get_example_path(os.path.join(
"data", file)), model,
86 rb.set_coordinates_are_optimized(
True)
87 optimized_particles.append(rb)
88 excluded_volume_particles.extend(s.get_children())
93 def add_protein_from_pdbs(model, name, files, parent, restraints,
94 excluded_volume_particles, optimized_particles):
96 for i, f
in enumerate(files):
97 add_protein_from_pdb(model, name + str(i), f, h, restraints,
98 excluded_volume_particles, optimized_particles)
100 for c
in h.get_children()],
101 k,
"connect " + name)
104 r.set_maximum_score(k)
109 def create_representation(model):
111 optimized_particles = []
112 excluded_volume_particles = []
116 add_protein_from_length(model,
"Nup85", 570, universe, restraints,
117 excluded_volume_particles, optimized_particles)
121 hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
122 terminus=IMP.atom.Selection.C)
125 d.set_coordinates_are_optimized(
False)
127 add_protein_from_length(model,
"Nup84", 460, universe, restraints,
128 excluded_volume_particles, optimized_particles)
129 add_protein_from_length(model,
"Nup145C", 442, universe, restraints,
130 excluded_volume_particles, optimized_particles)
131 add_protein_from_length(
132 model,
"Nup120", [0, 500, 761], universe, restraints,
133 excluded_volume_particles, optimized_particles)
134 add_protein_from_length(
135 model,
"Nup133", [0, 450, 778, 1160], universe, restraints,
136 excluded_volume_particles, optimized_particles)
137 add_protein_from_pdb(model,
"Seh1",
"seh1.pdb", universe, restraints,
138 excluded_volume_particles, optimized_particles)
139 add_protein_from_pdb(model,
"Sec13",
"sec13.pdb", universe, restraints,
140 excluded_volume_particles, optimized_particles)
141 return universe, restraints, excluded_volume_particles, optimized_particles
144 def add_distance_restraint(selection0, selection1, name, restraints):
146 r.set_maximum_score(k)
150 def encode_data_as_restraints(universe, restraints):
152 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
153 molecule=
"Nup145C", residue_indexes=[(0, 423)])
155 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
158 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
161 [s0, s1, s2], k,
"Nup145C Nup84 Sec13")
162 r.set_maximum_score(k)
165 add_distance_restraint(
167 residue_indexes=[(0, 423)],
169 IMP.atom.FRAGMENT_TYPE]),
171 hierarchy=universe, molecule=
"Nup85",
173 IMP.atom.FRAGMENT_TYPE]),
174 "Num145C, Nup85", restraints)
175 add_distance_restraint(
177 residue_indexes=[(0, 423)],
179 IMP.atom.FRAGMENT_TYPE]),
181 hierarchy=universe, molecule=
"Nup120",
182 residue_indexes=[(500, 762)],
184 IMP.atom.FRAGMENT_TYPE]),
185 "Nup145C Nup120", restraints)
186 add_distance_restraint(
189 IMP.atom.FRAGMENT_TYPE]),
191 hierarchy=universe, molecule=
"Nup133",
192 residue_indexes=[(778, 1160)],
194 IMP.atom.FRAGMENT_TYPE]),
195 "Nup84 Nup133", restraints)
196 add_distance_restraint(
199 IMP.atom.FRAGMENT_TYPE]),
201 hierarchy=universe, molecule=
"Seh1",
203 IMP.atom.FRAGMENT_TYPE]),
204 "Nup85 Seh1", restraints)
205 add_distance_restraint(
207 residue_indexes=[(0, 423)],
209 IMP.atom.FRAGMENT_TYPE]),
211 hierarchy=universe, molecule=
"Sec13",
213 IMP.atom.FRAGMENT_TYPE]),
214 "Nup145C Sec13", restraints)
218 def get_configurations(
221 excluded_volume_particles,
222 optimized_particles):
229 for p
in optimized_particles:
240 mc.add_mover(serial_mover)
242 optimized_particles, restraints)
244 excluded_volume_particles)
249 for i
in range(number_of_sampling_attempts):
250 for p
in optimized_particles:
253 mc.optimize(number_of_mc_steps)
254 if scoring_function.get_had_good_score():
255 configuration_set.save()
256 return configuration_set
260 universe, restraints, excluded_volume_particles, optimized_particles = create_representation(
262 encode_data_as_restraints(universe, restraints)
264 configuration_set = get_configurations(model, restraints,
265 excluded_volume_particles,
268 print(
"Found", configuration_set.get_number_of_configurations(),
"good configurations")
272 rmf = RMF.create_rmf_file(rmf_file_name)
279 for i
in range(0, configuration_set.get_number_of_configurations()):
280 configuration_set.load_configuration(i)
285 for p
in optimized_particles]
287 tr = IMP.algebra.get_transform_taking_first_to_second(
288 optimized_particles, base_coords)
294 print(
"You can now open", rmf_file_name,
"in chimera")