@staticmethod
def _distance_matrix(data, i, metric, cache, matrix):
    """
        Function to calculate distance from the ith sequence of the ith row to the remaining entries in the same row
        :param data: list with all sequences
        :param i: int that indicates the matrix row being processed
        :param metric: function that takes two string and calculates distance
        :param cache: either a Manager or Cache object to cache results
        :param matrix: either a Manager or Cache object to store results in a matrix
        :return: None
        """
    row = []
    seq_1 = data[i]
    for j, seq_2 in enumerate(data):
        if i == j:
            row.append(0)
            continue
        keys = '{}-{}'.format(i, j), '{}-{}'.format(j, i)
        if keys[0] not in cache or keys[1] not in cache:
            cache['{}-{}'.format(i, j)] = metric(seq_1, seq_2)
        if keys[0] in cache:
            row.append(cache[keys[0]])
        elif keys[1] in cache:
            row.append(cache[keys[0]])
        else:
            raise ValueError('Bug in row {} and column {}'.format(i, j))
    matrix[i] = row
