def test_needleman_wunsch_sim_score(self): """Test abydos.distance.NeedlemanWunsch.sim_score.""" self.assertEqual(NeedlemanWunsch().sim_score('', ''), 0) # https://en.wikipedia.org/wiki/Needleman–Wunsch_algorithm self.assertEqual( NeedlemanWunsch(1, _sim_nw).sim_score('GATTACA', 'GCATGCU'), 0 ) self.assertEqual( NeedlemanWunsch(5, _sim_wikipedia).sim_score( 'AGACTAGTTAC', 'CGAGACGT' ), 16, ) # checked against http://ds9a.nl/nwunsch/ (mismatch=1, gap=5, skew=5) nw5 = NeedlemanWunsch(5, _sim_nw) self.assertEqual(nw5.sim_score('CGATATCAG', 'TGACGSTGC'), -5) self.assertEqual(nw5.sim_score('AGACTAGTTAC', 'TGACGSTGC'), -7) self.assertEqual(nw5.sim_score('AGACTAGTTAC', 'CGAGACGT'), -15) # test wrapper self.assertEqual( needleman_wunsch('AGACTAGTTAC', 'CGAGACGT', 5, _sim_nw), -15 )
def test_needleman_wunsch_dist_abs_nialls(self): """Test abydos.distance.NeedlemanWunsch.dist_abs (Nialls set).""" # checked against http://ds9a.nl/nwunsch/ (mismatch=1, gap=2, skew=2) nw_vals = (5, 0, -2, 3, 1, 1, -2, -2, -1, -3, -3, -5, -3, -7, -7, -19) nw2 = NeedlemanWunsch(2, _sim_nw) for i in range(len(NIALL)): self.assertEqual(nw2.sim_score(NIALL[0], NIALL[i]), nw_vals[i])
def test_gotoh_sim_score_nialls(self): """Test abydos.distance.Gotoh.sim_score (Nialls set).""" # checked against http://ds9a.nl/nwunsch/ (mismatch=1, gap=2, skew=2) nw_vals = (5, 0, -2, 3, 1, 1, -2, -2, -1, -3, -3, -5, -3, -7, -7, -19) g22 = Gotoh(2, 2, _sim_nw) for i in range(len(NIALL)): self.assertEqual(g22.sim_score(NIALL[0], NIALL[i]), nw_vals[i]) nw_vals2 = (5, 0, -2, 3, 1, 1, -2, -2, -1, -2, -3, -3, -2, -6, -6, -8) g21 = Gotoh(2, 1, _sim_nw) g205 = Gotoh(2, 0.5, _sim_nw) nw2 = NeedlemanWunsch(2, _sim_nw) for i in range(len(NIALL)): self.assertEqual(g21.sim_score(NIALL[0], NIALL[i]), nw_vals2[i]) self.assertGreaterEqual( g205.sim_score(NIALL[0], NIALL[i]), nw2.sim_score(NIALL[0], NIALL[i]), )