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.1.0.36 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.34 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.33 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.32 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.31 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.30 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.29 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.28 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.27 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.26 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.25 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.24 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.23 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.22 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.21 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.20 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.19 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.18 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.17 tracks/python/exercises/hamming/hamming_test.py
trackler-2.1.0.16 tracks/python/exercises/hamming/hamming_test.py