/** * \file distance.h * \brief distance metrics * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #ifndef IMPATOM_DISTANCE_H #define IMPATOM_DISTANCE_H #include "atom_config.h" #include #include "Hierarchy.h" IMPATOM_BEGIN_NAMESPACE //! Calculate the root mean square deviation between two sets of 3D points. /** \note the function assumes correspondence between the two sets of points and does not perform rigid alignment. \genericgeometry */ template double get_rmsd(const Vecto3DsOrXYZs0& m1 ,const Vecto3DsOrXYZs1& m2, const IMP::algebra::Transformation3D &tr_for_second = IMP::algebra::get_identity_transformation_3d()) { IMP_USAGE_CHECK(std::distance(m1.begin(), m1.end()) ==std::distance(m2.begin(), m2.end()), "The input sets of XYZ points " <<"should be of the same size"); float rmsd=0.0; typename Vecto3DsOrXYZs0::const_iterator it0= m1.begin(); typename Vecto3DsOrXYZs1::const_iterator it1= m2.begin(); for(; it0!= m1.end(); ++it0, ++it1) { algebra::VectorD<3> tred =tr_for_second.get_transformed(get_vector_d_geometry(*it1)); rmsd += algebra::get_squared_distance(get_vector_d_geometry(*it0), tred); } return std::sqrt(rmsd / m1.size()); } //! Computes the native overlap between two sets of 3D points /** \param[in] m1 first set \param[in] m2 second set \param[in] threshold threshold distance (amstrongs) for the calculation \note The result is returned as a percentage (from 0 to 100) \note the function assumes correspondence between two sets of points and does not perform rigid alignment. \genericgeometry **/ template double get_native_overlap(const Vecto3DsOrXYZs0& m1, const Vecto3DsOrXYZs1& m2,double threshold) { IMP_USAGE_CHECK(m1.size()==m2.size(), "native_verlap: The input sets of XYZ points " <<"should be of the same size"); unsigned int distances=0; for(unsigned int i=0;i