IMP logo
IMP Reference Guide  2.7.0
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 RMF
7 import IMP.atom
8 import IMP.rmf
9 import IMP.pmi
10 import IMP.pmi.topology
11 import IMP.pmi.dof
12 import IMP.pmi.macros
14 import math
15 import sys
16 
17 IMP.setup_from_argv(sys.argv, "Symmetry constraint example")
18 
19 # Create System and State
20 mdl = IMP.Model()
22 st = s.create_state()
23 
24 # Create a simple all-bead molecule
25 mol = st.create_molecule("mymol",sequence='A'*10,chain_id='A')
26 mol.add_representation(mol,
27  resolutions=[1])
28 
29 # Clone the molecule multiple times
30 # Calling molecule.create_clone makes a new molecule with the same name, sequence,
31 # initial structure, and choice of representations
32 # Note: another function, molecule.create_copy(), just copies the name and sequence
33 mols = [mol]
34 chains='BCDEFGHI'
35 for nc in range(7):
36  clone = mol.create_clone(chains[nc])
37  mols.append(clone)
38 
39 hier = s.build()
40 
41 # Create a symmetry constraint
42 # A constrant is invariant: IMP will automatically move all clones to match the reference
43 # If instead you want some more flexiblity, consider IMP.pmi.restraints.stereochemistry.SymmetryRestraint
45 center = IMP.algebra.Vector3D([50,0,0])
46 for nc in range(7):
47  rot = IMP.algebra.get_rotation_about_axis([0,0,1],2*math.pi*(nc+1)/8)
48  transform = IMP.algebra.get_rotation_about_point(center,rot)
49  dof.constrain_symmetry(mols[0],mols[nc+1],transform)
50 mdl.update() # propagates coordinates
51 
52 
53 ############ Make stuff look cool with restraints ###########
54 
55 # set up the original molecule as flexible beads
56 dof.create_flexible_beads(mols[0])
57 
58 # Create a connectivity restraint for the first molecule
60 cr.add_to_model()
61 
62 # Create excluded volume for all particles
64 evr.add_to_model()
65 
66 # Quickly move all flexible beads into place
67 dof.optimize_flexible_beads(100)
68 
69 # write a single-frame RMF to view the helix
71 out.init_rmf("example_symmetry.rmf3",hierarchies=[hier])
72 out.write_rmf("example_symmetry.rmf3")