IMP logo
IMP Reference Guide  2.6.1
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-2016 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 
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  ParticleIndexPairs get_close_pairs(
38  Model *m, const 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  ParticlePairsTemp get_close_pairs(const 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  Model *m, const ParticleIndexPair &vt) const;
54 
55  virtual double evaluate_index(Model *m,
56  const ParticleIndexPair &p,
59  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
60  virtual double evaluate_if_good_index(Model *m,
61  const 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  ParticleIndexPairs get_close_pairs(
81  Model *m, const 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  ParticlePairsTemp get_close_pairs(const 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  Model *m, const ParticleIndexPair &vt) const;
99 
100  virtual double evaluate_index(Model *m,
101  const ParticleIndexPair &p,
103  virtual double evaluate_if_good_index(Model *m,
104  const ParticleIndexPair &vt,
106  double max) const IMP_OVERRIDE;
108  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
111 };
112 
113 IMPCORE_END_NAMESPACE
114 
115 #endif /* IMPCORE_CLOSE_PAIRS_PAIR_SCORE_H */
Abstract class for scoring object(s) of type ParticleIndexPair.
Definition: PairScore.h:37
#define IMP_PAIR_SCORE_METHODS(Name)
Definition: pair_macros.h:25
A class to store an fixed array of same-typed values.
Definition: Array.h:33
#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
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
Decompose this pair score acting on the pair into a set of restraints.
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.