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.
37 number_of_sampling_attempts = 1
38 number_of_mc_steps = 10000
43 def add_protein_from_length(model, name, residues, parent, restraints,
44 excluded_volume_particles, optimized_particles):
51 optimized_particles.extend(leaves)
52 excluded_volume_particles.extend(leaves)
56 for c
in h.get_children()], k,
62 r.set_maximum_score(k)
67 def add_protein_from_pdb(model, name, file, parent, restraints,
68 excluded_volume_particles, optimized_particles):
73 IMP.get_example_path(os.path.join(
"data", file)), model,
85 rb.set_coordinates_are_optimized(
True)
86 optimized_particles.append(rb)
87 excluded_volume_particles.extend(s.get_children())
92 def add_protein_from_pdbs(model, name, files, parent, restraints,
93 excluded_volume_particles, optimized_particles):
95 for i, f
in enumerate(files):
96 add_protein_from_pdb(model, name + str(i), f, h, restraints,
97 excluded_volume_particles, optimized_particles)
99 for c
in h.get_children()],
100 k,
"connect " + name)
103 r.set_maximum_score(k)
108 def create_representation(model):
110 optimized_particles = []
111 excluded_volume_particles = []
115 add_protein_from_length(model,
"Nup85", 570, universe, restraints,
116 excluded_volume_particles, optimized_particles)
120 hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
121 terminus=IMP.atom.Selection.C)
124 d.set_coordinates_are_optimized(
False)
126 add_protein_from_length(model,
"Nup84", 460, universe, restraints,
127 excluded_volume_particles, optimized_particles)
128 add_protein_from_length(model,
"Nup145C", 442, universe, restraints,
129 excluded_volume_particles, optimized_particles)
130 add_protein_from_length(
131 model,
"Nup120", [0, 500, 761], universe, restraints,
132 excluded_volume_particles, optimized_particles)
133 add_protein_from_length(
134 model,
"Nup133", [0, 450, 778, 1160], universe, restraints,
135 excluded_volume_particles, optimized_particles)
136 add_protein_from_pdb(model,
"Seh1",
"seh1.pdb", universe, restraints,
137 excluded_volume_particles, optimized_particles)
138 add_protein_from_pdb(model,
"Sec13",
"sec13.pdb", universe, restraints,
139 excluded_volume_particles, optimized_particles)
140 return universe, restraints, excluded_volume_particles, optimized_particles
143 def add_distance_restraint(selection0, selection1, name, restraints):
145 r.set_maximum_score(k)
149 def encode_data_as_restraints(universe, restraints):
151 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
152 molecule=
"Nup145C", residue_indexes=[(0, 423)])
154 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
157 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
160 [s0, s1, s2], k,
"Nup145C Nup84 Sec13")
161 r.set_maximum_score(k)
164 add_distance_restraint(
166 residue_indexes=[(0, 423)],
168 IMP.atom.FRAGMENT_TYPE]),
170 hierarchy=universe, molecule=
"Nup85",
172 IMP.atom.FRAGMENT_TYPE]),
173 "Num145C, Nup85", restraints)
174 add_distance_restraint(
176 residue_indexes=[(0, 423)],
178 IMP.atom.FRAGMENT_TYPE]),
180 hierarchy=universe, molecule=
"Nup120",
181 residue_indexes=[(500, 762)],
183 IMP.atom.FRAGMENT_TYPE]),
184 "Nup145C Nup120", restraints)
185 add_distance_restraint(
188 IMP.atom.FRAGMENT_TYPE]),
190 hierarchy=universe, molecule=
"Nup133",
191 residue_indexes=[(778, 1160)],
193 IMP.atom.FRAGMENT_TYPE]),
194 "Nup84 Nup133", restraints)
195 add_distance_restraint(
198 IMP.atom.FRAGMENT_TYPE]),
200 hierarchy=universe, molecule=
"Seh1",
202 IMP.atom.FRAGMENT_TYPE]),
203 "Nup85 Seh1", restraints)
204 add_distance_restraint(
206 residue_indexes=[(0, 423)],
208 IMP.atom.FRAGMENT_TYPE]),
210 hierarchy=universe, molecule=
"Sec13",
212 IMP.atom.FRAGMENT_TYPE]),
213 "Nup145C Sec13", restraints)
217 def get_configurations(
220 excluded_volume_particles,
221 optimized_particles):
228 for p
in optimized_particles:
239 mc.add_mover(serial_mover)
241 optimized_particles, restraints)
243 excluded_volume_particles)
248 for i
in range(number_of_sampling_attempts):
249 for p
in optimized_particles:
252 mc.optimize(number_of_mc_steps)
253 if scoring_function.get_had_good_score():
254 configuration_set.save()
255 return configuration_set
259 universe, restraints, excluded_volume_particles, optimized_particles = create_representation(
261 encode_data_as_restraints(universe, restraints)
263 configuration_set = get_configurations(model, restraints,
264 excluded_volume_particles,
267 print "Found", configuration_set.get_number_of_configurations(),
"good configurations"
271 rmf = RMF.create_rmf_file(rmf_file_name)
278 for i
in range(0, configuration_set.get_number_of_configurations()):
279 configuration_set.load_configuration(i)
284 for p
in optimized_particles]
286 tr = IMP.algebra.get_transform_taking_first_to_second(
287 optimized_particles, base_coords)
293 print "You can now open", rmf_file_name,
"in chimera"