IMP logo
IMP Reference Guide  2.6.2
The Integrative Modeling Platform
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 import sys
12 
13 IMP.setup_from_argv(sys.argv, "molecular hierarchy")
14 
15 m = IMP.Model()
16 mp0 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
17 # get the 16th residue of the first chain
18 hchain = IMP.atom.get_by_type(mp0, IMP.atom.CHAIN_TYPE)[0]
19 # decorate the chain particle with an IMP.atom.Chain decorator.
20 # unfortunately, our python wrapper does not handle converseions properly
21 # as a result you have to manually get the particle for that chain
22 chain = IMP.atom.Chain(hchain.get_particle())
23 r16 = IMP.atom.get_residue(chain, 16)
24 r16.show()
25 
26 # get all the atoms
27 atoms = IMP.atom.get_by_type(mp0, IMP.atom.ATOM_TYPE)
28 # I didn't really have anything interesting to do with them...
29 
30 # create a new version of the protein that is coarsened (one particle per
31 # residue)
33 
34 # we don't need mp0 any more
35 IMP.atom.destroy(mp0)
36 
37 # load another copy
38 mp1 = IMP.atom.read_pdb(IMP.atom.get_example_path('example_protein.pdb'), m)
39 
40 # create a graph from the hierarchy
42 # process the file with dot like
43 # dot -Tpdf hierarchy.dot > hierarchy.pdf
44 mp1t.show_graphviz(open("hierarchy.dot", "w"))
45 # try to display it graphically, assuming altgraph is installed
46 try:
47  mp1t.show_with_altgraph()
48 except:
49  pass
50 
51 # make this one rigid
53 
54 # create a hierarchy which contains the two proteins
55 p = IMP.Particle(m)
57 rmp.add_child(smp0)
58 rmp.add_child(mp1)
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
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
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
Basic functionality that is expected to be used by a wide variety of IMP users.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Class to handle individual model particles.
Definition: Particle.h:37
Store info for a chain of a protein.
Definition: Chain.h:21
Functionality for loading, creating, manipulating and scoring atomic structures.