IMP
2.1.1
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
File List
File Members
simple.py
1
## \example core/simple.py
2
# Illustration of simple usage of the IMP library from Python.
3
#
4
5
import
IMP
6
import
IMP.algebra
7
import
IMP.core
8
9
m =
IMP.kernel.Model
()
10
11
# Create two "untyped" Particles
12
p1 =
IMP.kernel.Particle
(m)
13
p2 =
IMP.kernel.Particle
(m)
14
15
# "Decorate" the Particles with x,y,z attributes (point-like particles)
16
d1 =
IMP.core.XYZ.setup_particle
(p1)
17
d2 =
IMP.core.XYZ.setup_particle
(p2)
18
19
# Use some XYZ-specific functionality (set coordinates)
20
d1.set_coordinates(
IMP.algebra.Vector3D
(10.0, 10.0, 10.0))
21
d2.set_coordinates(
IMP.algebra.Vector3D
(-10.0, -10.0, -10.0))
22
print
d1, d2
23
24
# Harmonically restrain p1 to be zero distance from the origin
25
f =
IMP.core.Harmonic
(0.0, 1.0)
26
s =
IMP.core.DistanceToSingletonScore
(f,
IMP.algebra.Vector3D
(0., 0., 0.))
27
r1 =
IMP.core.SingletonRestraint
(s, p1)
28
m.add_restraint(r1)
29
30
# Harmonically restrain p1 and p2 to be distance 5.0 apart
31
f =
IMP.core.Harmonic
(5.0, 1.0)
32
s =
IMP.core.DistancePairScore
(f)
33
r2 =
IMP.core.PairRestraint
(s, (p1, p2))
34
m.add_restraint(r2)
35
36
# Optimize the x,y,z coordinates of both particles with conjugate gradients
37
d1.set_coordinates_are_optimized(
True
)
38
d2.set_coordinates_are_optimized(
True
)
39
o =
IMP.core.ConjugateGradients
(m)
40
o.optimize(50)
41
print
d1, d2
IMP::core::ConjugateGradients
Simple conjugate gradients optimizer.
Definition:
core/ConjugateGradients.h:33
IMP::core::XYZ::setup_particle
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition:
XYZ.h:53
IMP::algebra::VectorD< 3 >
IMP::core::GenericDistanceToSingletonScore
Apply a function to the distance to a fixed point.
Definition:
DistanceToSingletonScore.h:34
IMP::kernel::Particle
Class to handle individual model particles.
Definition:
kernel/declare_Particle.h:34
IMP::core::DistancePairScore
Definition:
core/DistancePairScore.h:22
IMP::core
See IMP.core for more information.
Definition:
AngleRestraint.h:19
IMP::algebra
See IMP.algebra for more information.
Definition:
algebra_config.h:113
IMP::core::PairRestraint
Applies a PairScore to a Pair.
Definition:
PairRestraint.h:30
IMP::core::SingletonRestraint
Applies a SingletonScore to a Singleton.
Definition:
SingletonRestraint.h:30
IMP::kernel::Model
Class for storing model, its restraints, constraints, and particles.
Definition:
kernel/declare_Model.h:72
IMP::core::Harmonic
Harmonic function (symmetric about the mean)
Definition:
core/Harmonic.h:25