IMP  2.1.0
The Integrative Modeling Platform
_restraint.py
1 """Interface between XML Restraint and IMP.kernel.Restraint."""
2 
3 import IMP.core
4 import IMP.em
5 import IMP.saxs
6 import IMP.restrainer
7 
8 class _RestraintSets(object):
9  def __init__(self):
10  self._restraint_sets = dict()
11  self.set_by_restraint = dict()
12  self.set_by_name = dict()
13  def add(self, restraint_type, weight, name, restraint, model = None):
14  if restraint_type is None:
15  return
16  weight = str(weight)
17  restraint_type = '%s|%s' % (restraint_type, name)
18  try:
19  set_by_weight = self._restraint_sets[weight]
20  except KeyError:
21  set_by_weight = self._restraint_sets[weight] = dict()
22  try:
23  current_set = set_by_weight[restraint_type]
24  except KeyError:
25  current_set = set_by_weight[restraint_type] = IMP.kernel.RestraintSet()
26  if model:
27  model.add_restraint(current_set)
28  current_set.add_restraint(restraint)
29  self.set_by_restraint[restraint] = current_set
30  self.set_by_name[name] = current_set
31  def set_model(self, model):
32  for weight, set_by_weight in self._restraint_sets.iteritems():
33  for rest_set in set_by_weight.itervalues():
34  model.add_restraint(rest_set)
35  rest_set.set_weight(float(weight))
36  def remove_restraint(self, restraint):
37  try:
38  current_set = self.set_by_restraint[restraint]
39  except KeyError:
40  return
41  current_set.remove_restraint(restraint)
42  del self.set_by_restraint[restraint]
43  def get_weight(self, restraint):
44  try:
45  current_set = self.set_by_restraint[restraint]
46  except KeyError:
47  return 1.0
48  return current_set.get_weight()
49  def remove_all(self, model):
50  for set_by_weight in self._restraint_sets.itervalues():
51  for rest_set in set_by_weight.itervalues():
52  model.remove_restraint(rest_set)
53  self._restraint_sets.clear()
54 
55 class Restraint(object):
56  """Store Restraint"""
57  def __init__(self):
58  """"""
59  self._children = list()
60  self._restraint_sets = _RestraintSets()
61 
62  def add_to_representation(self, repr):
63  """ Place restraint into IMP Model."""
64 
65  if repr._model is None:
66  repr.get_model()
67  self._set_root()
68  self._model = repr._model
69  for child in self._children:
70  child.create_restraint(repr)
71  self.set_include(include=True)
72  self.add_to_model()
73 
74  def add_to_model(self):
75  self._restraint_sets.remove_all(self._model)
76  for child in self._children:
77  child.include_restraint(self._restraint_sets)
78  self._restraint_sets.set_model(self._model)
79 
80  def set_include(self, name=None, include=False, weight=-1.0):
81 
82  def set_include_rec(node):
83  for child in node._children:
84  set_include_rec(child)
85  node.include_me = include
86  if weight >= 0:
87  node.weight = weight
88 
89  if not name:
90  for child in self._children:
91  set_include_rec(child)
92  return
93  r = self.get_restraint_by_name(name)
94  if r:
95  if weight >= 0:
96  r.weight = weight
97  r.include_me = include
98 
99  def clear(self):
100 
101  def clear_rec(node):
102  node.include_me = False
103  for child in node._children:
104  clear_rec(child)
105 
106  for child in self._children:
107  clear_rec(child)
108  self._restraint_sets.remove_all(self._model)
109 
110 
111  def show_all_restraints(self):
112  """Show restraint name, initial weight, and score for the current state of the model"""
113 
114  def find_rec(node):
115  if node.imp_restraint is not None:
116  print "=== ", node.name, " ==="
117  print "Restraint initial weight = ", node.root._restraint_sets.get_weight(node.imp_restraint)
118  node.imp_restraint.evaluate(False)
119  found.append(node)
120  for child in node._children:
121  find_rec(child)
122 
123  found = list()
124  for child in self._children:
125  find_rec(child)
126  return found
127 
128 
129  def get_all_restraints_by_name(self, name):
130  """Assuming there are many restraint objects with the same name."""
131 
132  def find_rec(node):
133  if node.name == name:
134  found.append(node)
135  for child in node._children:
136  find_rec(child)
137 
138  found = list()
139  for child in self._children:
140  find_rec(child)
141  return found
142 
143  def get_restraint_by_name(self, name):
144  """Assuming there is just one restraint object with the same name."""
145 
146  def find_rec(node):
147  if node.name == name:
148  return node
149  for child in node._children:
150  r = find_rec(child)
151  if r:
152  return r
153  return None
154 
155  for child in self._children:
156  r = find_rec(child)
157  if r:
158  return r
159  return None
160 
161  def get_restraint_set_by_name(self, name):
162  """Get an IMP::RestraintSet by name specified in restraint XML file."""
163  return self._restraint_sets.set_by_name.get(name)
164 
165  def get_rigid_body_by_id(self, id):
166  """Get rigid body by particle id."""
167 
168  def find_rec(node):
169  if node.id == id:
170  return node.rigid_body
171  for child in node._children:
172  r = find_rec(child)
173  if r:
174  return r
175  return None
176 
177  for child in self._children:
178  r = find_rec(child)
179  if r:
180  return r
181  return None
182 
183 
184  def get_all_rigid_bodies(self):
185  """Get all rigid bodies."""
186 
187  def find_rec(node):
188  if node.rigid_body:
189  all_bodies.append(node.rigid_body)
190  for child in node._children:
191  find_rec(child)
192 
193  all_bodies = list()
194  for child in self._children:
195  find_rec(child)
196  return all_bodies
197 
198 
199  def _set_root(self):
200 
201  def set_root_rec(node):
202  node.root = self
203  for child in node._children:
204  set_root_rec(child)
205 
206  for child in self._children:
207  set_root_rec(child)
208 
209 
210 class _RestraintNode(object):
211  counter = 0
212 
213  def __init__(self, attributes, restraint_type=None):
214  self.imp_restraint = None
215  self.rigid_body = None
216  self.id = None
217  name = attributes.get('name')
218  if name:
219  self.name = name
220  else:
221  self.name = 'object_%d' % _RestraintNode.counter
222  _RestraintNode.counter += 1
223  self._children = list()
224  self.child_restraints = list()
225  self.restraint_type = restraint_type
226  self.include_me = False
227  self.repr_particle = None
228 
229  def get_particle(self):
230  particle_list = list()
231  for child in self._children:
232  if isinstance(child, _RestraintParticle):
233  particle_list.append(child)
234  return particle_list
235 
236  def get_source(self):
237  source_list = list()
238  for child in self._children:
239  counter = 0
240  if isinstance(child, _RestraintSource):
241  source_list.append(child)
242  source_list[counter].author_list = child.get_author()
243  source_list[counter].journal = child.get_journal()
244  source_list[counter].title = child.get_title()
245  source_list[counter].year = child.get_year()
246  counter += 1
247  return source_list
248 
249  def append_restraint_with_weight(self, restraint, restraint_sets):
250  if restraint:
251  self.child_restraints.append(restraint)
252  if self.restraint_type:
253  restraint_sets.add(self.restraint_type, self.weight, self.name, restraint)
254 
255  def create_restraint(self, repr):
256  self.child_restraints = list()
257  for child in self._children:
258  restraint = child.create_restraint(repr)
259  if restraint:
260  self.child_restraints.append(restraint)
261 
262  def include_restraint(self, restraint_sets):
263  if self.restraint_type and self.include_me:
264  for child in self.child_restraints:
265  restraint_sets.add(self.restraint_type, self.weight, self.name,
266  child)
267  for child in self._children:
268  child.include_restraint(restraint_sets)
269 
270 
271 class _RestraintNodeWithWeight(_RestraintNode):
272  def __init__(self, attributes, type):
273  _RestraintNode.__init__(self, attributes, type)
274  self.weight = float(attributes.get('weight', 1))
275 
276 
277 class _RigidBodyRestraintNode(_RestraintNodeWithWeight):
278  def __init__(self, attributes):
279  _RestraintNodeWithWeight.__init__(self, attributes, 'RigidBody')
280 
281  def create_restraint(self, repr):
282  for child in self._children:
283  restraint = child.create_rigid_body_restraint(repr)
284 
285 
286 class _ExcludedVolumeRestraintNode(_RestraintNodeWithWeight):
287  def __init__(self, attributes, restraint_type):
288  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
289 
290  def create_restraint(self, repr):
291  self.child_restraints = list()
292  for child in self._children:
293  restraint = child.create_excluded_volume_restraint(repr)
294  #self.append_restraint_with_weight(restraint, restraint_sets)
295  if restraint:
296  self.child_restraints.append(restraint)
297 
298 
299 class _ConnectivityRestraintNode(_RestraintNodeWithWeight):
300  def __init__(self, attributes, restraint_type):
301  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
302 
303  def create_restraint(self, repr):
304  self.child_restraints = list()
305  for child in self._children:
306  restraint = child.create_connectivity_restraint(repr)
307  #self.append_restraint_with_weight(restraint, restraint_sets)
308  if restraint:
309  self.child_restraints.append(restraint)
310 
311 
312 class _CrosslinkRestraintNode(_RestraintNodeWithWeight):
313  def __init__(self, attributes, restraint_type):
314  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
315 
316  def create_restraint(self, repr):
317  self.child_restraints = list()
318  for child in self._children:
319  restraint = child.create_crosslink_restraint(repr)
320  #self.append_restraint_with_weight(restraint, restraint_sets)
321  if restraint:
322  self.child_restraints.append(restraint)
323 
324 
325 class _DistanceRestraintNode(_RestraintNodeWithWeight):
326  def __init__(self, attributes, restraint_type):
327  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
328 
329  def create_restraint(self, repr):
330  self.child_restraints = list()
331  for child in self._children:
332  restraint = child.create_distance_restraint(repr)
333  #self.append_restraint_with_weight(restraint, restraint_sets)
334  if restraint:
335  self.child_restraints.append(restraint)
336 
337 
338 class _DiameterRestraintNode(_RestraintNodeWithWeight):
339  def __init__(self, attributes, restraint_type):
340  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
341 
342  def create_restraint(self, repr):
343  self.child_restraints = list()
344  for child in self._children:
345  restraint = child.create_diameter_restraint(repr)
346  #self.append_restraint_with_weight(restraint)
347  if restraint:
348  self.child_restraints.append(restraint)
349 
350 
351 class _SAXSRestraintNode(_RestraintNodeWithWeight):
352  def __init__(self, attributes, restraint_type):
353  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
354 
355  def create_restraint(self, repr):
356  self.child_restraints = list()
357  for child in self._children:
358  restraint = child.create_saxs_restraint(repr)
359  #self.append_restraint_with_weight(restraint, restraint_sets)
360  if restraint:
361  self.child_restraints.append(restraint)
362 
363 
364 class _SANSRestraintNode(_RestraintNodeWithWeight):
365  def __init__(self, attributes, restraint_type):
366  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
367 
368  def create_restraint(self, repr):
369  self.child_restraints = list()
370 
371 class _EMRestraintNode(_RestraintNodeWithWeight):
372  def __init__(self, attributes, restraint_type):
373  _RestraintNodeWithWeight.__init__(self, attributes, restraint_type)
374 
375  def create_restraint(self, repr):
376  self.child_restraints = list()
377  for child in self._children:
378  restraint = child.create_em_restraint(repr)
379  #self.append_restraint_with_weight(restraint)
380  if restraint:
381  self.child_restraints.append(restraint)
382 
383 
384 class _RestraintY2H(_ConnectivityRestraintNode):
385  def __init__(self, attributes):
386  _ConnectivityRestraintNode.__init__(self, attributes, "Y2H")
387 
388 class _RestraintExcludedVolume(_ExcludedVolumeRestraintNode):
389  def __init__(self, attributes):
390  _ExcludedVolumeRestraintNode.__init__(self, attributes, "ExcludedVolume")
391 
392 class _RestraintPulldown(_ConnectivityRestraintNode):
393  def __init__(self, attributes):
394  _ConnectivityRestraintNode.__init__(self, attributes, "Pulldown")
395 
396 class _RestraintXrayStruc(_ConnectivityRestraintNode):
397  def __init__(self, attributes):
398  _ConnectivityRestraintNode.__init__(self, attributes, "XrayStruc")
399 
400 class _RestraintMSMS(_ConnectivityRestraintNode):
401  def __init__(self, attributes):
402  _ConnectivityRestraintNode.__init__(self, attributes, "MSMS")
403 
404 class _RestraintArray(_ConnectivityRestraintNode):
405  def __init__(self, attributes):
406  _ConnectivityRestraintNode.__init__(self, attributes, "Array")
407 
408 class _RestraintCopurification(_ConnectivityRestraintNode):
409  def __init__(self, attributes):
410  _ConnectivityRestraintNode.__init__(self, attributes, "Copurification")
411 
412 class _RestraintCrossLink(_CrosslinkRestraintNode):
413  def __init__(self, attributes):
414  _CrosslinkRestraintNode.__init__(self, attributes, "CrossLink")
415 
416 class _RestraintDistance(_DistanceRestraintNode):
417  def __init__(self, attributes):
418  _DistanceRestraintNode.__init__(self, attributes, "Distance")
419 
420 class _RestraintDiameter(_DiameterRestraintNode):
421  def __init__(self, attributes):
422  _DiameterRestraintNode.__init__(self, attributes, "Diameter")
423 
424 class _RestraintSAXS(_SAXSRestraintNode):
425  def __init__(self, attributes):
426  _SAXSRestraintNode.__init__(self, attributes, "SAXS")
427 
428 class _RestraintSANS(_SANSRestraintNode):
429  def __init__(self, attributes):
430  _SANSRestraintNode.__init__(self, attributes, "SANS")
431 
432 class _RestraintEM(_EMRestraintNode):
433  def __init__(self, attributes):
434  _EMRestraintNode.__init__(self, attributes, "EM")
435 
436 class _RestraintRestraint(_RestraintNode):
437  def __init__(self, attributes):
438  _RestraintNode.__init__(self, attributes)
439  self.imp_restraint = None
440  self.std_dev = float(attributes.get('std_dev', 1))
441  self.distance = float(attributes.get('distance', 0))
442  self.max_diameter = float(attributes.get('max_diameter', -1))
443  self.profile_filename = attributes.get('profile_filename', '')
444  self.density_filename = attributes.get('density_filename', '')
445  self.resolution = float(attributes.get('resolution', -1))
446  self.spacing = float(attributes.get('spacing', -1))
447  self.xorigin = float(attributes.get('xorigin', 0.0))
448  self.yorigin = float(attributes.get('yorigin', 0.0))
449  self.zorigin = float(attributes.get('zorigin', 0.0))
450  self.linker_length = float(attributes.get('linker_length', -1))
451 
452  def include_restraint(self, restraint_sets):
453  pass
454 
455  def get_weight(self):
456  return self.root._restraint_sets.get_weight(self.imp_restraint)
457 
458  def create_rigid_body_restraint(self, repr):
459  _RestraintNode.create_restraint(self, repr)
460  self.rigid_bodies = list()
461  for child, child_r in zip(self._children, self.child_restraints):
462  if child.repr_particle:
463  child.repr_particle.force_field = 0
464  mhs = IMP.atom.Hierarchies()
465  mhs.append(child_r)
467  self.rigid_bodies.append(rb[0])
468  child.rigid_body = rb[0]
469  return None
470 
471  def create_force(self):
472  for child in self._children:
473  repr = child.repr_particle
474  print 'repr = ',repr
475  if repr:
476  print 'repr.force_field=', repr.force_field
477  if repr and repr.force_field == 1:
478  print 'Use the force.'
479  hierarchy = repr.model_decorator
480  if not hierarchy:
481  continue
482  repr.force_field = 0
483  print 'hierarchy present'
484  id = repr.id
485  m = self.root._model
486  ff = IMP.atom.CHARMMParameters(repr.topology_file, repr.param_file)
487  topology = ff.create_topology(hierarchy)
488  topology.apply_default_patches(ff)
489  #topology.add_atom_types(hierarchy)
490  bonds = topology.add_bonds(hierarchy, ff)
491  angles = ff.create_angles(bonds)
492  dihedrals = ff.create_dihedrals(bonds)
493  impropers = topology.add_impropers(hierarchy, ff)
494  cont = IMP.container.ListSingletonContainer(bonds, "bonds_%s" % id)
496  m.add_restraint(IMP.container.SingletonsRestraint(bss, cont))
497  cont = IMP.container.ListSingletonContainer(angles, "angles_%s" % id)
499  m.add_restraint(IMP.container.SingletonsRestraint(bss, cont))
500  cont = IMP.container.ListSingletonContainer(dihedrals, "dihedrals_%s" % id)
502  m.add_restraint(IMP.container.SingletonsRestraint(bss, cont))
503  cont = IMP.container.ListSingletonContainer(impropers, "impropers_%s" % id)
505  m.add_restraint(IMP.container.SingletonsRestraint(bss, cont))
506  #ff.add_radii(hierarchy)
507  ff.add_well_depths(hierarchy)
508  atoms = IMP.atom.get_by_type(hierarchy, IMP.atom.ATOM_TYPE)
510  nbl = IMP.container.ClosePairContainer(cont, 4.0)
511  pair_filter = IMP.atom.StereochemistryPairFilter()
512  pair_filter.set_bonds(bonds)
513  pair_filter.set_angles(angles)
514  pair_filter.set_dihedrals(dihedrals)
515  nbl.add_pair_filter(pair_filter)
516  sf = IMP.atom.ForceSwitch(6.0, 7.0)
518  m.add_restraint(IMP.container.PairsRestraint(ps, nbl))
519 
520 
521  def create_connectivity_restraint(self, repr):
522  _RestraintNode.create_restraint(self, repr)
523  self.create_force()
524  if self.std_dev > 0:
525  k = 1.0/(2.0*self.std_dev*self.std_dev)
526  else:
527  k = 1.0
528  mhs = IMP.atom.Hierarchies()
529  if not self.child_restraints:
530  raise Exception, "Restraint %s is empty" % self.id
531  for child in self.child_restraints:
532  mhs.append(child)
533  first_particle = self.child_restraints[0].get_particle()
534  if IMP.core.RigidBody.get_is_setup(first_particle):
535  rbs_tmp = []
536  for mh in mhs:
537  rbs_tmp.append(mh.get_particle())
538  rbs = IMP.core.RigidBodies(rbs_tmp)
541  else:
543  self.sc.set_k(k)
544  connectivity_restraint = self.sc.get_restraint()
545  self.imp_restraint = connectivity_restraint
546  return connectivity_restraint
547 
548  def create_excluded_volume_restraint(self, repr):
549  _RestraintNode.create_restraint(self, repr)
550  self.create_force()
551  mhs = IMP.atom.Hierarchies()
552  if not self.child_restraints:
553  raise Exception, "Restraint %s is empty" % self.id
554  for child in self.child_restraints:
555  mhs.append(child)
556  first_particle = self.child_restraints[0].get_particle()
557  if IMP.core.RigidBody.get_is_setup(first_particle):
558  rbs_tmp = []
559  for mh in mhs:
560  rbs_tmp.append(mh.get_particle())
561  rbs = IMP.core.RigidBodies(rbs_tmp)
563  else:
565  ev_restraint = self.sev.get_restraint()
566  self.imp_restraint = ev_restraint
567  return ev_restraint
568 
569  def create_saxs_restraint(self, repr):
570  _RestraintNode.create_restraint(self, repr)
571  self.create_force()
572  if self.profile_filename:
573  self.exp_profile = IMP.saxs.Profile(self.profile_filename)
574  particles = IMP.atom.Hierarchies()
575  for child in self.child_restraints:
576  for atoms in IMP.atom.get_by_type(child, IMP.atom.ATOM_TYPE):
577  particles.append(atoms)
578  if particles:
579  self.saxs_restraint = IMP.saxs.Restraint(particles, self.exp_profile)
580  self.imp_restraint = self.saxs_restraint
581  return self.saxs_restraint
582 
583  def create_em_restraint(self, repr):
584  _RestraintNode.create_restraint(self, repr)
585  self.create_force()
586  if self.density_filename:
587  mhs = IMP.atom.Hierarchies()
588  self.dmap = IMP.restrainer.load_em_density_map(self.density_filename,
589  self.spacing, self.resolution)
590  self.dmap_header = self.dmap.get_header_writable()
591 
592  self.dmap.set_origin (self.xorigin, self.yorigin, self.zorigin)
593  self.dmap.update_voxel_size(self.spacing)
594  self.dmap_header.set_resolution (self.resolution)
595 
596  for child in self.child_restraints:
597  mhs.append(child)
598  if mhs:
599  self.sef = IMP.restrainer.create_simple_em_fit(mhs, self.dmap)
600  em_restraint = self.sef.get_restraint()
601  self.imp_restraint = em_restraint
602  return em_restraint
603 
604  def create_crosslink_restraint(self, repr):
605  _RestraintNode.create_restraint(self, repr)
606  self.create_force()
607 
608  def create_distance_restraint(self, repr):
609  _RestraintNode.create_restraint(self, repr)
610  self.create_force()
611  if self.std_dev > 0:
612  k = 1.0/(2.0*self.std_dev*self.std_dev)
613  else:
614  k = 1.0
615  h = IMP.core.Harmonic(self.distance, k)
616  self.imp_restraint = IMP.core.DistanceRestraint(h, self.child_restraints[0],
617  self.child_restraints[1])
618  return self.imp_restraint
619 
620  def create_diameter_restraint(self, repr):
621  _RestraintNode.create_restraint(self, repr)
622  self.create_force()
623  ps = []
624  for child in self.child_restraints:
625  ps.append(child.get_particle())
626  self.diameter_restraint = IMP.restrainer.create_simple_diameter(
627  ps, self.max_diameter)
628  self.imp_restraint = self.diameter_restraint.get_restraint()
629  return self.imp_restraint
630 
631 class _RestraintSource(_RestraintNode):
632  def __init__(self, attributes):
633  _RestraintNode.__init__(self, attributes)
634  self.pubmed_id = int(attributes.get('pubmed_id', -1))
635 
636  self.__author_list = list()
637  self.__journal = None
638  self.__title = None
639  self.__year = None
640 
641  def get_author(self):
642  if not self.__author_list:
643  for child in self._children:
644  if isinstance(child, _RestraintAuthor):
645  self.__author_list.append(child)
646  break
647  return self.__author_list
648 
649  def get_journal(self):
650  if self.__journal is None:
651  for child in self._children:
652  if isinstance(child, _RestraintJournal):
653  self.__journal = child.text
654  break
655  return self.__journal
656 
657  def get_title(self):
658  if self.__title is None:
659  for child in self._children:
660  if isinstance(child, _RestraintTitle):
661  self.__title = child.text
662  break
663  return self.__title
664 
665  def get_year(self):
666  if self.__year is None:
667  for child in self._children:
668  if isinstance(child, _RestraintYear):
669  self.__year = child.text
670  break
671  return self.__year
672 
673 class _RestraintAuthor(_RestraintNode):
674  def __init__(self, attributes):
675  _RestraintNode.__init__(self, attributes)
676  self.first_name = attributes.get('first_name', '')
677  self.last_name = attributes.get('last_name', '')
678 
679 class _RestraintJournal(_RestraintNode):
680  def __init__(self, attributes, text):
681  _RestraintNode.__init__(self, attributes)
682  self.text = text
683 
684 class _RestraintTitle(_RestraintNode):
685  def __init__(self, attributes, text):
686  _RestraintNode.__init__(self, attributes)
687  self.text = text
688 
689 class _RestraintYear(_RestraintNode):
690  def __init__(self, attributes, text):
691  _RestraintNode.__init__(self, attributes)
692  self.text = text
693 
694 class _RestraintParticle(_RestraintNode):
695  def __init__(self, attributes):
696  _RestraintNode.__init__(self, attributes)
697  self.id = attributes.get('id', '')
698  self.residue = attributes.get('residue', '')
699  self.atom = attributes.get('atom', '')
700 
701  def create_restraint(self, repr):
702  self.repr_particle = self.find_representation(repr)
703  if not self.repr_particle:
704  raise Exception, "Particle with id=%s not found" % (self.id)
705  decorator = self.repr_particle.model_decorator
706  if self.residue:
707  decorator = IMP.atom.get_residue(decorator, int(self.residue))
708  if self.atom:
709  decorator = IMP.atom.Residue(decorator.get_particle())
710  atom_type = IMP.atom.AtomType(self.atom)
711  decorator = IMP.atom.get_atom(decorator, atom_type)
712  return decorator
713 
714  def find_representation(self, repr):
715  return repr.find_by_id(self.id)
Applies a SingletonScore to each Singleton in a list.
SimpleDiameter create_simple_diameter(const kernel::Particles &ps, Float diameter)
Score the angle based on a UnaryFunction,.
Return the hierarchy leaves under a particle.
Definition: LeavesRefiner.h:25
SimpleEMFit create_simple_em_fit(atom::Hierarchy const &mh, em::DensityMap *dmap)
Creates EM FitRestraint.
See IMP.restrainer for more information.
Calculate score based on fit to SAXS profile.
Object used to hold a set of restraints.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
Definition: rigid_bodies.h:124
The type of an atom.
Hierarchy get_residue(Hierarchy mhd, unsigned int index)
Get the residue with the specified index.
kernel::Restraint * create_distance_restraint(const Selection &n0, const Selection &n1, double x0, double k, std::string name="Distance%1%")
Return all close unordered pairs of particles taken from the SingletonContainer.
Atom get_atom(Residue rd, AtomType at)
Return a particle atom from the residue.
Distance restraint between two particles.
CHARMM force field parameters.
kernel::Restraint * create_connectivity_restraint(const Selections &s, double k, std::string name="Connectivity%1%")
SimpleExcludedVolume create_simple_excluded_volume_on_molecules(const atom::Hierarchies &mhs)
Lennard-Jones score between a pair of particles.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Score the improper dihedral based on a UnaryFunction,.
SimpleConnectivity create_simple_connectivity_on_rigid_bodies(const core::RigidBodies &rbs, Refiner *ref=IMP::core::internal::get_rigid_members_refiner())
SimpleConnectivity create_simple_connectivity_on_molecules(const atom::Hierarchies &mhs)
See IMP.em for more information.
Definition: CoarseCC.h:23
Score the bond based on a UnaryFunction,.
static const IMP::core::HierarchyTraits & get_traits()
Get the molecular hierarchy HierararchyTraits.
A decorator for a residue.
Definition: Residue.h:133
See IMP.core for more information.
core::RigidBodies set_rigid_bodies(atom::Hierarchies const &mhs)
kernel::Restraint * create_excluded_volume_restraint(const Hierarchies &hs, double resolution=-1)
A filter that excludes bonds, angles and dihedrals.
em::DensityMap * load_em_density_map(char const *map_fn, float spacing, float resolution)
SimpleExcludedVolume create_simple_excluded_volume_on_rigid_bodies(const core::RigidBodies &rbs, Refiner *ref=IMP::core::internal::get_rigid_members_refiner())
Smooth interaction scores by switching the derivatives (force switch).
IMP::kernel::Restraint Restraint
Applies a PairScore to each Pair in a list.
kernel::Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())
See IMP.saxs for more information.
Definition: ChiFreeScore.h:14
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:25