IMP  2.1.1
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/base/object_macros.h>
19 #include <IMP/core/XYZR.h>
20 #include <IMP/base/flags.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
32  for (unsigned int i = 0; i < 2; ++i) {
33  IMP::kernel::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 
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 
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::kernel::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::base::setup_from_argv(argc, argv,
66  "Show to 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  IMP::kernel::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], IMP_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 }
static Residue setup_particle(kernel::Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
Definition: Residue.h:156
A Score on the distance between a pair of particles.
A Score on the distance between a pair of particles.
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
static Atom setup_particle(kernel::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
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
void add_radii(Hierarchy d, const ForceFieldParameters *ffp=get_all_atom_CHARMM_parameters(), FloatKey radius_key=FloatKey("radius"))
Simple atom decorator.
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZ.h:53
ParticleIndex add_particle(std::string name)
Add particle to the model.
A Score on the distance between a pair of particles.
static Chain setup_particle(kernel::Model *m, ParticleIndex pi, char id)
Definition: Chain.h:37
Create efficient distance-based pair scores.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Define functions to add bonds and radii to atoms.
Various general useful macros for IMP.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
IMP::kernel::Model Model
A decorator for Residues.
Dope scoring.
A Score on the distance between a pair of particles.
Store the chain ID.
A decorator for a residue.
Definition: Residue.h:133
Provide a nullptr keyword analog.
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:21
void setup_from_argv(int argc, char **argv, std::string description)
Decorator for a sphere-like particle.
Class for storing model, its restraints, constraints, and particles.