bioin.replication.hamming_distance

bioin.replication.hamming_distance(p, q)[source]

Calculate the HammingDistance for two strings. We say that position i in k-mers p and q is a mismatch if the symbols at position i of the two strings are not the same. The total number of mismatches between strings p and q is called the Hamming distance between these strings. We will let you implement a function to compute this distance, called HammingDistance(p, q).

Parameters:
  • p (str) – the first DNA string.
  • q (str) – the second DNA string, p and q of the equal length.
Returns:

Integer, number of different base count between p and q, i.e. the Hamming distance between these strings.

Examples

Solving the Hamming distance of two DNA Genomes.

>>> p = 'GGGCCGTTGGT'
>>> q = 'GGACCGTTGAC'
>>> hammingdistance = hamming_distance(p, q)
>>> hammingdistance
    3