IMP logo
IMP Reference Guide  2.5.0
The Integrative Modeling Platform
sampling_tools.py
1 """@namespace IMP.pmi.sampling_tools
2  Useful tools for setting up sampling"""
3 
4 import IMP
5 import IMP.atom
6 
7 class SampleObjects(object):
8  """Hack class to provide things to sample for PMI::samplers """
9  def __init__(self,dict_name,pack_in_dict):
10  self.d={dict_name:pack_in_dict}
11  def get_particles_to_sample(self):
12  return self.d
13 
14 def create_floppy_bodies(particles,max_step):
15  for p in particles:
16  IMP.core.XYZ(p).set_coordinates_are_optimized(True)
17  return [SampleObjects('Floppy_Bodies_SimplifiedModel',[particles,max_step])]
18 
20  hier=None,
21  particles=None,
22  hierarchies=None,
23  include_siblings=False,
24  exclude_backbone=False):
25  """Add necessary attributes to the selected residues for MD sampling.
26  @param mdl The IMP model
27  @param hier Hierarchy to sample
28  @param particles Particles to sample
29  @param include_siblings Get the siblings of the passed particles and sample them too
30  @param exclude_backbone Don't sample backbone atoms
31  """
32  vxkey = IMP.FloatKey('vx')
33  vykey = IMP.FloatKey('vy')
34  vzkey = IMP.FloatKey('vz')
35  backbone = [IMP.atom.AT_C,IMP.atom.AT_N, IMP.atom.AT_CA]
36  if particles is None:
37  particles=[]
38  if hier is not None:
39  particles+=IMP.atom.get_leaves(hier)
40  if hierarchies is not None:
41  particles+=[h.get_particle() for h in hierarchies]
42  all_ps=[]
43  for p in particles:
44  if include_siblings:
45  ps=[x.get_particle() for x in IMP.atom.Hierarchy(p).get_parent().get_children()]
46  else:
47  ps=[p]
48  for pp in ps:
49  if exclude_backbone and IMP.atom.Atom(mdl,pp.get_index()).get_atom_type() in backbone:
50  continue
51  IMP.core.XYZ(mdl,pp.get_index()).set_coordinates_are_optimized(True)
52  mdl.add_attribute(vxkey,pp.get_index(),0.0)
53  mdl.add_attribute(vykey,pp.get_index(),0.0)
54  mdl.add_attribute(vzkey,pp.get_index(),0.0)
55  all_ps.append(pp)
56  return [SampleObjects('Floppy_Bodies_SimplifiedModel',[all_ps])]
Hack class to provide things to sample for PMI::samplers.
def enable_md_sampling
Add necessary attributes to the selected residues for MD sampling.
The standard decorator for manipulating molecular structures.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchies get_leaves(const Selection &h)