IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/22
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 
5 import IMP
6 import IMP.core
7 import IMP.atom
8 import IMP.container
9 import sys
10 
11 IMP.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 
16 m = 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
22 bd0 = IMP.atom.Bonded.setup_particle(m, ps.get_indexes()[0])
23 bd1 = IMP.atom.Bonded.setup_particle(m, ps.get_indexes()[1])
24 IMP.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
28 nbl = IMP.container.ClosePairContainer(ps, 0.0, 3.0)
29 nbl.add_pair_filter(IMP.atom.BondedPairFilter())
30 
31 # Set up excluded volume
33 evr = IMP.container.PairsRestraint(sdps, nbl)
34 
35 # Set up optimizer
37 o.set_scoring_function([evr])
38 
39 o.optimize(1000)
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Various classes to hold sets of particles.
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
Simple conjugate gradients optimizer.
Return all close unordered pairs of particles taken from the SingletonContainer.
Bond create_custom_bond(Bonded a, Bonded b, Float length, Float stiffness=-1)
Connect the two wrapped particles by a custom bond.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Store a list of ParticleIndexes.
static Bonded setup_particle(Model *m, ParticleIndex pi)
Basic functionality that is expected to be used by a wide variety of IMP users.
Functionality for loading, creating, manipulating and scoring atomic structures.
Applies a PairScore to each Pair in a list.
A filter for bonds.