IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
atom/molecular_hierarchy.py

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. Then a second copy of the protein is loaded and they are both added to the same hierarchy to define a hypothetical assembly.

1 ## \example atom/molecular_hierarchy.py
2 # In this example, we read a protein from a PDB file and set the center and
3 # radius of each residue to enclose the atoms in that residue.
4 #
5 # Then a second copy of the protein is loaded and they are both added to the
6 # same hierarchy to define a hypothetical assembly.
7 #
8 
9 import IMP
10 import IMP.core
11 import IMP.atom
12 import sys
13 
14 IMP.setup_from_argv(sys.argv, "molecular hierarchy")
15 
16 m = IMP.Model()
17 mp0 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
18 # get the 16th residue of the first chain
19 hchain = IMP.atom.get_by_type(mp0, IMP.atom.CHAIN_TYPE)[0]
20 # decorate the chain particle with an IMP.atom.Chain decorator.
21 # unfortunately, our Python wrapper does not handle conversions properly
22 # as a result you have to manually get the particle for that chain
23 chain = IMP.atom.Chain(hchain.get_particle())
24 r16 = IMP.atom.get_residue(chain, 16)
25 r16.show()
26 
27 # get all the atoms
28 atoms = IMP.atom.get_by_type(mp0, IMP.atom.ATOM_TYPE)
29 # I didn't really have anything interesting to do with them...
30 
31 # create a new version of the protein that is coarsened (one particle per
32 # residue)
34 
35 # we don't need mp0 any more
36 IMP.atom.destroy(mp0)
37 
38 # load another copy
39 mp1 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
40 
41 # create a graph from the hierarchy
43 # process the file with dot like
44 # dot -Tpdf hierarchy.dot > hierarchy.pdf
45 mp1t.show_graphviz(open("hierarchy.dot", "w"))
46 # try to display it graphically, assuming altgraph is installed
47 try:
48  mp1t.show_with_altgraph()
49 except:
50  pass
51 
52 # make this one rigid
54 
55 # create a hierarchy which contains the two proteins
56 p = IMP.Particle(m)
58 rmp.add_child(smp0)
59 rmp.add_child(mp1)