IMP  2.3.1
The Integrative Modeling Platform
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 
8 m.set_log_level(IMP.base.SILENT)
9 ps = []
10 # create 4 xyz particles
11 for i in range(0, 4):
12  p = IMP.kernel.Particle(m)
13  ps.append(p)
16 
17 # set the 0 particle as the reference particle for the others as
18 # they will get their positions from it
19 for i, p in enumerate(ps[1:]):
20  # the other 3 particles are all symmetric copies of the first
22  # the symmetry operation is rotation around the z axis
24  IMP.algebra.get_rotation_about_axis(IMP.algebra.get_basis_vector_3d(2),
25  3.14 / 2.0 * (
26  i + 1)),
27  IMP.algebra.Vector3D(0, 0, 0))
29  # set up a constraint for the one particle, if you have more than one with the same symmetry
30  # transform, you should use an IMP.container.SingletonsConstraint.
31  c = IMP.core.SingletonConstraint(sm, None, p)
32  m.add_score_state(c)
34  1)
35 m.add_restraint(r)
36 
37 d0 = IMP.core.XYZ(ps[0])
38 # print only optimize the main particle
39 d0.set_coordinates_are_optimized(True)
40 
42 opt.optimize(10)
43 print "score is ", m.evaluate(False)
44 for p in ps:
45  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:75
Various classes to hold sets of particles.
Simple conjugate gradients optimizer.
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Apply a SingletonFunction to a Singleton.
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
static Reference setup_particle(kernel::Model *m, ParticleIndex pi, kernel::ParticleIndexAdaptor reference)
Definition: core/symmetry.h:31
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Store a kernel::ParticleIndexes.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
Class to handle individual model particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Prevent a set of particles and rigid bodies from inter-penetrating.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73