def tokenize_ensembl(anno, keep_unknown=True):
    """
    Take an Ensembl annotation loaded from json and extract the domains, like
    words in a document. Collapse the double strand into one string of domains.

    Omit all domains that are not on the chromosome, e.g. plasmids such
    as p3ABAYE. The GTDB omits plasmids, bc/ they behave differently from the
    chromosome and follow their own "life history" (think the selfish gene).

    Return the assembly ID and a dict of contigs (keys) and associated
    domains (values), the latter linearly ordered. If <keep_unknown>, ORFs
    without Pfam annotations will receive the "unknown" label.
    """
    from collections import defaultdict
    genome = anno['assembly']['accession']
    d = {}
    for g in anno['genes']:
        start = int(g['start'])
        end = int(g['end'])
        strand = g['strand']
        try:
            contig = g['ENA_FEATURE_GENE'][0].split(':')[0]
        except KeyError:
            contig = 'NA'
        uid = contig, start, end
        try:
            domains = g['Pfam']
        except KeyError:
            if keep_unknown:
                domains = ['unknown']
            else:
                pass
        if contig != 'NA':
            d[uid] = domains
    result = defaultdict(list)
    for k, v in sorted(d.items()):
        result[k[0]].extend(v)
    return genome, result
