Skip to content

Commit

Permalink
update bed parsing
Browse files Browse the repository at this point in the history
slightly faster IntervalTree.from_tuples than .addi
  • Loading branch information
ACEnglish committed Aug 11, 2024
1 parent b63c5c3 commit e0f9ce6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Use Truvari's comparison engine to consolidate redundant variants in a merged mu
- [segment](https://github.com/acenglish/truvari/wiki/segment) - Normalization of SVs into disjointed genomic regions
- [stratify](https://github.com/acenglish/truvari/wiki/stratify) - Count variants per-region in vcf
- [divide](https://github.com/ACEnglish/truvari/wiki/divide) - Divide a VCF into independent shards
- [ga4gh](https://github.com/ACEnglish/truvari/wiki/ga4gh) - Consolidate benchmarking result VCFs

## 🔎 More Information

Expand Down
Binary file modified repo_utils/answer_key/anno/anno_bpovl.jl
Binary file not shown.
4 changes: 2 additions & 2 deletions truvari/annotations/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def density_main(args):
# setting new indexes after masking
new_tree = defaultdict(IntervalTree)
cnt = 0
for chrom in tree:
for intv in tree[chrom]:
for chrom, intvs in tree.items():
for intv in intvs:
for i in range(intv.begin, intv.end, args.stepsize):
new_tree[chrom].addi(
i, min(intv.end, i + args.windowsize), data=cnt)
Expand Down
7 changes: 5 additions & 2 deletions truvari/region_vcf_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def build_anno_tree(filename, chrom_col=0, start_col=1, end_col=2, one_based=Fal
"""
idx = 0
correction = 1 if one_based else 0
tree = defaultdict(IntervalTree)
ttree = defaultdict(list)
for line in truvari.opt_gz_open(filename):
if line.startswith(comment):
continue
Expand All @@ -115,8 +115,11 @@ def build_anno_tree(filename, chrom_col=0, start_col=1, end_col=2, one_based=Fal
m_idx = idxfmt.format(idx)
else:
m_idx = idx
tree[chrom].addi(start, end + 1, data=m_idx)
ttree[chrom].append((start, end + 1, m_idx))
idx += 1
tree = {}
for chrom in ttree:
tree[chrom] = IntervalTree.from_tuples(ttree[chrom])
return tree, idx


Expand Down

0 comments on commit e0f9ce6

Please sign in to comment.