IMP  2.4.0
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-2015 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  IMP::Floats get_solvent_accessibility(const core::XYZRs& points,
34  float probe_radius = 1.8,
35  float density = 5.0);
36 
37  private:
38  bool is_intersecting(const algebra::Vector3D& sphere_center1,
39  const algebra::Vector3D& sphere_center2,
40  const float radius1, const float radius2) {
41  float squared_radius_sum = (radius1 + radius2) * (radius1 + radius2);
42  float 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(float radius, float density);
50 
51  // generate and save sphere dots for radii present in the ps set
52  void create_sphere_dots(const core::XYZRs& ps, float density);
53 
54  const algebra::Vector3Ds& get_sphere_dots(float r) const {
55  boost::unordered_map<float, 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,
59  ValueException);
60  }
61  return sphere_dots_[it->second];
62  }
63 
64  private:
65  boost::unordered_map<float, int> radii2type_;
66  std::vector<algebra::Vector3Ds> sphere_dots_;
67  float 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:201
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Definition: check_macros.h:50
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Decorator for a sphere-like particle.