IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
atom/cg_pdb.py

This example shows how to properly write out a pdb of the structure results when using coarse grained rigid bodies.

1 ## \example atom/cg_pdb.py
2 # This example shows how to properly write out a pdb of the structure
3 # results when using coarse grained rigid bodies.
4 
5 import IMP.atom
6 import sys
7 
8 IMP.setup_from_argv(sys.argv, "CG pdb")
9 
10 m = IMP.Model()
11 full = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
12 chain = IMP.atom.get_by_type(full, IMP.atom.CHAIN_TYPE)[0]
13 print(chain)
14 # for some reason the Python wrapper won't make the implicit conversion to
15 # Chain
17  IMP.atom.Chain(chain), 3)
18 IMP.atom.destroy(full)
19 rb = IMP.atom.create_rigid_body(simplified)
20 original_transform = rb.get_reference_frame().get_transformation_to()
21 
22 
23 # fake optimization, just move the rigid body
25 rb.set_reference_frame(IMP.algebra.ReferenceFrame3D(
27 
28 # extract the difference
29 diff = rb.get_reference_frame().get_transformation_to() / original_transform
30 reload = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
31 IMP.atom.transform(reload, diff)
32 name = IMP.create_temporary_file("out", ".pdb")
33 IMP.atom.write_pdb(reload, name)