IMP  2.3.1
The Integrative Modeling Platform
atom/edit_molecular_hierarchy.py

In this example, we read a protein from a PDB file and then add a layer of atom::Fragments below the chain.

1 ## \example atom/edit_molecular_hierarchy.py
2 # In this example, we read a protein from a PDB file and then add a
3 # layer of atom::Fragments below the chain.
4 
5 import IMP.kernel
6 import IMP.core
7 import IMP.atom
8 
10 ep = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
11 
12 hchain = IMP.atom.get_by_type(ep, IMP.atom.CHAIN_TYPE)[0]
13 
14 children = hchain.get_children()
15 
16 # create two fragments with 10 residues each and transfer the residues
17 # to be their children
18 
19 f0 = IMP.atom.Fragment.setup_particle(m, m.add_particle("F0"),
21  for x in children[:10]])
22 for c in children[:10]:
23  hchain.remove_child(c)
24  f0.add_child(c)
25 
26 f1 = IMP.atom.Fragment.setup_particle(m, m.add_particle("F1"),
28  for x in children[10:20]])
29 for c in children[10:20]:
30  hchain.remove_child(c)
31  f1.add_child(c)
32 
33 # remove the rest to make the graph simple
34 for c in children[20:]:
35  hchain.remove_child(c)
36 
37 # add the fragments under the chain
38 hchain.add_child(f0)
39 hchain.add_child(f1)
40 
41 # create a graph from the hierarchy
43 
44 IMP.base.show_graphviz(ept)