def test_needleman_wunsch_dist_abs(self):
        """Test abydos.distance.NeedlemanWunsch.dist_abs."""
        self.assertEqual(NeedlemanWunsch().dist_abs('', ''), 0)

        # https://en.wikipedia.org/wiki/Needleman–Wunsch_algorithm
        self.assertEqual(
            NeedlemanWunsch(1, _sim_nw).dist_abs('GATTACA', 'GCATGCU'), 0
        )
        self.assertEqual(
            NeedlemanWunsch(5, _sim_wikipedia).dist_abs(
                'AGACTAGTTAC', 'CGAGACGT'
            ),
            16,
        )

        # checked against http://ds9a.nl/nwunsch/ (mismatch=1, gap=5, skew=5)
        nw5 = NeedlemanWunsch(5, _sim_nw)
        self.assertEqual(nw5.dist_abs('CGATATCAG', 'TGACGSTGC'), -5)
        self.assertEqual(nw5.dist_abs('AGACTAGTTAC', 'TGACGSTGC'), -7)
        self.assertEqual(nw5.dist_abs('AGACTAGTTAC', 'CGAGACGT'), -15)

        # test wrapper
        self.assertEqual(
            needleman_wunsch('AGACTAGTTAC', 'CGAGACGT', 5, _sim_nw), -15
        )
Esempio n. 2
0
 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.dist_abs(NIALL[0], NIALL[i]), nw_vals[i])
 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.dist_abs(NIALL[0], NIALL[i]), nw_vals[i])
Esempio n. 4
0
    def test_needleman_wunsch_dist_abs(self):
        """Test abydos.distance.NeedlemanWunsch.dist_abs."""
        self.assertEqual(NeedlemanWunsch().dist_abs('', ''), 0)

        # https://en.wikipedia.org/wiki/Needleman–Wunsch_algorithm
        self.assertEqual(
            NeedlemanWunsch(1, _sim_nw).dist_abs('GATTACA', 'GCATGCU'), 0)
        self.assertEqual(
            NeedlemanWunsch(5,
                            _sim_wikipedia).dist_abs('AGACTAGTTAC',
                                                     'CGAGACGT'),
            16,
        )

        # checked against http://ds9a.nl/nwunsch/ (mismatch=1, gap=5, skew=5)
        nw5 = NeedlemanWunsch(5, _sim_nw)
        self.assertEqual(nw5.dist_abs('CGATATCAG', 'TGACGSTGC'), -5)
        self.assertEqual(nw5.dist_abs('AGACTAGTTAC', 'TGACGSTGC'), -7)
        self.assertEqual(nw5.dist_abs('AGACTAGTTAC', 'CGAGACGT'), -15)

        # test wrapper
        self.assertEqual(
            needleman_wunsch('AGACTAGTTAC', 'CGAGACGT', 5, _sim_nw), -15)
Esempio n. 5
0
 def test_gotoh_dist_abs_nialls(self):
     """Test abydos.distance.Gotoh.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)
     g22 = Gotoh(2, 2, _sim_nw)
     for i in range(len(NIALL)):
         self.assertEqual(g22.dist_abs(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.dist_abs(NIALL[0], NIALL[i]), nw_vals2[i])
         self.assertGreaterEqual(
             g205.dist_abs(NIALL[0], NIALL[i]),
             nw2.dist_abs(NIALL[0], NIALL[i]),
         )
Esempio n. 6
0
 def test_gotoh_dist_abs_nialls(self):
     """Test abydos.distance.Gotoh.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)
     g22 = Gotoh(2, 2, _sim_nw)
     for i in range(len(NIALL)):
         self.assertEqual(g22.dist_abs(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.dist_abs(NIALL[0], NIALL[i]), nw_vals2[i])
         self.assertGreaterEqual(
             g205.dist_abs(NIALL[0], NIALL[i]),
             nw2.dist_abs(NIALL[0], NIALL[i]),
         )