IMP logo
IMP Reference Guide  2.12.0
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 #include <IMP/nullptr_macros.h>
22 
23 namespace {
24 const double dope_threshold = 16;
25 const double spring_constant = 1;
26 
27 // create some pairs that can be score with dope
28 IMP::ParticleIndexPairs setup_pairs(IMP::Model *m) {
29  IMP::ParticleIndex rpi = m->add_particle("root");
32  for (unsigned int i = 0; i < 2; ++i) {
33  IMP::ParticleIndex rpi = m->add_particle("residue");
34  IMP::atom::Residue residue =
35  IMP::atom::Residue::setup_particle(m, rpi, IMP::atom::ALA, i);
36  chain.add_child(residue);
37 
38  IMP::ParticleIndex api = m->add_particle("atom");
39  IMP::atom::Atom atom =
41  IMP::algebra::Vector3D coords(0, 10 * i, 0);
42  IMP::core::XYZ::setup_particle(m, api, coords);
43  residue.add_child(atom);
44  atoms.push_back(api);
45  }
46 
47  // add Dope atom types
48  IMP::atom::add_radii(chain);
50 
51  IMP::ParticleIndexPairs all_pairs;
52  for (unsigned int i = 0; i < atoms.size(); ++i) {
53  for (unsigned int j = 0; j < i; ++j) {
54  all_pairs.push_back(IMP::ParticleIndexPair(atoms[i], atoms[j]));
55  }
56  }
57  return all_pairs;
58 }
59 }
60 
61 int main(int argc, char *argv[]) {
62  try {
63  // do normal IMP initialization of command line arguments
64  // Run with --help to see options.
65  IMP::setup_from_argv(argc, argv,
66  "Show how to use dope and excluded volume");
67 
71  Score;
73  DopeAndExcludedVolumeDistancePairScore;
74 
75  // create one
77  new DopeAndExcludedVolumeDistancePairScore(
78  Score(IMP::score_functor::Dope(dope_threshold),
79  SoftSphere(Harmonic(spring_constant))));
80 
81  // Now let's use it
83  new IMP::Model();
84  IMP::ParticleIndexPairs pips = setup_pairs(model);
85 
86  for (unsigned int i = 0; i < pips.size(); ++i) {
87  std::cout << "Score is " << score->evaluate_index(
88  model, pips[i], IMP_NULLPTR) << std::endl;
89  }
90  return 0;
91  }
92  catch (const std::exception &e) {
93  std::cerr << "ERROR: " << e.what() << std::endl;
94  return 1;
95  }
96 }
Various general useful macros for IMP.
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:242
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"))
Simple atom decorator.
static Residue setup_particle(Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
Definition: Residue.h:158
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:72
Define functions to add bonds and radii to atoms.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
A decorator for Residues.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
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:135
VectorD< 3 > Vector3D
Definition: VectorD.h:421
Various general useful macros for IMP.
void add_dope_score_data(atom::Hierarchy h)
Store info for a chain of a protein.
Definition: Chain.h:61
Provide a nullptr keyword analog.
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:81
Decorator for a sphere-like particle.