IMP logo
IMP Reference Guide  develop.7400db2aee,2024/11/24
The Integrative Modeling Platform
selection.py
1 ## \example pmi/selection.py
2 """This script demonstrates a few different ways you can perform selection
3  in PMI.
4  In PMI we first set up molecules at various resolutions.
5  Then you call System.build() and this creates all requested representations.
6 """
7 
8 import IMP
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
29 # the sequence.
30 mol = st.create_molecule("Rpb4", seqs["1WCM:D"], chain_id="D")
31 
32 # No structure has been built yet - you have to call
33 # 'Molecule.add_representation'
34 # The first argument to that function is a set of "TempResidues"
35 # Here are some ways of getting them:
36 
37 # Slice a molecule (uses python-style 0-ordering)
38 myres1 = mol[0:10]
39 
40 # Use PDB numbering with residue_range (inclusive on both ends)
41 myres2 = mol.residue_range('1', '10')
42 
43 # If you add a PDB, this returns the set of TempResidues that were in
44 # the PDB file
45 atomic = mol.add_structure(IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
46  chain_id="D")
47 
48 # You can also call these helper functions at any time
49 atomic = mol.get_atomic_residues()
50 non_atomic = mol.get_non_atomic_residues()
51 
52 # All of the above objects are OrderedSets, so you can actually perform
53 # set operations
54 myres3 = mol[0:50] - atomic # non-atomic residues from 0 to 50
55 myres4 = mol[0:50] & atomic # atomic residues between 0 and 50
56 
57 # Finally, pass your favorite handle to add_representation
58 mol.add_representation(
59  myres3,
60  # creates beads with size 1 (non-atomic can only have one beadsize)
61  resolutions=[1])
62 mol.add_representation(myres4,
63  resolutions=[1, 10]) # creates beads with size 1 and 10
64 
65 # When you have decided all representations, call build()
66 # This returns an IMP hierarchy
67 hier = s.build()
68 
69 # View your creation with this function
71 
72 
73 # ############### AFTER BUILDING ###################
74 # After building, only what you requested with add_representation()
75 # can be selected
76 
77 # PMI selection
78 # Most PMI functions will let you pass Molecules or TempResidues and it
79 # will automatically gather things.
81  resolution=1)
82 
83 # Similarly for rigid body creation, we recommend passing PMI objects
84 # and it will gather all resolutions
86 dof.create_rigid_body(mol, nonrigid_parts=non_atomic,
87  resolution='all')
88 
89 # Advanced: IMP selection
90 # Note if you request a resolution this will find the NEAREST available
91 # resolution.
92 # e.g. if only resolution 1 is built, those particles will be returned below:
93 sel = IMP.atom.Selection(hier, resolution=10, molecule="Rpb4",
94  residue_indexes=range(1, 10))
95 particles = sel.get_selected_particles()
96 
97 # Retrieving the molecule object
98 # The molecules are stored within the state, so you can do :
99 all_mol_copies = st.molecules["Rpb4"] # a list of all copies
100 mol = all_mol_copies[0]
Simplify creation 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
Represent the root node of the global IMP.atom.Hierarchy.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Classes to handle different kinds of restraints.
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object...
Create movers and set up 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:70
Support for the RMF file format for storing hierarchical molecular data and markup.