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 (DList::const_iterator dit1 = doublets1.begin();
97 dit1 != doublets1.end(); ++dit1) {
98 for (DList::const_iterator dit2 = doublets2.begin();
99 dit2 != doublets2.end(); ++dit2) {
100 score += score_doublets(a1, a2, distbin, *dit1, *dit2);
105 #endif // IMP_SCORE_FUNCTOR_USE_HDF5
108 template <
unsigned int D>
110 Model *m,
const Array<D, ParticleIndex> &pis,
111 double distance)
const {
113 return DerivativePair(get_score_with_cache(m, pis, distance), 0.);
115 template <
unsigned int D>
116 double get_maximum_range(
117 Model *,
const Array<D, ParticleIndex> &)
const {
121 double get_distance_threshold()
const {
return maxrange_; }
123 template <
unsigned int D>
124 bool get_is_trivially_zero_with_cache(Model *,
125 const Array<D, ParticleIndex> &,
126 double squared_distance)
const {
127 return squared_distance > algebra::get_squared(maxrange_);
131 Model *m,
const ParticleIndexes &pis)
const {
133 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
138 for (
unsigned int i = 0; i < pis.size(); ++i) {
139 if (atom::Atom::get_is_setup(m, pis[i])) {
149 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 an 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.