def count_terms(geneset, assoc, obo_dag):
    """count the number of terms in the study group
    """
    term_cnt = Counter()
    for gene in (g for g in geneset if g in assoc):
        for goid in assoc[gene]:
            if goid in obo_dag:
                term_cnt[obo_dag[goid].id] += 1

    return term_cnt
count the number of terms in the study group