from pathlib import Path
from typing import Dict


def ploidy_file_to_dict(ploidy_file: Path) -> Dict[str, int]:
    """
    Generates a dictionary from a ploidy tsv file
    :param ploidy_file:
    :return: A dictionary of contigs and their ploidy
    """
    ploidy_dict = dict()
    with ploidy_file.open("r") as file_h:
        for line in file_h:
            chromosome, ploidy = line.strip().split("\t")
            ploidy_dict[chromosome] = int(ploidy)
    return ploidy_dict