IMP  2.4.0
The Integrative Modeling Platform
basic.py
1 """@namespace IMP.pmi.restraints.basic
2 Some miscellaneous simple restraints.
3 """
4 
5 from __future__ import print_function
6 import IMP
7 import IMP.core
8 import IMP.base
9 import IMP.algebra
10 import IMP.atom
11 import IMP.container
12 
13 
14 class ExternalBarrier(object):
15 
16  def __init__(
17  self,
18  representation,
19  radius,
20  hierarchies=None,
21  resolution=None):
22  self.m = representation.prot.get_model()
23  self.rs = IMP.RestraintSet(self.m, 'barrier')
24 
25  self.radius = radius
26  self.label = "None"
27 
28  c3 = IMP.algebra.Vector3D(0, 0, 0)
29  ub3 = IMP.core.HarmonicUpperBound(radius, 10.0)
32  # IMP.atom.get_by_type
33  particles = IMP.pmi.tools.select(
34  representation,
35  resolution=resolution,
36  hierarchies=hierarchies)
37  lsc.add_particles(particles)
39  self.rs.add_restraint(r3)
40 
41  def set_label(self, label):
42  self.label = label
43 
44  def add_to_model(self):
45  self.m.add_restraint(self.rs)
46 
47  def get_restraint(self):
48  return self.rs
49 
50  def get_output(self):
51  self.m.update()
52  output = {}
53  score = self.rs.unprotected_evaluate(None)
54  output["_TotalScore"] = str(score)
55  output["ExternalBarrier_" + self.label] = str(score)
56  return output
57 
58 
59 class DistanceRestraint(object):
60 
61  def __init__(
62  self,
63  representation,
64  tuple_selection1,
65  tuple_selection2,
66  distancemin,
67  distancemax,
68  resolution=1.0,
69  kappa=1.0):
70  self.m = representation.prot.get_model()
71  self.rs = IMP.RestraintSet(self.m, 'distance')
72  self.weight=1.0
73  self.label="None"
74 
75  #ts = IMP.core.Harmonic(distance,kappa)
76 
77  ts1 = IMP.core.HarmonicUpperBound(distancemax, kappa)
78  ts2 = IMP.core.HarmonicLowerBound(distancemin, kappa)
79 
80  # IMP.atom.get_by_type
81  particles1 = IMP.pmi.tools.select(
82  representation,
83  resolution=resolution,
84  name=tuple_selection1[2],
85  residue=tuple_selection1[0])
86  particles2 = IMP.pmi.tools.select(
87  representation,
88  resolution=resolution,
89  name=tuple_selection2[2],
90  residue=tuple_selection2[0])
91 
92  for p in particles1:
93  print(p.get_name())
94 
95  for p in particles2:
96  print(p.get_name())
97 
98  if len(particles1) > 1 or len(particles2) > 1:
99  raise ValueError("more than one particle selected")
100 
101  self.rs.add_restraint(
103  particles1[0],
104  particles2[0]))
105  self.rs.add_restraint(
107  particles1[0],
108  particles2[0]))
109 
110  def set_weight(self,weight):
111  self.weight = weight
112  self.rs.set_weight(weight)
113 
114  def set_label(self, label):
115  self.label = label
116 
117  def add_to_model(self):
118  self.m.add_restraint(self.rs)
119 
120  def get_restraint(self):
121  return self.rs
122 
123  def get_output(self):
124  self.m.update()
125  output = {}
126  score = self.weight * self.rs.unprotected_evaluate(None)
127  output["_TotalScore"] = str(score)
128  output["DistanceRestraint_" + self.label] = str(score)
129  return output
130 
131  def evaluate(self):
132  return self.weight * self.rs.unprotected_evaluate(None)
Applies a SingletonScore to each Singleton in a list.
Lower bound harmonic function (non-zero when feature < mean)
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
Object used to hold a set of restraints.
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
Distance restraint between two particles.
Store a kernel::ParticleIndexes.
Apply a function to the distance to a fixed point.
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...
VectorD< 3 > Vector3D
Definition: VectorD.h:395
def select
this function uses representation=SimplifiedModel it returns the corresponding selected particles rep...
Definition: tools.py:633
Functionality for loading, creating, manipulating and scoring atomic structures.