def get_gene(variant): for anno in annos: consequences = variant.INFO[anno].split(",") effs = (Effect.new(anno, c, annos[anno]) for c in consequences) # limit to requested severity if severity is not None: effs = [e for e in effs if e.impact_severity in severity] effs = sorted(effs, reverse=True) for eff in effs: if eff.gene: return eff.gene