def count_genes_in_pathway(pathways_gene_sets, genes):
    """Calculate how many of the genes are associated to each pathway gene set.

    :param dict pathways_gene_sets: pathways and their gene sets
    :param set genes: genes queried
    :rtype: dict
    """
    return {
        pathway: len(gene_set.intersection(genes))
        for pathway, gene_set in pathways_gene_sets.items()
    }