import typing
from typing import Counter


def alignment_conservation(alignment: typing.Dict[str, str]) -> typing.List[float]:
    """
    Obtain residue conservations of each position in a sequence alignment

    Parameters
    ----------
    alignment
        dict of key: aligned sequence

    Returns
    -------
    list of conservation values
    """
    conservations = []
    length = len(alignment[list(alignment.keys())[0]])
    for pos in range(length):
        aligned_residues_count = Counter(
            [alignment[key][pos] for key in alignment if alignment[key][pos] != "-"]
        )
        conservation = aligned_residues_count.most_common(1)[0][1] / len(alignment)
        conservations.append(conservation)
    return conservations