def align_matches(matches: list):
    """
    takes matches from find_matches and converts it to a dictionary of counts per offset and file name

    Args
        matches (list[str, int]): list of matches from find_matches

    Returns
    -------
        sample_difference_counter (dict{str{int}}): of the form dict{file_name{number of matching offsets}}
    """

    print("Aligning matches")
    sample_difference_counter = {}
    for file_name, sample_difference, _, _ in matches:
        if file_name not in sample_difference_counter:
            sample_difference_counter[file_name] = {}
        if sample_difference not in sample_difference_counter[file_name]:
            sample_difference_counter[file_name][sample_difference] = [0, None]
        sample_difference_counter[file_name][sample_difference][0] += 1

    return sample_difference_counter