IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
rigid_collisions.py
1
## \example core/rigid_collisions.py
2
## Collision detection and building of a non-bonded list can be sped up when rigid bodies are used.
3
## To do this, use a RigidClosePairsFinder.
4
5
import
IMP
6
import
IMP.core
7
import
IMP.atom
8
import
IMP.container
9
10
# This example addes a restraint on nonbonded interactions
11
# Since it is between two rigid bodies, internal interactions are ignored
12
13
m=
IMP.Model
()
14
# The particles in the rigid bodies
15
rbps0=
IMP.core.create_xyzr_particles
(m, 3, 1)
16
rbps1=
IMP.core.create_xyzr_particles
(m, 3, 1)
17
18
rbp0=
IMP.Particle
(m)
19
rbp1=
IMP.Particle
(m)
20
21
rbss0 =
IMP.core.RigidBody.setup_particle
(rbp0, IMP.core.XYZs(rbps0))
22
23
rbss1 =
IMP.core.RigidBody.setup_particle
(rbp1, IMP.core.XYZs(rbps1))
24
25
lsc=
IMP.container.ListSingletonContainer
(m)
26
lsc.add_particles(rbps0)
27
lsc.add_particles(rbps1)
28
29
# Set up the nonbonded list
30
nbl=
IMP.container.ClosePairContainer
(lsc, 0,
IMP.core.RigidClosePairsFinder
(), 2.0)
31
32
# Set up excluded volume
33
ps=
IMP.core.SphereDistancePairScore
(
IMP.core.HarmonicLowerBound
(0,1))
34
evr=
IMP.container.PairsRestraint
(ps, nbl)
35
evri= m.add_restraint(evr)
36
37
# Set up optimizer
38
o=
IMP.core.ConjugateGradients
()
39
o.set_model(m)
40
41
done=
False
42
while
not
done:
43
try
:
44
o.optimize(1000)
45
except
IMP.base.ModelException
:
46
for
d
in
[rbss0, rbss1]:
47
d.set_transformation(
IMP.algebra.Transformation3D
(
IMP.algebra.get_random_rotation_3d
(),
48
IMP.algebra.get_random_vector_in
(
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0,0,0),
49
IMP.algebra.Vector3D
(10,10,10)))))
50
else
:
51
done=
True