Modify the Nup84 CG example by replacing a couple of the protein representations with higher resolution representations generated from PDB files. 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.
38 number_of_sampling_attempts=1
39 number_of_mc_steps=10000
42 def add_protein_from_length(model, name, residues, parent, restraints,
43 excluded_volume_particles, optimized_particles):
50 optimized_particles.extend(leaves)
51 excluded_volume_particles.extend(leaves)
55 for c
in h.get_children()], k,
61 r.set_maximum_score(k)
64 def add_protein_from_pdb(model, name, file, parent, restraints,
65 excluded_volume_particles, optimized_particles):
80 rb.set_coordinates_are_optimized(
True)
81 optimized_particles.append(rb)
82 excluded_volume_particles.extend(s.get_children())
87 def add_protein_from_pdbs(model, name, files, parent, restraints,
88 excluded_volume_particles, optimized_particles):
90 for i, f
in enumerate(files):
91 add_protein_from_pdb(model, name+str(i), f, h, restraints,
92 excluded_volume_particles, optimized_particles)
94 for c
in h.get_children()],
98 r.set_maximum_score(k)
101 def create_representation(model):
103 optimized_particles = []
104 excluded_volume_particles = []
107 add_protein_from_length(model,
"Nup85", 570, universe, restraints,
108 excluded_volume_particles, optimized_particles)
112 hierarchy_types = [IMP.atom.FRAGMENT_TYPE],
113 terminus = IMP.atom.Selection.C)
116 d.set_coordinates_are_optimized(
False)
118 add_protein_from_length(model,
"Nup84", 460, universe, restraints,
119 excluded_volume_particles, optimized_particles)
120 add_protein_from_length(model,
"Nup145C", 442, universe, restraints,
121 excluded_volume_particles, optimized_particles)
122 add_protein_from_length(model,
"Nup120", [0, 500, 761], universe, restraints,
123 excluded_volume_particles, optimized_particles)
124 add_protein_from_length(model,
"Nup133", [0, 450, 778, 1160], universe, restraints,
125 excluded_volume_particles, optimized_particles)
126 add_protein_from_pdb(model,
"Seh1",
"seh1.pdb", universe, restraints,
127 excluded_volume_particles, optimized_particles)
128 add_protein_from_pdb(model,
"Sec13",
"sec13.pdb", universe, restraints,
129 excluded_volume_particles, optimized_particles)
130 return universe, restraints, excluded_volume_particles, optimized_particles
132 def add_distance_restraint(selection0, selection1, name, restraints):
134 r.set_maximum_score(k)
138 def encode_data_as_restraints(universe, restraints):
140 molecule=
"Nup145C", residue_indexes=[(0,423)])
146 r.set_maximum_score(k)
150 residue_indexes=[(0,423)],
151 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
153 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
154 "Num145C, Nup85", restraints)
156 residue_indexes=[(0,423)],
157 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
159 residue_indexes= [(500, 762)],
160 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
161 "Nup145C Nup120", restraints)
163 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
165 residue_indexes=[(778, 1160)],
166 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
167 "Nup84 Nup133", restraints)
169 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
171 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
172 "Nup85 Seh1", restraints)
174 residue_indexes=[(0,423)],
175 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
177 hierarchy_types=[IMP.atom.FRAGMENT_TYPE]),
178 "Nup145C Sec13", restraints)
183 def get_configurations(model, restraints, excluded_volume_particles, optimized_particles):
190 for p
in optimized_particles:
199 mc.add_mover(serial_mover)
202 excluded_volume_particles)
206 for i
in range(number_of_sampling_attempts):
207 for p
in optimized_particles:
209 mc.optimize(number_of_mc_steps)
210 if scoring_function.get_had_good_score():
211 configuration_set.save()
212 return configuration_set
216 universe, restraints, excluded_volume_particles, optimized_particles= create_representation(model)
217 encode_data_as_restraints(universe, restraints)
219 configuration_set= get_configurations(model, restraints,
220 excluded_volume_particles,
223 print "Found", configuration_set.get_number_of_configurations(),
"good configurations"
227 rmf= RMF.create_rmf_file(rmf_file_name)
234 for i
in range(0, configuration_set.get_number_of_configurations()):
235 configuration_set.load_configuration(i)
239 base_coords=[
IMP.core.XYZ(p).get_coordinates()
for p
in optimized_particles]
241 tr= IMP.algebra.get_transform_taking_first_to_second(optimized_particles, base_coords)
247 print "You can now open", rmf_file_name,
"in chimera"