IMP  2.0.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
28  IMP::ParticleIndexPairs setup_pairs(IMP::Model *m) {
29  IMP::ParticleIndex rpi= m->add_particle("root");
30  IMP::atom::Chain chain=IMP::atom::Chain::setup_particle(m, rpi, 'A');
32  for (unsigned int i=0; i< 2; ++i) {
33  IMP::ParticleIndex rpi= m->add_particle("residue");
34  IMP::atom::Residue residue
36  IMP::atom::ALA, i);
37  chain.add_child(residue);
38 
39  IMP::ParticleIndex api= m->add_particle("atom");
40  IMP::atom::Atom atom
42  IMP::atom::AT_CA);
43  IMP::algebra::Vector3D coords(0,10*i, 0);
44  IMP::core::XYZ::setup_particle(m, api, coords);
45  residue.add_child(atom);
46  atoms.push_back(api);
47  }
48 
49  // add Dope atom types
50  IMP::atom::add_radii(chain);
52 
53  IMP::ParticleIndexPairs all_pairs;
54  for (unsigned int i=0; i< atoms.size(); ++i) {
55  for (unsigned int j=0; j< i; ++j) {
56  all_pairs.push_back(IMP::ParticleIndexPair(atoms[i], atoms[j]));
57  }
58  }
59  return all_pairs;
60  }
61 }
62 
63 int main(int argc, char *argv[]) {
64  try {
65  // do normal IMP initialization of command line arguments
66  // Run with --help to see options.
67  IMP::base::setup_from_argv(argc, argv,
68  "Show to to use dope and excluded volume");
69 
73  SoftSphere> Score;
75  DopeAndExcludedVolumeDistancePairScore;
76 
77  // create one
79  score= new DopeAndExcludedVolumeDistancePairScore
80  (Score(IMP::score_functor::Dope(dope_threshold),
81  SoftSphere(Harmonic(spring_constant))));
82 
83  // Now let's use it
85  IMP::ParticleIndexPairs pips= setup_pairs(model);
86 
87  for (unsigned int i=0; i< pips.size(); ++i) {
88  std::cout << "Score is " << score->evaluate_index(model, pips[i],
89  IMP_NULLPTR)
90  << std::endl;
91  }
92  return 0;
93  } catch (const std::exception &e) {
94  std::cerr << "ERROR: " << e.what() << std::endl;
95  return 1;
96  }
97 }