Sha256: d21c152d46fa4fd33d379a4a7049cdb378f591a45e7109b27375674db1527223

Contents?: true

Size: 1.89 KB

Versions: 144

Compression:

Stored size: 1.89 KB

Contents

import unittest

import hamming


# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0

class HammingTest(unittest.TestCase):

    def test_identical_strands(self):
        self.assertEqual(hamming.distance("A", "A"), 0)

    def test_long_identical_strands(self):
        self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)

    def test_complete_distance_in_single_nucleotide_strands(self):
        self.assertEqual(hamming.distance("A", "G"), 1)

    def test_complete_distance_in_small_strands(self):
        self.assertEqual(hamming.distance("AG", "CT"), 2)

    def test_small_distance_in_small_strands(self):
        self.assertEqual(hamming.distance("AT", "CT"), 1)

    def test_small_distance(self):
        self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)

    def test_small_distance_in_long_strands(self):
        self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)

    def test_non_unique_character_in_first_strand(self):
        self.assertEqual(hamming.distance("AGA", "AGG"), 1)

    def test_non_unique_character_in_second_strand(self):
        self.assertEqual(hamming.distance("AGG", "AGA"), 1)

    def test_same_nucleotides_in_different_positions(self):
        self.assertEqual(hamming.distance("TAG", "GAT"), 2)

    def test_large_distance(self):
        self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)

    def test_large_distance_in_off_by_one_strand(self):
        self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)

    def test_empty_strands(self):
        self.assertEqual(hamming.distance("", ""), 0)

    def test_disallow_first_strand_longer(self):
        with self.assertRaises(ValueError):
            hamming.distance("AATG", "AAA")

    def test_disallow_second_strand_longer(self):
        with self.assertRaises(ValueError):
            hamming.distance("ATA", "AGTG")


if __name__ == '__main__':
    unittest.main()

Version data entries

144 entries across 144 versions & 1 rubygems

Version Path
trackler-2.2.1.53 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.52 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.51 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.50 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.49 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.48 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.47 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.46 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.45 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.44 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.43 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.42 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.41 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.40 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.39 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.38 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.37 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.36 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.35 tracks/python/exercises/hamming/hamming_test.py
trackler-2.2.1.34 tracks/python/exercises/hamming/hamming_test.py