IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
nonbonded_interactions.py
1## \example container/nonbonded_interactions.py
2# This example shows how to set up an excluded volume restraint for a set
3# of XYZRDecorator-style particles.
4
5import IMP
6import IMP.core
7import IMP.atom
8import IMP.container
9import sys
10
11IMP.setup_from_argv(sys.argv, "nonbonded interactions")
12
13# This example adds a restraint on nonbonded interactions
14# after excluding a set of bonded interactions.
15
16m = IMP.Model()
17# The set of particles
19 m, IMP.core.create_xyzr_particles(m, 20, 1.0))
20
21# create a bond between two particles
22bd0 = IMP.atom.Bonded.setup_particle(m, ps.get_indexes()[0])
23bd1 = IMP.atom.Bonded.setup_particle(m, ps.get_indexes()[1])
24IMP.atom.create_custom_bond(bd0, bd1, 2.0)
25
26# Set up the nonbonded list for all pairs that are touching
27# and let things move 3 before updating the list
28nbl = IMP.container.ClosePairContainer(ps, 0.0, 3.0)
29nbl.add_pair_filter(IMP.atom.BondedPairFilter())
30
31# Set up excluded volume
33evr = IMP.container.PairsRestraint(sdps, nbl)
34
35# Set up optimizer
37o.set_scoring_function([evr])
38
39o.optimize(1000)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
static Bonded setup_particle(Model *m, ParticleIndex pi)
Return all close unordered pairs of particles taken from the SingletonContainer.
Applies a PairScore to each Pair in a list.
Simple conjugate gradients optimizer.
Bond create_custom_bond(Bonded a, Bonded b, Float length, Float stiffness=-1)
Connect the two wrapped particles by a custom bond.
Functionality for loading, creating, manipulating and scoring atomic structures.
Various classes to hold sets of particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.