IMP logo
IMP Reference Guide  2.6.2
The Integrative Modeling Platform
selection.py
1 ## \example pmi/selection.py
2 """This script demonstrates a few different ways you can perform selection in PMI.
3 In PMI we first set up molecules at various resolutions.
4 Then you call System.build() and this creates all requested representations.
5 """
6 
7 import IMP
8 import RMF
9 import IMP.atom
10 import IMP.rmf
11 import IMP.pmi
12 import IMP.pmi.topology
13 import IMP.pmi.dof
14 import IMP.pmi.macros
15 import IMP.pmi.restraints
17 
18 ################ BEFORE BUILDING ###################
19 # Preliminaries: read sequences, create a system and a state
21 mdl = IMP.Model()
23 st = s.create_state()
24 
25 # Create a molecule. This sets up "TempResidues" for all elements in the sequence.
26 mol = st.create_molecule("Rpb4",seqs["1WCM:D"],chain_id="D")
27 
28 # No structure has been built yet - you have to call 'Molecule.add_representation'
29 # The first argument to that function is a set of "TempResidues"
30 # Here are some ways of getting them:
31 
32 # Slice a molecule (uses python-style 0-ordering)
33 myres1 = mol[0:10]
34 
35 # Use PDB numbering with residue_range (inclusive on both ends)
36 myres2 = mol.residue_range('1','10')
37 
38 # If you add a PDB, this returns the set of TempResidues that were in the PDB file
39 atomic = mol.add_structure(IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
40  chain_id="D")
41 
42 # You can also call these helper functions at any time
43 atomic = mol.get_atomic_residues()
44 non_atomic = mol.get_non_atomic_residues()
45 
46 # All of the above objects are OrderedSets, so you can actually perform set operations
47 myres3 = mol[0:50] - atomic # non-atomic residues from 0 to 50
48 myres4 = mol[0:50] & atomic # atomic residues between 0 and 50
49 
50 # Finally, pass your favorite handle to add_representation
51 mol.add_representation(myres3,
52  resolutions=[1]) #creates beads with size 1 (non-atomic can only have one beadsize)
53 mol.add_representation(myres4,
54  resolutions=[1,10]) #creates beads with size 1 and 10
55 
56 # When you have decided all representations, call build()
57 # This returns an IMP hierarchy
58 hier = s.build()
59 
60 # View your creation with this function
62 
63 
64 ################ AFTER BUILDING ###################
65 # After building, only what you requested with add_representation() can be selected
66 
67 # PMI selection
68 # Most PMI functions will let you pass Molecules or TempResidues and it will automatically gather things.
70  resolution=1)
71 
72 # Similarly for rigid body creation, we recommend passing PMI objects and it will gather all resolutions
74 dof.create_rigid_body(mol,
75  nonrigid_parts = non_atomic,
76  resolution='all')
77 
78 # Advanced: IMP selection
79 # Note if you request a resolution this will find the NEAREST available resolution.
80 # E.g. if only resolution 1 is built, those particles will be returned below:
81 sel = IMP.atom.Selection(hier,resolution=10,molecule="Rpb4",residue_indexes=range(1,10))
82 particles = sel.get_selected_particles()
83 
84 # Retrieving the molecule object
85 # The molecules are stored within the state, so you can do :
86 all_mol_copies = st.molecules["Rpb4"] # a list of all copies
87 mol = all_mol_copies[0]
A class to simplify create of constraints and movers for an IMP Hierarchy.
Restraints for keeping correct stereochemistry.
void show_with_representations(Hierarchy h, std::ostream &out=std::cout)
Traverse through the tree and show atom info, including representations.
Set of python classes to create a multi-state, multi-resolution IMP hierarchy.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Protocols for sampling structures and analyzing them.
Definition: macros.py:1
This class initializes the root node of the global IMP.atom.Hierarchy.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Classes to handle different kinds of restraints.
This class creates a restraint between consecutive TempResidue objects OR an entire PMI MOlecule obje...
Create movers and setup constraints for PMI objects.
Python classes to represent, score, sample and analyze models.
A dictionary-like wrapper for reading and storing sequence data.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Definition: Selection.h:66
Support for the RMF file format for storing hierarchical molecular data and markup.