IMP logo
IMP Reference Guide  2.20.2
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 
13 #include <IMP/atom/DopePairScore.h>
14 #include <IMP/atom/Chain.h>
15 #include <IMP/atom/force_fields.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 
22 namespace {
23 const double dope_threshold = 16;
24 const double spring_constant = 1;
25 
26 // create some pairs that can be score with dope
27 IMP::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
47  IMP::atom::add_radii(chain);
49 
50  IMP::ParticleIndexPairs all_pairs;
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 
60 int 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 }
Helper macros for implementing IMP Objects.
A Score on the distance between a pair of particles.
A Score on the distance between a pair of particles.
ParticleIndex add_particle(std::string name)
Add particle to the model.
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
static Atom setup_particle(Model *m, ParticleIndex pi, Atom other)
Definition: atom/Atom.h:246
A Score on the distance between a pair of particles.
const AtomType AT_CA
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.
Simple atom decorator.
static Residue setup_particle(Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
Definition: Residue.h:160
A Score on the distance between a pair of particles.
Create efficient distance-based pair scores.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Define functions to add bonds and radii to atoms.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:238
A decorator for Residues.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
Dope scoring.
A harmonic score on the negative directed distance between a pair of particles. The score equals zero...
Store the chain ID.
A decorator for a residue.
Definition: Residue.h:137
VectorD< 3 > Vector3D
Definition: VectorD.h:425
Support for shared command line flags.
void add_dope_score_data(atom::Hierarchy h)
Score pair of atoms based on DOPE.
Definition: Dope.h:32
Store info for a chain of a protein.
Definition: Chain.h:61
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.
static Chain setup_particle(Model *m, ParticleIndex pi, std::string id)
Definition: Chain.h:83
Decorator for a sphere-like particle.