8 #ifndef IMPSCORE_FUNCTOR_ORIENTED_SOAP_H
9 #define IMPSCORE_FUNCTOR_ORIENTED_SOAP_H
11 #include <IMP/score_functor/score_functor_config.h>
13 #include <IMP/core/internal/angle_helpers.h>
14 #include <IMP/core/internal/dihedral_helpers.h>
15 #include "internal/soap_hdf5.h"
16 #include "internal/soap_helpers.h"
19 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
31 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
32 internal::SoapPotential potential_;
33 internal::SoapDoublets doublets_;
35 typedef std::vector<internal::SoapModelDoublet> DList;
37 void read_library(std::string library) {
38 internal::Hdf5File file_id(library);
39 doublets_.read(file_id);
40 potential_.read(file_id, doublets_);
41 maxrange_ = potential_.get_max_range();
46 const internal::SoapModelDoublet &d1,
47 const internal::SoapModelDoublet &d2)
const {
49 core::internal::angle(a1, a2, d2.atom,
nullptr,
nullptr,
nullptr) *
52 core::internal::angle(d1.atom, a1, a2,
nullptr,
nullptr,
nullptr) *
54 double dih = core::internal::dihedral(d1.atom, a1, a2, d2.atom,
nullptr,
55 nullptr,
nullptr,
nullptr) *
57 return potential_.get_value(distbin, ang1, ang2, dih, d1.doublet_class,
60 #endif // IMP_SCORE_FUNCTOR_USE_HDF5
67 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
68 read_library(library);
75 void check_cache_valid(
Model *m)
const {
76 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
77 doublets_.check_cache_valid(m);
81 template <
unsigned int D>
83 double distance)
const {
85 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
87 potential_.get_index(internal::SoapPotential::DISTANCE, distance);
93 const DList &doublets1 = doublets_.get_for_atom(a1);
94 if (doublets1.size() > 0) {
95 const DList &doublets2 = doublets_.get_for_atom(a2);
96 for (
const internal::SoapModelDoublet &dit1 : doublets1) {
97 for (
const internal::SoapModelDoublet &dit2 : doublets2) {
98 score += score_doublets(a1, a2, distbin, dit1, dit2);
103 #endif // IMP_SCORE_FUNCTOR_USE_HDF5
106 template <
unsigned int D>
108 Model *m,
const Array<D, ParticleIndex> &pis,
109 double distance)
const {
111 return DerivativePair(get_score_with_cache(m, pis, distance), 0.);
113 template <
unsigned int D>
114 double get_maximum_range(
115 Model *,
const Array<D, ParticleIndex> &)
const {
119 double get_distance_threshold()
const {
return maxrange_; }
121 template <
unsigned int D>
122 bool get_is_trivially_zero_with_cache(Model *,
123 const Array<D, ParticleIndex> &,
124 double squared_distance)
const {
125 return squared_distance > algebra::get_squared(maxrange_);
129 Model *m,
const ParticleIndexes &pis)
const {
131 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
136 for (
unsigned int i = 0; i < pis.size(); ++i) {
137 if (atom::Atom::get_is_setup(m, pis[i])) {
147 IMPSCOREFUNCTOR_END_NAMESPACE
OrientedSoap(std::string library)
Constructor.
Orientation-dependent SOAP score.
A Score on the distance between a pair of particles, with cache.
static const double PI
the constant pi
A class to store a fixed array of same-typed values.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
A cached functor for computing a distance based score for D particles.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
A decorator for a particle representing an atom.
Various useful constants.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
An exception for an invalid value being passed to IMP.