Пример #1
0
    def test_disallow_second_strand_longer(self):
        with self.assertRaises(ValueError) as err:
            distance("ATA", "AGTG")

        self.assertEqual(type(err.exception), ValueError)
        self.assertEqual(err.exception.args[0],
                         "Strands must be of equal length.")
Пример #2
0
    def test_disallow_right_empty_strand(self):
        with self.assertRaises(ValueError) as err:
            distance("G", "")

        self.assertEqual(type(err.exception), ValueError)
        self.assertEqual(err.exception.args[0],
                         "Strands must be of equal length.")
Пример #3
0
 def test_disallow_second_strand_longer(self):
     with self.assertRaisesWithMessage(ValueError):
         hamming.distance("ATA", "AGTG")
Пример #4
0
 def test_empty_strands(self):
     self.assertEqual(hamming.distance("", ""), 0)
def test_raises_with_msg_if_second_has_invalid_base():
    with pytest.raises(ValueError) as exception_info:
        hamming.distance("CAGT", "CAGE")
    assert hamming.INVALID_BASE_MESSAGE in str(exception_info)
Пример #6
0
 def test_long_different_strands(self):
     self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
def test_three_different_at_end_means_distance_one():
    assert hamming.distance("GCA", "GCG") == 1
def test_different_three_means_distance_three():
    assert hamming.distance("GCA", "CAG") == 3
Пример #9
0
 def test_same_nucleotides_in_different_positions(self):
     self.assertEqual(hamming.distance("TAG", "GAT"), 2)
def test_different_singles_means_distance_one():
    assert hamming.distance("G", "C") == 1
Пример #11
0
 def test_small_distance_in_long_strands(self):
     self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)
Пример #12
0
 def test_non_unique_character_in_second_strand(self):
     self.assertEqual(hamming.distance("AGG", "AGA"), 1)
Пример #13
0
 def test_small_distance(self):
     self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)
Пример #14
0
 def test_small_distance_in_small_strands(self):
     self.assertEqual(hamming.distance("AT", "CT"), 1)
Пример #15
0
 def test_complete_distance_in_small_strands(self):
     self.assertEqual(hamming.distance("AG", "CT"), 2)
Пример #16
0
 def test_complete_distance_in_single_nucleotide_strands(self):
     self.assertEqual(hamming.distance("A", "G"), 1)
Пример #17
0
 def test_large_distance(self):
     self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)
Пример #18
0
def test_distance_returns_zero_with_two_empty_strings():
    assert distance('', '') == 0
Пример #19
0
 def test_large_distance_in_off_by_one_strand(self):
     self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
def test_three_different_at_start_means_distance_one():
    assert hamming.distance("GCA", "CCA") == 1
Пример #21
0
 def test_empty_strands(self):
     self.assertEqual(hamming.distance("", ""), 0)
def test_three_same_only_in_middle_means_distance_two():
    assert hamming.distance("GCA", "TCC") == 2
Пример #23
0
 def test_disallow_first_strand_longer(self):
     with self.assertRaises(ValueError):
         hamming.distance("AATG", "AAA")
def test_raises_with_msg_if_second_shorter():
    with pytest.raises(ValueError) as exception_info:
        hamming.distance("GCA", "TG")
    assert hamming.LENGTH_MISMATCH_MESSAGE in str(exception_info)
Пример #25
0
 def test_disallow_second_strand_longer(self):
     with self.assertRaises(ValueError):
         hamming.distance("ATA", "AGTG")
Пример #26
0
 def test_small_hamming_distance2(self):
     self.assertEqual(2, hamming.distance('ATA', 'CTG'))
Пример #27
0
 def test_identical_strands(self):
     self.assertEqual(hamming.distance("A", "A"), 0)
Пример #28
0
 def test_disallow_first_strand_longer(self):
     with self.assertRaisesWithMessage(ValueError):
         hamming.distance("AATG", "AAA")
Пример #29
0
def test_distance_raises_exception_with_more_than_two_strings():
    with pytest.raises(Exception):
        distance('', '', '')
Пример #30
0
 def test_disallow_right_empty_strand(self):
     with self.assertRaisesWithMessage(ValueError):
         hamming.distance("G", "")
Пример #31
0
def test_distance_returns_zero_with_one_non_empty_and_one_space_string():
    assert distance('ab', '  ab') == 0
Пример #32
0
def test_distance_raises_exception_with_one_string():
    with pytest.raises(Exception):
        distance('')
Пример #33
0
 def test_long_identical_strands(self):
     self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)
Пример #34
0
def test_distance_raises_exception_when_left_non_empty_string_shorter_than_right():
    with pytest.raises(Exception):
        distance('st', 'str')
Пример #35
0
 def test_complete_hamming_distance_of_for_single_nucleotide_strand(self):
     self.assertEqual(1, hamming.distance('A', 'G'))
Пример #36
0
def test_distance_with_distance_two():
    assert distance('abc', 'aeo') == 2
    
Пример #37
0
 def test_complete_hamming_distance_of_for_small_strand(self):
     self.assertEqual(2, hamming.distance('AG', 'CT'))
Пример #38
0
def test_distance_raises_exception_without_strings():
    with pytest.raises(Exception):
        distance()
Пример #39
0
 def test_small_hamming_distance(self):
     self.assertEqual(1, hamming.distance('AT', 'CT'))
def test_same_three_means_distance_zero():
    assert hamming.distance("GCA", "GCA") == 0
Пример #41
0
 def test_small_hamming_distance_in_longer_strand(self):
     self.assertEqual(1, hamming.distance('GGACG', 'GGTCG'))
def test_three_different_in_middle_means_distance_one():
    assert hamming.distance("GCA", "GGA") == 1
Пример #43
0
 def test_large_hamming_distance(self):
     self.assertEqual(4, hamming.distance('GATACA', 'GCATAA'))
def test_three_same_only_at_start_means_distance_two():
    assert hamming.distance("GCA", "GTG") == 2
Пример #45
0
 def test_hamming_distance_in_very_long_strand(self):
     self.assertEqual(9, hamming.distance('GGACGGATTCTG', 'AGGACGGATTCT'))
def test_three_same_only_at_end_means_distance_two():
    assert hamming.distance("GCA", "CGA") == 2
Пример #47
0
 def test_no_difference_between_identical_strands(self):
     self.assertEqual(0, hamming.distance('A', 'A'))
def test_two_empty_means_distance_zero():
    assert hamming.distance("", "") == 0
Пример #49
0
 def test_single_letter_different_strands(self):
     self.assertEqual(hamming.distance("G", "T"), 1)
def test_same_singles_means_distance_zero():
    assert hamming.distance("G", "G") == 0
Пример #51
0
 def test_long_identical_strands(self):
     self.assertEqual(hamming.distance("GGACTGAAATCTG", "GGACTGAAATCTG"), 0)
def test_raises_with_msg_if_second_not_string():
    with pytest.raises(ValueError) as exception_info:
        hamming.distance("TG", 3)
    assert hamming.NOT_STRING_MESSAGE in str(exception_info)
Пример #53
0
 def test_non_unique_character_in_first_strand(self):
     self.assertEqual(hamming.distance("AAG", "AAA"), 1)