8 #ifndef IMPSCORE_FUNCTOR_STATISTICAL_H
9 #define IMPSCORE_FUNCTOR_STATISTICAL_H
11 #include <IMP/score_functor/score_functor_config.h>
14 #include "internal/PMFTable.h"
17 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
52 template <
class Key,
bool BIPARTITE,
bool INTERPOLATE,
bool SPARSE = false>
54 typedef internal::PMFTable<BIPARTITE, INTERPOLATE, SPARSE> Table;
65 : table_(new Table(data_file, 0, Key())), threshold_(threshold), key_(k) {
67 "Constructor can only be used for non-bipartite scores.");
78 : table_(new Table(data_file, shift, Key())),
79 threshold_(threshold),
82 "Constructor can only be used for bipartite scores.");
86 double get_score(
kernel::Model *m,
const ParticleIndexPair &pp,
87 double distance)
const {
88 if (distance >= threshold_ || distance < 0.001) {
93 if (pt == -1 || lt == -1)
return 0;
94 return table_->get_score(pt, lt, distance);
97 kernel::Model *m,
const base::Array<2, kernel::ParticleIndex> &pp,
98 double distance)
const {
99 if (distance >= threshold_ || distance < 0.001) {
102 int pt = m->get_attribute(key_, pp[0]);
103 int lt = m->get_attribute(key_, pp[1]);
105 return table_->get_score_with_derivative(pt, lt, distance);
107 double get_maximum_range(
kernel::Model *,
const ParticleIndexPair &)
const {
108 return std::min(threshold_, table_->get_max());
110 bool get_is_trivially_zero(
kernel::Model *m,
const ParticleIndexPair &p,
111 double squared_distance)
const {
112 return squared_distance > algebra::get_squared(get_maximum_range(m, p));
116 IMPSCOREFUNCTOR_END_NAMESPACE
Statistical(IntKey k, double threshold, base::TextInput data_file)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Functions to deal with very common math operations.
Storage of a model, its restraints, constraints and particles.
A Score on the distance between a pair of particles.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
A nullptr-initialized pointer to an IMP Object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A functor for computing a distance based score for two particles.
Statistical(IntKey k, double threshold, base::TextInput data_file, unsigned int shift)
Class for storing model, its restraints, constraints, and particles.