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