IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pmi/symmetry.py
1## \example pmi/symmetry.py
2"""Clone molecules and use a symmetry constraint
3"""
4
5import IMP
6import IMP.atom
7import IMP.rmf
8import IMP.pmi
10import IMP.pmi.dof
11import IMP.pmi.macros
13import math
14import sys
15
16IMP.setup_from_argv(sys.argv, "Symmetry constraint example")
17
18# Create System and State
19mdl = IMP.Model()
21st = s.create_state()
22
23# Create a simple all-bead molecule
24mol = st.create_molecule("mymol", sequence='A'*10, chain_id='A')
25mol.add_representation(mol, resolutions=[1])
26
27# Clone the molecule multiple times
28# Calling molecule.create_clone makes a new molecule with the same name,
29# sequence, initial structure, and choice of representations
30# Note: another function, molecule.create_copy(), just copies the name
31# and sequence
32mols = [mol]
33chains = 'BCDEFGHI'
34for nc in range(7):
35 clone = mol.create_clone(chains[nc])
36 mols.append(clone)
37
38hier = s.build()
39
40# Create a symmetry constraint
41# A constraint is invariant: IMP will automatically move all clones to
42# match the reference
43# If instead you want some more flexibility, consider
44# IMP.pmi.restraints.stereochemistry.SymmetryRestraint
46center = IMP.algebra.Vector3D([50, 0, 0])
47for nc in range(7):
48 rot = IMP.algebra.get_rotation_about_axis([0, 0, 1], 2*math.pi*(nc+1)/8)
49 transform = IMP.algebra.get_rotation_about_point(center, rot)
50 dof.constrain_symmetry(mols[0], mols[nc+1], transform)
51mdl.update() # propagates coordinates
52
53
54# ########### Make stuff look cool with restraints ###########
55
56# set up the original molecule as flexible beads
57dof.create_flexible_beads(mols[0])
58
59# Create a connectivity restraint for the first molecule
61cr.add_to_model()
62
63# Create excluded volume for all particles
65 included_objects=mols)
66evr.add_to_model()
67
68# Quickly move all flexible beads into place
69dof.optimize_flexible_beads(100)
70
71# write a single-frame RMF to view the helix
73out.init_rmf("example_symmetry.rmf3", hierarchies=[hier])
74out.write_rmf("example_symmetry.rmf3")
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Simplify creation of constraints and movers for an IMP Hierarchy.
Class for easy writing of PDBs, RMFs, and stat files.
Definition output.py:199
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object.
A class to create an excluded volume restraint for a set of particles at a given resolution.
Represent the root node of the global IMP.atom.Hierarchy.
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
Definition Rotation3D.h:417
VectorD< 3 > Vector3D
Definition VectorD.h:407
Transformation2D get_rotation_about_point(const Vector2D &point, const Rotation2D &rotation)
Generate a Transformation2D object from a rotation around a point.
Functionality for loading, creating, manipulating and scoring atomic structures.
Create movers and set up constraints for PMI objects.
Protocols for sampling structures and analyzing them.
Definition macros.py:1
Restraints for keeping correct stereochemistry.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
Python classes to represent, score, sample and analyze models.
Support for the RMF file format for storing hierarchical molecular data and markup.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.