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) {
44 return std::sqrt(rmsd / m1.size());
64 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
65 inline double get_drmsd(
const Vector3DsOrXYZs0& m0,
const Vector3DsOrXYZs1& m1)
68 "The input sets of XYZ points "
69 <<
"should be of the same size");
73 for(
unsigned i=0;i<m0.size()-1;++i){
77 for(
unsigned j=i+1;j<m0.size();++j){
83 drmsd+=(dist0-dist1)*(dist0-dist1);
87 return std::sqrt(drmsd/npairs);
101 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
103 const Vector3DsOrXYZs1& m2,
double threshold) {
105 "native_verlap: The input sets of XYZ points "
106 <<
"should be of the same size");
107 unsigned int distances=0;
108 for(
unsigned int i=0;i<m1.size();i++) {
111 if(d<=threshold) distances++;
113 return 100.0*distances/m1.size();
125 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
127 const Vector3DsOrXYZs1& m2) {
129 "native_verlap: The input sets of XYZ points "
130 <<
"should be of the same size");
132 unsigned int n = m1.size();
134 double sum_d1ij = 0.0;
135 for (
unsigned int i=0; i < n; ++i) {
136 for (
unsigned int j= i+1; j< n; ++j) {
141 drms += (sqd1 - sqd2)*(sqd1 - sqd2);
145 drms /= (4 * sum_d1ij);
158 template <
class Vector3DsOrXYZs0,
class Vector3DsOrXYZs1>
160 const Vector3DsOrXYZs1 &m2,
163 "get_rigid_bodies_drms: The input sets of XYZ points "
164 <<
"should be of the same size");
166 int rn = ranges.size();
168 double sum_d1ij = 0.0;
169 for (
int i=0; i < n; ++i) {
171 for (
int k=0; k < rn; ++k) {
172 if(i >= ranges[k].first && i <= ranges[k].second) {
177 IMP_USAGE_CHECK(range1 >=0,
"Point " << i <<
" of m1 does not belong to "
179 for (
int j= i+1; j < n; ++j) {
181 for (
int k=0; k < rn; ++k) {
182 if(j >= ranges[k].first && j <= ranges[k].second) {
187 IMP_USAGE_CHECK(range2 >=0,
"Point " << j <<
" of m2 does not belong to "
193 if(range1 != range2) {
195 double sqd2 = algebra::get_squared_distance(
198 drms += (sqd1 - sqd2) * (sqd1 - sqd2);
202 drms /= (4 * sum_d1ij);
225 const core::XYZs& target);
247 const core::XYZs& ref1 ,
const core::XYZs& ref2,
248 const core::XYZs& mdl1 ,
const core::XYZs& mdl2);
269 const core::XYZs& ref1 ,
const core::XYZs& ref2,
270 const core::XYZs& mdl1 ,
const core::XYZs& mdl2);
305 return sqrt(get_squared_rmsd(t1, t2));}
321 IMPATOM_END_NAMESPACE