IMP logo
IMP Reference Guide  2.6.2
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.core
6 import IMP.atom
7 import sys
8 
9 IMP.setup_from_argv(sys.argv, "edit molecular hierarchy")
10 
11 m = IMP.Model()
12 ep = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
13 
14 hchain = IMP.atom.get_by_type(ep, IMP.atom.CHAIN_TYPE)[0]
15 
16 children = hchain.get_children()
17 
18 # create two fragments with 10 residues each and transfer the residues
19 # to be their children
20 
21 f0 = IMP.atom.Fragment.setup_particle(m, m.add_particle("F0"),
23  for x in children[:10]])
24 for c in children[:10]:
25  hchain.remove_child(c)
26  f0.add_child(c)
27 
28 f1 = IMP.atom.Fragment.setup_particle(m, m.add_particle("F1"),
30  for x in children[10:20]])
31 for c in children[10:20]:
32  hchain.remove_child(c)
33  f1.add_child(c)
34 
35 # remove the rest to make the graph simple
36 for c in children[20:]:
37  hchain.remove_child(c)
38 
39 # add the fragments under the chain
40 hchain.add_child(f0)
41 hchain.add_child(f1)
42 
43 # create a graph from the hierarchy
45 
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
static Fragment setup_particle(Model *m, ParticleIndex pi)
Definition: Fragment.h:63
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
HierarchyTree get_hierarchy_tree(Hierarchy h)
Get a graph for the passed Hierarchy.
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
A decorator for a residue.
Definition: Residue.h:134
Basic functionality that is expected to be used by a wide variety of IMP users.
std::string show_graphviz(Graph g)
Functionality for loading, creating, manipulating and scoring atomic structures.