<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_terms(desc, geneset, assoc, obo_dag, log):
 """Get the terms in the study group """

    _chk_gene2go(assoc)
    term2itemids = defaultdict(set)
    genes = [g for g in geneset if g in assoc]
    for gene in genes:
        for goid in assoc[gene]:
            if goid in obo_dag:
                term2itemids[obo_dag[goid].id].add(gene)
    if log is not None:
        num_stu = len(genes)
        num_pop = len(geneset)
        perc = 100.0*num_stu/num_pop if num_pop != 0 else 0.0
        log.write("{P:3.0f}% {N:>6,} of {M:>6,} {DESC} items found in association\n".format(
            DESC=desc, N=num_stu, M=num_pop, P=perc))
    return term2itemids