IMP logo
IMP Reference Guide  2.7.0
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 import sys
18 
19 IMP.setup_from_argv(sys.argv, "Selection in PMI")
20 
21 ################ BEFORE BUILDING ###################
22 # Preliminaries: read sequences, create a system and a state
24 mdl = IMP.Model()
26 st = s.create_state()
27 
28 # Create a molecule. This sets up "TempResidues" for all elements in the sequence.
29 mol = st.create_molecule("Rpb4",seqs["1WCM:D"],chain_id="D")
30 
31 # No structure has been built yet - you have to call 'Molecule.add_representation'
32 # The first argument to that function is a set of "TempResidues"
33 # Here are some ways of getting them:
34 
35 # Slice a molecule (uses python-style 0-ordering)
36 myres1 = mol[0:10]
37 
38 # Use PDB numbering with residue_range (inclusive on both ends)
39 myres2 = mol.residue_range('1','10')
40 
41 # If you add a PDB, this returns the set of TempResidues that were in the PDB file
42 atomic = mol.add_structure(IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
43  chain_id="D")
44 
45 # You can also call these helper functions at any time
46 atomic = mol.get_atomic_residues()
47 non_atomic = mol.get_non_atomic_residues()
48 
49 # All of the above objects are OrderedSets, so you can actually perform set operations
50 myres3 = mol[0:50] - atomic # non-atomic residues from 0 to 50
51 myres4 = mol[0:50] & atomic # atomic residues between 0 and 50
52 
53 # Finally, pass your favorite handle to add_representation
54 mol.add_representation(myres3,
55  resolutions=[1]) #creates beads with size 1 (non-atomic can only have one beadsize)
56 mol.add_representation(myres4,
57  resolutions=[1,10]) #creates beads with size 1 and 10
58 
59 # When you have decided all representations, call build()
60 # This returns an IMP hierarchy
61 hier = s.build()
62 
63 # View your creation with this function
65 
66 
67 ################ AFTER BUILDING ###################
68 # After building, only what you requested with add_representation() can be selected
69 
70 # PMI selection
71 # Most PMI functions will let you pass Molecules or TempResidues and it will automatically gather things.
73  resolution=1)
74 
75 # Similarly for rigid body creation, we recommend passing PMI objects and it will gather all resolutions
77 dof.create_rigid_body(mol,
78  nonrigid_parts = non_atomic,
79  resolution='all')
80 
81 # Advanced: IMP selection
82 # Note if you request a resolution this will find the NEAREST available resolution.
83 # E.g. if only resolution 1 is built, those particles will be returned below:
84 sel = IMP.atom.Selection(hier,resolution=10,molecule="Rpb4",residue_indexes=range(1,10))
85 particles = sel.get_selected_particles()
86 
87 # Retrieving the molecule object
88 # The molecules are stored within the state, so you can do :
89 all_mol_copies = st.molecules["Rpb4"] # a list of all copies
90 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.
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.
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.