IMP logo
IMP Reference Guide  2.16.0
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 
5 from __future__ import print_function
6 import IMP.atom
7 import sys
8 
9 IMP.setup_from_argv(sys.argv, "CG pdb")
10 
11 m = IMP.Model()
12 full = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
13 chain = IMP.atom.get_by_type(full, IMP.atom.CHAIN_TYPE)[0]
14 print(chain)
15 # for some reason the Python wrapper won't make the implicit conversion to
16 # Chain
18  IMP.atom.Chain(chain), 3)
19 IMP.atom.destroy(full)
20 rb = IMP.atom.create_rigid_body(simplified)
21 original_transform = rb.get_reference_frame().get_transformation_to()
22 
23 
24 # fake optimization, just move the rigid body
26 rb.set_reference_frame(IMP.algebra.ReferenceFrame3D(
28 
29 # extract the difference
30 diff = rb.get_reference_frame().get_transformation_to() / original_transform
31 reload = IMP.atom.read_pdb(IMP.atom.get_example_path("example_protein.pdb"), m)
32 IMP.atom.transform(reload, diff)
33 name = IMP.create_temporary_file("out", ".pdb")
34 IMP.atom.write_pdb(reload, name)
Simple 3D transformation class.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Rotation3D get_random_rotation_3d(const Rotation3D &center, double distance)
Pick a rotation at random near the provided one.
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 read_pdb(TextInput input, int model, Hierarchy h)
TextOutput create_temporary_file(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file. The path can be extracted from the TextOutput.
A reference frame in 3D.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
VectorD< 3 > Vector3D
Definition: VectorD.h:421
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Store info for a chain of a protein.
Definition: Chain.h:61
Functionality for loading, creating, manipulating and scoring atomic structures.