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