9 #ifndef IMPATOM_DISTANCE_H
10 #define IMPATOM_DISTANCE_H
12 #include <IMP/atom/atom_config.h>
18 IMPATOM_BEGIN_NAMESPACE
27 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
28 inline double get_rmsd(
const Vector3DsOrXYZs0& m1,
const Vector3DsOrXYZs1& m2,
32 std::distance(m2.begin(), m2.end()),
33 "The input sets of XYZ points "
34 <<
"should be of the same size");
36 typename Vector3DsOrXYZs0::const_iterator it0 = m1.begin();
37 typename Vector3DsOrXYZs1::const_iterator it1 = m2.begin();
38 for (; it0 != m1.end(); ++it0, ++it1) {
40 tr_for_second.get_transformed(get_vector_d_geometry(*it1));
43 return std::sqrt(rmsd / m1.size());
62 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
64 const Vector3DsOrXYZs1& m1) {
66 <<
"should be of the same size");
70 for (
unsigned i = 0; i < m0.size() - 1; ++i) {
74 for (
unsigned j = i + 1; j < m0.size(); ++j) {
80 drmsd += (dist0 - dist1) * (dist0 - dist1);
84 return std::sqrt(drmsd / npairs);
97 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
99 const Vector3DsOrXYZs1& m2,
double threshold) {
101 "native_verlap: The input sets of XYZ points "
102 <<
"should be of the same size");
103 unsigned int distances = 0;
104 for (
unsigned int i = 0; i < m1.size(); i++) {
106 get_vector_d_geometry(m2[i]));
107 if (d <= threshold) distances++;
109 return 100.0 * distances / m1.size();
120 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
121 inline double get_drms(
const Vector3DsOrXYZs0& m1,
const Vector3DsOrXYZs1& m2) {
123 "native_verlap: The input sets of XYZ points "
124 <<
"should be of the same size");
126 unsigned int n = m1.size();
128 double sum_d1ij = 0.0;
129 for (
unsigned int i = 0; i < n; ++i) {
130 for (
unsigned int j = i + 1; j < n; ++j) {
132 get_vector_d_geometry(m1[j]));
134 get_vector_d_geometry(m2[j]));
135 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
139 drms /= (4 * sum_d1ij);
151 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
153 const Vector3DsOrXYZs1& m2,
156 "get_rigid_bodies_drms: The input sets of XYZ points "
157 <<
"should be of the same size");
159 int rn = ranges.size();
161 double sum_d1ij = 0.0;
162 for (
int i = 0; i < n; ++i) {
164 for (
int k = 0; k < rn; ++k) {
165 if (i >= ranges[k].first && i <= ranges[k].second) {
170 IMP_USAGE_CHECK(range1 >= 0,
"Point " << i <<
" of m1 does not belong to "
172 for (
int j = i + 1; j < n; ++j) {
174 for (
int k = 0; k < rn; ++k) {
175 if (j >= ranges[k].first && j <= ranges[k].second) {
180 IMP_USAGE_CHECK(range2 >= 0,
"Point " << j <<
" of m2 does not belong to "
184 get_vector_d_geometry(m1[j]));
186 if (range1 != range2) {
189 get_vector_d_geometry(m2[i]), get_vector_d_geometry(m2[j]));
190 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
194 drms /= (4 * sum_d1ij);
268 IMPATOM_END_NAMESPACE
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 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 Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, const IMP::algebra::Transformation3D &tr_for_second=IMP::algebra::get_identity_transformation_3d())
Calculate the root mean square deviation between two sets of 3D points.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Decorator for helping deal with a hierarchy of molecules.
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.
double get_radius_of_gyration(const Vector3Ds &ps)
Return the radius of gyration of a set of points.
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.
FloatPair get_placement_score(const core::XYZs &source, const core::XYZs &target)
Measure the difference between two placements of the same set of points.
A set of useful functionality on IMP::atom::Hierarchy decorators.
kernel::ParticlesTemp get_selected_particles() const
Get the selected particles.