IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
cg_pdb.py
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
5import IMP.atom
6import sys
7
8IMP.setup_from_argv(sys.argv, "CG pdb")
9
10m = IMP.Model()
11full = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
12chain = IMP.atom.get_by_type(full, IMP.atom.CHAIN_TYPE)[0]
13print(chain)
14# for some reason the Python wrapper won't make the implicit conversion to
15# Chain
17 IMP.atom.Chain(chain), 3)
19rb = IMP.atom.create_rigid_body(simplified)
20original_transform = rb.get_reference_frame().get_transformation_to()
21
22
23# fake optimization, just move the rigid body
25rb.set_reference_frame(IMP.algebra.ReferenceFrame3D(
27
28# extract the difference
29diff = rb.get_reference_frame().get_transformation_to() / original_transform
30reload = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
31IMP.atom.transform(reload, diff)
32name = IMP.create_temporary_file("out", ".pdb")
33IMP.atom.write_pdb(reload, name)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A reference frame in 3D.
Simple 3D transformation class.
Store info for a chain of a protein.
Definition Chain.h:61
void destroy(Hierarchy d)
Delete the Hierarchy.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
Rotation3D get_random_rotation_3d()
Pick a rotation at random from all possible rotations.
VectorD< 3 > Vector3D
Definition VectorD.h:407
Functionality for loading, creating, manipulating and scoring atomic structures.
IMP::core::RigidBody create_rigid_body(const Hierarchies &h, std::string name=std::string("created rigid body"))
Rigidify a molecule or collection of molecules.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
Hierarchy create_simplified_along_backbone(Hierarchy input, int num_res, bool keep_detailed=false, Model *m=nullptr)
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
TextOutput create_temporary_file(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file. The path can be extracted from the TextOutput.