home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.20.1
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
version 2.20.1
core/pair_restraint.py
Restrain the distance between a pair of particles.
1
## \example core/pair_restraint.py
2
# Restrain the distance between a pair of particles.
3
#
4
5
import
IMP.algebra
6
import
IMP.core
7
import
sys
8
9
IMP.setup_from_argv
(sys.argv,
"pair restraint"
)
10
11
# Make two xyz particles randomly distributed in space
12
m =
IMP.Model
()
13
b =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0,0,0),
14
IMP.algebra.Vector3D
(10,10,10))
15
inds = []
16
for
i
in
range(2):
17
p = m.add_particle(
"p"
)
18
d =
IMP.core.XYZR.setup_particle
(m, p,
19
IMP.algebra.Sphere3D
(
IMP.algebra.get_random_vector_in
(b), 1))
20
inds.append(p)
21
22
# Score the distance between the two particles with a harmonic function
23
uf =
IMP.core.Harmonic
(0, 1)
24
df =
IMP.core.DistancePairScore
(uf)
25
r =
IMP.core.PairRestraint
(m, df, (inds[0], inds[1]))
26
27
# Print the current score of the restraint, without first derivatives
28
print(r.evaluate(
False
))