IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
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.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 residue)
28
smp0=
IMP.atom.create_simplified_along_backbone
(chain, 1)
29
30
# we don't need mp0 any more
31
IMP.atom.destroy
(mp0)
32
33
# load another copy
34
mp1=
IMP.atom.read_pdb
(
IMP.atom.get_example_path
(
'example_protein.pdb'
), m)
35
36
# create a graph from the hierarchy
37
mp1t=
IMP.atom.get_hierarchy_tree
(mp1)
38
# process the file with dot like
39
# dot -Tpdf hierarchy.dot > hierarchy.pdf
40
mp1t.show_graphviz(open(
"hierarchy.dot"
,
"w"
))
41
# try to display it graphically, assuming altgraph is installed
42
try
:
43
mp1t.show_with_altgraph()
44
except
:
45
pass
46
47
# make this one rigid
48
IMP.atom.create_rigid_body
(mp1)
49
50
# create a hierarchy which contains the two proteins
51
p =
IMP.Particle
(m)
52
rmp=
IMP.atom.Hierarchy.setup_particle
(p)
53
rmp.add_child(smp0)
54
rmp.add_child(mp1)