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.0.8.51 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.50 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.49 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.48 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.47 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.46 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.45 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.44 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.43 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.42 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.41 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.40 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.39 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.38 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.37 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.36 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.35 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.34 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.33 tracks/python/exercises/hamming/hamming_test.py
trackler-2.0.8.32 tracks/python/exercises/hamming/hamming_test.py