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);
74 template <
unsigned int D>
75 double get_score(
Model *m,
77 double distance)
const {
79 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
81 potential_.get_index(internal::SoapPotential::DISTANCE, distance);
87 DList doublets1 = doublets_.get_for_atom(a1);
88 if (doublets1.size() > 0) {
89 DList doublets2 = doublets_.get_for_atom(a2);
90 for (DList::const_iterator dit1 = doublets1.begin();
91 dit1 != doublets1.end(); ++dit1) {
92 for (DList::const_iterator dit2 = doublets2.begin();
93 dit2 != doublets2.end(); ++dit2) {
94 score += score_doublets(a1, a2, distbin, *dit1, *dit2);
99 #endif // IMP_SCORE_FUNCTOR_USE_HDF5
102 template <
unsigned int D>
104 Model *m,
const Array<D, ParticleIndex> &pis,
105 double distance)
const {
109 template <
unsigned int D>
110 double get_maximum_range(
111 Model *,
const Array<D, ParticleIndex> &)
const {
115 double get_distance_threshold()
const {
return maxrange_; }
117 template <
unsigned int D>
118 bool get_is_trivially_zero(Model *,
119 const Array<D, ParticleIndex> &,
120 double squared_distance)
const {
121 return squared_distance > algebra::get_squared(maxrange_);
125 Model *m,
const ParticleIndexes &pis)
const {
127 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
132 for (
unsigned int i = 0; i < pis.size(); ++i) {
133 if (atom::Atom::get_is_setup(m, pis[i])) {
143 IMPSCOREFUNCTOR_END_NAMESPACE
OrientedSoap(std::string library)
Constructor.
Orientation-dependent SOAP score.
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)
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.
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.
#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.
A functor for computing a distance based score for D particles.
An exception for an invalid value being passed to IMP.