Example of optimizing an EM2D restraint using Monte Carlo.
19 def __init__(self, restraints):
20 IMP.OptimizerState.__init__(self)
22 self.restraints = restraints
25 if (self.count != 10):
30 o = self.get_optimizer()
32 for r
in self.restraints:
33 print r.get_name(), r.get_last_score()
48 print "there are", len(chains),
"chains in 1z5s.pdb"
51 native_chain_centers = []
56 rbd.set_coordinates_are_optimized(
True)
57 rigid_bodies.append(rbd)
58 print "chain has", rbd.get_number_of_members(), \
59 "atoms",
"coordinates: ", rbd.get_coordinates()
60 native_chain_centers.append(rbd.get_coordinates())
65 for rbd
in rigid_bodies:
69 rbd.get_coordinates(), rotation)
75 transformation1, transformation2)
77 print "Writing transformed assembly"
83 native_chain_centers[0], native_chain_centers[1])
86 r01.set_name(
"distance 0-1")
88 native_chain_centers[1], native_chain_centers[2])
91 r12.set_name(
"distance 1-2")
93 native_chain_centers[2], native_chain_centers[3])
96 r23.set_name(
"distance 2-3")
98 native_chain_centers[3], native_chain_centers[0])
101 r30.set_name(
"distance 3-0")
102 print "Distances in the solution: d01 =", \
103 d01,
"d12 =", d12,
"d23 =", d23,
"d30 =", d30
106 print "adding distance restraints "
107 for r
in [r01, r12, r23, r30]:
109 print "model has ", m.get_number_of_restraints(),
"restraints"
115 IMP.em2d.read_selection_file(selection_file)]
117 print len(em_images),
"images read"
127 params = IMP.em2d.Em2DRestraintParameters(apix, resolution, n_projections)
131 params.coarse_registration_method = IMP.em2d.ALIGN2D_PREPROCESSING
134 params.save_match_images =
False
138 em2d_restraint.setup(score_function, params)
139 em2d_restraint.set_images(em_images)
140 em2d_restraint.set_name(
"em2d restraint")
142 em2d_restraint.set_particles(container)
151 print "adding em2d restraint "
152 m.add_restraint(em2d_restraints_set)
154 print "model has ", m.get_number_of_restraints(),
"restraints"
161 for rbd
in rigid_bodies:
164 print "MonteCarlo sampler has", s.get_number_of_movers(),
"movers"
167 o_state.set_period(10)
168 s.add_optimizer_state(o_state)
170 ostate2 = WriteStatisticsOptimizerScore(m.get_restraints())
171 s.add_optimizer_state(ostate2)
174 temperatures = [200, 100, 60, 40, 20, 5]
177 optimization_steps = 10
178 for T
in temperatures:
180 s.optimize(optimization_steps)
185 print "*** End optimization ***"
187 for rbd
in rigid_bodies:
188 print "chain has", rbd.get_number_of_members(), \
189 "atoms",
"coordinates: ", rbd.get_coordinates()
190 new_centers.append(rbd.get_coordinates())
196 print "Distances at the end of the optimization: d01 =", \
197 d01,
"d12 =", d12,
"d23 =", d23,
"d30 =", d30