00001 /** 00002 * \file distance.h 00003 * \brief distance metrics 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 * 00007 */ 00008 #ifndef IMPATOM_DISTANCE_H 00009 #define IMPATOM_DISTANCE_H 00010 00011 #include "atom_config.h" 00012 #include <IMP/core/XYZ.h> 00013 #include "Hierarchy.h" 00014 00015 IMPATOM_BEGIN_NAMESPACE 00016 00017 //! Calculate the root mean square deviation between two sets of 3D points. 00018 /** 00019 \note the function assumes correspondence between the two sets of 00020 points and does not perform rigid alignment. 00021 00022 \genericgeometry 00023 */ 00024 template <class Vecto3DsOrXYZs0, class Vecto3DsOrXYZs1> 00025 double get_rmsd(const Vecto3DsOrXYZs0& m1 ,const Vecto3DsOrXYZs1& m2, 00026 const IMP::algebra::Transformation3D &tr_for_second 00027 = IMP::algebra::get_identity_transformation_3d()) { 00028 IMP_USAGE_CHECK(std::distance(m1.begin(), m1.end()) 00029 ==std::distance(m2.begin(), m2.end()), 00030 "The input sets of XYZ points " 00031 <<"should be of the same size"); 00032 float rmsd=0.0; 00033 typename Vecto3DsOrXYZs0::const_iterator it0= m1.begin(); 00034 typename Vecto3DsOrXYZs1::const_iterator it1= m2.begin(); 00035 for(; it0!= m1.end(); ++it0, ++it1) { 00036 algebra::VectorD<3> tred 00037 =tr_for_second.get_transformed(core::get_geometry(*it1)); 00038 rmsd += algebra::get_squared_distance(core::get_geometry(*it0), 00039 tred); 00040 } 00041 return std::sqrt(rmsd / m1.size()); 00042 } 00043 00044 00045 //! Computes the native overlap between two sets of 3D points 00046 /** 00047 \param[in] m1 first set 00048 \param[in] m2 second set 00049 \param[in] threshold threshold distance (amstrongs) for the calculation 00050 \note The result is returned as a percentage (from 0 to 100) 00051 \note the function assumes correspondence between two sets of points and does 00052 not perform rigid alignment. 00053 \genericgeometry 00054 **/ 00055 template <class Vecto3DsOrXYZs0, class Vecto3DsOrXYZs1> 00056 double get_native_overlap(const Vecto3DsOrXYZs0& m1, 00057 const Vecto3DsOrXYZs1& m2,double threshold) { 00058 IMP_USAGE_CHECK(m1.size()==m2.size(), 00059 "native_verlap: The input sets of XYZ points " 00060 <<"should be of the same size"); 00061 unsigned int distances=0; 00062 for(unsigned int i=0;i<m1.size();i++) { 00063 double d = algebra::get_distance(core::get_geometry(m1[i]), 00064 core::get_geometry(m2[i])); 00065 if(d<=threshold) distances++; 00066 } 00067 return 100.0*distances/m1.size(); 00068 } 00069 00070 00071 //! Measure the difference between two placements of the same set of points 00072 /** 00073 \param[in] from The reference placement represented by XYZ coordinates 00074 \param[in] to The modeled placement represented by XYZ coordinates 00075 \note The measure quantifies the difference between placements 00076 of the same structure. A rigid transformation that brings mdl1 to 00077 ref1 is reported. 00078 \return (d,a), A transformation from mdl to ref represented by 00079 a a distance (d) and an angle (a). 00080 d is the distance bewteen the centroids of the two 00081 placements and a is the axis angle of the rotation matrix between 00082 the two placements 00083 \note see Lasker,Topf et al JMB, 2009 for details 00084 */ 00085 IMPATOMEXPORT std::pair<double,double> 00086 get_placement_score(const core::XYZs& from, 00087 const core::XYZs& to); 00088 00089 //! Measure the difference between two placements of the same set of points 00090 /** 00091 \param[in] ref1 The reference placement of the first component represented 00092 by XYZ coordinates 00093 \param[in] ref2 The reference placement of the second component represented 00094 by XYZ coordinates 00095 \param[in] mdl1 The modeled placement of the first component 00096 represented by XYZ coordinates 00097 \param[in] mdl2 The modeled placement of the second component 00098 represented by XYZ coordinates 00099 \return the function returns (distance score,angle score) 00100 \note The measure quantifies the difference between the relative placements 00101 of two components compared to a reference relative placement. 00102 First, the two compared structures are brought into 00103 the same frame of reference by superposing the first pair of 00104 equivalent domains (ref1 and mdl1). Next, the distance and angle 00105 scores are calculated for the second component using placement_score. 00106 \note see Topf, Lasker et al Structure, 2008 for details 00107 */ 00108 IMPATOMEXPORT std::pair<double,double> get_component_placement_score( 00109 const core::XYZs& ref1 ,const core::XYZs& ref2, 00110 const core::XYZs& mdl1 ,const core::XYZs& mdl2); 00111 00112 //! Measure the RMSD between two placements of the same set of points 00113 /** 00114 \param[in] ref1 The reference placement of the first component represented 00115 by XYZ coordinates 00116 \param[in] ref2 The reference placement of the second component represented 00117 by XYZ coordinates 00118 \param[in] mdl1 The modeled placement of the first component 00119 represented by XYZ coordinates 00120 \param[in] mdl2 The modeled placement of the second component 00121 represented by XYZ coordinates 00122 \note The measure quantifies the RMSD between the relative placements 00123 of two components compared to a reference relative placement. 00124 First, the two compared structures are brought into 00125 the same frame of reference by superposing the first pair of 00126 equivalent domains (ref1 and mdl1). Next, the RMSD is calculated 00127 for the second component 00128 \note see Lasker et al JMB, 2009 for details 00129 */ 00130 IMPATOMEXPORT double get_pairwise_rmsd_score( 00131 const core::XYZs& ref1 ,const core::XYZs& ref2, 00132 const core::XYZs& mdl1 ,const core::XYZs& mdl2); 00133 00134 00135 IMPATOM_END_NAMESPACE 00136 00137 #endif /* IMPATOM_DISTANCE_H */