IMP logo
container examples

bipartite nonbonded interactions

This example shows how set up excluded volume interactions between two sets of particles.

import IMP
import IMP.core
# This example addes a restraint on bipartite nonbonded interactions
# after excluding a set of bonded interactions.
# The set of particles
# Set up the nonbonded list
# Set up excluded volume
m.add_restraint(evr)
# Set up optimizer
o.set_model(m)
o.optimize(1000)

connectivity

Shows how to use and visualize the IMP::misc::ConnectingPairContainer.

m.evaluate(False)
w.add_geometry(pg)
print pg.get_name()
del w

filter close pairs

This example shows how to filter the list of close pairs generated in the IMP.container.ClosePairContainer (or IMP.container.CloseBipartitePairContainer). Eventually the filter should probably be implemented in C++, for speed but implementing the filter in python is good for prototyping.

import IMP
import IMP.core
np=10
bb= IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0,0,0),
ik= IMP.IntKey("num")
IMP.set_log_level(IMP.SILENT)
l= []
for i in range(0, np):
p.add_attribute(ik, i)
l.append(p)
m.update()
print "without",[(x[0].get_name(), x[1].get_name()) for x in cpc.get_particle_pairs()]
class ConsecutiveFilter(IMP.PairPredicate):
def __init__(self):
IMP.PairPredicate.__init__(self, "ConsecutiveFilter%1%")
def get_value(self, pp):
diff= pp[0].get_value(ik) - pp[1].get_value(ik)
if diff==-1 or diff ==1:
return 1
return 0
def get_input_particles(self, p):
return [p]
def get_input_containers(self, p):
return []
def do_show(self, out):
pass
f= ConsecutiveFilter()
cpc.add_pair_filter(f)
m.update()
print "with",[(x[0].get_name(), x[1].get_name()) for x in cpc.get_particle_pairs()]

nonbonded interactions

This example shows how to set up an excluded volume restraint for a set of XYZRDecorator-style particles.

import IMP
import IMP.core
import IMP.atom
# This example addes a restraint on nonbonded interactions
# after excluding a set of bonded interactions.
# The set of particles
# create a bond between two particles
bd0= IMP.atom.Bonded.setup_particle(ps.get_particle(0))
bd1= IMP.atom.Bonded.setup_particle(ps.get_particle(1))
# Set up the nonbonded list for all pairs at are touching
# and let things move 3 before updating the list
nbl.add_pair_filter(IMP.atom.BondedPairFilter())
# Set up excluded volume
m.add_restraint(evr)
# Set up optimizer
o.set_model(m)
o.optimize(1000)

restrain in sphere

This fragment shows how to restrain a set of points stored in a SingletonContainer in a sphere of radius 'radius' centered around 'center'.

radius=10
stiffness=2
center= IMP.algebra.Vector3D(1,2,3)
(m,c)=IMP.example.create_model_and_particles()
ub= IMP.core.HarmonicUpperBound(radius, stiffness)
# Restrain based on the distance to a single point (hence a ball
m.add_restraint(r)
m.evaluate(False)


Generated on Tue May 22 2012 23:33:20 for IMP by doxygen 1.8.1