IMP  2.1.1
The Integrative Modeling Platform
edit_molecular_hierarchy.py
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)
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
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)
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
See IMP.kernel for more information.
A decorator for a residue.
Definition: Residue.h:133
See IMP.core for more information.
static Fragment setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: Fragment.h:66
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.