def determine_corrections(valid, invalid): corrections = [] for iv in invalid: for v in valid: if pm.hamming_distance(iv, v) == 1: corrections.append([iv, v]) return corrections
def test_no_difference_between_identical_strands(self): self.assertEqual(hamming_distance('GGACTGA', 'GGACTGA'), 0)
def test_no_difference_between_empty_strands(self): self.assertEqual(hamming_distance('', ''), 0)
def test_ignores_extra_length_on_original_strand_when_longer(self): self.assertEqual( hamming_distance('GACTACGGACAGGGTAGGGAAT', 'GACATCGCACACC'), 5)
def test_ignores_extra_length_on_other_strand_when_longer(self): self.assertEqual(hamming_distance('AAACTAGGGG', 'AGGCTAGCGGTAGGAC'), 3)
def test_larger_distance(self): self.assertEqual(hamming_distance('ACCAGGG', 'ACTATGG'), 2)
def test_small_hamming_distance_in_middle_somewhere(self): self.assertEqual(hamming_distance('GGACG', 'GGTCG'), 1)
def test_hamming_distance_in_off_by_one_strand(self): self.assertEqual( hamming_distance('GGACGGATTCTGACCTGGACTAATTTTGGGG', 'AGGACGGATTCTGACCTGGACTAATTTTGGGG'), 19)
def test_complete_hamming_distance_in_small_strand(self): self.assertEqual(hamming_distance('ACT', 'GGA'), 3)
def p_distance(s1, s2): # hamming distance / total bases return pm.hamming_distance(s1, s2) / len(s1)