While we do not recommend doing serious work using restraints written in Python, it is often useful when prototyping or testing code. Copy this example and modify as needed.
11 def __init__(self, m, ps, k):
12 IMP.Restraint.__init__(self, m)
15 def unprotected_evaluate(self, da):
17 for i
in range(1, len(self.ps)):
20 if p0.get_value(k) > p1.get_value(k):
21 diff=(p0.get_value(k)-p1.get_value(k))
23 p0.add_to_derivative(k, -1, da)
24 p1.add_to_derivative(k, 1, da)
26 if IMP.get_log_level() >= IMP.base.TERSE:
27 print p0.get_name(),
"and", p1.get_name(),
" are ok"
42 r= MyRestraint(m, ps, k)
44 print r.evaluate(
True)