IMP logo
IMP Reference Guide  2.22.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-2022 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/Pointer.h>
18 #include <IMP/Refiner.h>
19 #include <IMP/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 /** Apply the score to the k closest pairs (sphere distance). The
24  envisioned use case is that the two particles each represent a protein
25  and the refiners return the geometry for that protein.
26 
27  Rigid bodies are special cased for efficiency.
28  \see ClosePairsScoreState
29  */
30 class IMPCOREEXPORT KClosePairsPairScore : public PairScore {
33  int k_;
34  mutable double last_distance_;
36  ParticleIndexPairs get_close_pairs(
37  Model *m, const ParticleIndexPair &pp) const;
38 
39  public:
40  //! only score the k closest pairs.
41  KClosePairsPairScore(PairScore *f, Refiner *r, int k = 1);
42 
43  ParticlePairsTemp get_close_pairs(const ParticlePair &pp)
44  const {
45  return IMP::internal::get_particle(
46  std::get<0>(pp)->get_model(),
47  get_close_pairs(std::get<0>(pp)->get_model(),
49  }
50 
52  Model *m, const ParticleIndexPair &vt) const;
53 
54  virtual double evaluate_index(Model *m,
55  const ParticleIndexPair &p,
56  DerivativeAccumulator *da) const override;
58  Model *m, const ParticleIndexes &pis) const override;
59  virtual double evaluate_if_good_index(Model *m,
60  const ParticleIndexPair &vt,
62  double max) const override;
65 };
66 
67 //! Apply the score to all pairs whose spheres are within a distance threshold.
68 /** Rigid bodies are special cased for efficiency.
69 
70  \see ClosePairsScoreState
71  */
72 class IMPCOREEXPORT ClosePairsPairScore : public PairScore {
75  Float th_;
77  ParticleIndexPairs get_close_pairs(
78  Model *m, const ParticleIndexPair &pp) const;
79 
80  public:
81  //! Constructor.
82  /** \param[in] r The Refiner to call on each particle
83  \param[in] f The pair score to apply to the generated pairs
84  \param[in] max_distance Only score pairs which are close than
85  the max_distance
86  */
87  ClosePairsPairScore(PairScore *f, Refiner *r, Float max_distance);
88 
89  ParticlePairsTemp get_close_pairs(const ParticlePair &pp)
90  const {
91  return IMP::internal::get_particle(
92  std::get<0>(pp)->get_model(),
93  get_close_pairs(std::get<0>(pp)->get_model(),
95  }
97  Model *m, const ParticleIndexPair &vt) const;
98 
99  virtual double evaluate_index(Model *m,
100  const ParticleIndexPair &p,
101  DerivativeAccumulator *da) const override;
102  virtual double evaluate_if_good_index(Model *m,
103  const ParticleIndexPair &vt,
105  double max) const override;
107  Model *m, const ParticleIndexes &pis) const override;
110 };
111 
112 IMPCORE_END_NAMESPACE
113 
114 #endif /* IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H */
Abstract class for scoring object(s) of type ParticleIndexPair.
Definition: PairScore.h:44
Apply a score to a fixed number of close pairs from the two sets.
#define IMP_PAIR_SCORE_METHODS(Name)
Definition: pair_macros.h:25
Apply the score to all pairs whose spheres are within a distance threshold.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Single variable function.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Refine a particle into a list of particles.
Define PairScore.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
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:19
Abstract class to implement hierarchical methods.
Definition: Refiner.h:34
Restraints create_current_decomposition(Model *m, const ParticleIndexPair &vt) const
virtual double evaluate_if_good_index(Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da, double max) const
Compute the score and the derivative if needed, only if "good".
Decorator for a sphere-like particle.
virtual double evaluate_index(Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da) const =0
Compute the score and the derivative if needed.
Class for adding derivatives from restraints to the model.