9 #ifndef IMPATOM_DISTANCE_H
10 #define IMPATOM_DISTANCE_H
12 #include <IMP/atom/atom_config.h>
19 IMPATOM_BEGIN_NAMESPACE
25 const core::XYZs& s1);
30 IMPATOMEXPORT
double get_rmsd(
const core::XYZs& s0,
const core::XYZs& s1);
37 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
38 IMPATOM_DEPRECATED_FUNCTION_DECL(2.2) inline
double get_rmsd(
39 const Vector3DsOrXYZs0& m1, const Vector3DsOrXYZs1& m2,
40 const algebra::Transformation3D& tr_for_second =
42 IMPATOM_DEPRECATED_FUNCTION_DEF(2.2,
"Use it in IMP::algebra");
47 IMPATOMEXPORT
double get_rmsd(
const Selection& s0,
const Selection& s1);
57 IMPATOM_DEPRECATED_FUNCTION_DECL(2.2)
58 IMPATOMEXPORT
double get_rmsd(const Selection& s0, const Selection& s1,
59 const algebra::Transformation3D& tr_for_second);
65 IMPATOM_DEPRECATED_FUNCTION_DECL(2.2)
68 const algebra::Transformation3D& tr_for_second);
74 IMPATOM_DEPRECATED_FUNCTION_DECL(2.2)
76 const core::XYZs& s0, const core::XYZs& s1,
77 const IMP::algebra::Transformation3D& tr_for_second);
87 template <class Vector3DsOrXYZs0, class Vector3DsOrXYZs1>
89 const Vector3DsOrXYZs1& m1) {
90 using algebra::get_vector_geometry;
92 <<
"should be of the same size");
96 for (
unsigned i = 0; i < m0.size() - 1; ++i) {
100 for (
unsigned j = i + 1; j < m0.size(); ++j) {
106 drmsd += (dist0 - dist1) * (dist0 - dist1);
110 return std::sqrt(drmsd / npairs);
123 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
125 const Vector3DsOrXYZs1& m1,
double threshold) {
126 using algebra::get_vector_geometry;
127 IMP_USAGE_CHECK(m0.size() == m1.size(),
"The input sets of XYZ points "
128 <<
"should be of the same size");
132 for (
unsigned i = 0; i < m0.size() - 1; ++i) {
136 for (
unsigned j = i + 1; j < m0.size(); ++j) {
142 if (dist0<=threshold || dist1<=threshold){
143 drmsd += (dist0 - dist1) * (dist0 - dist1);
148 return std::sqrt(drmsd / npairs);
162 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
164 const Vector3DsOrXYZs1& m2,
double threshold) {
166 "native_overlap: The input sets of XYZ points "
167 <<
"should be of the same size");
168 unsigned int distances = 0;
169 for (
unsigned int i = 0; i < m1.size(); i++) {
171 get_vector_geometry(m2[i]));
172 if (d <= threshold) distances++;
174 return 100.0 * distances / m1.size();
185 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
186 inline double get_drms(
const Vector3DsOrXYZs0& m1,
const Vector3DsOrXYZs1& m2) {
188 "native_overlap: The input sets of XYZ points "
189 <<
"should be of the same size");
191 unsigned int n = m1.size();
193 double sum_d1ij = 0.0;
194 for (
unsigned int i = 0; i < n; ++i) {
195 for (
unsigned int j = i + 1; j < n; ++j) {
197 get_vector_geometry(m1[j]));
199 get_vector_geometry(m2[j]));
200 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
204 drms /= (4 * sum_d1ij);
216 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
218 const Vector3DsOrXYZs1& m2,
221 "get_rigid_bodies_drms: The input sets of XYZ points "
222 <<
"should be of the same size");
224 int rn = ranges.size();
226 double sum_d1ij = 0.0;
227 for (
int i = 0; i < n; ++i) {
229 for (
int k = 0; k < rn; ++k) {
230 if (i >= ranges[k].first && i <= ranges[k].second) {
235 IMP_USAGE_CHECK(range1 >= 0,
"Point " << i <<
" of m1 does not belong to "
237 for (
int j = i + 1; j < n; ++j) {
239 for (
int k = 0; k < rn; ++k) {
240 if (j >= ranges[k].first && j <= ranges[k].second) {
245 IMP_USAGE_CHECK(range2 >= 0,
"Point " << j <<
" of m2 does not belong to "
249 get_vector_geometry(m1[j]));
251 if (range1 != range2) {
254 get_vector_geometry(m2[j]));
255 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
259 drms /= (4 * sum_d1ij);
333 IMPATOM_END_NAMESPACE
double get_radius_of_gyration(const kernel::ParticlesTemp &ps)
double get_rigid_bodies_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, const IMP::IntRanges &ranges)
Import IMP/kernel/base_types.h in the namespace.
double get_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
double get_native_overlap(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, double threshold)
Computes the native overlap between two sets of 3D points.
double get_drmsd(const Vector3DsOrXYZs0 &m0, const Vector3DsOrXYZs1 &m1)
Calculate distance the root mean square deviation between two sets of 3D points.
std::pair< double, double > FloatPair
A generic pair of floats.
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the squared distance between two vectors.
double get_rmsd(const core::XYZs &s0, const core::XYZs &s1, const IMP::algebra::Transformation3D &tr_for_second)
Decorator for helping deal with a hierarchy of molecules.
base::Vector< VectorD< 3 > > Vector3Ds
FloatPair get_component_placement_score(const core::XYZs &ref1, const core::XYZs &ref2, const core::XYZs &mdl1, const core::XYZs &mdl2)
Measure the difference between two placements of the same set of points.
double get_distance(const Plane3D &pln, const Vector3D &p)
Return the distance between a plane and a point in 3D.
Transformation3D get_identity_transformation_3d()
Return a transformation that does not do anything.
double get_pairwise_rmsd_score(const core::XYZs &ref1, const core::XYZs &ref2, const core::XYZs &mdl1, const core::XYZs &mdl2)
Measure the RMSD between two placements of the same set of points.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
FloatPair get_placement_score(const core::XYZs &source, const core::XYZs &target)
Measure the difference between two placements of the same set of points.
double get_drmsd_Q(const Vector3DsOrXYZs0 &m0, const Vector3DsOrXYZs1 &m1, double threshold)
Select a subset of a hierarchy.
double get_rmsd_transforming_first(const algebra::Transformation3D &tr, const Selection &s0, const Selection &s1)