IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
tasks.py
1## \example parallel/tasks.py
2# This module contains the setup and task functions used by local_distance.py.
3#
4
5import IMP
6import IMP.algebra
7import IMP.core
8
9
10def setup():
11 """Create a Model containing two XYZ particles linked by a harmonic
12 distance restraint, one fixed at the origin. Return the Model,
13 the ScoringFunction, and the free XYZ particle."""
14 m = IMP.Model()
15 p1 = IMP.Particle(m)
17 p2 = IMP.Particle(m)
19 d1.set_coordinates(IMP.algebra.Vector3D(0, 0, 0))
22 return m, sf, 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# manager to the workers.
28
29
30class Task:
31
32 def __init__(self, dist):
33 self.dist = dist
34
35 def __call__(self, m, sf, 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, sf, 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, sf.evaluate(False))
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Distance restraint between two particles.
Harmonic function (symmetric about the mean)
Create a scoring function on a list of restraints.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition XYZ.h:51
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition VectorD.h:407
Basic functionality that is expected to be used by a wide variety of IMP users.
setup
Definition setup.py:1