IMP logo
IMP Reference Guide  2.11.0
The Integrative Modeling Platform
pmi/restraints/proteomics.py
1 """@namespace IMP.pmi.restraints.proteomics
2 Restraints for handling various kinds of proteomics data.
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.pmi
12 import IMP.pmi.tools
13 import IMP.pmi.output
14 import numpy
15 import math
16 import math
17 import sys
18 import warnings
19 
20 
21 class ConnectivityRestraint(object):
22 
23  '''
24  generate a connectivity restraint between domains
25  setting up the restraint
26  example:
27  cr=restraints.ConnectivityRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")])
28  cr.add_to_model()
29  cr.set_label("CR1")
30  Multistate support =No
31  Selection type=selection tuple
32  Resolution=Yes
33  '''
34 
35  def __init__(
36  self,
37  representation,
38  selection_tuples,
39  kappa=10.0,
40  resolution=None,
41  label="None"):
42 
43  self.weight = 1.0
44  self.kappa = kappa
45  self.label = label
46  if self.label == "None":
47  self.label = str(selection_tuples)
48  self.m = representation.prot.get_model()
49  self.rs = IMP.RestraintSet(self.m, label)
50 
51  sels = []
52 
53  for s in selection_tuples:
54  particles = IMP.pmi.tools.select_by_tuple(representation, s,
55  resolution=resolution, name_is_ambiguous=True)
56  sel = IMP.atom.Selection(particles)
57  sels.append(sel)
58 
60  sels,
61  self.kappa,
62  self.label)
63  self.rs.add_restraint(cr)
64 
65  def set_label(self, label):
66  self.label = label
67  self.rs.set_name(label)
68  for r in self.rs.get_restraints():
69  r.set_name(label)
70 
71  def add_to_model(self):
73 
74  def get_restraint(self):
75  return self.rs
76 
77  def get_restraints(self):
78  rlist = []
79  for r in self.rs.get_restraints():
80  rlist.append(IMP.core.PairRestraint.get_from(r))
81  return rlist
82 
83  def set_weight(self, weight):
84  self.weight = weight
85  self.rs.set_weight(weight)
86 
87  def get_output(self):
88  output = {}
89  score = self.weight * self.rs.unprotected_evaluate(None)
90  output["_TotalScore"] = str(score)
91  output["ConnectivityRestraint_" + self.label] = str(score)
92  return output
93 
94 #
95 
96 
97 class CompositeRestraint(object):
98 
99  '''
100  handleparticles is a selection tuple
101  compositeparticles is a list of selection tuples
102  '''
103 
104  def __init__(
105  self,
106  representation,
107  handleparticles_tuples,
108  compositeparticles_tuple_list,
109  cut_off=5.0,
110  lam=1.0,
111  plateau=0.0,
112  resolution=None,
113  label="None"):
114 
115  # composite particles: all particles beside the handle
116  self.label = label
117  self.m = representation.prot.get_model()
118  self.rs = IMP.RestraintSet(self.m, 'cr')
119 
120  self.handleparticles = []
121  for s in handleparticles_tuples:
122  self.handleparticles += IMP.pmi.tools.select_by_tuple(
123  representation, s,
124  resolution=resolution, name_is_ambiguous=True)
125  self.compositeparticles = []
126  compositeparticle_list = []
127  for list in compositeparticles_tuple_list:
128  tmplist = []
129  for s in list:
130  tmplist += IMP.pmi.tools.select_by_tuple(
131  representation, s,
132  resolution=resolution, name_is_ambiguous=True)
133  compositeparticle_list.append(tmplist)
134  self.compositeparticles += tmplist
135 
137  self.m,
138  self.handleparticles,
139  cut_off,
140  lam,
141  True,
142  plateau)
143 
144  for ps in compositeparticle_list:
145  # composite particles is a list of list of particles
146  ln.add_composite_particle(ps)
147 
148  self.rs.add_restraint(ln)
149 
150  def set_label(self, label):
151  self.label = label
152 
153  def get_handle_particles(self):
154  return self.handleparticles
155 
156  def get_composite_particles(self):
157  return self.compositeparticles
158 
159  def get_restraint(self):
160  return self.rs
161 
162  def add_to_model(self):
163  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
164 
165  def get_output(self):
166  output = {}
167  score = self.rs.unprotected_evaluate(None)
168  output["_TotalScore"] = str(score)
169  output["CompositeRestraint_" + self.label] = str(score)
170  return output
171 
172 
173 #
175 
176  '''
177  this restraint allows ambiguous crosslinking between multiple copies
178  excluding between symmetric copies
179  It allows name ambiguity
180  '''
181 
182  def __init__(
183  self,
184  representation,
185  restraints_file,
186  cut_off=5.0,
187  lam=1.0,
188  plateau=0.01,
189  resolution=None,
190  label="None"):
191 
192  self.weight = 1.0
193  self.m = representation.prot.get_model()
194  self.rs = IMP.RestraintSet(self.m, 'data')
195  self.label = "None"
196  self.pairs = []
197 
198  self.outputlevel = "low"
199  self.cut_off = cut_off
200  self.lam = lam
201  self.plateau = plateau
202 
203  fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
204 
205  for line in fl:
206 
207  tokens = line.split()
208  # skip character
209  if (tokens[0] == "#"):
210  continue
211  r1 = int(tokens[2])
212  c1 = tokens[0]
213  r2 = int(tokens[3])
214  c2 = tokens[1]
215 
216  ps1 = IMP.pmi.tools.select(
217  representation,
218  resolution=resolution,
219  name=c1,
220  name_is_ambiguous=True,
221  residue=r1)
222  hrc1 = [representation.hier_db.particle_to_name[p] for p in ps1]
223  ps1nosym = [
224  p for p in ps1 if IMP.pmi.Symmetric(
225  p).get_symmetric(
226  ) == 0]
227  hrc1nosym = [representation.hier_db.particle_to_name[p]
228  for p in ps1nosym]
229 
230  if len(ps1) == 0:
231  warnings.warn(
232  "AmbiguousCompositeRestraint: residue %d of chain %s "
233  "is not there" % (r1, c1), IMP.pmi.StructureWarning)
234  continue
235 
236  ps2 = IMP.pmi.tools.select(
237  representation,
238  resolution=resolution,
239  name=c2,
240  name_is_ambiguous=True,
241  residue=r2)
242  hrc2 = [representation.hier_db.particle_to_name[p] for p in ps2]
243  ps2nosym = [
244  p for p in ps2 if IMP.pmi.Symmetric(
245  p).get_symmetric(
246  ) == 0]
247  hrc2nosym = [representation.hier_db.particle_to_name[p]
248  for p in ps2nosym]
249 
250  if len(ps2) == 0:
251  warnings.warn(
252  "AmbiguousCompositeRestraint: residue %d of chain %s "
253  "is not there" % (r2, c2), IMP.pmi.StructureWarning)
254  continue
255 
257  self.m,
258  ps1nosym,
259  self.cut_off,
260  self.lam,
261  True,
262  self.plateau)
263  cr.add_composite_particle(ps2)
264 
265  self.rs.add_restraint(cr)
266  self.pairs.append(
267  (ps1nosym,
268  hrc1nosym,
269  c1,
270  r1,
271  ps2,
272  hrc2,
273  c2,
274  r2,
275  cr))
276 
278  self.m,
279  ps1,
280  self.cut_off,
281  self.lam,
282  True,
283  self.plateau)
284  cr.add_composite_particle(ps2nosym)
285 
286  self.rs.add_restraint(cr)
287  self.pairs.append(
288  (ps1,
289  hrc1,
290  c1,
291  r1,
292  ps2nosym,
293  hrc2nosym,
294  c2,
295  r2,
296  cr))
297 
298  def plot_restraint(
299  self,
300  maxdist=100,
301  npoints=100):
302 
303  p1 = IMP.Particle(self.m)
304  p2 = IMP.Particle(self.m)
308  self.m,
309  [p1],
310  self.cut_off,
311  self.lam,
312  True,
313  self.plateau)
314  cr.add_composite_particle([p2])
315  dists = []
316  scores = []
317  for i in range(npoints):
318  d2.set_coordinates(
319  IMP.algebra.Vector3D(maxdist / npoints * float(i), 0, 0))
320  dists.append(IMP.core.get_distance(d1, d2))
321  scores.append(cr.unprotected_evaluate(None))
322  IMP.pmi.output.plot_xy_data(dists, scores)
323 
324  def set_label(self, label):
325  self.label = label
326  self.rs.set_name(label)
327  for r in self.rs.get_restraints():
328  r.set_name(label)
329 
330  def add_to_model(self):
331  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
332 
333  def get_hierarchies(self):
334  return self.prot
335 
336  def get_restraint_sets(self):
337  return self.rs
338 
339  def get_restraint(self):
340  return self.rs
341 
342  def set_output_level(self, level="low"):
343  # this might be "low" or "high"
344  self.outputlevel = level
345 
346  def set_weight(self, weight):
347  self.weight = weight
348  self.rs.set_weight(weight)
349 
350  def get_output(self):
351  # content of the crosslink database pairs
352  # self.pairs.append((p1,p2,dr,r1,c1,r2,c2))
353  output = {}
354  score = self.weight * self.rs.unprotected_evaluate(None)
355  output["_TotalScore"] = str(score)
356  output["AmbiguousCompositeRestraint_Score_" + self.label] = str(score)
357  for n, p in enumerate(self.pairs):
358 
359  ps1 = p[0]
360  hrc1 = p[1]
361  c1 = p[2]
362  r1 = p[3]
363  ps2 = p[4]
364  hrc2 = p[5]
365  c2 = p[6]
366  r2 = p[7]
367  cr = p[8]
368  for n1, p1 in enumerate(ps1):
369  name1 = hrc1[n1]
370 
371  for n2, p2 in enumerate(ps2):
372  name2 = hrc2[n2]
373  d1 = IMP.core.XYZR(p1)
374  d2 = IMP.core.XYZR(p2)
375  label = str(r1) + ":" + name1 + "_" + str(r2) + ":" + name2
376  output["AmbiguousCompositeRestraint_Distance_" +
377  label] = str(IMP.core.get_distance(d1, d2))
378 
379  label = str(r1) + ":" + c1 + "_" + str(r2) + ":" + c2
380  output["AmbiguousCompositeRestraint_Score_" +
381  label] = str(self.weight * cr.unprotected_evaluate(None))
382 
383  return output
384 
385 
386 #
387 class SimplifiedPEMAP(object):
388 
389  def __init__(
390  self,
391  representation,
392  restraints_file,
393  expdistance,
394  strength,
395  resolution=None):
396 
397  self.m = representation.prot.get_model()
398  self.rs = IMP.RestraintSet(self.m, 'data')
399  self.label = "None"
400  self.pairs = []
401 
402  self.outputlevel = "low"
403  self.expdistance = expdistance
404  self.strength = strength
405 
406  fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
407 
408  for line in fl:
409 
410  tokens = line.split()
411  # skip character
412  if (tokens[0] == "#"):
413  continue
414  r1 = int(tokens[2])
415  c1 = tokens[0]
416  r2 = int(tokens[3])
417  c2 = tokens[1]
418  pcc = float(tokens[4])
419 
420  ps1 = IMP.pmi.tools.select(
421  representation,
422  resolution=resolution,
423  name=c1,
424  name_is_ambiguous=False,
425  residue=r1)
426  if len(ps1) == 0:
427  warnings.warn(
428  "SimplifiedPEMAP: residue %d of chain %s is not there "
429  "(w/ %d %s)" % (r1, c1, r2, c2), IMP.pmi.StructureWarning)
430  continue
431  if len(ps1) > 1:
432  warnings.warn(
433  "SimplifiedPEMAP: residue %d of chain %s selected "
434  "multiple particles" % (r1, c1), IMP.pmi.StructureWarning)
435  continue
436 
437  ps2 = IMP.pmi.tools.select(
438  representation,
439  resolution=resolution,
440  name=c2,
441  name_is_ambiguous=False,
442  residue=r2)
443  if len(ps2) == 0:
444  warnings.warn(
445  "SimplifiedPEMAP: residue %d of chain %s is not there "
446  "(w/ %d %s)" % (r1, c1, r2, c2), IMP.pmi.StructureWarning)
447  continue
448  if len(ps2) > 1:
449  warnings.warn(
450  "SimplifiedPEMAP: residue %d of chain %s selected "
451  "multiple particles" % (r2, c2), IMP.pmi.StructureWarning)
452  continue
453 
454  p1 = ps1[0]
455  p2 = ps2[0]
456 
457  # This is harmonic potential for the pE-MAP data
458  upperdist = self.get_upper_bond(pcc)
459  limit = self.strength * (upperdist + 15) ** 2 + 10.0
461  upperdist,
462  self.strength,
463  upperdist +
464  15,
465  limit)
466 
467  # This is harmonic for the X-link
468  #hub= IMP.core.TruncatedHarmonicBound(17.0,self.strength,upperdist+15,limit)
469 
471  dr = IMP.core.PairRestraint(self.m, df, (p1, p2))
472  self.rs.add_restraint(dr)
473  self.pairs.append((p1, p2, dr, r1, c1, r2, c2))
474 
475  # Lower-bound restraint
476  lowerdist = self.get_lower_bond(pcc)
477  limit = self.strength * (lowerdist - 15) ** 2 + 10.0
479  lowerdist,
480  self.strength,
481  lowerdist +
482  15,
483  limit)
484 
485  # This is harmonic for the X-link
486  #hub2= IMP.core.TruncatedHarmonicBound(17.0,self.strength,upperdist+15,limit)
487 
489  dr2 = IMP.core.PairRestraint(df2, (p1, p2))
490  self.rs.add_restraint(dr2)
491  self.pairs.append((p1, p2, dr2, r1, c1, r2, c2))
492 
493  def get_upper_bond(self, pearsoncc):
494  # return (pearsoncc-1.)/-0.0075
495  return (pearsoncc - .5) / (-0.005415)
496 
497  def get_lower_bond(self, pearsoncc):
498  return (pearsoncc - 1.) / -0.0551
499 
500  def set_label(self, label):
501  self.label = label
502 
503  def add_to_model(self):
504  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
505 
506  def get_hierarchies(self):
507  return self.prot
508 
509  def get_restraint_sets(self):
510  return self.rs
511 
512  def set_output_level(self, level="low"):
513  # this might be "low" or "high"
514  self.outputlevel = level
515 
516  def get_output(self):
517  # content of the crosslink database pairs
518  # self.pairs.append((p1,p2,dr,r1,c1,r2,c2))
519  output = {}
520  score = self.rs.unprotected_evaluate(None)
521  output["_TotalScore"] = str(score)
522  output["SimplifiedPEMAP_Score_" + self.label] = str(score)
523  for i in range(len(self.pairs)):
524 
525  p0 = self.pairs[i][0]
526  p1 = self.pairs[i][1]
527  crosslinker = 'standard'
528  ln = self.pairs[i][2]
529  resid1 = self.pairs[i][3]
530  chain1 = self.pairs[i][4]
531  resid2 = self.pairs[i][5]
532  chain2 = self.pairs[i][6]
533 
534  label = str(resid1) + ":" + chain1 + "_" + \
535  str(resid2) + ":" + chain2
536  output["SimplifiedPEMAP_Score_" + crosslinker + "_" +
537  label] = str(ln.unprotected_evaluate(None))
538 
539  d0 = IMP.core.XYZ(p0)
540  d1 = IMP.core.XYZ(p1)
541  output["SimplifiedPEMAP_Distance_" +
542  label] = str(IMP.core.get_distance(d0, d1))
543 
544  return output
545 
546 
548 
549  '''
550  generates and wraps a IMP.pmi.ConnectivityRestraint between domains
551  example:
552  cr=restraints.ConnectivityNetworkRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")])
553  cr.add_to_model()
554  cr.set_label("CR1")
555 
556  Multistate support =No
557  Selection type=selection tuple
558  Resolution=Yes
559  '''
560 
561  def __init__(
562  self,
563  representation=None,
564  objects=None,
565  kappa=10.0,
566  resolution=1.0,
567  label="None"):
568 
569  self.weight = 1.0
570  self.kappa = kappa
571  self.label = label
572  if self.label == "None":
573  self.label = str(selection_tuples)
574 
575  hiers=[]
576 
577  if representation is None:
578  print(objects)
579  for obj in objects:
580  hiers.append(IMP.pmi.tools.input_adaptor(obj,
581  resolution,
582  flatten=True))
583  self.m=hiers[0][0].get_model()
584  else:
585  self.m = representation.m
586  for s in objects:
587  hiers.append(IMP.pmi.tools.select_by_tuple(representation, s,
588  resolution=resolution,
589  name_is_ambiguous=False))
590 
591  #particles=[h.get_particle() for h in hiers]
592  cr = ConnectivityNetworkRestraint(self.m)
593  for hs in hiers:
594  cr.add_particles([h.get_particle() for h in hs])
595  self.rs = IMP.RestraintSet(self.m, label)
596  self.rs.add_restraint(cr)
597 
598  def set_label(self, label):
599  self.label = label
600  self.rs.set_name(label)
601  for r in self.rs.get_restraints():
602  r.set_name(label)
603 
604  def add_to_model(self):
605  IMP.pmi.tools.add_restraint_to_model(self.m, self.rs)
606 
607  def get_restraint(self):
608  return self.rs
609 
610  def get_restraints(self):
611  rlist = []
612  for r in self.rs.get_restraints():
613  rlist.append(IMP.core.PairRestraint.get_from(r))
614  return rlist
615 
616  def set_weight(self, weight):
617  self.weight = weight
618  self.rs.set_weight(weight)
619 
620  def get_output(self):
621  output = {}
622  score = self.weight * self.rs.unprotected_evaluate(None)
623  output["_TotalScore"] = str(score)
624  output["ConnectivityNetworkRestraint_" + self.label] = str(score)
625  return output
626 
627 
629 
630  '''
631  a python restraint that computes the score for a composite of proteins
632  Authors: G. Bouvier, R. Pellarin. Pasteur Institute.
633  '''
634 
635  def __init__(self, m, slope=1.0, theta=0.0, plateau=0.0000000001, linear_slope=0.015):
636  '''
637  input a list of particles, the slope and theta of the sigmoid potential
638  theta is the cutoff distance for a protein-protein contact
639  '''
640  # Import networkx here so that we don't introduce it as a dependency
641  # for *every* proteomics restraint, only this one
642  import networkx
643  self.networkx = networkx
644  IMP.Restraint.__init__(self, m, "ConnectivityNetworkRestraint %1%")
645  self.slope = slope
646  self.theta = theta
647  self.linear_slope = linear_slope
648  self.plateau = plateau
649  self.particles_blocks = []
650  self.particle_list = []
651 
652  def get_number_of_particle_blocks(self):
653  return len(self.particles_blocks)
654 
655  def get_number_of_particles_for_block(self, block_index):
656  return len(self.particles_blocks[block_index])
657 
658  def add_particles(self, particles):
659  self.particles_blocks.append(particles)
660  self.particle_list += particles
661 
662  def get_full_graph(self):
663  '''
664  get the full graph of distances between every particle pair
665  '''
666  import scipy.spatial
667  pdist_array = numpy.array(
669  pdist_mat = scipy.spatial.distance.squareform(pdist_array)
670  pdist_mat[pdist_mat < 0] = 0
671  graph = self.networkx.Graph(pdist_mat)
672  return graph
673 
675  """
676  return the minimum spanning tree
677  """
678  graph = self.get_full_graph()
679  graph = self.networkx.minimum_spanning_tree(graph)
680  return graph
681 
682  def sigmoid(self, x):
683  '''
684  a sigmoid function that scores the probability of a contact
685  between two proteins
686  '''
687  # return 1 - (x)**self.slope/ float(((x)**self.slope +
688  # self.theta**self.slope))
689  argvalue = (x - self.theta) / self.slope
690  return 1.0 - (1.0 - self.plateau) / (1.0 + math.exp(-argvalue))
691 
692  def unprotected_evaluate(self, da):
693  graph = self.get_minimum_spanning_tree()
694  score = 0.0
695  for e in graph.edges():
696  dist = graph.get_edge_data(*e)['weight']
697  prob = self.sigmoid(dist)
698  score += -numpy.log(prob)
699  score += self.linear_slope * dist
700  return score
701 
702  def do_get_inputs(self):
703  return self.particle_list
704 
705 
706 class FuzzyBoolean(object):
707 
708  '''
709  Fully Ambiguous Restraint that can be built using boolean logic
710  R. Pellarin. Pasteur Institute.
711  '''
712 
713  def __init__(self, p1, operator=None, p2=None):
714  '''
715  input a list of particles, the slope and theta of the sigmoid potential
716  theta is the cutoff distance for a protein-protein contact
717  '''
718  if isinstance(p1, FuzzyBoolean) and isinstance(p2, FuzzyBoolean):
719  self.operations = [p1, operator, p2]
720  self.value = None
721  else:
722  self.operations = []
723  self.value = p1
724 
725  def __or__(self, FuzzyBoolean2):
726  return FuzzyBoolean(self, self.or_, FuzzyBoolean2)
727 
728  def __and__(self, FuzzyBoolean2):
729  return FuzzyBoolean(self, self.and_, FuzzyBoolean2)
730 
731  def and_(self, a, b):
732  return a * b
733 
734  def or_(self, a, b):
735  return 1.0 - (1.0 - a) * (1.0 - b)
736 
737  def evaluate(self):
738 
739  if len(self.operations) == 0:
740  return self.value
741  FuzzyBoolean1, op, FuzzyBoolean2 = self.operations
742 
743  return op(FuzzyBoolean1.evaluate(), FuzzyBoolean2.evaluate())
744 
745 
747 
748  '''
749  Fully Ambiguous Restraint that can be built using boolean logic
750  R. Pellarin. Pasteur Institute.
751  '''
752  plateau = 0.00000000000001
753  theta = 5.0
754  slope = 2.0
755  innerslope = 0.01
756 
757  def __init__(self, m, p1, p2, operator=None):
758  '''
759  input a list of particles, the slope and theta of the sigmoid potential
760  theta is the cutoff distance for a protein-protein contact
761  '''
762  IMP.Restraint.__init__(self, m, "FuzzyRestraint %1%")
763  self.m = m
764  self.min = sys.float_info.min
765  if isinstance(p1, FuzzyRestraint) and isinstance(p2, FuzzyRestraint):
766  self.operations = [p1, operator, p2]
767  self.particle_pair = None
768  elif isinstance(p1, FuzzyRestraint) and p2 is None:
769  self.operations = [p1, operator, None]
770  self.particle_pair = None
771  else:
772  self.operations = []
773  self.particle_pair = (p1, p2)
774 
775  def __or__(self, FuzzyRestraint2):
776  return FuzzyRestraint(self.m, self, FuzzyRestraint2, self.or_)
777 
778  def __and__(self, FuzzyRestraint2):
779  return FuzzyRestraint(self.m, self, FuzzyRestraint2, self.and_)
780 
781  def __invert__(self):
782  return FuzzyRestraint(self.m, self, None, self.invert_)
783 
784  def and_(self, a, b):
785  c = a + b
786  return c
787 
788  def or_(self, a, b):
789  c = math.exp(-a) + math.exp(-b) - math.exp(-a - b)
790  return -math.log(c)
791 
792  def invert_(self, a):
793  c = 1.0 - math.exp(-a)
794  return -math.log(c)
795 
796  def evaluate(self):
797  if len(self.operations) == 0:
798  return self.distance()
799  FuzzyRestraint1, op, FuzzyRestraint2 = self.operations
800 
801  if FuzzyRestraint2 is not None:
802  return op(FuzzyRestraint1.evaluate(), FuzzyRestraint2.evaluate())
803  else:
804  return op(FuzzyRestraint1.evaluate())
805 
806  def distance(self):
807  d1 = IMP.core.XYZ(self.particle_pair[0])
808  d2 = IMP.core.XYZ(self.particle_pair[1])
809  d = IMP.core.get_distance(d1, d2)
810  argvalue = (d-self.theta)/self.slope
811  return -math.log(1.0 -(1.0-self.plateau)/(1.0+math.exp(-argvalue)))+self.innerslope*d
812 
813  def add_to_model(self):
815 
816  def unprotected_evaluate(self, da):
817  return self.evaluate()
818 
819  def __str__(self):
820  if len(self.operations) == 0:
821  return str(self.particle_pair)
822  FuzzyRestraint1, op, FuzzyRestraint2 = self.operations
823  if FuzzyRestraint2 is not None:
824  return str(FuzzyRestraint1) +str(op)+str(FuzzyRestraint2)
825  else:
826  return str(FuzzyRestraint1) +str(op)
827 
828  def do_get_inputs(self):
829  if len(self.operations) == 0:
830  return list(self.particle_pair)
831  FuzzyRestraint1, op, FuzzyRestraint2 = self.operations
832  if FuzzyRestraint2 is not None:
833  return list(set(FuzzyRestraint1.do_get_inputs() +FuzzyRestraint2.do_get_inputs()))
834  else:
835  return list(set(FuzzyRestraint1.do_get_inputs()))
A function that is harmonic over an interval.
this restraint allows ambiguous crosslinking between multiple copies excluding between symmetric copi...
void add_particles(RMF::FileHandle fh, const ParticlesTemp &hs)
Various classes to hold sets of particles.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition: XYZR.h:48
generate a connectivity restraint between domains setting up the restraint example: cr=restraints...
def get_full_graph
get the full graph of distances between every particle pair
Miscellaneous utilities.
Definition: tools.py:1
Add symmetric attribute to a particle.
Definition: Symmetric.h:23
A score on the distance between the surfaces of two spheres.
double get_distance(XYZR a, XYZR b)
Compute the sphere distance between a and b.
Definition: XYZR.h:89
generates and wraps a IMP.pmi.ConnectivityRestraint between domains example: cr=restraints.ConnectivityNetworkRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")]) cr.add_to_model() cr.set_label("CR1")
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:1275
Warning related to handling of structures.
a python restraint that computes the score for a composite of proteins Authors: G.
def __init__
input a list of particles, the slope and theta of the sigmoid potential theta is the cutoff distance ...
def add_restraint_to_model
Add a PMI restraint to the model.
Definition: tools.py:86
A restraint for ambiguous cross-linking MS data and multiple state approach.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
handleparticles is a selection tuple compositeparticles is a list of selection tuples ...
Classes for writing output files and processing them.
Definition: output.py:1
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...
Fully Ambiguous Restraint that can be built using boolean logic R.
def __init__
input a list of particles, the slope and theta of the sigmoid potential theta is the cutoff distance ...
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Class to handle individual particles of a Model object.
Definition: Particle.h:41
Floats get_list_of_bipartite_minimum_sphere_distance(const ParticlesTemps &pss)
Definition: utilities.h:71
def sigmoid
a sigmoid function that scores the probability of a contact between two proteins
Restraint * create_connectivity_restraint(const Selections &s, double x0, double k, std::string name="Connectivity%1%")
Create a restraint connecting the selections.
Applies a PairScore to a Pair.
Definition: PairRestraint.h:29
def select
this function uses representation=SimplifiedModel it returns the corresponding selected particles rep...
Definition: tools.py:545
Python classes to represent, score, sample and analyze models.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Definition: Selection.h:66
Fully Ambiguous Restraint that can be built using boolean logic R.
def __init__
input a list of particles, the slope and theta of the sigmoid potential theta is the cutoff distance ...
virtual ModelObjectsTemp do_get_inputs() const =0
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:54
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27