IMP logo
IMP Reference Guide  2.20.1
The Integrative Modeling Platform
SolventAccessibleSurface.h
Go to the documentation of this file.
1 /**
2  * \file IMP/saxs/SolventAccessibleSurface.h \brief
3  *
4  * Copyright 2007-2022 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPSAXS_SOLVENT_ACCESSIBLE_SURFACE_H
9 #define IMPSAXS_SOLVENT_ACCESSIBLE_SURFACE_H
10 
11 #include <IMP/saxs/saxs_config.h>
12 #include <IMP/core/XYZR.h>
13 
14 IMPSAXS_BEGIN_NAMESPACE
15 
16 /**
17  Class for estimation of accessible surface area. The probe (sampled
18  with dots) is rolled over the atoms. The area is estimated by the
19  number of dots that do not collide with atoms. Note, this is a rough
20  estimate of the area (enough for SAXS).
21 */
22 class IMPSAXSEXPORT SolventAccessibleSurface {
23  public:
24  //! estimate surface accessibility of each atom.
25  /**
26  \param[in] points A set of points for which surface accessibility is
27  computed. Each point should have an XYZ coordinate and a radius.
28  \param[in] probe_radius Radius of the probe to roll over points.
29  \param[in] density Sampling density per A^2 for area estimation
30  \return a value between 0 to 1, for surface accessibility,
31  where 0 means buried and 1 means fully accessible to the water
32  */
33  Vector<double> get_solvent_accessibility(const core::XYZRs& points,
34  double probe_radius = 1.8,
35  double density = 5.0);
36 
37  private:
38  bool is_intersecting(const algebra::Vector3D& sphere_center1,
39  const algebra::Vector3D& sphere_center2,
40  const double radius1, const double radius2) {
41  double squared_radius_sum = (radius1 + radius2) * (radius1 + radius2);
42  double squared_dist =
43  algebra::get_squared_distance(sphere_center1, sphere_center2);
44  if (fabs(squared_radius_sum - squared_dist) < 0.0001) return false;
45  if (squared_radius_sum > squared_dist) return true;
46  return false;
47  }
48 
49  algebra::Vector3Ds create_sphere_dots(double radius, double density);
50 
51  // generate and save sphere dots for radii present in the ps set
52  void create_sphere_dots(const core::XYZRs& ps, double density);
53 
54  const algebra::Vector3Ds& get_sphere_dots(double r) const {
55  boost::unordered_map<double, int>::const_iterator it = radii2type_.find(r);
56  if (it == radii2type_.end()) {
57  IMP_THROW("SolventAccessibleSurface: can't find sphere dots for radius "
58  << r,
60  }
61  return sphere_dots_[it->second];
62  }
63 
64  private:
65  boost::unordered_map<double, int> radii2type_;
66  Vector<algebra::Vector3Ds> sphere_dots_;
67  double density_;
68 };
69 
70 IMPSAXS_END_NAMESPACE
71 
72 #endif /* IMPSAXS_SOLVENT_ACCESSIBLE_SURFACE_H */
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the squared distance between two vectors.
Definition: VectorD.h:205
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Definition: check_macros.h:50
VectorD< 3 > Vector3D
Definition: VectorD.h:425
An exception for an invalid value being passed to IMP.
Definition: exception.h:136
Decorator for a sphere-like particle.