IMP logo
IMP Reference Guide  2.14.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-2020 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  pp[0]->get_model(),
47  get_close_pairs(pp[0]->get_model(), IMP::internal::get_index(pp)));
48  }
49 
51  Model *m, const ParticleIndexPair &vt) const;
52 
53  virtual double evaluate_index(Model *m,
54  const ParticleIndexPair &p,
57  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
58  virtual double evaluate_if_good_index(Model *m,
59  const ParticleIndexPair &vt,
61  double max) const IMP_OVERRIDE;
64 };
65 
66 //! Apply the score to all pairs whose spheres are within a distance threshold.
67 /** Rigid bodies are special cased for efficiency.
68 
69  \see ClosePairsScoreState
70  */
71 class IMPCOREEXPORT ClosePairsPairScore : public PairScore {
74  Float th_;
76  ParticleIndexPairs get_close_pairs(
77  Model *m, const ParticleIndexPair &pp) const;
78 
79  public:
80  //! Constructor.
81  /** \param[in] r The Refiner to call on each particle
82  \param[in] f The pair score to apply to the generated pairs
83  \param[in] max_distance Only score pairs which are close than
84  the max_distance
85  */
86  ClosePairsPairScore(PairScore *f, Refiner *r, Float max_distance);
87 
88  ParticlePairsTemp get_close_pairs(const ParticlePair &pp)
89  const {
90  return IMP::internal::get_particle(
91  pp[0]->get_model(),
92  get_close_pairs(pp[0]->get_model(), IMP::internal::get_index(pp)));
93  }
95  Model *m, const ParticleIndexPair &vt) const;
96 
97  virtual double evaluate_index(Model *m,
98  const ParticleIndexPair &p,
100  virtual double evaluate_if_good_index(Model *m,
101  const ParticleIndexPair &vt,
103  double max) const IMP_OVERRIDE;
105  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
108 };
109 
110 IMPCORE_END_NAMESPACE
111 
112 #endif /* IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H */
Abstract class for scoring object(s) of type ParticleIndexPair.
Definition: PairScore.h:37
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:72
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:146
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:20
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.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.