IMP  2.3.1
The Integrative Modeling Platform
molecular_hierarchy.py
1 ## \example atom/molecular_hierarchy.py
2 # In this example, we read a protein from a PDB file and set the center and radius of each residue to enclose the atoms in that residue.
3 #
4 # Then a second copy of the protein is loaded and they are both added to the same hierarchy
5 # to define a hypothetical assembly.
6 #
7 
8 import IMP
9 import IMP.core
10 import IMP.atom
11 
12 m = IMP.kernel.Model()
13 mp0 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
14 # get the 16th residue of the first chain
15 hchain = IMP.atom.get_by_type(mp0, IMP.atom.CHAIN_TYPE)[0]
16 # decorate the chain particle with an IMP.atom.Chain decorator.
17 # unfortunately, our python wrapper does not handle converseions properly
18 # as a result you have to manually get the particle for that chain
19 chain = IMP.atom.Chain(hchain.get_particle())
20 r16 = IMP.atom.get_residue(chain, 16)
21 r16.show()
22 
23 # get all the atoms
24 atoms = IMP.atom.get_by_type(mp0, IMP.atom.ATOM_TYPE)
25 # I didn't really have anything interesting to do with them...
26 
27 # create a new version of the protein that is coarsened (one particle per
28 # residue)
30 
31 # we don't need mp0 any more
33 
34 # load another copy
35 mp1 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
36 
37 # create a graph from the hierarchy
39 # process the file with dot like
40 # dot -Tpdf hierarchy.dot > hierarchy.pdf
41 mp1t.show_graphviz(open("hierarchy.dot", "w"))
42 # try to display it graphically, assuming altgraph is installed
43 try:
44  mp1t.show_with_altgraph()
45 except:
46  pass
47 
48 # make this one rigid
50 
51 # create a hierarchy which contains the two proteins
54 rmp.add_child(smp0)
55 rmp.add_child(mp1)
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
HierarchyTree get_hierarchy_tree(Hierarchy h)
Get a graph for the passed Hierarchy.
Hierarchy get_residue(Hierarchy mhd, unsigned int index)
Get the residue with the specified index.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Class to handle individual model particles.
void destroy(Hierarchy d)
Delete the Hierarchy.
Basic functionality that is expected to be used by a wide variety of IMP users.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Store info for a chain of a protein.
Definition: Chain.h:21
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73