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