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);
33 IMPATOMEXPORT
double get_rmsd(
const Selection& s0,
const Selection& s1);
37 const algebra::Transformation3D& tr,
const Selection& s0,
48 template <
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);
84 template <
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);
123 template <
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++) {
132 get_vector_geometry(m2[i]));
133 if (d <= threshold) distances++;
135 return 100.0 * distances / m1.size();
146 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
147 inline 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) {
158 get_vector_geometry(m1[j]));
160 get_vector_geometry(m2[j]));
161 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
165 drms /= (4 * sum_d1ij);
178 template <
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 "
211 get_vector_geometry(m1[j]));
213 if (range1 != range2) {
216 get_vector_geometry(m2[j]));
217 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
221 drms /= (4 * sum_d1ij);
308 IMPATOM_END_NAMESPACE
double get_rigid_bodies_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2, const IMP::IntRanges &ranges)
DRMS between two sets of rigid bodies.
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.
A more IMP-like version of the std::vector.
Decorator for helping deal with a hierarchy of molecules.
double get_rmsd(const Selection &s0, const Selection &s1)
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_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_radius_of_gyration(const ParticlesTemp &ps, bool weighted=true)
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)
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.