IMP  2.3.0
The Integrative Modeling Platform
ClosePairsPairScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/ClosePairsPairScore.h
3  * \brief Apply a PairScore to close pairs.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H
9 #define IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H
10 
11 #include <IMP/core/core_config.h>
12 #include "XYZR.h"
13 #include "RigidClosePairsFinder.h"
14 
15 #include <IMP/PairScore.h>
16 #include <IMP/UnaryFunction.h>
17 #include <IMP/base/Pointer.h>
18 #include <IMP/Refiner.h>
19 #include <IMP/kernel/internal/container_helpers.h>
20 
21 IMPCORE_BEGIN_NAMESPACE
22 /** Apply a score to a fixed number of close pairs from the two sets.
23 
24  Apply the score to either the k closest pairs (sphere distance). The
25  envisioned use case is that the two particles each represent a protein
26  and the refiners return the geometry for that protein.
27 
28  Rigid bodies are special cased for efficiency.
29  \see ClosePairsScoreState
30  */
31 class IMPCOREEXPORT KClosePairsPairScore : public PairScore {
34  int k_;
35  mutable double last_distance_;
37  kernel::ParticleIndexPairs get_close_pairs(
38  kernel::Model *m, const kernel::ParticleIndexPair &pp) const;
39 
40  public:
41  /** only score the k closest pairs.
42  */
43  KClosePairsPairScore(PairScore *f, Refiner *r, int k = 1);
44 
45  kernel::ParticlePairsTemp get_close_pairs(const kernel::ParticlePair &pp)
46  const {
47  return IMP::internal::get_particle(
48  pp[0]->get_model(),
49  get_close_pairs(pp[0]->get_model(), IMP::internal::get_index(pp)));
50  }
51 
53  kernel::Model *m, const kernel::ParticleIndexPair &vt) const;
54 
55  virtual double evaluate_index(kernel::Model *m,
60  virtual double evaluate_if_good_index(kernel::Model *m,
61  const kernel::ParticleIndexPair &vt,
63  double max) const IMP_OVERRIDE;
66 };
67 
68 /** Apply the score to all pairs whose
69  spheres are within a certain distance threshold.
70 
71  Rigid bodies are special cased for efficiency.
72 
73  \see ClosePairsScoreState
74  */
75 class IMPCOREEXPORT ClosePairsPairScore : public PairScore {
78  Float th_;
80  kernel::ParticleIndexPairs get_close_pairs(
81  kernel::Model *m, const kernel::ParticleIndexPair &pp) const;
82 
83  public:
84  /** \param[in] r The Refiner to call on each particle
85  \param[in] f The pair score to apply to the generated pairs
86  \param[in] max_distance Only score pairs which are close than
87  the max_distance
88  */
89  ClosePairsPairScore(PairScore *f, Refiner *r, Float max_distance);
90 
91  kernel::ParticlePairsTemp get_close_pairs(const kernel::ParticlePair &pp)
92  const {
93  return IMP::internal::get_particle(
94  pp[0]->get_model(),
95  get_close_pairs(pp[0]->get_model(), IMP::internal::get_index(pp)));
96  }
98  kernel::Model *m, const kernel::ParticleIndexPair &vt) const;
99 
100  virtual double evaluate_index(kernel::Model *m,
101  const kernel::ParticleIndexPair &p,
103  virtual double evaluate_if_good_index(kernel::Model *m,
104  const kernel::ParticleIndexPair &vt,
106  double max) const IMP_OVERRIDE;
108  kernel::Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE;
111 };
112 
113 IMPCORE_END_NAMESPACE
114 
115 #endif /* IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H */
Class for adding derivatives from restraints to the model.
virtual double evaluate_if_good_index(kernel::Model *m, const kernel::ParticleIndexPair &vt, DerivativeAccumulator *da, double max) const
Compute the score and the derivative if needed.
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/UnaryFunction.h in the namespace.
#define IMP_PAIR_SCORE_METHODS(Name)
virtual double evaluate_index(kernel::Model *m, const kernel::ParticleIndexPair &vt, DerivativeAccumulator *da) const
Compute the score and the derivative if needed.
Restraints create_current_decomposition(kernel::Model *m, const kernel::ParticleIndexPair &vt) const
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Abstract class for scoring object(s) of type ParticlePair.
Import IMP/kernel/Refiner.h in the namespace.
virtual ModelObjectsTemp do_get_inputs(kernel::Model *m, const ParticleIndexes &pis) const
Import IMP/kernel/PairScore.h in the namespace.
A nullptr-initialized pointer to an IMP Object.
Handle rigid bodies by looking at their members.
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Abstract class to implement hierarchical methods.
Decorator for a sphere-like particle.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73