IMP logo
IMP Reference Guide  2.14.0
The Integrative Modeling Platform
restraints/stereochemistry.py
1 """@namespace IMP.pmi.restraints.stereochemistry
2 Restraints for keeping correct stereochemistry.
3 """
4 
5 from __future__ import print_function
6 import IMP
7 import IMP.core
8 import IMP.atom
9 import IMP.container
10 import IMP.isd
11 import IMP.pmi.tools
12 from operator import itemgetter
13 from math import pi,log,sqrt
14 
15 
16 class ConnectivityRestraint(object):
17  """Create a restraint between consecutive TempResidue objects
18  or an entire PMI Molecule object."""
19 
20  def __init__(self,
21  objects,
22  scale=1.0,
23  disorderedlength=False,
24  upperharmonic=True,
25  resolution=1,
26  label="None"):
27  """
28  @param objects - a list of hierarchies, PMI TempResidues OR a single Molecule
29  @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
30  The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
31  @param disorderedlength - This flag uses either disordered length
32  calculated for random coil peptides (True) or zero
33  surface-to-surface distance between beads (False)
34  as optimal distance for the sequence connectivity
35  restraint.
36  @param upperharmonic - This flag uses either harmonic (False)
37  or upperharmonic (True) in the intra-pair
38  connectivity restraint.
39  @param resolution - The resolution to connect things at - only used if you pass PMI objects
40  @param label - A string to identify this restraint in the output/stat file
41  """
42  self.label = label
43  self.weight = 1.0
44 
45  hiers = IMP.pmi.tools.input_adaptor(objects,resolution)
46  if len(hiers)>1:
47  raise Exception("ConnectivityRestraint: only pass stuff from one Molecule, please")
48  hiers = hiers[0]
49 
50  self.kappa = 10 # spring constant used for the harmonic restraints
51  self.m = list(hiers)[0].get_model()
52  SortedSegments = []
53  self.rs = IMP.RestraintSet(self.m, "connectivity_restraint")
54  for h in hiers:
55  try:
56  start = IMP.atom.Hierarchy(h).get_children()[0]
57  except:
58  start = IMP.atom.Hierarchy(h)
59 
60  try:
61  end = IMP.atom.Hierarchy(h).get_children()[-1]
62  except:
63  end = IMP.atom.Hierarchy(h)
64 
65  startres = IMP.pmi.tools.get_residue_indexes(start)[0]
66  endres = IMP.pmi.tools.get_residue_indexes(end)[-1]
67  SortedSegments.append((start, end, startres))
68  SortedSegments = sorted(SortedSegments, key=itemgetter(2))
69 
70  # connect the particles
71  self.particle_pairs=[]
72  for x in range(len(SortedSegments) - 1):
73 
74  last = SortedSegments[x][1]
75  first = SortedSegments[x + 1][0]
76 
77  apply_restraint = True
78 
79  # Apply connectivity runless ALL of the following are true:
80  # - first and last both have RigidBodyMember decorators
81  # - first and last are both RigidMembers
82  # - first and last are part of the same RigidBody object
83 
84  # Check for both in a rigid body
87 
88  #Check if the rigid body objects for each particle are the same object.
89  # if so, skip connectivity restraint
90  if IMP.core.RigidBodyMember(first).get_rigid_body() == IMP.core.RigidBodyMember(last).get_rigid_body():
91  apply_restraint = False
92 
93  if apply_restraint:
94 
95  nreslast = len(IMP.pmi.tools.get_residue_indexes(last))
96  lastresn = IMP.pmi.tools.get_residue_indexes(last)[-1]
97  nresfirst = len(IMP.pmi.tools.get_residue_indexes(first))
98  firstresn = IMP.pmi.tools.get_residue_indexes(first)[0]
99 
100  residuegap = firstresn - lastresn - 1
101  if disorderedlength and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
102  # calculate the distance between the sphere centers using Kohn
103  # PNAS 2004
104  optdist = sqrt(5 / 3) * 1.93 * \
105  (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
106  # optdist2=sqrt(5/3)*1.93*((nreslast)**0.6+(nresfirst)**0.6)/2
107  if upperharmonic:
108  hu = IMP.core.HarmonicUpperBound(optdist, self.kappa)
109  else:
110  hu = IMP.core.Harmonic(optdist, self.kappa)
112  else: # default
113  optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
114  if upperharmonic: # default
115  hu = IMP.core.HarmonicUpperBound(optdist, self.kappa)
116  else:
117  hu = IMP.core.Harmonic(optdist, self.kappa)
119 
120  pt0 = last.get_particle()
121  pt1 = first.get_particle()
122  self.particle_pairs.append((pt0,pt1))
123  r = IMP.core.PairRestraint(self.m, dps, (pt0.get_index(), pt1.get_index()))
124 
125  print("Adding sequence connectivity restraint between", pt0.get_name(), " and ", pt1.get_name(), 'of distance', optdist)
126  self.rs.add_restraint(r)
127 
128  def set_label(self, label):
129  self.label = label
130 
131  def get_weight(self):
132  return self.weight
133 
134  def add_to_model(self):
135  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
136 
137  def get_restraint(self):
138  return self.rs
139 
140  def set_weight(self, weight):
141  self.weight = weight
142  self.rs.set_weight(weight)
143 
144  def get_output(self):
145  output = {}
146  score = self.weight * self.rs.unprotected_evaluate(None)
147  output["_TotalScore"] = str(score)
148  output["ConnectivityRestraint_" + self.label] = str(score)
149  return output
150 
152  """ Returns number of connectivity restraints """
153  return len(self.rs.get_restraints())
154 
156  """ Returns the list of connected particles pairs """
157  return self.particle_pairs
158 
159  def evaluate(self):
160  return self.weight * self.rs.unprotected_evaluate(None)
161 
162 class ExcludedVolumeSphere(object):
163  """A class to create an excluded volume restraint for a set of particles at a given resolution.
164  Can be initialized as a bipartite restraint between two sets of particles.
165  # Potential additional function: Variable resolution for each PMI object. Perhaps passing selection_tuples
166  with (PMI_object, resolution)
167  """
168 
169  def __init__(self,
170  included_objects,
171  other_objects=None,
172  resolution=1000,
173  kappa=1.0):
174  """Constructor.
175  @param included_objects Can be one of the following inputs:
176  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
177  @param other_objects Initializes a bipartite restraint between included_objects and other_objects
178  Same format as included_objects
179  @param resolution The resolution particles at which to impose the restraint.
180  By default, the coarsest particles will be chosen.
181  If a number is chosen, for each particle, the closest
182  resolution will be used (see IMP.atom.Selection).
183  @param kappa Restraint strength
184  """
185 
186  self.weight = 1.0
187  self.kappa = kappa
188  self.label = "None"
189  self.cpc = None
190  bipartite = False
191 
192  # gather IMP hierarchies from input objects
193  hierarchies = IMP.pmi.tools.input_adaptor(included_objects,
194  resolution,
195  flatten=True)
196  included_ps = []
197  if other_objects is not None:
198  bipartite = True
199  other_hierarchies = IMP.pmi.tools.input_adaptor(other_objects,
200  resolution,
201  flatten=True)
202  other_ps = []
203 
204  # perform selection
205  if hierarchies is None:
206  raise Exception("Must at least pass included objects")
207  self.mdl = hierarchies[0].get_model()
208  included_ps = [h.get_particle() for h in hierarchies]
209  if bipartite:
210  other_ps = [h.get_particle() for h in other_hierarchies]
211 
212  # setup score
213  self.rs = IMP.RestraintSet(self.mdl, 'excluded_volume')
214  ssps = IMP.core.SoftSpherePairScore(self.kappa)
216  lsa.add(IMP.get_indexes(included_ps))
217 
218  # setup close pair container
219  if not bipartite:
221  self.cpc = IMP.container.ClosePairContainer(lsa, 0.0, rbcpf, 10.0)
222  evr = IMP.container.PairsRestraint(ssps, self.cpc)
223  else:
224  other_lsa = IMP.container.ListSingletonContainer(self.mdl)
225  other_lsa.add(IMP.get_indexes(other_ps))
227  lsa,
228  other_lsa,
229  0.0,
230  10.0)
231  evr = IMP.container.PairsRestraint(ssps, self.cpc)
232 
233  self.rs.add_restraint(evr)
234 
235  def add_excluded_particle_pairs(self, excluded_particle_pairs):
236  # add pairs to be filtered when calculating the score
237  inverted=[(p1,p0)for p0,p1 in excluded_particle_pairs]
238  lpc = IMP.container.ListPairContainer(self.mdl)
239  lpc.add(IMP.get_indexes(excluded_particle_pairs))
240  lpc.add(IMP.get_indexes(inverted))
242  self.cpc.add_pair_filter(icpf)
243 
244  def set_label(self, label):
245  self.label = label
246 
247  def add_to_model(self):
248  IMP.pmi.tools.add_restraint_to_model(self.mdl, self.rs, add_to_rmf=True)
249 
250  def get_restraint(self):
251  return self.rs
252 
253  def set_weight(self, weight):
254  self.weight = weight
255  self.rs.set_weight(weight)
256 
257  def get_output(self):
258  output = {}
259  score = self.weight * self.rs.unprotected_evaluate(None)
260  output["_TotalScore"] = str(score)
261  output["ExcludedVolumeSphere_" + self.label] = str(score)
262  return output
263 
264  def evaluate(self):
265  return self.weight * self.rs.unprotected_evaluate(None)
266 
267 class HelixRestraint(object):
268  """Enforce ideal Helix dihedrals and bonds for a selection at resolution 0"""
269  def __init__(self,
270  hierarchy,
271  selection_tuple,
272  weight=1.0,
273  label=''):
274  """Constructor
275  @param hierarchy the root node
276  @param selection_tuple (start, stop, molname, copynum=0)
277  @param weight
278  """
279  self.mdl = hierarchy.get_model()
280  self.rs = IMP.RestraintSet(self.mdl)
281  self.weight = weight
282  self.label = label
283  start = selection_tuple[0]
284  stop = selection_tuple[1]
285  mol = selection_tuple[2]
286  copy_index = 0
287  if len(selection_tuple)>3:
288  copy_index = selection_tuple[3]
289 
290  sel = IMP.atom.Selection(hierarchy,molecule=mol,copy_index=copy_index,
291  residue_indexes=range(start,stop+1))
292  ps = sel.get_selected_particles(with_representation=False)
293  res = [IMP.atom.Residue(p) for p in ps]
294  self.rs = IMP.RestraintSet(self.mdl,self.weight)
295  self.r = IMP.atom.HelixRestraint(res)
296  self.rs.add_restraint(self.r)
297  print('Created helix %s.%i.%i-%i with %i dihedrals and %i bonds'%(
298  mol,copy_index,start,stop,
299  self.get_number_of_bonds(),self.get_number_of_dihedrals()))
300  def set_label(self, label):
301  self.label = label
302 
303  def get_weight(self):
304  return self.weight
305 
306  def add_to_model(self):
307  IMP.pmi.tools.add_restraint_to_model(self.mdl, self.rs)
308 
309  def get_restraint(self):
310  return self.rs
311 
312  def set_weight(self, weight):
313  self.weight = weight
314  self.rs.set_weight(weight)
315 
316  def get_number_of_bonds(self):
317  return self.r.get_number_of_bonds()
318 
319  def get_number_of_dihedrals(self):
320  return self.r.get_number_of_dihedrals()
321 
322  def evaluate(self):
323  return self.weight * self.rs.unprotected_evaluate(None)
324 
325  def get_output(self):
326  output = {}
327  score = self.evaluate()
328  output["_TotalScore"] = str(score)
329  output["HelixRestraint_" + self.label] = str(score)
330  return output
331 
332 class ResidueBondRestraint(object):
333  """ Add bond restraint between pair of consecutive
334  residues/beads to enforce the stereochemistry.
335  """
336  def __init__(self, objects, distance=3.78, strength=10.0, jitter=None):
337  """Constructor
338  @param objects Objects to restrain
339  @param distance Resting distance for restraint
340  @param strength Bond constant
341  @param jitter Defines the +- added to the optimal distance in the harmonic well restraint
342  used to increase the tolerance
343  """
344 
345  particles = IMP.pmi.tools.input_adaptor(objects,1,flatten=True)
346  self.m = particles[0].get_model()
347 
348  self.rs = IMP.RestraintSet(self.m, "Bonds")
349  self.weight = 1
350  self.label = "None"
351  self.pairslist = []
352 
353 
354 
355  if not jitter:
356  ts = IMP.core.Harmonic(distance, strength)
357  else:
359  (distance - jitter, distance + jitter), strength)
360 
361  for ps in IMP.pmi.tools.sublist_iterator(particles, 2, 2):
362  pair = []
363  if len(ps) != 2:
364  raise ValueError("wrong length of pair")
365  for p in ps:
367  raise TypeError("%s is not a residue" % p)
368  else:
369  pair.append(p)
370  print("ResidueBondRestraint: adding a restraint between %s %s" % (pair[0].get_name(), pair[1].get_name()))
371  self.rs.add_restraint(
372  IMP.core.DistanceRestraint(self.m, ts, pair[0], pair[1]))
373  self.pairslist.append(IMP.ParticlePair(pair[0], pair[1]))
374  self.pairslist.append(IMP.ParticlePair(pair[1], pair[0]))
375 
376  def set_label(self, label):
377  self.label = label
378  self.rs.set_name(label)
379  for r in self.rs.get_restraints():
380  r.set_name(label)
381 
382  def add_to_model(self):
383  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
384 
385  def get_restraint(self):
386  return self.rs
387 
388  def set_weight(self, weight):
389  self.weight = weight
390  self.rs.set_weight(weight)
391 
392  def get_excluded_pairs(self):
393  return self.pairslist
394 
395  def get_output(self):
396  output = {}
397  score = self.weight * self.rs.unprotected_evaluate(None)
398  output["_TotalScore"] = str(score)
399  output["ResidueBondRestraint_" + self.label] = str(score)
400  return output
401 
402 
403 class ResidueAngleRestraint(object):
404  """Add angular restraint between triplets of consecutive
405  residues/beads to enforce the stereochemistry.
406  """
407  def __init__(self, objects, anglemin=100.0, anglemax=140.0, strength=10.0):
408 
409  particles = IMP.pmi.tools.input_adaptor(objects,1,flatten=True)
410  self.m = particles[0].get_model()
411 
412  self.rs = IMP.RestraintSet(self.m, "Angles")
413  self.weight = 1
414  self.label = "None"
415  self.pairslist = []
416 
418  (pi * anglemin / 180.0,
419  pi * anglemax / 180.0),
420  strength)
421 
422  for ps in IMP.pmi.tools.sublist_iterator(particles, 3, 3):
423  triplet = []
424  if len(ps) != 3:
425  raise ValueError("wrong length of triplet")
426  for p in ps:
428  raise TypeError("%s is not a residue" % p)
429  else:
430  triplet.append(p)
431  print("ResidueAngleRestraint: adding a restraint between %s %s %s" % (triplet[0].get_name(), triplet[1].get_name(), triplet[2].get_name()))
432  self.rs.add_restraint(
433  IMP.core.AngleRestraint(triplet[0].get_model(), ts,
434  triplet[0],
435  triplet[1],
436  triplet[2]))
437  self.pairslist.append(IMP.ParticlePair(triplet[0], triplet[2]))
438  self.pairslist.append(IMP.ParticlePair(triplet[2], triplet[0]))
439 
440  def set_label(self, label):
441  self.label = label
442  self.rs.set_name(label)
443  for r in self.rs.get_restraints():
444  r.set_name(label)
445 
446  def add_to_model(self):
447  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
448 
449  def get_restraint(self):
450  return self.rs
451 
452  def set_weight(self, weight):
453  self.weight = weight
454  self.rs.set_weight(weight)
455 
456  def get_excluded_pairs(self):
457  return self.pairslist
458 
459  def get_output(self):
460  output = {}
461  score = self.weight * self.rs.unprotected_evaluate(None)
462  output["_TotalScore"] = str(score)
463  output["ResidueAngleRestraint_" + self.label] = str(score)
464  return output
465 
466 
468  """Add dihedral restraints between quadruplet of consecutive
469  residues/beads to enforce the stereochemistry.
470  Give as input a string of "C" and "T", meaning cys (0+-40) or trans (180+-40)
471  dihedral. The length of the string must be \#residue-3.
472  Without the string, the dihedral will be assumed trans.
473  """
474  def __init__(self, objects, stringsequence=None, strength=10.0):
475 
476  particles = IMP.pmi.tools.input_adaptor(objects,1,flatten=True)
477  self.m = particles[0].get_model()
478 
479  self.rs = IMP.RestraintSet(self.m, "Angles")
480  self.weight = 1
481  self.label = "None"
482  self.pairslist = []
483 
484  if stringsequence is None:
485  stringsequence = "T" * (len(particles) - 3)
486 
487  for n, ps in enumerate(IMP.pmi.tools.sublist_iterator(particles, 4, 4)):
488  quadruplet = []
489  if len(ps) != 4:
490  raise ValueError("wrong length of quadruplet")
491  for p in ps:
493  raise TypeError("%s is not a residue" % p)
494  else:
495  quadruplet.append(p)
496  dihedraltype = stringsequence[n]
497  if dihedraltype == "C":
498  anglemin = -20.0
499  anglemax = 20.0
501  (pi * anglemin / 180.0,
502  pi * anglemax / 180.0),
503  strength)
504  print("ResidueDihedralRestraint: adding a CYS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
505  quadruplet[2].get_name(), quadruplet[3].get_name()))
506  if dihedraltype == "T":
507  anglemin = 180 - 70.0
508  anglemax = 180 + 70.0
510  (pi * anglemin / 180.0,
511  pi * anglemax / 180.0),
512  strength)
513  print("ResidueDihedralRestraint: adding a TRANS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
514  quadruplet[2].get_name(), quadruplet[3].get_name()))
515  self.rs.add_restraint(
516  IMP.core.DihedralRestraint(self.m,ts,
517  quadruplet[0],
518  quadruplet[1],
519  quadruplet[2],
520  quadruplet[3]))
521  self.pairslist.append(
522  IMP.ParticlePair(quadruplet[0], quadruplet[3]))
523  self.pairslist.append(
524  IMP.ParticlePair(quadruplet[3], quadruplet[0]))
525 
526  def set_label(self, label):
527  self.label = label
528  self.rs.set_name(label)
529  for r in self.rs.get_restraints():
530  r.set_name(label)
531 
532  def add_to_model(self):
533  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
534 
535  def get_restraint(self):
536  return self.rs
537 
538  def set_weight(self, weight):
539  self.weight = weight
540  self.rs.set_weight(weight)
541 
542  def get_excluded_pairs(self):
543  return self.pairslist
544 
545  def get_output(self):
546  output = {}
547  score = self.weight * self.rs.unprotected_evaluate(None)
548  output["_TotalScore"] = str(score)
549  output["ResidueDihedralRestraint_" + self.label] = str(score)
550  return output
551 
552 class SecondaryStructure(object):
553  """Experimental, requires isd_emxl for now"""
554  def __init__(self,
555  representation,
556  selection_tuple,
557  ssstring,
558  mixture=False,
559  nativeness=1.0,
560  kt_caff=0.1):
561 
562  if no_isd_emxl:
563  raise ValueError("IMP.isd_emxl is needed")
564 
565  # check that the secondary structure string
566  # is compatible with the ssstring
567 
568  self.particles = IMP.pmi.tools.select_by_tuple(
569  representation,
570  selection_tuple,
571  resolution=1)
572  self.m = representation.prot.get_model()
573  self.dihe_dict = {}
574  self.ang_dict = {}
575  self.do_mix = {}
576  self.anglfilename = IMP.isd_emxl.get_data_path("CAAngleRestraint.dat")
577  self.dihefilename = IMP.isd_emxl.get_data_path(
578  "CADihedralRestraint.dat")
579  self.nativeness = nativeness
580  self.kt_caff = kt_caff
581  self.anglrs = IMP.RestraintSet(self.m, "Angles")
582  self.dihers = IMP.RestraintSet(self.m, "Dihedrals")
583  self.bondrs = IMP.RestraintSet(self.m, "Bonds")
584  self.label = "None"
585 
586  if len(self.particles) != len(ssstring):
587  print(len(self.particles), len(ssstring))
588  print("SecondaryStructure: residue range and SS string incompatible")
589  self.ssstring = ssstring
590 
591  (bondrslist, anglrslist, diherslist,
592  pairslist) = self.get_CA_force_field()
593  self.pairslist = pairslist
594 
595  # print anglrslist, diherslist, bondrslist, self.particles
596  self.anglrs.add_restraints(anglrslist)
597  self.dihers.add_restraints(diherslist)
598  self.bondrs.add_restraints(bondrslist)
599 
600  def set_label(self, label):
601  self.label = label
602 
603  def add_to_model(self):
604  IMP.pmi.tools.add_restraint_to_model(self.m, self.anglrs)
605  IMP.pmi.tools.add_restraint_to_model(self.m, self.dihers)
606  IMP.pmi.tools.add_restraint_to_model(self.m, self.bondrs)
607 
608  def get_CA_force_field(self):
609  bondrslist = []
610  anglrslist = []
611  diherslist = []
612  pairslist = []
613  # add bonds
614  for res in range(0, len(self.particles) - 1):
615 
616  ps = self.particles[res:res + 2]
617  pairslist.append(IMP.ParticlePair(ps[0], ps[1]))
618  pairslist.append(IMP.ParticlePair(ps[1], ps[0]))
619  br = self.get_distance_restraint(ps[0], ps[1], 3.78, 416.0)
620  br.set_name('Bond_restraint')
621  bondrslist.append(br)
622  # add dihedrals
623  for res in range(0, len(self.particles) - 4):
624 
625  # if res not in dihe_dict: continue
626  # get the appropriate parameters
627  # get the particles
628  ps = self.particles[res:res + 5]
629  [phi0,
630  phi1,
631  score_dih] = self.read_potential_dihedral(
632  self.ssstring[res:res + 4],
633  True)
634  pairslist.append(IMP.ParticlePair(ps[0], ps[3]))
635  pairslist.append(IMP.ParticlePair(ps[3], ps[0]))
636  pairslist.append(IMP.ParticlePair(ps[1], ps[4]))
637  pairslist.append(IMP.ParticlePair(ps[4], ps[1]))
638  dr = IMP.isd_emxl.CADihedralRestraint(
639  ps[0],
640  ps[1],
641  ps[2],
642  ps[3],
643  ps[4],
644  phi0,
645  phi1,
646  score_dih)
647  dr.set_name('Dihedral restraint')
648  diherslist.append(dr)
649  # add angles
650  for res in range(0, len(self.particles) - 2):
651  ps = self.particles[res:res + 3]
652  [psi, score_ang] = self.read_potential_angle(
653  self.ssstring[res:res + 2], True)
654  pairslist.append(IMP.ParticlePair(ps[0], ps[2]))
655  pairslist.append(IMP.ParticlePair(ps[2], ps[0]))
656  dr = IMP.isd_emxl.CAAngleRestraint(
657  ps[0],
658  ps[1],
659  ps[2],
660  psi,
661  score_ang)
662  dr.set_name('Angle restraint')
663  anglrslist.append(dr)
664  return (bondrslist, anglrslist, diherslist, pairslist)
665 
666  def read_potential_dihedral(self, string, mix=False):
667  # read potentials for dihedral
668  score_dih = []
669  phi0 = []
670  phi1 = []
671  for i in range(0, 36):
672  phi0.append(i * 10.0 / 180.0 * pi)
673  phi1.append(i * 10.0 / 180.0 * pi)
674  for j in range(0, 36):
675  score_dih.append(0.0)
676  # open file
677  if not mix:
678  f = open(self.dihefilename, 'r')
679  for line in f.readlines():
680  riga = (line.strip()).split()
681  if (len(riga) == 4 and riga[0] == string):
682  ii = int(float(riga[1]) / 10.0)
683  jj = int(float(riga[2]) / 10.0)
684  score_dih[ii * len(phi0) + jj] = - \
685  self.kt_caff * self.log(float(riga[3]))
686  f.close()
687  if mix:
688  # mix random coil and native secondary structure
689  counts = []
690  for i in range(0, 36):
691  for j in range(0, 36):
692  counts.append(1.0)
693  f = open(self.dihefilename, 'r')
694  for line in f.readlines():
695  riga = (line.strip()).split()
696  if (len(riga) == 4 and riga[0] == string):
697  ii = int(float(riga[1]) / 10.0)
698  jj = int(float(riga[2]) / 10.0)
699  counts[ii * len(phi0) + jj] += self.nativeness * \
700  float(riga[3])
701  if (len(riga) == 4 and riga[0] == "-----"):
702  ii = int(float(riga[1]) / 10.0)
703  jj = int(float(riga[2]) / 10.0)
704  counts[ii * len(phi0) + jj] += (1.0 - self.nativeness) * \
705  float(riga[3])
706  f.close()
707  for i in range(len(counts)):
708  score_dih[i] = -self.kt_caff * self.log(counts[i])
709  return [phi0, phi1, score_dih]
710 
711  def read_potential_angle(self, string, mix=False):
712  # read potentials for angles
713  score_ang = []
714  psi = []
715  for i in range(0, 180):
716  psi.append(i / 180.0 * pi)
717  score_ang.append(0.0)
718  # read file
719  if not mix:
720  f = open(self.anglfilename, 'r')
721  for line in f.readlines():
722  riga = (line.strip()).split()
723  if (len(riga) == 3 and riga[0] == string):
724  ii = int(riga[1])
725  score_ang[ii] = -self.kt_caff * self.log(float(riga[2]))
726  f.close()
727  if mix:
728  # mix random coil and native secondary structure
729  counts = []
730  for i in range(0, 180):
731  counts.append(1.0)
732 
733  f = open(self.anglfilename, 'r')
734  for line in f.readlines():
735  riga = (line.strip()).split()
736  if (len(riga) == 3 and riga[0] == string):
737  ii = int(riga[1])
738  counts[ii] += self.nativeness * float(riga[2])
739  if (len(riga) == 3 and riga[0] == "---"):
740  ii = int(riga[1])
741  counts[ii] += (1.0 - self.nativeness) * float(riga[2])
742  f.close()
743  for i in range(0, 180):
744  score_ang[i] = -self.kt_caff * self.log(counts[i])
745  return [psi, score_ang]
746 
747  def get_excluded_pairs(self):
748  return self.pairslist
749 
750  def get_restraint(self):
751  tmprs = IMP.RestraintSet(self.m, 'tmp')
752  tmprs.add_restraint(self.anglrs)
753  tmprs.add_restraint(self.dihers)
754  tmprs.add_restraint(self.bondrs)
755  return tmprs
756 
757  def get_distance_restraint(self, p0, p1, d0, kappa):
758  h = IMP.core.Harmonic(d0, kappa)
760  pr = IMP.core.PairRestraint(self.m, dps, IMP.ParticlePair(p0, p1))
761  return pr
762 
763  def get_output(self):
764  output = {}
765  score_angle = self.anglrs.unprotected_evaluate(None)
766  score_dihers = self.dihers.unprotected_evaluate(None)
767  score_bondrs = self.bondrs.unprotected_evaluate(None)
768  output["_TotalScore"] = str(score_angle + score_dihers + score_bondrs)
769 
770  output["SecondaryStructure_Angles_" + self.label] = str(score_angle)
771  output["SecondaryStructure_Dihedrals_" +
772  self.label] = str(score_dihers)
773  output["SecondaryStructure_Bonds_" + self.label] = str(score_bondrs)
774  return output
775 
776 
778  """Add harmonic restraints between all pairs
779  """
780  def __init__(self, hierarchy, selection_tuples=None, resolution=1,
781  strength=0.01, dist_cutoff=10.0, ca_only=True):
782  """Constructor
783  @param hierarchy Root hierarchy to select from
784  @param selection_tuples Selecting regions for the restraint [[start,stop,molname,copy_index=0],...]
785  @param resolution Resolution for applying restraint
786  @param strength Bond strength
787  @param dist_cutoff Cutoff for making restraints
788  @param ca_only Selects only CAlphas. Only matters if resolution=0.
789  """
790 
791  particles = []
792  self.m = hierarchy.get_model()
793  for st in selection_tuples:
794  copy_index=0
795  if len(st)>3:
796  copy_index=st[3]
797  if not ca_only:
798  sel = IMP.atom.Selection(
799  hierarchy, molecule=st[2],
800  residue_indexes=range(st[0],st[1]+1),
801  copy_index=copy_index)
802  else:
803  sel = IMP.atom.Selection(
804  hierarchy, molecule=st[2],
805  residue_indexes=range(st[0],st[1]+1),
806  copy_index=copy_index,
807  atom_type=IMP.atom.AtomType("CA"))
808  particles+=sel.get_selected_particles()
809 
810  self.weight = 1
811  self.label = "None"
812  self.pairslist = []
813 
814  # create score
815  self.rs = IMP.pmi.create_elastic_network(particles,dist_cutoff,strength)
816  for r in self.rs.get_restraints():
817  a1,a2 = r.get_inputs()
818  self.pairslist.append(IMP.ParticlePair(a1,a2))
819  self.pairslist.append(IMP.ParticlePair(a2,a1))
820  print('ElasticNetwork: created',self.rs.get_number_of_restraints(),'restraints')
821 
822  def set_label(self, label):
823  self.label = label
824  self.rs.set_name(label)
825  for r in self.rs.get_restraints():
826  r.set_name(label)
827 
828  def add_to_model(self):
829  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
830 
831  def get_restraint(self):
832  return self.rs
833 
834  def set_weight(self, weight):
835  self.weight = weight
836  self.rs.set_weight(weight)
837 
838  def get_excluded_pairs(self):
839  return self.pairslist
840 
841  def get_output(self):
842  output = {}
843  score = self.weight * self.rs.unprotected_evaluate(None)
844  output["_TotalScore"] = str(score)
845  output["ElasticNetworkRestraint_" + self.label] = str(score)
846  return output
847 
848 
850  """ Enable CHARMM force field """
851  def __init__(self,
852  root,
853  ff_temp=300.0,
854  zone_ps=None,
855  zone_size=10.0,
856  enable_nonbonded=True,
857  enable_bonded=True,
858  zone_nonbonded=False):
859  """Setup the CHARMM restraint on a selection. Expecting atoms.
860  @param root The node at which to apply the restraint
861  @param ff_temp The temperature of the force field
862  @param zone_ps Create a zone around this set of particles
863  Automatically includes the entire residue (incl. backbone)
864  @param zone_size The size for looking for neighbor residues
865  @param enable_nonbonded Allow the repulsive restraint
866  @param enable_bonded Allow the bonded restraint
867  @param zone_nonbonded EXPERIMENTAL: exclude from nonbonded all sidechains that aren't in zone!
868  """
869 
870  kB = (1.381 * 6.02214) / 4184.0
871 
872  self.mdl = root.get_model()
873  self.bonds_rs = IMP.RestraintSet(self.mdl, 1.0 / (kB * ff_temp), 'BONDED')
874  self.nonbonded_rs = IMP.RestraintSet(self.mdl, 1.0 / (kB * ff_temp), 'NONBONDED')
875  self.weight = 1.0
876  self.label = ""
877 
878  ### setup topology and bonds etc
879  if enable_bonded:
881  topology = ff.create_topology(root)
882  topology.apply_default_patches()
883  topology.setup_hierarchy(root)
884  if zone_ps is not None:
885  limit_to_ps=IMP.pmi.topology.get_particles_within_zone(
886  root,
887  zone_ps,
888  zone_size,
889  entire_residues=True,
890  exclude_backbone=False)
892  topology,
893  limit_to_ps)
894  self.ps = limit_to_ps
895  else:
896  r = IMP.atom.CHARMMStereochemistryRestraint(root, topology)
897  self.ps = IMP.core.get_leaves(root)
898  print('init bonds score',r.unprotected_evaluate(None))
899  self.bonds_rs.add_restraint(r)
900  ff.add_radii(root)
901  ff.add_well_depths(root)
902 
903  atoms = IMP.atom.get_by_type(root,IMP.atom.ATOM_TYPE)
904  ### non-bonded forces
905  if enable_nonbonded:
906  if (zone_ps is not None) and zone_nonbonded:
907  print('stereochemistry: zone_nonbonded is True')
908  # atoms list should only include backbone plus zone_ps!
909  backbone_types=['C','N','CB','O']
910  sel = IMP.atom.Selection(root,atom_types=[IMP.atom.AtomType(n)
911  for n in backbone_types])
912  backbone_atoms = sel.get_selected_particles()
913  #x = list(set(backbone_atoms)|set(limit_to_ps))
914  sel_ps=IMP.pmi.topology.get_particles_within_zone(
915  root,
916  zone_ps,
917  zone_size,
918  entire_residues=True,
919  exclude_backbone=True)
920 
922  IMP.container.ListSingletonContainer(backbone_atoms),
924  4.0)
925  else:
926  cont = IMP.container.ListSingletonContainer(self.mdl,atoms)
927  self.nbl = IMP.container.ClosePairContainer(cont, 4.0)
928  if enable_bonded:
929  self.nbl.add_pair_filter(r.get_full_pair_filter())
930  pairscore = IMP.isd.RepulsiveDistancePairScore(0,1)
931  pr=IMP.container.PairsRestraint(pairscore, self.nbl)
932  self.nonbonded_rs.add_restraint(pr)
933  print('CHARMM is set up')
934 
935  def set_label(self, label):
936  self.label = label
937  self.rs.set_name(label)
938  for r in self.rs.get_restraints():
939  r.set_name(label)
940 
941  def add_to_model(self):
942  IMP.pmi.tools.add_restraint_to_model(self.mdl, self.bonds_rs)
943  IMP.pmi.tools.add_restraint_to_model(self.mdl, self.nonbonded_rs)
944 
945  def get_restraint(self):
946  return self.rs
947 
948  def get_close_pair_container(self):
949  return self.nbl
950 
951  def set_weight(self, weight):
952  self.weight = weight
953  self.rs.set_weight(weight)
954 
955  def get_output(self):
956  output = {}
957  bonds_score = self.weight * self.bonds_rs.unprotected_evaluate(None)
958  nonbonded_score = self.weight * self.nonbonded_rs.unprotected_evaluate(None)
959  score=bonds_score+nonbonded_score
960  output["_TotalScore"] = str(score)
961  output["CHARMM_BONDS"] = str(bonds_score)
962  output["CHARMM_NONBONDED"] = str(nonbonded_score)
963  return output
964 
965 
966 class PseudoAtomicRestraint(object):
967  """Add bonds and improper dihedral restraints for the CBs
968  """
969  def __init__(
970  self, rnums, representation, selection_tuple, strength=10.0, kappa=1.0,
971  jitter_angle=0.0, jitter_improper=0.0):
972  '''
973  need to add:
974  ca-ca bond
975  ca-cb is a constraint, no restraint needed
976  ca-ca-ca
977  cb-ca-ca-cb
978  '''
979 
980  self.m = representation.prot.get_model()
981  self.rs = IMP.RestraintSet(self.m, "PseudoAtomic")
982  self.rset_angles = IMP.RestraintSet(self.m, "PseudoAtomic_Angles")
983  self.rset_bonds = IMP.RestraintSet(self.m, "PseudoAtomic_Bonds")
984  self.weight = 1
985  self.label = "None"
986  self.pairslist = []
987 
988  # residues=IMP.pmi.tools.select_by_tuple(representation,selection_tuple,resolution=1)
989  for rnum in rnums:
990  ca, cb = self.get_ca_cb(
991  IMP.pmi.tools.select_by_tuple(representation,
992  (rnum, rnum, 'chainA'), resolution=0))
993  if not cb is None:
994  nter = False
995  cter = False
996  ca_prev, cb_prev = self.get_ca_cb(
997  IMP.pmi.tools.select_by_tuple(representation,
998  (rnum - 1, rnum - 1, 'chainA'), resolution=0))
999  ca_next, cb_next = self.get_ca_cb(
1000  IMP.pmi.tools.select_by_tuple(representation,
1001  (rnum + 1, rnum + 1, 'chainA'), resolution=0))
1002  if ca_prev is None:
1003  nter = True
1004  else:
1005  if ca_next is None:
1006  cter = True
1007  else:
1008  if (nter and cter):
1009  continue
1010 
1011  # adding a bond restraint between CA and CB
1012  # h=IMP.core.Harmonic(6.0,kappa)
1013  # dps=IMP.core.DistancePairScore(h)
1014  # pr=IMP.core.PairRestraint(dps,IMP.ParticlePair(ca,cb))
1015  # self.pairslist.append((ca,cb))
1016  # self.rset_bonds.add_restraint(pr)
1017 
1018  # creating improper dihedral restraint
1019  # hus=IMP.core.Harmonic(2.09,kappa)
1021  2.09 +
1022  jitter_angle /
1023  0.5,
1024  kappa)
1026  2.09 -
1027  jitter_angle /
1028  0.5,
1029  kappa)
1030  if not nter:
1031  # ar13=IMP.core.AngleRestraint(hus,ca_prev,ca,cb)
1032  # self.rset_angles.add_restraint(ar13)
1033  ar13u = IMP.core.AngleRestraint(hupp, ca_prev, ca, cb)
1034  ar13l = IMP.core.AngleRestraint(hlow, ca_prev, ca, cb)
1035  self.rset_angles.add_restraint(ar13u)
1036  self.rset_angles.add_restraint(ar13l)
1037  if not cter:
1038  # ar23=IMP.core.AngleRestraint(hus,ca_next,ca,cb)
1039  # self.rset_angles.add_restraint(ar23)
1040  ar23u = IMP.core.AngleRestraint(hupp, ca_next, ca, cb)
1041  ar23l = IMP.core.AngleRestraint(hlow, ca_next, ca, cb)
1042  self.rset_angles.add_restraint(ar23u)
1043  self.rset_angles.add_restraint(ar23l)
1044  if not nter and not cter:
1045  # hus2=IMP.core.Harmonic(0,kappa)
1046  # idr=IMP.core.DihedralRestraint(hus2,ca,ca_prev,ca_next,cb)
1047  # self.rset_angles.add_restraint(idr)
1048 
1049  hus2upp = IMP.core.HarmonicUpperBound(
1050  jitter_improper,
1051  kappa)
1052  hus2low = IMP.core.HarmonicLowerBound(
1053  -
1054  jitter_improper,
1055  kappa)
1057  hus2upp,
1058  ca,
1059  ca_prev,
1060  ca_next,
1061  cb)
1063  hus2low,
1064  ca,
1065  ca_prev,
1066  ca_next,
1067  cb)
1068  self.rset_angles.add_restraint(idru)
1069  self.rset_angles.add_restraint(idrl)
1070  self.rs.add_restraint(self.rset_bonds)
1071  self.rs.add_restraint(self.rset_angles)
1072 
1073  def get_ca_cb(self, atoms):
1074  ca = None
1075  cb = None
1076  for a in atoms:
1077  if IMP.atom.Atom(a).get_atom_type() == IMP.atom.AtomType("CA"):
1078  ca = a.get_particle()
1079  elif IMP.atom.Atom(a).get_atom_type() == IMP.atom.AtomType("CB"):
1080  cb = a.get_particle()
1081  return ca, cb
1082 
1083  def set_label(self, label):
1084  self.label = label
1085  self.rs.set_name(label)
1086  for r in self.rs.get_restraints():
1087  r.set_name(label)
1088 
1089  def add_to_model(self):
1090  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
1091 
1092  def get_restraint(self):
1093  return self.rs
1094 
1095  def set_weight(self, weight):
1096  self.weight = weight
1097  self.rs.set_weight(weight)
1098 
1099  def get_excluded_pairs(self):
1100  return self.pairslist
1101 
1102  def get_output(self):
1103  output = {}
1104  score = self.weight * self.rs.unprotected_evaluate(None)
1105  output["_TotalScore"] = str(score)
1106  output["PseudoAtomicRestraint_" + self.label] = str(score)
1107  return output
1108 
1109 class SymmetryRestraint(object):
1110  """Create harmonic restraints between the reference and (transformed) clones.
1111  @note Wraps IMP::core::TransformedDistancePairScore with an IMP::core::Harmonic
1112  """
1113  def __init__(self,
1114  references,
1115  clones_list,
1116  transforms,
1117  label='',
1118  strength=10.0,
1119  ca_only=False):
1120  """Constructor
1121  @param references Can be one of the following inputs:
1122  IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
1123  @param clones_list List of lists of the above
1124  @param transforms Transforms moving each selection to the first selection
1125  @param label Label for output
1126  @param strength The elastic bond strength
1127  @param ca_only Optionally select so only CAlpha particles are used
1128  """
1129 
1130  refs = IMP.pmi.tools.input_adaptor(references,flatten=True)
1131  self.mdl = refs[0].get_model()
1132  self.rs = IMP.RestraintSet(self.mdl, "Symmetry")
1133  self.weight = 1
1134  self.label = label
1135  if len(clones_list)!=len(transforms):
1136  raise Exception('Error: There should be as many clones as transforms')
1137 
1138  harmonic = IMP.core.Harmonic(0.,strength)
1139  for tmp_clones,trans in zip(clones_list,transforms):
1140  clones = IMP.pmi.tools.input_adaptor(tmp_clones,flatten=True)
1141  if len(clones)!=len(refs):
1142  raise Exception("Error: len(references)!=len(clones)")
1143  pair_score = IMP.core.TransformedDistancePairScore(harmonic,trans)
1144  for p0,p1 in zip(refs,clones):
1145  if not ca_only or (IMP.atom.Atom(p0).get_atom_type()==IMP.atom.AtomType("CA")
1146  and IMP.atom.Atom(p1).get_atom_type()==IMP.atom.AtomType("CA")):
1147  r = IMP.core.PairRestraint(self.mdl, pair_score, [p0.get_particle_index(),
1148  p1.get_particle_index()])
1149  self.rs.add_restraint(r)
1150  print('created symmetry network with',self.rs.get_number_of_restraints(),'restraints')
1151 
1152  def set_label(self, label):
1153  self.label = label
1154  self.rs.set_name(label)
1155  for r in self.rs.get_restraints():
1156  r.set_name(label)
1157 
1158  def add_to_model(self):
1159  IMP.pmi.tools.add_restraint_to_model(self.mdl, self.rs)
1160 
1161  def get_restraint(self):
1162  return self.rs
1163 
1164  def set_weight(self, weight):
1165  self.weight = weight
1166  self.rs.set_weight(weight)
1167 
1168  def get_excluded_pairs(self):
1169  return self.pairslist
1170 
1171  def get_output(self):
1172  output = {}
1173  score = self.weight * self.rs.unprotected_evaluate(None)
1174  output["SymmetryRestraint_" + self.label] = str(score)
1175  output["_TotalScore"] = str(score)
1176  return output
1177 
1178 
1179 class FusionRestraint(object):
1180  """ This class creates a restraint between the termini two polypeptides, to simulate the sequence connectivity. """
1181  def __init__(self,
1182  nterminal,
1183  cterminal,
1184  scale=1.0,
1185  disorderedlength=False,
1186  upperharmonic=True,
1187  resolution=1,
1188  label="None"):
1189  """
1190  @param nterminal - single PMI2 Hierarchy/molecule at the nterminal
1191  @param cterminal - single PMI2 Hierarchy/molecule at the cterminal
1192  @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
1193  The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
1194  @param disorderedlength - This flag uses either disordered length
1195  calculated for random coil peptides (True) or zero
1196  surface-to-surface distance between beads (False)
1197  as optimal distance for the sequence connectivity
1198  restraint.
1199  @param upperharmonic - This flag uses either harmonic (False)
1200  or upperharmonic (True) in the intra-pair
1201  connectivity restraint.
1202  @param resolution - The resolution to connect things at - only used if you pass PMI objects
1203  @param label - A string to identify this restraint in the output/stat file
1204  """
1205  self.label = label
1206  self.weight = 1.0
1207  ssn=IMP.pmi.tools.get_sorted_segments(nterminal)
1208  ssc=IMP.pmi.tools.get_sorted_segments(cterminal)
1209  nter_lastres=ssn[-1][1]
1210  cter_firstres=ssc[0][0]
1211  self.m = nter_lastres.get_model()
1212 
1213  self.kappa = 10 # spring constant used for the harmonic restraints
1214 
1215  optdist = (3.6) * scale
1216  if upperharmonic: # default
1217  hu = IMP.core.HarmonicUpperBound(optdist, self.kappa)
1218  else:
1219  hu = IMP.core.Harmonic(optdist, self.kappa)
1221 
1222  pt0 = nter_lastres.get_particle()
1223  pt1 = cter_firstres.get_particle()
1224  r = IMP.core.PairRestraint(self.m, dps, (pt0.get_index(), pt1.get_index()))
1225  self.rs = IMP.RestraintSet(self.m, "fusion_restraint")
1226  print("Adding fusion connectivity restraint between", pt0.get_name(), " and ", pt1.get_name(), 'of distance', optdist)
1227  self.rs.add_restraint(r)
1228 
1229  def set_label(self, label):
1230  self.label = label
1231 
1232  def get_weight(self):
1233  return self.weight
1234 
1235  def add_to_model(self):
1236  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
1237 
1238  def get_restraint(self):
1239  return self.rs
1240 
1241  def set_weight(self, weight):
1242  self.weight = weight
1243  self.rs.set_weight(weight)
1244 
1245  def get_output(self):
1246  output = {}
1247  score = self.weight * self.rs.unprotected_evaluate(None)
1248  output["_TotalScore"] = str(score)
1249  output["FusionRestraint_" + self.label] = str(score)
1250  return output
1251 
1252  def evaluate(self):
1253  return self.weight * self.rs.unprotected_evaluate(None)
1254 
1255 
1256 
1257 
1258 class PlaneDihedralRestraint(IMP.pmi.restraints.RestraintBase):
1259 
1260  """Restrain the dihedral between planes defined by three particles.
1261 
1262  This restraint is useful for restraining the twist of a string of
1263  more or less identical rigid bodies, so long as the curvature is mild.
1264  """
1265 
1266  def __init__(self, particle_triplets, angle=0., k=1., label=None,
1267  weight=1.):
1268  """Constructor
1269  @param particle_triplets List of lists of 3 particles. Each triplet
1270  defines a plane. Dihedrals of adjacent planes
1271  in list are scored.
1272  @param angle Angle of plane dihedral in degrees
1273  @param k Strength of restraint
1274  @param label Label for output
1275  @param weight Weight of restraint
1276  @note Particles defining planes should be rigid and more or less
1277  parallel for proper behavior
1278  """
1279  model = particle_triplets[0][0].get_model()
1280  super(PlaneDihedralRestraint, self).__init__(model, label=label,
1281  weight=weight)
1282 
1283  angle = pi * angle / 180.
1284  ds = IMP.core.Cosine(.5 * k, 1., -angle)
1285  for i, t1 in enumerate(particle_triplets[:-1]):
1286  t2 = particle_triplets[i + 1]
1287  q1 = [t1[1], t1[0], t2[0], t2[1]]
1288  q2 = [t1[2], t1[0], t2[0], t2[2]]
1289  self.rs.add_restraint(
1290  IMP.core.DihedralRestraint(self.model, ds, *q1))
1291  self.rs.add_restraint(
1292  IMP.core.DihedralRestraint(self.model, ds, *q2))
A filter which returns true if a container containers the Pair.
Add dihedral restraints between quadruplet of consecutive residues/beads to enforce the stereochemist...
CHARMMParameters * get_heavy_atom_CHARMM_parameters()
Lower bound harmonic function (non-zero when feature < mean)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: Residue.h:156
Enforce CHARMM stereochemistry on the given Hierarchy.
A member of a rigid body, it has internal (local) coordinates.
Definition: rigid_bodies.h:616
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: rigid_bodies.h:617
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Enforce ideal Helix dihedrals and bonds for a selection at resolution 0.
Miscellaneous utilities.
Definition: tools.py:1
Cosine function.
Definition: Cosine.h:22
This class creates a restraint between the termini two polypeptides, to simulate the sequence connect...
Apply a function to the distance between two particles after transforming the second.
Restrain the dihedral between planes defined by three particles.
Dihedral restraint between four particles.
The type of an atom.
A score on the distance between the surfaces of two spheres.
Return all close unordered pairs of particles taken from the SingletonContainer.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: rigid_bodies.h:731
Return all spatially-proximals pairs of particles (a,b) from the two SingletonContainers A and B...
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Distance restraint between two particles.
Object used to hold a set of restraints.
Definition: RestraintSet.h:36
def input_adaptor
Adapt things for PMI (degrees of freedom, restraints, ...) Returns list of list of hierarchies...
Definition: tools.py:917
Store a list of ParticleIndexPairs.
A well with harmonic barriers.
Definition: HarmonicWell.h:25
Angle restraint between three particles.
ParticleIndexPairs get_indexes(const ParticlePairsTemp &ps)
Add bond restraint between pair of consecutive residues/beads to enforce the stereochemistry.
The standard decorator for manipulating molecular structures.
RestraintSet * create_elastic_network(const Particles &ps, Float dist_cutoff, Float strength)
Create an elastic network restraint set.
Definition: pmi/utilities.h:26
Add bonds and improper dihedral restraints for the CBs.
Store a list of ParticleIndexes.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
def get_particle_pairs
Returns the list of connected particles pairs.
def add_restraint_to_model
Add a PMI restraint to the model.
Definition: tools.py:84
Create harmonic restraints between the reference and (transformed) clones.
Add angular restraint between triplets of consecutive residues/beads to enforce the stereochemistry...
def get_num_restraints
Returns number of connectivity restraints.
A decorator for a residue.
Definition: Residue.h:135
Basic functionality that is expected to be used by a wide variety of IMP users.
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object...
A class to create an excluded volume restraint for a set of particles at a given resolution.
The general base class for IMP exceptions.
Definition: exception.h:49
def __init__
need to add: ca-ca bond ca-cb is a constraint, no restraint needed ca-ca-ca cb-ca-ca-cb ...
Applies a PairScore to a Pair.
Definition: PairRestraint.h:29
def get_sorted_segments
Returns sequence-sorted segments array, each containing the first particle the last particle and the ...
Definition: tools.py:1043
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Definition: Selection.h:66
Applies a PairScore to each Pair in a list.
def get_residue_indexes
Retrieve the residue indexes for the given particle.
Definition: tools.py:553
A repulsive potential on the distance between two atoms.
Perform more efficient close pair finding when rigid bodies are involved.
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
def sublist_iterator
Yield all sublists of length >= lmin and <= lmax.
Definition: tools.py:626
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:24
Restraint a set of residues to use ideal helix dihedrals and bonds.