import statistics


def calculate_median_depths(document: dict) -> dict:
    """
    Calculate the median depth for all hits (sequences) in a Pathoscope result document.

    :param document: the pathoscope analysis document to calculate depths for
    :return: a dict of median depths keyed by hit (sequence) ids

    """
    depths = dict()

    for hit in document["results"]:
        depths[hit["id"]] = statistics.median(hit["align"])

    return depths