IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
pmi/dof/__init__.py
1 """@namespace IMP.pmi.dof
2  Create movers and set up constraints for PMI objects.
3  See the documentation of the DegreesOfFreedom class for more information.
4 """
5 
6 from __future__ import print_function
7 import IMP
8 import IMP.atom
9 import IMP.algebra
10 import IMP.pmi
11 import IMP.pmi.topology
12 import IMP.pmi.samplers
13 import IMP.pmi.tools
14 import itertools
15 import IMP.pmi.samplers
16 
17 
18 def create_rigid_body_movers(dof,maxtrans,maxrot):
19  mvs = []
20  for rb in dof.rigid_bodies:
21  mvs.append(IMP.core.RigidBodyMover(rb.get_model(), rb,
22  maxtrans, maxrot))
23  return mvs
24 
25 class DegreesOfFreedom(object):
26  """Simplify creation of constraints and movers for an IMP Hierarchy.
27 
28  * The various "create X" functions make movers for system components
29  as well as set up necessary constraints. For each of these functions,
30  you can generally pass PMI objects like
31  [Molecule](@ref IMP::pmi::topology::Molecule) or slices thereof.
32  * DegreesOfFreedom.create_rigid_body() lets you rigidify a molecule
33  (but allows you to also pass "nonrigid" components which move with
34  the body and also independently).
35  * DegreesOfFreedom.create_super_rigid_body() sets up a special
36  "Super Rigid Body" which moves rigidly but is not always constrained
37  to be rigid (so you can later move the parts separately). This is
38  good for speeding up sampling.
39  * DegreesOfFreedom.create_flexible_beads() sets up particles to move
40  individually.
41  * DegreesOfFreedom.setup_md() sets up particles to move with molecular
42  dynamics. Note that this is not (yet) compatible with rigid bodies,
43  and only works with some restraints.
44  * DegreesOfFreedom.constrain_symmetry() makes a symmetry constraint so
45  that clones automatically move with their references. If instead you
46  want a softer restraint, check out the
47  [SymmetryRestraint](@ref IMP::pmi::restraints::stereochemistry::SymmetryRestraint).
48  * When you are done you can access all movers with
49  DegreesOfFreedom.get_movers(). If you have set up rigid, super rigid,
50  or flexible beads, pass the movers to the `monte_carlo_sample_objects`
51  argument of
52  [ReplicaExchange0](@ref IMP::pmi::macros::ReplicaExchange0).
53  * If you are running MD, you have to separately pass the particles
54  (also returned from DegreesOfFreedom.setup_md()) to the
55  `molecular_dynamics_sample_objects` argument of
56  [ReplicaExchange0](@ref IMP::pmi::macros::ReplicaExchange0). Check
57  out an [MD example here](pmi_2atomistic_8py-example.html).
58  """
59  def __init__(self,model):
60  self.model = model
61  self.movers = []
62  self.fb_movers = [] #stores movers corresponding to floppy parts
63  self.rigid_bodies = [] #stores rigid body objects
64  self.flexible_beads = [] # stores all beads including nonrigid members of rigid bodies
65  self.nuisances = []
66  self._rb2mov = {} # Keys are the RigidBody objects, values are list of movers
67  # the following is needed to keep track of disabled movers
68  self.movers_particles_map=IMP.pmi.tools.OrderedDict()
69  self.movers_rb_map={}
70  self.movers_xyz_map={}
71  self.disabled_movers=[]
72 
73  #self.particle_map = {} # map from particles/rb objects to relevant movers+constraints
74  # internal mover = [mover obj, list of particles, enabled?] ?
75  # mover map = {particles/rbs : movers}
76 
77  @property
78  @IMP.deprecated_method("2.10", "Model should be accessed with `.model`.")
79  def mdl(self):
80  return self.model
81 
82  def _get_nonrigid_hiers(self, nonrigid_parts, rigid_hiers, resolution):
83  """Get Hierarchy objects for nonrigid parts. Make sure that they are
84  a subset of the rigid body Hierarchies."""
85  if not nonrigid_parts:
86  return
87  nr_hiers = IMP.pmi.tools.input_adaptor(nonrigid_parts, resolution,
88  flatten=True)
89  if nr_hiers:
90  rb_idxs = set(h.get_particle_index() for h in rigid_hiers)
91  for h in nr_hiers:
92  p = h.get_particle()
93  if p.get_index() not in rb_idxs:
94  raise ValueError(
95  "You tried to create nonrigid members from "
96  "particles that aren't in the RigidBody!")
97  return nr_hiers
98 
100  rigid_parts,
101  nonrigid_parts=None,
102  max_trans=4.0,
103  max_rot=0.5,
104  nonrigid_max_trans = 4.0,
105  resolution='all',
106  name=None):
107  """Create rigid body constraint and mover
108  @param rigid_parts Can be one of the following inputs:
109  IMP Hierarchy, PMI System/State/Molecule/TempResidue, a list/set
110  (of list/set) of them or a RigidBody object.
111  Must be uniform input, however. No mixing object types.
112  @param nonrigid_parts Same input format as rigid_parts.
113  Must be a subset of rigid_parts particles.
114  @param max_trans Maximum rigid body translation
115  @param max_rot Maximum rigid body rotation
116  @param nonrigid_max_trans Maximum step for the nonrigid (bead) particles
117  @param resolution Only used if you pass PMI objects. Probably you
118  want 'all'.
119  @param name Rigid body name (if None, use IMP default)
120  @eturn (rb_movers,rb_object)
121  @note If you want all resolutions, pass PMI objects because this
122  function will get them all. Alternatively you can do your
123  selection elsewhere and just pass hierarchies.
124  """
125 
126  rb_movers = []
127 
128  # ADD CHECK: these particles are not already part of some RB or SRB
129 
130  # First, is this already a rigid body?
131  if type(rigid_parts) is IMP.core.RigidBody:
132  print("WARNING: Rigid Body Already Setup")
133  rb = rigid_parts
134  model=rb.get_model()
135  if name is None:
136  name = rb.get_name()
137  hiers= [IMP.atom.get_leaves(IMP.atom.Hierarchy(m.get_particle(i)))[0] for i in rb.get_member_particle_indexes()]
138  else:
139  ### Otherwise, setup RB
140  hiers = IMP.pmi.tools.input_adaptor(rigid_parts,
141  resolution,
142  flatten=True)
143 
144  if not hiers:
145  print("WARNING: No hierarchies were passed to create_rigid_body()")
146  return []
147 
148  # Need to do this before rigid body is set up so that we leave the
149  # system in a consistent state if a sanity check fails
150  nr_hiers = self._get_nonrigid_hiers(nonrigid_parts, hiers, resolution)
151 
152  if type(rigid_parts) is not IMP.core.RigidBody:
153  model=hiers[0].get_model()
154 
155  #we need to use the following constructor because the IMP.core.create_rigid_body seems
156  #to construct an arbitrary reference frame, which will be different for all copies.
157  #therefore, symmetry won't work all the time
158 
160  comcoor=IMP.core.XYZ(com).get_coordinates()
163  rbp=IMP.Particle(model)
165  for h in hiers:
166  rb.add_member(h.get_particle())
167 
168  self.rigid_bodies.append(rb)
169  rb.set_coordinates_are_optimized(True)
170  rb_mover = IMP.core.RigidBodyMover(rb.get_model(), rb, max_trans,
171  max_rot)
172  if name is not None:
173  rb.set_name(name)
174  rb_mover.set_name(name)
175  rb_movers.append(rb_mover)
176  self.movers_particles_map[rb_mover]=[]
177  self.movers_rb_map[rb_mover]=[rb]
178  rb_mover.set_was_used(True)
179  for h in hiers:
180  self.movers_particles_map[rb_mover]+=IMP.atom.get_leaves(h)
181  ### setup nonrigid parts
182  if nr_hiers:
183  floatkeys = [IMP.FloatKey(4), IMP.FloatKey(5), IMP.FloatKey(6)]
184  for h in nr_hiers:
185  self.flexible_beads.append(h)
186  p = h.get_particle()
187  rb.set_is_rigid_member(p.get_index(),False)
188  for fk in floatkeys:
189  p.set_is_optimized(fk,True)
190  fbmv=IMP.core.BallMover(p.get_model(), p,
191  IMP.FloatKeys(floatkeys),
192  nonrigid_max_trans)
193  self.fb_movers.append(fbmv)
194  self.movers_particles_map[fbmv]=IMP.atom.get_leaves(h)
195  self.movers_xyz_map[fbmv]=IMP.atom.get_leaves(h)
196  fbmv.set_was_used(True)
197  rb_movers.append(fbmv)
198 
199  self.movers += rb_movers # probably need to store more info
200  self._rb2mov[rb] = rb_movers #dictionary relating rb to movers
201 
202  return rb_movers,rb
203 
204  def create_main_chain_mover(self,molecule,resolution=10,lengths=[5,10]):
205  """Create crankshaft moves from a set of SUPER rigid body mover from one molecule.
206  See http://scfbm.biomedcentral.com/articles/10.1186/1751-0473-3-12
207  """
208  hiers=IMP.pmi.tools.input_adaptor(molecule,resolution,flatten=True)
209 
210  for length in lengths:
211  for n in range(len(hiers)-length):
212  hs=hiers[n+1:n+length]
213  #print("MIDDLE",n+1,n+length,hs)
214  self.create_super_rigid_body(hs, max_trans=0.0,max_rot=0.05, axis=(hiers[n].get_particle(),hiers[n+length].get_particle()))
215  #for n in range(1,len(hiers)-1,10):
216  # hs=hiers[n:]
217  # print("END",n,hs)
218  # self.create_super_rigid_body(hs, max_trans=0.01,axis=(hiers[n].get_particle(),hiers[n+1].get_particle()))
219  # hs=hiers[:n+1]
220  # print("BEGIN",n-1,hs)
221  # self.create_super_rigid_body(hs, max_trans=0.01,axis=(hiers[n].get_particle(),hiers[n-1].get_particle()))
222 
223  def create_super_rigid_body(self,
224  srb_parts,
225  max_trans=1.0,
226  max_rot=0.1,
227  chain_min_length=None,
228  chain_max_length=None,
229  resolution='all',
230  name=None,
231  axis=None):
232  """Create SUPER rigid body mover from one or more hierarchies.
233 
234  Can also create chain of SRBs. If you don't pass chain min/max,
235  it'll treat everything you pass as ONE rigid body.
236  If you DO pass chain min/max, it'll expect srb_parts is a list
237  and break it into bits.
238  @param srb_parts Can be one of the following inputs:
239  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
240  or a list/set (of list/set) of them.
241  Must be uniform input, however. No mixing object types.
242  @param max_trans Maximum super rigid body translation
243  @param max_rot Maximum super rigid body rotation
244  @param chain_min_length Create a CHAIN of super rigid bodies -
245  must provide list; this parameter is the minimum chain length.
246  @param chain_max_length Maximum chain length
247  @param resolution Only used if you pass PMI objects. Probably you
248  want 'all'.
249  @param name The name of the SRB (hard to assign a good one
250  automatically)
251  @param axis A tuple containing two particles which are used to
252  compute the rotation axis of the SRB. The default is None,
253  meaning that the rotation axis is random.
254 
255  @note If you set the chain parameters, will NOT create an SRB from
256  all of them together, but rather in groups made from the
257  outermost list.
258  """
259 
260  srb_movers = []
261 
262  ## organize hierarchies based on chains
263  if chain_min_length is None and chain_max_length is None:
264  # the "chain" is just everything together
265  h = IMP.pmi.tools.input_adaptor(srb_parts,resolution,flatten=True)
266  if len(h)==0:
267  print('WARNING: No hierarchies were passed to create_super_rigid_body()')
268  return srb_movers
269  srb_groups = [h]
270  else:
271  if not hasattr(srb_parts,'__iter__'):
272  raise Exception("You tried to make a chain without a list!")
273  srb_groups = [IMP.pmi.tools.input_adaptor(h,resolution,flatten=True,
274  warn_about_slices=False) for h in srb_parts]
275 
276  ## create SRBs either from all hierarchies or chain
277  if chain_min_length is None and chain_max_length is None:
278  mv = self._setup_srb(srb_groups,max_trans,max_rot,axis)
279  if mv:
280  mv.set_was_used(True)
281  srb_movers.append(mv)
282  elif chain_min_length is not None and chain_max_length is not None:
283  for hs in IMP.pmi.tools.sublist_iterator(srb_groups, chain_min_length, chain_max_length):
284  mv = self._setup_srb(hs,max_trans,max_rot,axis)
285  if mv:
286  mv.set_was_used(True)
287  srb_movers.append(mv)
288  else:
289  raise Exception("DegreesOfFreedom: SetupSuperRigidBody: if you want chain, specify min AND max")
290  self.movers += srb_movers
291  if name is not None:
292  if len(srb_movers)>1:
293  for n,mv in enumerate(srb_movers):
294  mv.set_name(name+'_'+str(n))
295  else:
296  srb_movers[0].set_name(name)
297  return srb_movers
298 
299  def _setup_srb(self,hiers,max_trans,max_rot,axis):
300  if axis is None:
301  srbm = IMP.pmi.TransformMover(hiers[0][0].get_model(), max_trans, max_rot)
302  else:
303  srbm = IMP.pmi.TransformMover(hiers[0][0].get_model(),axis[0],axis[1],max_trans, max_rot)
304  super_rigid_rbs,super_rigid_xyzs = IMP.pmi.tools.get_rbs_and_beads(hiers)
305  ct = 0
306  self.movers_particles_map[srbm]=[]
307  for h in hiers:
308  self.movers_particles_map[srbm]+=IMP.atom.get_leaves(h)
309  for xyz in super_rigid_xyzs:
310  srbm.add_xyz_particle(xyz)
311  ct+=1
312  for rb in super_rigid_rbs:
313  srbm.add_rigid_body_particle(rb)
314  ct+=1
315  if ct>1:
316  return srbm
317  else:
318  return 0
319 
320 
322  flex_parts,
323  max_trans=3.0,
324  resolution='all'):
325  """Create a chain of flexible beads
326 
327  @param flex_parts Can be one of the following inputs:
328  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
329  or a list/set (of list/set) of them.
330  Must be uniform input, however. No mixing object types.
331  @param max_trans Maximum flexible bead translation
332  @param resolution Only used if you pass PMI objects. Probably
333  you want 'all'.
334  """
335 
336  fb_movers = []
337  hiers = IMP.pmi.tools.input_adaptor(flex_parts,
338  resolution,
339  flatten=True)
340  if not hiers or len(hiers)==0:
341  print('WARNING: No hierarchies were passed to create_flexible_beads()')
342  return fb_movers
343  for h in hiers:
344  p = h.get_particle()
345  IMP.core.XYZ(p).set_coordinates_are_optimized(True)
347  raise Exception("Cannot create flexible beads from members of rigid body")
348  self.flexible_beads.append(h)
349  fbmv=IMP.core.BallMover(p.get_model(), p, max_trans)
350  fb_movers.append(fbmv)
351  fbmv.set_was_used(True)
352  self.fb_movers.append(fbmv)
353  self.movers_particles_map[fbmv]=IMP.atom.get_leaves(h)
354  self.movers_xyz_map[fbmv]=IMP.atom.get_leaves(h)
355  self.movers += fb_movers
356  return fb_movers
357 
359  nuisance_p,
360  step_size,
361  name=None):
362  """Create MC normal mover for nuisance particles.
363  We will add an easier interface to add all of them from a PMI restraint
364  @param nuisance_p The Nuisance particle (an ISD::Scale)
365  @param step_size The maximum step size for Monte Carlo
366  @param name The name of the mover, useful for better output reading.
367  """
368  mv = IMP.core.NormalMover([nuisance_p],
369  IMP.FloatKeys([IMP.FloatKey("nuisance")]),
370  step_size)
371  if name is not None:
372  mv.set_name(name)
373  mv.set_was_used(True)
374  self.nuisances.append(nuisance_p)
375  self.movers.append(mv)
376  return [mv]
377 
378  def setup_md(self,
379  hspec):
380  """Setup particles for MD simulation. Returns all particles, just
381  pass this to molecular_dynamics_sample_objects in ReplicaExchange0.
382  @param hspec Can be one of the following inputs:
383  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set (of list/set) of them.
384  Must be uniform input, however. No mixing object types.
385  """
386  vxkey = IMP.FloatKey('vx')
387  vykey = IMP.FloatKey('vy')
388  vzkey = IMP.FloatKey('vz')
389  hiers = IMP.pmi.tools.input_adaptor(hspec,flatten=True)
390  model = hiers[0].get_model()
391  all_ps = []
392  for hl in hiers:
393  for h in IMP.core.get_leaves(hl):
394  p = h.get_particle()
395  IMP.core.XYZ(model,p.get_index()).set_coordinates_are_optimized(True)
396  model.add_attribute(vxkey,p.get_index(),0.0)
397  model.add_attribute(vykey,p.get_index(),0.0)
398  model.add_attribute(vzkey,p.get_index(),0.0)
399  all_ps.append(p)
400  return all_ps
401 
403  references,
404  clones,
405  transform,
406  resolution='all',
407  type="AXIAL"):
408  """Create a symmetry constraint. Checks:
409  same number of particles
410  disable ANY movers involving symmetry copies
411  (later may support moving them WITH references,
412  but requires code to propagate constraint)
413  @param references Can be one of the following inputs:
414  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set (of list/set) of them
415  @param clones Same format as references
416  @param transform The transform that moves a clone onto a reference
417  IMP.algebra.Transformation3D
418  @param resolution Only used if you pass PMI objects.
419  If you have a multires system, assuming each are rigid
420  bodies you probably only need one resolution.
421  @param type of symmetry. Implemented = AXIAL, RIGID_BODY
422  """
423 
424  # get all RBs and particles
425  href = IMP.pmi.tools.input_adaptor(references,resolution,flatten=True)
426  hclones = IMP.pmi.tools.input_adaptor(clones,resolution,flatten=True)
427 
428  ref_rbs,ref_beads = IMP.pmi.tools.get_rbs_and_beads(href)
429  clones_rbs,clones_beads = IMP.pmi.tools.get_rbs_and_beads(hclones)
430 
431  # dumb check for matching numbers of particles
432  #if len(ref_rbs)!=len(clones_rbs) or len(ref_beads)!=len(clones_beads):
433  # raise Exception("ERROR: Your references don't match your clones")
434 
435  # symmetry RBs
436  # this code produces weird results (random flipping of rigid bodies
437  #for ref,clone in zip(ref_rbs+ref_beads,clones_rbs+clones_beads):
438  # print(clone.get_particle().get_index(),ref.get_particle().get_index())
439  # IMP.core.Reference.setup_particle(clone.get_particle(),ref.get_particle())
440  for ref,clone in zip(ref_rbs,clones_rbs):
442 
443  for ref,clone in zip(ref_beads,clones_beads):
445 
446  # removing movers involved in clones
447  self.disable_movers(hclones)
448 
449  if type=="AXIAL":
450  sm = IMP.core.TransformationSymmetry(transform)
451 
452 
453  if type=="RIGID_BODY":
454  p=IMP.Particle(self.model)
455  p.set_name("RigidBody_Symmetry")
457  for cp in [(10,0,0),(0,10,0),(0,0,10)]:
458  p=IMP.Particle(self.model)
460  rb.add_member(p)
461  sm = IMP.core.TransformationSymmetry(rb.get_particle_index())
462  self.rigid_bodies.append(rb)
463  rb.set_coordinates_are_optimized(True)
464  rb_mover_tr = IMP.core.RigidBodyMover(rb.get_model(), rb.get_particle_index(), 0.0, 1.0)
465  rb_mover_rt = IMP.core.RigidBodyMover(rb.get_model(), rb.get_particle_index(), 10.0, 0.0)
466 
467  rb_mover_tr.set_name("RigidBody_Symmetry_Mover_Translate")
468  rb_mover_rt.set_name("RigidBody_Symmetry_Mover_Rotate")
469  print('Created rigid body symmetry restraint')
470  self.movers_particles_map[rb_mover_tr]=[]
471  self.movers_particles_map[rb_mover_rt]=[]
472  self.movers_rb_map[rb_mover_tr]=[rb]
473  self.movers_rb_map[rb_mover_rt]=[rb]
474  for h in hclones:
475  self.movers_particles_map[rb_mover_tr]+=IMP.atom.get_leaves(h)
476  self.movers_particles_map[rb_mover_rt]+=IMP.atom.get_leaves(h)
477  self.movers.append(rb_mover_tr) # probably need to store more info
478  self.movers.append(rb_mover_rt) # probably need to store more info
479  self._rb2mov[rb] = [rb_mover_tr,rb_mover_rt] #dictionary relating rb to movers
480  #self._rb2mov[rb] = [rb_mover_tr] #dictionary relating rb to movers
481 
483  self.model,[p.get_particle().get_index() for p in clones_rbs+clones_beads])
484  c = IMP.container.SingletonsConstraint(sm, None, lsc)
485  self.model.add_score_state(c)
486  print('Created symmetry restraint for',len(ref_rbs),'rigid bodies and',
487  len(ref_beads),'flexible beads')
488 
489 
490  #sym_movers = []
491 
492  #sym_movers = [m for cl in clones_rbs for m in self._rb2mov[cl]]
493  #self.movers = [m for m in self.movers if m not in sym_movers]
494  self.model.update()
495 
496 
497  def __repr__(self):
498  # would like something fancy like this:
499  #- super-rigid "SRB1"
500  # - rigid "Mol1" (8 rigid, 3 nonrigid)
501  # - rigid "Mol2" (8 rigid, 3 nonrigid)
502  # - rigid "Mol3" (8 rigid, 3 nonrigid)
503  return 'DegreesOfFreedom: ' + \
504  "\n".join(repr(m) for m in self.movers)
505 
506  def optimize_flexible_beads(self, nsteps, temperature=1.0):
507  '''Set up MC run with just flexible beads.
508  Optimization works much better when restraints
509  are already set up.'''
510  pts = IMP.pmi.tools.ParticleToSampleList()
511  for n, fb in enumerate(self.get_flexible_beads()):
512  pts.add_particle(fb, "Floppy_Bodies", 1.0, "Flexible_Bead_" + str(n))
513  if len(pts.get_particles_to_sample()) > 0:
514  mc = IMP.pmi.samplers.MonteCarlo(self.model, [pts], temperature)
515  print("optimize_flexible_beads: optimizing %i flexible beads" % len(self.get_flexible_beads()))
516  mc.optimize(nsteps)
517  else:
518  print("optimize_flexible_beads: no particle to optimize")
519 
520  def get_movers(self):
521  """Returns Enabled movers"""
522  if self.disabled_movers:
523  filtered_mover_list=[]
524  for mv in self.movers:
525  if not mv in self.disabled_movers:
526  filtered_mover_list.append(mv)
527  return filtered_mover_list
528  else:
529  return self.movers
530 
532  """Return all movers corresponding to individual beads"""
533  return self.fb_movers
534 
535  def get_rigid_bodies(self):
536  """Return list of rigid body objects"""
537  return self.rigid_bodies
538 
540  """Return all flexible beads, including nonrigid members of rigid bodies"""
541  return self.flexible_beads
542 
543  def disable_movers(self,objects,mover_types=None):
544  """Fix the position of the particles by disabling the corresponding movers
545  @param objects Can be one of the following inputs:
546  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set (of list/set) of them.
547  Must be uniform input, however. No mixing object types.
548  @param mover_types further filter the mover type that will be disabled, it can be a list of IMP.core.RigidBodyMover,
549  IMP.core.BallMover etc etc if one wants to fix the corresponding rigid body, or the floppy bodies.
550  An empty mover_types list is interpreted as all possible movers.
551  It returns the list of fixed xyz particles (ie, floppy bodies/beads) and rigid bodies
552  whose movers were disabled
553  """
554  hierarchies = IMP.pmi.tools.input_adaptor(objects,
555  pmi_resolution='all',
556  flatten=True)
557  tmp_set=set()
558  fixed_rb=set()
559  fixed_xyz=set()
560  if mover_types is None: mover_types=[]
561 
562  inv_map = {}
563  for mv, ps in self.movers_particles_map.items():
564  for p in ps:
565  if p in inv_map: inv_map[p].append(mv)
566  else: inv_map[p]=[mv]
567 
568  for h in hierarchies:
569  if h in inv_map:
570  for mv in inv_map[h]:
571  if (type(mv) in mover_types or not mover_types):
572  tmp_set.add(mv)
573  if mv in self.movers_rb_map:
574  fixed_rb|=set(self.movers_rb_map[mv])
575  if mv in self.movers_xyz_map:
576  fixed_xyz|=set(self.movers_xyz_map[mv])
577  print("Fixing %s movers" %(str(len(list(tmp_set)))))
578  self.disabled_movers+=list(tmp_set)
579  return list(fixed_xyz),list(fixed_rb)
580 
581  def enable_all_movers(self):
582  """Reenable all movers: previously fixed particles will be released"""
583  self.disabled_movers=[]
584 
586  """Extract the nuisances from get_particles_to_sample()"""
587  try:
588  pslist = r.get_particles_to_sample()
589  except:
590  raise Exception("dof.get_nuisances_from_restraint(): the passed object does not have a "
591  "get_particles_to_sample() function")
592  for name in pslist:
593  is_sampled = True
594  if len(pslist[name])==3:
595  ps,maxtrans,is_sampled = pslist[name]
596  else:
597  ps,maxtrans = pslist[name]
598  if is_sampled:
599  self.create_nuisance_mover(ps[0],maxtrans,name)
def optimize_flexible_beads
Set up MC run with just flexible beads.
def get_rigid_bodies
Return list of rigid body objects.
Simple 3D transformation class.
static CenterOfMass setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor members)
Definition: CenterOfMass.h:81
Apply a SingletonFunction to a SingletonContainer to maintain an invariant.
Set the coordinates of a particle to be a transformed version of a reference.
Definition: core/symmetry.h:76
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
def create_flexible_beads
Create a chain of flexible beads.
def enable_all_movers
Reenable all movers: previously fixed particles will be released.
Miscellaneous utilities.
Definition: tools.py:1
def get_nuisances_from_restraint
Extract the nuisances from get_particles_to_sample()
Modify the transformation of a rigid body.
def create_nuisance_mover
Create MC normal mover for nuisance particles.
def get_movers
Returns Enabled movers.
def get_floppy_body_movers
Return all movers corresponding to individual beads.
Move continuous particle variables by perturbing them within a ball.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: rigid_bodies.h:690
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
def setup_md
Setup particles for MD simulation.
A reference frame in 3D.
def create_main_chain_mover
Create crankshaft moves from a set of SUPER rigid body mover from one molecule.
def create_rigid_body
Create rigid body constraint and mover.
The standard decorator for manipulating molecular structures.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
def create_super_rigid_body
Create SUPER rigid body mover from one or more hierarchies.
Store a list of ParticleIndexes.
def deprecated_method
Python decorator to mark a method as deprecated.
Definition: __init__.py:9703
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
Modify the transformation of a rigid body.
Modify a set of continuous variables using a normal distribution.
Definition: NormalMover.h:20
Sampling of the system.
Definition: samplers.py:1
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Sample using Monte Carlo.
Definition: samplers.py:36
The general base class for IMP exceptions.
Definition: exception.h:49
static Reference setup_particle(Model *m, ParticleIndex pi, ParticleIndexAdaptor reference)
Definition: core/symmetry.h:32
Rotation3D get_identity_rotation_3d()
Return a rotation that does not do anything.
Definition: Rotation3D.h:302
Class to handle individual particles of a Model object.
Definition: Particle.h:41
def constrain_symmetry
Create a symmetry constraint.
Python classes to represent, score, sample and analyze models.
A decorator for a rigid body.
Definition: rigid_bodies.h:82
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchies get_leaves(const Selection &h)
def get_flexible_beads
Return all flexible beads, including nonrigid members of rigid bodies.
def disable_movers
Fix the position of the particles by disabling the corresponding movers.
static RigidBody setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor ps)
Definition: rigid_bodies.h:169
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: rigid_bodies.h:711