Dapid / tmscoring

Python implementation of the TMscore program
BSD 3-Clause "New" or "Revised" License
33 stars 12 forks source link

Something wrong with rmsd calculation #11

Open wewewexiao2008 opened 3 months ago

wewewexiao2008 commented 3 months ago

Thanks for creating this useful repo! However the current implementation might indeed be missing a crucial step. A modification to add .sum(axis=0) at the end of the _rmsd function seems to align better with the RMSD formula.

This change would sum up the squared distances along the axis, which is necessary to compute the total squared deviation before taking the square root (which I assume happens elsewhere in the code).

$$ \text{RMSD} = \sqrt{\frac{1}{n} \sum_{i=1}^{n} | | x_i - y_i | | ^2} $$

current:

def _rmsd(self, theta, phi, psi, dx, dy, dz):
        matrix = self.get_matrix(theta, phi, psi, dx, dy, dz)
        coord = matrix.dot(self.coord2)
        dist = coord - self.coord1
        return (dist * dist)

should be modified as

def _rmsd(self, theta, phi, psi, dx, dy, dz):
        matrix = self.get_matrix(theta, phi, psi, dx, dy, dz)
        coord = matrix.dot(self.coord2)
        dist = coord - self.coord1
        return (dist * dist).sum(axis=0)