IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pmi/symmetry.py

Clone molecules and use a symmetry constraint

## \example pmi/symmetry.py
"""Clone molecules and use a symmetry constraint
"""
import IMP
import IMP.atom
import IMP.rmf
import IMP.pmi
import math
import sys
IMP.setup_from_argv(sys.argv, "Symmetry constraint example")
# Create System and State
mdl = IMP.Model()
st = s.create_state()
# Create a simple all-bead molecule
mol = st.create_molecule("mymol", sequence='A'*10, chain_id='A')
mol.add_representation(mol, resolutions=[1])
# Clone the molecule multiple times
# Calling molecule.create_clone makes a new molecule with the same name,
# sequence, initial structure, and choice of representations
# Note: another function, molecule.create_copy(), just copies the name
# and sequence
mols = [mol]
chains = 'BCDEFGHI'
for nc in range(7):
clone = mol.create_clone(chains[nc])
mols.append(clone)
hier = s.build()
# Create a symmetry constraint
# A constraint is invariant: IMP will automatically move all clones to
# match the reference
# If instead you want some more flexibility, consider
# IMP.pmi.restraints.stereochemistry.SymmetryRestraint
center = IMP.algebra.Vector3D([50, 0, 0])
for nc in range(7):
rot = IMP.algebra.get_rotation_about_axis([0, 0, 1], 2*math.pi*(nc+1)/8)
transform = IMP.algebra.get_rotation_about_point(center, rot)
dof.constrain_symmetry(mols[0], mols[nc+1], transform)
mdl.update() # propagates coordinates
# ########### Make stuff look cool with restraints ###########
# set up the original molecule as flexible beads
dof.create_flexible_beads(mols[0])
# Create a connectivity restraint for the first molecule
cr.add_to_model()
# Create excluded volume for all particles
included_objects=mols)
evr.add_to_model()
# Quickly move all flexible beads into place
dof.optimize_flexible_beads(100)
# write a single-frame RMF to view the helix
out.init_rmf("example_symmetry.rmf3", hierarchies=[hier])
out.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.