def rms(config, inp: Tuple[str, str], out: click.File): """Calculate the root mean squared deviation between two structures using quaternions. Based on a Fortran implementation by Chaok Seok, Evangelos Coutsias, and Ken Dill.""" from kallisto.rmsd import rmsd mol1 = ksr.constructMolecule(geometry=inp[0], out=out) nat1 = mol1.get_number_of_atoms() mol2 = ksr.constructMolecule(geometry=inp[1], out=out) nat2 = mol2.get_number_of_atoms() # for RMSD comparison both coordinates need the same atom count if nat1 != nat2: errorbye( "Error: number of atoms do not match in {} and in {}".format( inp[0], inp[1]), ) coord1 = mol1.get_positions() coord2 = mol2.get_positions() # get RMSD error and rotation matrix u error, u = rmsd(nat1, coord1, coord2) silentPrinter(config.silent, "RMSD {} Angstrom".format(error), out) silentPrinter(config.silent, "Rotation Matrix", out) click.echo(u, file=out) # type: ignore return error, u
def test_rms(): mol1 = propanolLowest() nat1 = mol1.get_number_of_atoms() coord1 = mol1.get_positions() mol2 = propanolIntermediate() coord2 = mol2.get_positions() _, u = rmsd(nat1, coord1, coord2) assert np.isclose(u[0, 0], 0.98139458) assert np.isclose(u[0, 1], -0.04965545) assert np.isclose(u[0, 2], -0.18546973) assert np.isclose(u[1, 0], 0.06170977) assert np.isclose(u[1, 1], 0.9963015) assert np.isclose(u[1, 2], 0.05979323) assert np.isclose(u[2, 0], 0.18181471) assert np.isclose(u[2, 1], -0.07012604) assert np.isclose(u[2, 2], 0.98082911)
def test_rms(): mol1 = propanolLowest() nat1 = mol1.get_number_of_atoms() coord1 = mol1.get_positions() mol2 = propanolIntermediate() coord2 = mol2.get_positions() error, u = rmsd(nat1, coord1, coord2) assert (error - 1.12070194) < epsilon assert (u[0, 0] - 0.98139458) < epsilon assert (u[0, 1] - -0.04965545) < epsilon assert (u[0, 2] - -0.18546973) < epsilon assert (u[1, 0] - 0.06170977) < epsilon assert (u[1, 1] - 0.9963015) < epsilon assert (u[1, 2] - 0.05979323) < epsilon assert (u[2, 0] - 0.18181471) < epsilon assert (u[2, 1] - -0.07012604) < epsilon assert (u[2, 2] - 0.98082911) < epsilon