def gen_otu_dict(nex_obj, nexson_version=None):
    """Takes a NexSON object and returns a dict of
    otu_id -> otu_obj
    """
    if nexson_version is None:
        nexson_version = detect_nexson_version(nex_obj)
    if _is_by_id_hbf(nexson_version):
        otus = nex_obj['nexml']['otusById']
        if len(otus) > 1:
            d = {}
            for v in otus.values():
                d.update(v['otuById'])
            return d
        else:
            return otus.values()[0]['otuById']
    o_dict = {}
    for ob in nex_obj.get('otus', []):
        for o in ob.get('otu', []):
            oid = o['@id']
            o_dict[oid] = o
    return o_dict
def gen_otu_dict ( nex_obj , nexson_version = None ) : if nexson_version is None : nexson_version = detect_nexson_version ( nex_obj ) if _is_by_id_hbf ( nexson_version ) : otus = nex_obj [ 'nexml' ] [ 'otusById' ] if len ( otus ) > 1 : d = { } for v in otus . values ( ) : d . update ( v [ 'otuById' ] ) return d else : return otus . values ( ) [ 0 ] [ 'otuById' ] o_dict = { } for ob in nex_obj . get ( 'otus' , [ ] ) : for o in ob . get ( 'otu' , [ ] ) : oid = o [ '@id' ] o_dict [ oid ] = o return o_dict
Takes a NexSON object and returns a dict of
    otu_id -> otu_obj