def get_target_regions_dict(targets_file):
""" Gets the target regions from a targets file as a chrom-indexed dictionary,
with every entry given as a list of (start, end) tuples
"""
targets = {}
for line in targets_file:
info = line.strip().split('\t')
if line.startswith('browser') or line.startswith('track') or line.startswith('-browser') or line.startswith('-track') or line.startswith('#'):
continue
if len(line.strip()) == 0:
continue
chrom = info[0]
start = int(info[1])
end = int(info[2])
chrom_targs = targets.setdefault(chrom, [])
chrom_targs.append((start, end))
return targets
评论列表
文章目录