INNER CODE UNIT · Python
olap_gtf
BirolLab/straglr · straglr_compare.py:209
def olap_gtf(bed, gtf_file):
gtf = BedTool(gtf_file)
skipped_types = ('retained_intron', 'nonsense_mediated_decay', 'processed_transcript')
olaps = defaultdict(list)
assigned = {}
for cols in bed.intersect(gtf, wao=True, f=1.0):
locus = tuple(cols[:3])
if cols[3] == '.':
assigned[locus] = None
continue
feature = cols[5]
gff = create_interval_from_list(cols[3:-1])
gene = gff.attrs['gene_name']
transcript = None
transcript_type = None