import collections


def CountGO(gene2go):
    """count number of genes and go categories in mapping."""

    cats = collections.defaultdict(int)
    nmaps = 0
    for k, vv in gene2go.items():
        for v in vv:
            nmaps += 1
            cats[v.mGOId] += 1

    return len(gene2go), len(cats), nmaps, cats