IMP Reference Guide  develop.42a12322a9,2023/03/24 The Integrative Modeling Platform
pmi/symmetry.py
1 ## \example pmi/symmetry.py
2 """Clone molecules and use a symmetry constrant
3 """
4
5 import IMP
6 import IMP.atom
7 import IMP.rmf
8 import IMP.pmi
9 import IMP.pmi.topology
10 import IMP.pmi.dof
11 import IMP.pmi.macros
13 import math
14 import sys
15
16 IMP.setup_from_argv(sys.argv, "Symmetry constraint example")
17
18 # Create System and State
19 mdl = IMP.Model()
21 st = s.create_state()
22
23 # Create a simple all-bead molecule
24 mol = st.create_molecule("mymol", sequence='A'*10, chain_id='A')
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
32 mols = [mol]
33 chains = 'BCDEFGHI'
34 for nc in range(7):
35  clone = mol.create_clone(chains[nc])
36  mols.append(clone)
37
38 hier = s.build()
39
40 # Create a symmetry constraint
41 # A constrant is invariant: IMP will automatically move all clones to
42 # match the reference
43 # If instead you want some more flexiblity, consider
44 # IMP.pmi.restraints.stereochemistry.SymmetryRestraint
46 center = IMP.algebra.Vector3D([50, 0, 0])
47 for nc in range(7):
48  rot = IMP.algebra.get_rotation_about_axis([0, 0, 1], 2*math.pi*(nc+1)/8)
50  dof.constrain_symmetry(mols[0], mols[nc+1], transform)
51 mdl.update() # propagates coordinates
52
53
54 # ########### Make stuff look cool with restraints ###########
55
56 # set up the original molecule as flexible beads
58
59 # Create a connectivity restraint for the first molecule