Search code examples
binarybioinformaticshamming-distance

Calculate Hamming Distance with four taxa


I need to compute the Hamming Distance for the set of four taxa, L1, L2, L3, AND L4.

L1 = (0,1,0,1,0)
L2 = (0,0,0,0,0)
L3 = (1,0,0,0,0)
L4 = (1,0,1,0,1)

How can I do this to compute the hamming distance of all four together?


Solution

  • Just calculate the distance for each pair:

       L1  L2  L3  L4
    L1  0   3   2   0
    L2  3   0   4   2
    L3  2   4   0   3
    L4  0   2   3   0
    

    How to represent the matrix depends on the programming language you use. Some kind of two-dimensional array (or at least array-of-arrays) should be supported anywhere.