IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
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 import IMP
7 import IMP.atom
8 import IMP.algebra
9 import IMP.pmi
10 import IMP.pmi.topology
11 import IMP.pmi.samplers
12 import IMP.pmi.tools
13 import IMP.pmi.samplers
14 import warnings
15 
16 
17 def create_rigid_body_movers(dof, maxtrans, maxrot):
18  mvs = []
19  for rb in dof.rigid_bodies:
20  mvs.append(IMP.core.RigidBodyMover(rb.get_model(), rb,
21  maxtrans, maxrot))
22  return mvs
23 
24 
25 class DegreesOfFreedom:
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  [ReplicaExchange](@ref IMP::pmi::macros::ReplicaExchange).
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  [ReplicaExchange](@ref IMP::pmi::macros::ReplicaExchange). Check
57  out an [MD example here](pmi_2atomistic_8py-example.html).
58  """ # noqa: E501
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  # stores all beads including nonrigid members of rigid bodies
65  self.flexible_beads = []
66  self.nuisances = []
67  # Keys are the RigidBody objects, values are list of movers
68  self._rb2mov = {}
69  # the following is needed to keep track of disabled movers
70  self.movers_particles_map = IMP.pmi.tools.OrderedDict()
71  self.movers_rb_map = {}
72  self.movers_xyz_map = {}
73  self.disabled_movers = []
74 
75  def _get_nonrigid_hiers(self, nonrigid_parts, rigid_hiers, resolution):
76  """Get Hierarchy objects for nonrigid parts. Make sure that they are
77  a subset of the rigid body Hierarchies."""
78  if not nonrigid_parts:
79  return
80  nr_hiers = IMP.pmi.tools.input_adaptor(nonrigid_parts, resolution,
81  flatten=True)
82  if nr_hiers:
83  rb_idxs = set(h.get_particle_index() for h in rigid_hiers)
84  for h in nr_hiers:
85  p = h.get_particle()
86  if p.get_index() not in rb_idxs:
87  raise ValueError(
88  "You tried to create nonrigid members from "
89  "particles that aren't in the RigidBody!")
90  return nr_hiers
91 
92  def create_rigid_body(self, rigid_parts, nonrigid_parts=None,
93  max_trans=4.0, max_rot=0.5, nonrigid_max_trans=4.0,
94  resolution='all', name=None):
95  """Create rigid body constraint and mover
96  @param rigid_parts Can be one of the following inputs:
97  IMP Hierarchy, PMI System/State/Molecule/TempResidue, a list/set
98  (of list/set) of them or a RigidBody object.
99  Must be uniform input, however. No mixing object types.
100  @param nonrigid_parts Same input format as rigid_parts.
101  Must be a subset of rigid_parts particles.
102  @param max_trans Maximum rigid body translation
103  @param max_rot Maximum rigid body rotation
104  @param nonrigid_max_trans Maximum step for the nonrigid (bead)
105  particles
106  @param resolution Only used if you pass PMI objects. Probably you
107  want 'all'.
108  @param name Rigid body name (if None, use IMP default)
109  @return (rb_movers,rb_object)
110  @note If you want all resolutions, pass PMI objects because this
111  function will get them all. Alternatively you can do your
112  selection elsewhere and just pass hierarchies.
113  """
114 
115  rb_movers = []
116 
117  # ADD CHECK: these particles are not already part of some RB or SRB
118 
119  # First, is this already a rigid body?
120  if type(rigid_parts) is IMP.core.RigidBody:
121  warnings.warn("Rigid Body Already Setup", IMP.pmi.ParameterWarning)
122  rb = rigid_parts
123  model = rb.get_model()
124  if name is None:
125  name = rb.get_name()
127  model.get_particle(i)))[0]
128  for i in rb.get_member_particle_indexes()]
129  else:
130  # Otherwise, setup RB
131  hiers = IMP.pmi.tools.input_adaptor(rigid_parts,
132  resolution,
133  flatten=True)
134 
135  if not hiers:
136  warnings.warn(
137  "No hierarchies were passed to create_rigid_body()",
139  return []
140 
141  # Need to do this before rigid body is set up so that we leave the
142  # system in a consistent state if a sanity check fails
143  nr_hiers = self._get_nonrigid_hiers(nonrigid_parts, hiers, resolution)
144 
145  if type(rigid_parts) is not IMP.core.RigidBody:
146  model = hiers[0].get_model()
147 
148  # we need to use the following constructor because the
149  # IMP.core.create_rigid_body seems to construct an arbitrary
150  # reference frame, which will be different for all copies.
151  # therefore, symmetry won't work all the time
152 
154  hiers)
155  comcoor = IMP.core.XYZ(com).get_coordinates()
156 
157  # Don't needlessly update the COM of this particle for the
158  # entire sampling run; we are done with both the ScoreState
159  # and the Particle.
161  model.remove_particle(com)
162 
166  rbp = IMP.Particle(model)
168  for h in hiers:
169  rb.add_member(h.get_particle())
170 
171  self.rigid_bodies.append(rb)
172  rb.set_coordinates_are_optimized(True)
173  rb_mover = IMP.core.RigidBodyMover(rb.get_model(), rb, max_trans,
174  max_rot)
175  if name is not None:
176  rb.set_name(name)
177  rb_mover.set_name(name)
178  rb_movers.append(rb_mover)
179  self.movers_particles_map[rb_mover] = []
180  self.movers_rb_map[rb_mover] = [rb]
181  rb_mover.set_was_used(True)
182  for h in hiers:
183  self.movers_particles_map[rb_mover] += IMP.atom.get_leaves(h)
184  # setup nonrigid parts
185  if nr_hiers:
187  for h in nr_hiers:
188  self.flexible_beads.append(h)
189  p = h.get_particle()
190  rb.set_is_rigid_member(p.get_index(), False)
191  for fk in floatkeys:
192  p.set_is_optimized(fk, True)
193  fbmv = IMP.core.BallMover(p.get_model(), p,
194  IMP.FloatKeys(floatkeys),
195  nonrigid_max_trans)
196  self.fb_movers.append(fbmv)
197  self.movers_particles_map[fbmv] = IMP.atom.get_leaves(h)
198  self.movers_xyz_map[fbmv] = IMP.atom.get_leaves(h)
199  fbmv.set_was_used(True)
200  rb_movers.append(fbmv)
201 
202  self.movers += rb_movers # probably need to store more info
203  self._rb2mov[rb] = rb_movers # dictionary relating rb to movers
204 
205  return rb_movers, rb
206 
207  def create_main_chain_mover(self, molecule, resolution=10,
208  lengths=[5, 10]):
209  """Create crankshaft moves from a set of SUPER rigid body mover
210  from one molecule.
211  See http://scfbm.biomedcentral.com/articles/10.1186/1751-0473-3-12
212  """
213  hiers = IMP.pmi.tools.input_adaptor(molecule, resolution, flatten=True)
214 
215  for length in lengths:
216  for n in range(len(hiers)-length):
217  hs = hiers[n+1:n+length]
219  hs, max_trans=0.0, max_rot=0.05,
220  axis=(hiers[n].get_particle(),
221  hiers[n+length].get_particle()))
222 
223  def create_super_rigid_body(self, srb_parts, max_trans=1.0, max_rot=0.1,
224  chain_min_length=None, chain_max_length=None,
225  resolution='all', name=None, axis=None):
226  """Create SUPER rigid body mover from one or more hierarchies.
227 
228  Can also create chain of SRBs. If you don't pass chain min/max,
229  it'll treat everything you pass as ONE rigid body.
230  If you DO pass chain min/max, it'll expect srb_parts is a list
231  and break it into bits.
232  @param srb_parts Can be one of the following inputs:
233  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
234  or a list/set (of list/set) of them.
235  Must be uniform input, however. No mixing object types.
236  @param max_trans Maximum super rigid body translation
237  @param max_rot Maximum super rigid body rotation
238  @param chain_min_length Create a CHAIN of super rigid bodies -
239  must provide list; this parameter is the minimum
240  chain length.
241  @param chain_max_length Maximum chain length
242  @param resolution Only used if you pass PMI objects. Probably you
243  want 'all'.
244  @param name The name of the SRB (hard to assign a good one
245  automatically)
246  @param axis A tuple containing two particles which are used to
247  compute the rotation axis of the SRB. The default is None,
248  meaning that the rotation axis is random.
249 
250  @note If you set the chain parameters, will NOT create an SRB from
251  all of them together, but rather in groups made from the
252  outermost list.
253  """
254 
255  srb_movers = []
256 
257  # organize hierarchies based on chains
258  if chain_min_length is None and chain_max_length is None:
259  # the "chain" is just everything together
260  h = IMP.pmi.tools.input_adaptor(srb_parts, resolution,
261  flatten=True)
262  if len(h) == 0:
263  warnings.warn(
264  'No hierarchies were passed to create_super_rigid_body()',
266  return srb_movers
267  srb_groups = [h]
268  else:
269  if not hasattr(srb_parts, '__iter__'):
270  raise Exception("You tried to make a chain without a list!")
271  srb_groups = [IMP.pmi.tools.input_adaptor(
272  h, resolution, flatten=True, warn_about_slices=False)
273  for h in srb_parts]
274 
275  # create SRBs either from all hierarchies or chain
276  if chain_min_length is None and chain_max_length is None:
277  mv = self._setup_srb(srb_groups, max_trans, max_rot, axis)
278  if mv:
279  mv.set_was_used(True)
280  srb_movers.append(mv)
281  elif chain_min_length is not None and chain_max_length is not None:
283  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(
290  "DegreesOfFreedom: SetupSuperRigidBody: if you want "
291  "chain, specify min AND max")
292  self.movers += srb_movers
293  if name is not None:
294  if len(srb_movers) > 1:
295  for n, mv in enumerate(srb_movers):
296  mv.set_name(name + '_' + str(n))
297  else:
298  srb_movers[0].set_name(name)
299  return srb_movers
300 
301  def _setup_srb(self, hiers, max_trans, max_rot, axis):
302  if axis is None:
303  srbm = IMP.pmi.TransformMover(
304  hiers[0][0].get_model(), max_trans, max_rot)
305  else:
306  srbm = IMP.pmi.TransformMover(
307  hiers[0][0].get_model(), axis[0], axis[1], max_trans, max_rot)
308  srbm.set_name("Super rigid body transform mover")
309  srbm.set_was_used(True)
310  super_rigid_rbs, super_rigid_xyzs \
312  ct = 0
313  self.movers_particles_map[srbm] = []
314  for h in hiers:
315  self.movers_particles_map[srbm] += IMP.atom.get_leaves(h)
316  for xyz in super_rigid_xyzs:
317  srbm.add_xyz_particle(xyz)
318  ct += 1
319  for rb in super_rigid_rbs:
320  srbm.add_rigid_body_particle(rb)
321  ct += 1
322  if ct > 1:
323  return srbm
324  else:
325  return 0
326 
327  def create_flexible_beads(self, flex_parts, max_trans=3.0,
328  resolution='all'):
329  """Create a chain of flexible beads
330 
331  @param flex_parts Can be one of the following inputs:
332  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
333  or a list/set (of list/set) of them.
334  Must be uniform input, however. No mixing object types.
335  @param max_trans Maximum flexible bead translation
336  @param resolution Only used if you pass PMI objects. Probably
337  you want 'all'.
338  """
339 
340  fb_movers = []
341  hiers = IMP.pmi.tools.input_adaptor(flex_parts,
342  resolution,
343  flatten=True)
344  if not hiers or len(hiers) == 0:
345  warnings.warn(
346  'No hierarchies were passed to create_flexible_beads()',
348  return fb_movers
349  for h in hiers:
350  p = h.get_particle()
351  IMP.core.XYZ(p).set_coordinates_are_optimized(True)
354  raise Exception(
355  "Cannot create flexible beads from members of rigid body")
356  self.flexible_beads.append(h)
357  fbmv = IMP.core.BallMover(p.get_model(), p, max_trans)
358  fb_movers.append(fbmv)
359  fbmv.set_was_used(True)
360  self.fb_movers.append(fbmv)
361  self.movers_particles_map[fbmv] = IMP.atom.get_leaves(h)
362  self.movers_xyz_map[fbmv] = IMP.atom.get_leaves(h)
363  self.movers += fb_movers
364  return fb_movers
365 
366  def create_nuisance_mover(self, nuisance_p, step_size, name=None):
367  """Create MC normal mover for nuisance particles.
368  We will add an easier interface to add all of them from a PMI restraint
369  @param nuisance_p The Nuisance particle (an ISD::Scale)
370  @param step_size The maximum step size for Monte Carlo
371  @param name The name of the mover, useful for better output reading.
372  """
373  mv = IMP.core.NormalMover([nuisance_p],
374  IMP.FloatKeys([IMP.FloatKey("nuisance")]),
375  step_size)
376  if name is not None:
377  mv.set_name(name)
378  mv.set_was_used(True)
379  self.nuisances.append(nuisance_p)
380  self.movers.append(mv)
381  return [mv]
382 
383  def setup_md(self, hspec):
384  """Setup particles for MD simulation. Returns all particles, just
385  pass this to molecular_dynamics_sample_objects in ReplicaExchange.
386  @param hspec Can be one of the following inputs:
387  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
388  or a list/set (of list/set) of them.
389  Must be uniform input, however. No mixing object types.
390  """
391  hiers = IMP.pmi.tools.input_adaptor(hspec, flatten=True)
392  model = hiers[0].get_model()
393  all_ps = []
394  for hl in hiers:
395  for h in IMP.core.get_leaves(hl):
396  p = h.get_particle()
397  pxyz = IMP.core.XYZ(model, p.get_index())
398  pxyz.set_coordinates_are_optimized(True)
399  IMP.atom.LinearVelocity.setup_particle(p, [0., 0., 0.])
400  all_ps.append(p)
401  return all_ps
402 
403  def constrain_symmetry(self, references, clones, transform,
404  resolution='all', type="AXIAL"):
405  """Create a symmetry constraint. Checks:
406  same number of particles
407  disable ANY movers involving symmetry copies
408  (later may support moving them WITH references,
409  but requires code to propagate constraint)
410  @param references Can be one of the following inputs:
411  IMP Hierarchy, PMI System/State/Molecule/TempResidue,
412  or a list/set (of list/set) of them
413  @param clones Same format as references
414  @param transform The transform that moves a clone onto a reference
415  IMP.algebra.Transformation3D
416  @param resolution Only used if you pass PMI objects.
417  If you have a multires system, assuming each are rigid
418  bodies you probably only need one resolution.
419  @param type of symmetry. Implemented = AXIAL, RIGID_BODY
420  """
421 
422  # get all RBs and particles
423  href = IMP.pmi.tools.input_adaptor(references, resolution,
424  flatten=True)
425  hclones = IMP.pmi.tools.input_adaptor(clones, resolution, flatten=True)
426 
427  ref_rbs, ref_beads = IMP.pmi.tools.get_rbs_and_beads(href)
428  clones_rbs, clones_beads = IMP.pmi.tools.get_rbs_and_beads(hclones)
429 
430  for ref, clone in zip(ref_rbs, clones_rbs):
432 
433  for ref, clone in zip(ref_beads, clones_beads):
435 
436  # removing movers involved in clones
437  self.disable_movers(hclones)
438 
439  if type == "AXIAL":
440  sm = IMP.core.TransformationSymmetry(transform)
441 
442  if type == "RIGID_BODY":
443  p = IMP.Particle(self.model)
444  p.set_name("RigidBody_Symmetry")
446  p, IMP.algebra.ReferenceFrame3D(transform))
447  for cp in [(10, 0, 0), (0, 10, 0), (0, 0, 10)]:
448  p = IMP.Particle(self.model)
450  rb.add_member(p)
451  sm = IMP.core.TransformationSymmetry(rb.get_particle_index())
452  self.rigid_bodies.append(rb)
453  rb.set_coordinates_are_optimized(True)
454  rb_mover_tr = IMP.core.RigidBodyMover(
455  rb.get_model(), rb.get_particle_index(), 0.0, 1.0)
456  rb_mover_rt = IMP.core.RigidBodyMover(
457  rb.get_model(), rb.get_particle_index(), 10.0, 0.0)
458 
459  rb_mover_tr.set_name("RigidBody_Symmetry_Mover_Translate")
460  rb_mover_rt.set_name("RigidBody_Symmetry_Mover_Rotate")
461  print('Created rigid body symmetry restraint')
462  self.movers_particles_map[rb_mover_tr] = []
463  self.movers_particles_map[rb_mover_rt] = []
464  self.movers_rb_map[rb_mover_tr] = [rb]
465  self.movers_rb_map[rb_mover_rt] = [rb]
466  for h in hclones:
467  self.movers_particles_map[rb_mover_tr] \
468  += IMP.atom.get_leaves(h)
469  self.movers_particles_map[rb_mover_rt] \
470  += IMP.atom.get_leaves(h)
471  self.movers.append(rb_mover_tr) # probably need to store more info
472  self.movers.append(rb_mover_rt) # probably need to store more info
473  # dictionary relating rb to movers
474  self._rb2mov[rb] = [rb_mover_tr, rb_mover_rt]
475 
477  self.model,
478  [bead.get_particle().get_index()
479  for bead in clones_rbs+clones_beads])
480  c = IMP.container.SingletonsConstraint(sm, None, lsc)
481  self.model.add_score_state(c)
482  print('Created symmetry restraint for', len(ref_rbs),
483  'rigid bodies and', len(ref_beads), 'flexible beads')
484  self.model.update()
485 
486  def __repr__(self):
487  # would like something fancy like this:
488  # - super-rigid "SRB1"
489  # - rigid "Mol1" (8 rigid, 3 nonrigid)
490  # - rigid "Mol2" (8 rigid, 3 nonrigid)
491  # - rigid "Mol3" (8 rigid, 3 nonrigid)
492  return 'DegreesOfFreedom: ' + \
493  "\n".join(repr(m) for m in self.movers)
494 
495  def optimize_flexible_beads(self, nsteps, temperature=1.0):
496  '''Set up MC run with just flexible beads.
497  Optimization works much better when restraints
498  are already set up.'''
499  mvs = list(_get_floppy_body_movers(self.get_flexible_beads(), 1.0))
500  if mvs:
501  mc = IMP.pmi.samplers.MonteCarlo(self.model, mvs, temperature)
502  print("optimize_flexible_beads: optimizing %i flexible beads"
503  % len(self.get_flexible_beads()))
504  mc.optimize(nsteps)
505  else:
506  print("optimize_flexible_beads: no particle to optimize")
507 
508  def get_movers(self):
509  """Returns Enabled movers"""
510  if self.disabled_movers:
511  filtered_mover_list = []
512  for mv in self.movers:
513  if mv not in self.disabled_movers:
514  filtered_mover_list.append(mv)
515  return filtered_mover_list
516  else:
517  return self.movers
518 
520  """Return all movers corresponding to individual beads"""
521  return self.fb_movers
522 
523  def get_rigid_bodies(self):
524  """Return list of rigid body objects"""
525  return self.rigid_bodies
526 
528  "Return all flexible beads, including nonrigid members of rigid bodies"
529  return self.flexible_beads
530 
531  def disable_movers(self, objects, mover_types=None):
532  """Fix the position of the particles by disabling the corresponding
533  movers.
534  @param objects Can be one of the following inputs:
535  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a
536  list/set (of list/set) of them.
537  Must be uniform input, however. No mixing object types.
538  @param mover_types further filter the mover type that will be
539  disabled; it can be a list of IMP.core.RigidBodyMover,
540  IMP.core.BallMover etc etc if one wants to fix the corresponding
541  rigid body, or the floppy bodies.
542  An empty mover_types list is interpreted as all possible movers.
543  It returns the list of fixed xyz particles (ie, floppy bodies/beads)
544  and rigid bodies whose movers were disabled
545  """
546  hierarchies = IMP.pmi.tools.input_adaptor(objects,
547  pmi_resolution='all',
548  flatten=True)
549  tmp_set = set()
550  fixed_rb = set()
551  fixed_xyz = set()
552  if mover_types is None:
553  mover_types = []
554 
555  inv_map = {}
556  for mv, ps in self.movers_particles_map.items():
557  for p in ps:
558  if p in inv_map:
559  inv_map[p].append(mv)
560  else:
561  inv_map[p] = [mv]
562 
563  for h in hierarchies:
564  if h in inv_map:
565  for mv in inv_map[h]:
566  if (type(mv) in mover_types or not mover_types):
567  tmp_set.add(mv)
568  if mv in self.movers_rb_map:
569  fixed_rb |= set(self.movers_rb_map[mv])
570  if mv in self.movers_xyz_map:
571  fixed_xyz |= set(self.movers_xyz_map[mv])
572  print("Fixing %s movers" % (str(len(list(tmp_set)))))
573  self.disabled_movers += list(tmp_set)
574  return list(fixed_xyz), list(fixed_rb)
575 
576  def enable_all_movers(self):
577  """Re-enable all movers: previously fixed particles will be released"""
578  self.disabled_movers = []
579 
581  """Extract the nuisances from get_particles_to_sample()"""
582  try:
583  pslist = r.get_particles_to_sample()
584  except AttributeError:
585  raise Exception(
586  "dof.get_nuisances_from_restraint(): the passed object "
587  "does not have a get_particles_to_sample() function")
588  for name in pslist:
589  is_sampled = True
590  if len(pslist[name]) == 3:
591  ps, maxtrans, is_sampled = pslist[name]
592  else:
593  ps, maxtrans = pslist[name]
594  if is_sampled:
595  self.create_nuisance_mover(ps[0], maxtrans, name)
596 
597 
598 def _get_floppy_body_movers(fbs, maxtrans):
599  for fb in fbs:
600  # check is that is a rigid body member:
602  # if so force the particles to move anyway
603  floatkeys = \
605  for fk in floatkeys:
606  fb.set_is_optimized(fk, True)
607  yield IMP.core.BallMover(fb.get_model(), fb,
608  IMP.FloatKeys(floatkeys),
609  maxtrans)
610  else:
611  # otherwise use the normal ball mover
612  yield IMP.core.BallMover(fb.get_model(), fb, maxtrans)
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
Re-enable 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:749
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
static FloatKeys get_internal_coordinate_keys()
Definition: rigid_bodies.h:727
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 input_adaptor
Adapt things for PMI (degrees of freedom, restraints, ...) Returns list of list of hierarchies...
Definition: tools.py:872
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.
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:23
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:46
The general base class for IMP exceptions.
Definition: exception.h:48
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:352
Class to handle individual particles of a Model object.
Definition: Particle.h:43
def constrain_symmetry
Create a symmetry constraint.
static void teardown_particle(CenterOfMass com)
Make the particle no longer a center of mass.
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.
def get_rbs_and_beads
Returns unique objects in original order.
Definition: tools.py:1135
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:180
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: rigid_bodies.h:770
Warning for probably incorrect input parameters.
def sublist_iterator
Yield all sublists of length >= lmin and <= lmax.
Definition: tools.py:574