def make_clustering_matrix(matrix):
    """
    calculates similarity between reads to be put in the clustering matrix
    :param matrix:
    :return filled clustering matrix:
    """
    clustering_matrix = {}
    for i in range(len(matrix)):
        clustering_matrix[str(i)] = {}
        for j in range(i + 1):
            mutations_in_common = 0
            if j == i:
                clustering_matrix[str(i)][str(j)] = 0
            else:
                amount_positions = len(matrix[i])
                for pos in range(len(matrix[i])):
                    if matrix[i][pos] == '-' and matrix[j][pos] == '-':
                        amount_positions -= 1
                        continue
                    if matrix[i][pos] == matrix[j][pos]:
                        mutations_in_common += 1
                if amount_positions == 0:
                    clustering_matrix[str(i)][str(j)] = 0
                else:
                    clustering_matrix[str(i)][str(j)
                        ] = mutations_in_common / amount_positions
    return clustering_matrix
