IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
core/symmetry.py
1 ## \example core/symmetry.py
2 # Show how to use the code in core to enforce symmetry.
3 
4 import IMP.core
5 import IMP.container
6 import sys
7 
8 IMP.setup_from_argv(sys.argv, "symmetry example")
9 
10 m = IMP.Model()
11 m.set_log_level(IMP.SILENT)
12 ps = []
13 # create 4 xyz particles
14 for i in range(0, 4):
15  p = IMP.Particle(m)
16  ps.append(p)
19 
20 # set the 0 particle as the reference particle for the others as
21 # they will get their positions from it
22 for i, p in enumerate(ps[1:]):
23  # the other 3 particles are all symmetric copies of the first
25  # the symmetry operation is rotation around the z axis
27  IMP.algebra.get_rotation_about_axis(IMP.algebra.get_basis_vector_3d(2),
28  3.14 / 2.0 * (
29  i + 1)),
30  IMP.algebra.Vector3D(0, 0, 0))
32  # set up a constraint for the one particle; if you have more than one
33  # with the same symmetry transform, you should use
34  # an IMP.container.SingletonsConstraint.
35  c = IMP.core.SingletonConstraint(sm, None, m, p)
36  m.add_score_state(c)
40 
41 d0 = IMP.core.XYZ(ps[0])
42 # print only optimize the main particle
43 d0.set_coordinates_are_optimized(True)
44 
46 opt.set_scoring_function(sf)
47 opt.optimize(10)
48 print("score is ", sf.evaluate(False))
49 for p in ps:
50  print(p.get_name(), IMP.core.XYZ(p).get_coordinates())
Simple 3D transformation class.
Set the coordinates of a particle to be a transformed version of a reference.
Definition: core/symmetry.h:76
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Various classes to hold sets of particles.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Simple conjugate gradients optimizer.
Apply a SingletonFunction to a Singleton.
Create a scoring function on a list of restraints.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
Definition: Rotation3D.h:417
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Store a list of ParticleIndexes.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
Basic functionality that is expected to be used by a wide variety of IMP users.
VectorD< 3 > Vector3D
Definition: VectorD.h:408
static Reference setup_particle(Model *m, ParticleIndex pi, ParticleIndexAdaptor reference)
Definition: core/symmetry.h:32
Prevent a set of particles and rigid bodies from inter-penetrating.
Class to handle individual particles of a Model object.
Definition: Particle.h:43