9#ifndef IMPATOM_DISTANCE_H
10#define IMPATOM_DISTANCE_H
12#include <IMP/atom/atom_config.h>
19IMPATOM_BEGIN_NAMESPACE
25 const core::XYZs& s1);
30IMPATOMEXPORT
double get_rmsd(
const core::XYZs& s0,
const core::XYZs& s1);
48template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
50 const Vector3DsOrXYZs1& m1) {
51 using algebra::get_vector_geometry;
53 <<
"should be of the same size");
57 for (
unsigned i = 0; i < m0.size() - 1; ++i) {
61 for (
unsigned j = i + 1; j < m0.size(); ++j) {
67 drmsd += (dist0 - dist1) * (dist0 - dist1);
71 return std::sqrt(drmsd / npairs);
84template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
86 const Vector3DsOrXYZs1& m1,
double threshold) {
87 using algebra::get_vector_geometry;
89 <<
"should be of the same size");
93 for (
unsigned i = 0; i < m0.size() - 1; ++i) {
97 for (
unsigned j = i + 1; j < m0.size(); ++j) {
103 if (dist0<=threshold || dist1<=threshold){
104 drmsd += (dist0 - dist1) * (dist0 - dist1);
109 return std::sqrt(drmsd / npairs);
123template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
125 const Vector3DsOrXYZs1& m2,
double threshold) {
127 "native_overlap: The input sets of XYZ points "
128 <<
"should be of the same size");
129 unsigned int distances = 0;
130 for (
unsigned int i = 0; i < m1.size(); i++) {
133 if (d <= threshold) distances++;
135 return 100.0 * distances / m1.size();
146template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
147inline double get_drms(
const Vector3DsOrXYZs0& m1,
const Vector3DsOrXYZs1& m2) {
149 "native_overlap: The input sets of XYZ points "
150 <<
"should be of the same size");
152 unsigned int n = m1.size();
154 double sum_d1ij = 0.0;
155 for (
unsigned int i = 0; i < n; ++i) {
156 for (
unsigned int j = i + 1; j < n; ++j) {
161 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
165 drms /= (4 * sum_d1ij);
178template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
180 const Vector3DsOrXYZs1& m2,
183 "get_rigid_bodies_drms: The input sets of XYZ points "
184 <<
"should be of the same size");
186 int rn = ranges.size();
188 double sum_d1ij = 0.0;
189 for (
int i = 0; i < n; ++i) {
191 for (
int k = 0; k < rn; ++k) {
192 if (i >= ranges[k].first && i <= ranges[k].second) {
197 IMP_USAGE_CHECK(range1 >= 0,
"Point " << i <<
" of m1 does not belong to "
199 for (
int j = i + 1; j < n; ++j) {
201 for (
int k = 0; k < rn; ++k) {
202 if (j >= ranges[k].first && j <= ranges[k].second) {
207 IMP_USAGE_CHECK(range2 >= 0,
"Point " << j <<
" of m2 does not belong to "
213 if (range1 != range2) {
217 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
221 drms /= (4 * sum_d1ij);
262 const core::XYZs& ref2,
263 const core::XYZs& mdl1,
264 const core::XYZs& mdl2);
286(
const core::XYZs& ref1,
287 const core::XYZs& ref2,
288 const core::XYZs& mdl1,
289 const core::XYZs& mdl2);
305(
const ParticlesTemp& ps,
Select a subset of a hierarchy.
Decorator for helping deal with a hierarchy of molecules.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Select hierarchy particles identified by the biological name.
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the squared distance between two vectors.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
double get_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
double get_radius_of_gyration(const ParticlesTemp &ps, bool weighted=true)
double get_rigid_bodies_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, const IMP::IntRanges &ranges)
DRMS between two sets of rigid bodies.
double get_rmsd_transforming_first(const IMP::algebra::Transformation3D &tr, const core::XYZs &s0, const core::XYZs &s1)
double get_drmsd(const Vector3DsOrXYZs0 &m0, const Vector3DsOrXYZs1 &m1)
Calculate distance the root mean square deviation between two sets of 3D points.
double get_rmsd(const core::XYZs &s0, const core::XYZs &s1)
double get_native_overlap(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, double threshold)
Computes the native overlap between two sets of 3D points.
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.
double get_drmsd_Q(const Vector3DsOrXYZs0 &m0, const Vector3DsOrXYZs1 &m1, double threshold)
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.
FloatPair get_placement_score(const core::XYZs &source, const core::XYZs &target)
Measure the difference between two placements of the same set of points.
const algebra::Vector3D & get_vector_geometry(Particle *p)
IMP::Vector< IntRange > IntRanges
std::pair< double, double > FloatPair
A generic pair of floats.