IMP  2.1.0
The Integrative Modeling Platform
LogPairScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/misc/LogPairScore.h
3  * \brief Track the particles pairs passed to the pair score.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPMISC_LOG_PAIR_SCORE_H
9 #define IMPMISC_LOG_PAIR_SCORE_H
10 
11 #include <IMP/misc/misc_config.h>
12 #include <IMP/PairScore.h>
13 #include <IMP/generic.h>
14 #include <IMP/base/map.h>
15 
16 IMPMISC_BEGIN_NAMESPACE
17 
18 //! Track the pairs of particles passed.
19 /** Primarily for testing.
20  */
21 class LogPairScore : public PairScore {
23 
24  public:
25  //! create with an empty map
27  virtual double evaluate_index(kernel::Model *m,
29  DerivativeAccumulator *da) const IMP_OVERRIDE;
31  kernel::Model *, const kernel::ParticleIndexes &) const IMP_OVERRIDE {
32  return kernel::ModelObjectsTemp();
33  }
36 
37  //! Get a list of all pairs (without multiplicity)
41  map_.begin();
42  it != map_.end(); ++it) {
43  ret.push_back(it->first);
44  }
45  return ret;
46  }
47  //! Clear the lst of pairs
48  void clear() { map_.clear(); }
49  //! Return true if the pair is in the list
50  bool get_contains(const kernel::ParticlePair &pp) const {
51  return map_.find(pp) != map_.end();
52  }
53 };
54 
55 // doxygen spits out warnings
56 #ifndef IMP_DOXYGEN
57 
58 inline Float LogPairScore::evaluate_index(kernel::Model *m,
60  DerivativeAccumulator *) const {
61  kernel::ParticlePair pp(m->get_particle(p[0]), m->get_particle(p[1]));
62  if (map_.find(pp) == map_.end()) {
63  map_[pp] = 0;
64  }
65  ++map_[pp];
66  return 0.;
67 }
68 #endif
69 
70 IMPMISC_END_NAMESPACE
71 
72 #endif /* IMPMISC_LOG_PAIR_SCORE_H */
kernel::ParticlePairsTemp get_particle_pairs() const
Get a list of all pairs (without multiplicity)
Definition: LogPairScore.h:38
Class for adding derivatives from restraints to the model.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
Particle * get_particle(ParticleIndex p) const
Track the pairs of particles passed.
Definition: LogPairScore.h:21
#define IMP_PAIR_SCORE_METHODS(Name)
LogPairScore()
create with an empty map
Definition: LogPairScore.h:26
bool get_contains(const kernel::ParticlePair &pp) const
Return true if the pair is in the list.
Definition: LogPairScore.h:50
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
Definition: LogPairScore.h:30
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Abstract score function.
Import IMP/kernel/PairScore.h in the namespace.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
void clear()
Clear the lst of pairs.
Definition: LogPairScore.h:48
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
Declare an efficient stl-compatible map.
Class for storing model, its restraints, constraints, and particles.
Import IMP/kernel/generic.h in the namespace.