def test_calculate_rmsd_3(self): distogram_1 = Distogram("test_1") distogram_1.add(Distance(1, 5, (0.25, 0.45, 0.05, 0.05, 0.2), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(2, 3, (0.15, 0.15, 0.60, 0.1, 0.0), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(1, 4, (0.05, 0.2, 0.0, 0.6, 0.15), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(3, 5, (0.4, 0.1, 0.35, 0.05, 0.1), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.sequence = conkit.core.Sequence("test_seq", "AAAAA") distogram_2 = Distogram("test_2") distogram_2.add(Distance(1, 5, (0.45, 0.05, 0.25, 0.25), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(2, 3, (0.1, 0.15, 0.15, 0.6), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(1, 4, (0.75, 0.20, 0.05, 0.0), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(3, 5, (0.05, 0.1, 0.35, 0.5), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(1, 6, (0.5, 0.1, 0.35, 0.05), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.sequence = conkit.core.Sequence("test_seq", "AAAAA") with self.assertRaises(ValueError): Distogram.calculate_rmsd(distogram_1, distogram_2, seq_len=5, calculate_wrmsd=True)
def test_calculate_rmsd_2(self): distogram_1 = Distogram("test_1") distogram_1.add(Distance(1, 5, (0.25, 0.45, 0.05, 0.05, 0.2), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(2, 3, (0.15, 0.15, 0.60, 0.1, 0.0), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(1, 4, (0.05, 0.2, 0.0, 0.6, 0.15), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.add(Distance(3, 5, (0.4, 0.1, 0.35, 0.05, 0.1), ((0, 4), (4, 6), (6, 8), (8, 10), (10, np.inf)))) distogram_1.sequence = conkit.core.Sequence("test_seq", "AAAAA") distogram_2 = Distogram("test_2") distogram_2.add(Distance(1, 5, (0.45, 0.05, 0.25, 0.25), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(2, 3, (0.1, 0.15, 0.15, 0.6), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(1, 4, (0.75, 0.20, 0.05, 0.0), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.add(Distance(3, 5, (0.05, 0.1, 0.35, 0.5), ((0, 4), (4, 6), (6, 8), (8, np.inf)))) distogram_2.sequence = conkit.core.Sequence("test_seq", "AAAAA") output = Distogram.calculate_rmsd(distogram_1, distogram_2, seq_len=5, calculate_wrmsd=True) expected = [4.09, 2.324, 3.937, 5.422, 3.85] self.assertListEqual(expected, [round(x, 3) for x in output])
def get_rmsd(distogram_1, distogram_2, calculate_wrmsd=True): """Calculate the RMSD between two different distograms Parameters ---------- distogram_1 : :obj:`~conkit.core.distogram.Distogram` Distogram 1 distogram_2 : :obj:`~conkit.core.distogram.Distogram` Distogram 2 calculate_wrmsd: bool If True then the WRMSD is calculated using the confidence scores from distogram 1 Returns ------- tuple Two lists with the raw/smoothed RMSD values at each residue position """ rmsd_raw = Distogram.calculate_rmsd(distogram_1, distogram_2, calculate_wrmsd=calculate_wrmsd) rmsd_smooth = convolution_smooth_values(np.nan_to_num(rmsd_raw), 10) return rmsd_raw, rmsd_smooth