IMP logo

IMP.modeller examples

imp_restraints_in_modeller.py

This demonstrates using IMP Restraints as additional energy terms in the Modeller scoring function, so that IMP scoring terms can be incorporated into existing comparative modeling pipelines.

import modeller
import IMP
import IMP.core
import IMP.modeller

# Set up Modeller and build a model from the GGCC primary sequence
e = modeller.environ()
e.edat.dynamic_sphere = False
e.libs.topology.read('${LIB}/top_heav.lib')
e.libs.parameters.read('${LIB}/par.lib')
modmodel = modeller.model(e)
modmodel.build_sequence('GGCC')

# Set up IMP and load the Modeller model in as a new Hierarchy
m = IMP.Model()
protein = IMP.modeller.ModelLoader(modmodel).load_atoms(m)

# Create a simple IMP distance restraint between the first and last atoms
atoms = IMP.atom.get_by_type(protein, IMP.atom.ATOM_TYPE)
r = IMP.core.DistanceRestraint(IMP.core.Harmonic(10.0, 1.0),
                               atoms[0].get_particle(),
                               atoms[-1].get_particle())
m.add_restraint(r)

# Use the IMPRestraints class to add all of the IMP restraints to the
# Modeller scoring function
t = modmodel.env.edat.energy_terms
t.append(IMP.modeller.IMPRestraints(atoms.get_particles()))

# Calculate the Modeller energy (score) for the whole protein
sel = modeller.selection(modmodel)
sel.energy()

modeller_restraints_in_imp.py

This demonstrates using Modeller restraints as additional terms in the IMP scoring function, so that existing Modeller restraints can be used in combination with new IMP restraints and optimization protocols.

import modeller
import IMP
import IMP.modeller

# Set up Modeller and build a model from the GGCC primary sequence
e = modeller.environ()
e.edat.dynamic_sphere = False
e.libs.topology.read('${LIB}/top_heav.lib')
e.libs.parameters.read('${LIB}/par.lib')
modmodel = modeller.model(e)
modmodel.build_sequence('GGCC')

# Add a simple Modeller distance restraint between the first and last atoms
feat = modeller.features.distance(modmodel.atoms[0], modmodel.atoms[-1])
r = modeller.forms.gaussian(feature=feat, mean=10.0, stdev=1.0,
                            group=modeller.physical.xy_distance)
modmodel.restraints.add(r)

# Set up IMP and load the Modeller model in as a new Hierarchy
m = IMP.Model()
protein = IMP.modeller.ModelLoader(modmodel).load_atoms(m)
atoms = IMP.atom.get_by_type(protein, IMP.atom.ATOM_TYPE)

# Use the ModellerRestraints class to add all of the Modeller restraints to
# the IMP scoring function
m.add_restraint(IMP.modeller.ModellerRestraints(modmodel,
                                                atoms.get_particles()))

# Calculate the IMP score
print m.evaluate(False)

load_modeller_model.py

This demonstrates reading in an existing Modeller model, and converting the Modeller restraints (both static and dynamic) into equivalent IMP restraints.

import modeller
import IMP
import IMP.modeller

# Set up Modeller and build a model from the GGCC primary sequence
e = modeller.environ()
e.edat.dynamic_sphere = True
e.libs.topology.read('${LIB}/top_heav.lib')
e.libs.parameters.read('${LIB}/par.lib')
modmodel = modeller.model(e)
modmodel.build_sequence('GGCC')
# Generate Modeller stereochemistry
sel = modeller.selection(modmodel)
modmodel.restraints.make(sel, restraint_type='STEREO', spline_on_site=False)

# Set up IMP and use the ModelLoader class to load the atom coordinates
# from Modeller into IMP as a new Hierarchy
m = IMP.Model()
loader = IMP.modeller.ModelLoader(modmodel)
protein = loader.load_atoms(m)

# Load each Modeller static restraint in as an IMP Restraint
for r in loader.load_static_restraints():
    m.add_restraint(r)

# Load each Modeller dynamic restraint (soft-sphere in this case) in as an
# equivalent IMP Restraint
for r in loader.load_dynamic_restraints():
    m.add_restraint(r)

print m.evaluate(False)

Generated on Mon Mar 8 23:08:33 2010 for IMP by doxygen 1.5.8