IMP logo
IMP Reference Guide  2.17.0
The Integrative Modeling Platform
SingletonStatistical.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/SingletonStatistical.h
3  * \brief statistical score for a single particle based on one parameter,
4  * such as solvent accessibility
5  *
6  * \authors Dina Schneidman
7  * Copyright 2007-2022 IMP Inventors. All rights reserved.
8  *
9  */
10 
11 #ifndef IMPSCORE_FUNCTOR_SINGLETON_STATISTICAL_H
12 #define IMPSCORE_FUNCTOR_SINGLETON_STATISTICAL_H
13 
14 #include <IMP/score_functor/score_functor_config.h>
15 #include <IMP/Pointer.h>
16 #include "internal/SASTable.h"
17 
18 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
19 
20 //! Create a single key/single particle statistical potential from a file.
21 /** The Key passed as a template argument is used to determine how to map
22  the name of the type as described in the loaded file to table index.
23  That is, if atom::ResidueKey is passed as the Key, the potential will
24  expect a file which has one line for each residue name.
25 
26  The expected file format is:
27 \verbatim
28  bin_width number [offset]
29  key_0 bin0 bin1 bin2...
30  key_1 bin0 bin1 bin2...
31 \endverbatim
32 
33  The order of the lines (after the first one) does not matter.
34  The bin_width is how much distance is allocated per bin (the distance used
35  is that between the points). number is the number of particle types.
36 
37  \note The values read in the file are for bins. That is, the first bin
38  is from offset to offset+width. The second is offset+width to offset+
39  2width.
40  As a result, when interpolation is used, the function achieves the
41  bin value at the center of the bin.
42 
43  \param[in] Key is an IMP::Key which maps between names and indices
44  \param[in] INTERPOLATE If true, even the scores without derivatives are
45  spline interpolated. If false, only the evaluation of derivatives is
46  interpolated with a spline.
47 */
48 template <class Key, bool INTERPOLATE>
50  typedef internal::SASTable<INTERPOLATE> Table;
51  PointerMember<Table> table_;
52  IntKey key_;
53 
54  public:
56  get_data_path("soap_score_sas.lib"))
57  : table_(new Table(data_file, Key())), key_(k) {}
58 
59  double get_score(Model *m, const ParticleIndex pi,
60  double area) const {
61  int table_index = m->get_attribute(key_, pi);
62  if (table_index == -1) return 0;
63  return table_->get_score(table_index, area);
64  }
65 };
66 
67 IMPSCOREFUNCTOR_END_NAMESPACE
68 
69 #endif /* IMPSCORE_FUNCTOR_SINGLETON_STATISTICAL_H */
Create a single key/single particle statistical potential from a file.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
A nullptr-initialized pointer to an IMP Object.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key