IMP
2.4.0
The Integrative Modeling Platform
IMP Mainpage
Modules
Classes
Examples
doc
examples
parallel
tasks.py
1
## \example parallel/tasks.py
2
# This module contains the setup and task functions used by local_distance.py.
3
#
4
5
import
IMP
6
import
IMP.algebra
7
import
IMP.core
8
9
10
def
setup():
11
"""Create a Model containing two XYZ particles linked by a harmonic
12
distance restraint, one fixed at the origin. Return the Model and
13
the free XYZ particle."""
14
m =
IMP.kernel.Model
()
15
p1 =
IMP.kernel.Particle
(m)
16
d1 =
IMP.core.XYZ.setup_particle
(p1)
17
p2 =
IMP.kernel.Particle
(m)
18
d2 =
IMP.core.XYZ.setup_particle
(p2)
19
d1.set_coordinates(
IMP.algebra.Vector3D
(0, 0, 0))
20
r =
IMP.core.DistanceRestraint
(
IMP.core.Harmonic
(0, 1), p1, p2)
21
m.add_restraint(r)
22
return
m, d2
23
24
# Note that setup and tasks are Python callables, i.e. functions (like setup
25
# above) or classes that implement the __call__ method (like Task below).
26
# The latter allows for parameters (Python objects) to be passed from the
27
# master to the slaves.
28
29
30
class
Task(object):
31
32
def
__init__
(self, dist):
33
self.dist = dist
34
35
def
__call__(self, m, d):
36
"""Place the free XYZ particle at the specified distance from the
37
origin. Return the distance and the model's score. Note that the
38
input parameters to this method (m and d) are those returned by
39
the setup function above."""
40
d.set_coordinates(
IMP.algebra.Vector3D
(0, 0, self.dist))
41
return
(self.dist, m.evaluate(
False
))
setup
Definition:
setup.py:1
IMP::core::XYZ::setup_particle
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition:
XYZ.h:51
IMP::core::DistanceRestraint
Distance restraint between two particles.
Definition:
DistanceRestraint.h:32
IMP::isd.TALOSReader.TALOSReader.__init__
def __init__
start the TALOSReader sequence : a dictionnary of sequence number keys and 3-letter code values...
Definition:
TALOSReader.py:23
IMP::kernel::Particle
Class to handle individual model particles.
Definition:
kernel/Particle.h:37
IMP::core
Basic functionality that is expected to be used by a wide variety of IMP users.
IMP::algebra
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
IMP::algebra::Vector3D
VectorD< 3 > Vector3D
Definition:
VectorD.h:395
IMP::kernel::Model
Class for storing model, its restraints, constraints, and particles.
Definition:
kernel/Model.h:73
IMP::core::Harmonic
Harmonic function (symmetric about the mean)
Definition:
core/Harmonic.h:24