IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pmi/multiscale.py

This script shows how to represent a system at multiple scales and do basic sampling.

## \example pmi/multiscale.py
"""This script shows how to represent a system at multiple scales and do
basic sampling.
"""
import IMP
import IMP.atom
import IMP.rmf
import IMP.pmi
import sys
IMP.setup_from_argv(sys.argv, "Representation at multiple scales")
if IMP.get_check_level() >= IMP.USAGE_AND_INTERNAL:
print("This example is too slow to test in debug mode - run without")
print("internal tests enabled")
sys.exit(0)
# ##################### SYSTEM SETUP #####################
# Read sequences etc
components = ["Rpb1", "Rpb2", "Rpb3", "Rpb4"]
colors = ['medium purple', 'goldenrod', 'orchid', 'olive drab']
chains = "ABCD"
beadsize = 10
# Setup System and add a State
mdl = IMP.Model()
st = s.create_state()
# Add Molecules for each component as well as representations
mols = []
for n in range(len(components)):
print('PMI: setting up', components[n], '1WCM:'+chains[n])
mol = st.create_molecule( # create molecule
components[n],
sequence=seqs['1WCM:'+chains[n]],
chain_id=chains[n])
atomic = mol.add_structure(
IMP.pmi.get_example_path('data/1WCM_fitted.pdb'),
chain_id=chains[n], offset=0)
mol.add_representation(atomic, # res 1,10 for structured regions
resolutions=[1, 10],
color=colors[n])
mol.add_representation(mol[:]-atomic, # res 10 for unstructured regions
resolutions=[beadsize],
color=colors[n])
mols.append(mol)
# calling System.build() creates all States and Molecules (and their
# representations)
# Once you call build(), anything without representation is destroyed.
# You can still use handles like molecule[a:b], molecule.get_atomic_residues()
# or molecule.get_non_atomic_residues()
# However these functions will only return BUILT representations
root_hier = s.build()
# Uncomment this for verbose output of the representation
# IMP.atom.show_with_representations(root_hier)
# Setup degrees of freedom
# The DOF functions automatically select all resolutions
# Objects passed to nonrigid_parts move with the frame but also have
# their own independent movers.
for mol in mols:
dof.create_rigid_body(mol,
nonrigid_parts=mol.get_non_atomic_residues(),
max_trans=0.1,
max_rot=0.78,
nonrigid_max_trans=0.1)
# display the bonds between consecutive fragments,
# so that they are shown in the psf
# ##################### RESTRAINTS #####################
output_objects = [] # keep a list of functions that need to be reported
# Connectivity keeps things connected along the backbone (ignores if inside
# same rigid body)
crs = []
for mol in mols:
cr.add_to_model()
output_objects.append(cr)
crs.append(cr)
# Excluded volume - automatically more efficient due to rigid bodies
included_objects=mols)
evr.add_to_model()
output_objects.append(evr)
# ##################### SAMPLING #####################
# First shuffle the system
IMP.pmi.tools.shuffle_configuration(root_hier, max_translation=30)
# Quickly move all flexible beads into place
dof.optimize_flexible_beads(100)
# Run replica exchange Monte Carlo sampling
mdl,
# pass the root hierarchy
root_hier=root_hier,
# pass MC movers
monte_carlo_sample_objects=dof.get_movers(),
global_output_directory='multiscale_output/',
output_objects=output_objects,
monte_carlo_steps=10,
# set >0 to store best PDB files (but this is slow to do online)
number_of_best_scoring_models=0,
# increase number of frames to get better results!
number_of_frames=1)
rex.execute_macro()
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Simplify creation of constraints and movers for an IMP Hierarchy.
A macro to help setup and run replica exchange.
Definition macros.py:164
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object.
A class to create an excluded volume restraint for a set of particles at a given resolution.
A dictionary-like wrapper for reading and storing sequence data.
Represent the root node of the global IMP.atom.Hierarchy.
Functionality for loading, creating, manipulating and scoring atomic structures.
Create movers and set up constraints for PMI objects.
Protocols for sampling structures and analyzing them.
Definition macros.py:1
Restraints for keeping correct stereochemistry.
Classes to handle different kinds of restraints.
display_bonds(mol)
Decorate the sequence-consecutive particles from a PMI2 molecule with a bond, so that they appear con...
shuffle_configuration(objects, max_translation=300.0, max_rotation=2.0 *math.pi, avoidcollision_rb=True, avoidcollision_fb=False, cutoff=10.0, niterations=100, bounding_box=None, excluded_rigid_bodies=[], hierarchies_excluded_from_collision=[], hierarchies_included_in_collision=[], verbose=False, return_debug=False)
Shuffle particles.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
Python classes to represent, score, sample and analyze models.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Support for the RMF file format for storing hierarchical molecular data and markup.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
CheckLevel get_check_level()
Get the current audit mode.
Definition exception.h:80