def _biotype_lookup_fn(gtf):
    """
    return a function that will look up the biotype of a feature
    this checks for either gene_biotype or biotype being set or for the source
    column to have biotype information
    """
    db = get_gtf_db(gtf)
    sources = set([feature.source for feature in db.all_features()])
    gene_biotypes = set([feature.attributes.get("gene_biotype", [None])[0]
                         for feature in db.all_features()])
    biotypes = set([feature.attributes.get("biotype", [None])[0]
                    for feature in db.all_features()])
    if "protein_coding" in sources:
        return lambda feature: feature.source
    elif "protein_coding" in biotypes:
        return lambda feature: feature.attributes.get("biotype", [None])[0]
    elif "protein_coding" in gene_biotypes:
        return lambda feature: feature.attributes.get("gene_biotype", [None])[0]
    else:
        return None
def _biotype_lookup_fn ( gtf ) : db = get_gtf_db ( gtf ) sources = set ( [ feature . source for feature in db . all_features ( ) ] ) gene_biotypes = set ( [ feature . attributes . get ( "gene_biotype" , [ None ] ) [ 0 ] for feature in db . all_features ( ) ] ) biotypes = set ( [ feature . attributes . get ( "biotype" , [ None ] ) [ 0 ] for feature in db . all_features ( ) ] ) if "protein_coding" in sources : return lambda feature : feature . source elif "protein_coding" in biotypes : return lambda feature : feature . attributes . get ( "biotype" , [ None ] ) [ 0 ] elif "protein_coding" in gene_biotypes : return lambda feature : feature . attributes . get ( "gene_biotype" , [ None ] ) [ 0 ] else : return None
return a function that will look up the biotype of a feature
    this checks for either gene_biotype or biotype being set or for the source
    column to have biotype information