IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
dope_and_excluded_volume.cpp
1/** \example atom/dope_and_excluded_volume.cpp
2
3 This example shows you a way to create a pair score that combines
4 IMP::score_functor::Dope and excluded volume (via
5 IMP::score_functor::HarmonicLowerBound).
6*/
7
14#include <IMP/atom/Chain.h>
16#include <IMP/atom/Atom.h>
17#include <IMP/atom/Residue.h>
18#include <IMP/object_macros.h>
19#include <IMP/core/XYZR.h>
20#include <IMP/flags.h>
21
22namespace {
23const double dope_threshold = 16;
24const double spring_constant = 1;
25
26// create some pairs that can be score with dope
27IMP::ParticleIndexPairs setup_pairs(IMP::Model *m) {
28 IMP::ParticleIndex rpi = m->add_particle("root");
31 for (unsigned int i = 0; i < 2; ++i) {
32 IMP::ParticleIndex rpi = m->add_particle("residue");
33 IMP::atom::Residue residue =
34 IMP::atom::Residue::setup_particle(m, rpi, IMP::atom::ALA, i);
35 chain.add_child(residue);
36
37 IMP::ParticleIndex api = m->add_particle("atom");
38 IMP::atom::Atom atom =
40 IMP::algebra::Vector3D coords(0, 10 * i, 0);
41 IMP::core::XYZ::setup_particle(m, api, coords);
42 residue.add_child(atom);
43 atoms.push_back(api);
44 }
45
46 // add Dope atom types
49
51 for (unsigned int i = 0; i < atoms.size(); ++i) {
52 for (unsigned int j = 0; j < i; ++j) {
53 all_pairs.push_back(IMP::ParticleIndexPair(atoms[i], atoms[j]));
54 }
55 }
56 return all_pairs;
57}
58}
59
60int main(int argc, char *argv[]) {
61 try {
62 // do normal IMP initialization of command line arguments
63 // Run with --help to see options.
64 IMP::setup_from_argv(argc, argv,
65 "Show how to use dope and excluded volume");
66
70 Score;
72 DopeAndExcludedVolumeDistancePairScore;
73
74 // create one
76 new DopeAndExcludedVolumeDistancePairScore(
77 Score(IMP::score_functor::Dope(dope_threshold),
78 SoftSphere(Harmonic(spring_constant))));
79
80 // Now let's use it
82 new IMP::Model();
83 IMP::ParticleIndexPairs pips = setup_pairs(model);
84
85 for (unsigned int i = 0; i < pips.size(); ++i) {
86 std::cout << "Score is " << score->evaluate_index(
87 model, pips[i], nullptr) << std::endl;
88 }
89 return 0;
90 }
91 catch (const std::exception &e) {
92 std::cerr << "ERROR: " << e.what() << std::endl;
93 return 1;
94 }
95}
A Score on the distance between a pair of particles.
Simple atom decorator.
Store the chain ID.
Dope scoring.
A Score on the distance between a pair of particles.
A decorator for Residues.
A Score on the distance between a pair of particles.
Decorator for a sphere-like particle.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator for a particle representing an atom.
Definition Atom.h:238
static Atom setup_particle(Model *m, ParticleIndex pi, Atom other)
Definition Atom.h:246
Store info for a chain of a protein.
Definition Chain.h:61
static Chain setup_particle(Model *m, ParticleIndex pi, std::string id)
Definition Chain.h:84
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
A decorator for a residue.
Definition Residue.h:137
static Residue setup_particle(Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
Definition Residue.h:160
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition XYZ.h:51
Create efficient distance-based pair scores.
Score pair of atoms based on DOPE.
Definition Dope.h:32
Support for shared command line flags.
Define functions to add bonds and radii to atoms.
void add_dope_score_data(atom::Hierarchy h)
void add_radii(Hierarchy d, const ForceFieldParameters *ffp=get_all_atom_CHARMM_parameters(), FloatKey radius_key=FloatKey("radius"))
Add vdW radius from given force field.
const AtomType AT_CA
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
IMP::Vector< ParticleIndexPair, std::allocator< ParticleIndexPair > > ParticleIndexPairs
Definition base_types.h:208
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
VectorD< 3 > Vector3D
Definition VectorD.h:407
Array< 2, ParticleIndex > ParticleIndexPair
An ordered pair of particles, each identified by its ParticleIndex.
Definition base_types.h:202
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
Helper macros for implementing IMP Objects.
A Score on the distance between a pair of particles.
A harmonic score on the negative directed distance between a pair of particles. The score equals zero...
A smart pointer to a ref-counted Object that is a class member.
Definition Pointer.h:144