Skip to content

Commit

Permalink
anno chunks bed and unresolved sv fix
Browse files Browse the repository at this point in the history
can now count chunks with bed file restriction
Fix some SVs being incorrectly marked as unresolved
  • Loading branch information
ACEnglish committed Nov 20, 2024
1 parent fb0c3a0 commit 25898a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions truvari/annotations/chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def parse_args(args):
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("input", type=str,
help="Input VCF")
parser.add_argument("-b", "--bed", type=str, default=None,
help="Bed file of variants to chunk")
parser.add_argument("-o", "--output", type=str, default="/dev/stdout",
help="Output name")
parser.add_argument("-c", "--chunksize", type=int, default=500,
Expand Down Expand Up @@ -55,6 +57,9 @@ def chunks_main(args):
m.params.sizemax = args.sizemax
m.params.chunksize = args.chunksize
m.params.refdist = args.chunksize
if args.bed:
regions = truvari.build_region_tree(v, includebed=args.bed)
v = truvari.region_filter(v, regions)
c = truvari.chunker(m, ('base', v))

with open(args.output, 'w') as fout:
Expand Down
10 changes: 7 additions & 3 deletions truvari/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def filter_call(self, entry, base=False):
f"Cannot compare multi-allelic records. Please split\nline {str(entry)}")

# Don't compare BNDs, ever
if entry.alleles_variant_types[1] == 'BND':
return True
#if entry.alleles_variant_types[1] == 'BND':
# return True

if self.params.passonly and truvari.entry_is_filtered(entry):
return True
Expand Down Expand Up @@ -312,7 +312,7 @@ def chunker(matcher, *files):
continue

# check symbolic, resolve if needed/possible
if matcher.params.pctseq != 0 and entry.alts[0].startswith('<'):
if matcher.params.pctseq != 0 and entry.alleles_variant_types[-1] == 'BND' or entry.alts[0].startswith('<'):
was_resolved = resolve_sv(entry,
matcher.reference,
matcher.params.dup_to_ins)
Expand Down Expand Up @@ -354,6 +354,10 @@ def resolve_sv(entry, ref, dup_to_ins=False):
if ref is None or entry.alts[0] in ['<CNV>', '<INS>'] or entry.start > ref.get_reference_length(entry.chrom):
return False

if entry.alleles_variant_types[1] == 'BND' and "SVTYPE" in entry.info \
and truvari.entry_variant_type(entry) == truvari.SV.DEL:
entry.alts = ['<DEL>']

seq = ref.fetch(entry.chrom, entry.start, entry.stop)
if entry.alts[0] == '<DEL>':
entry.ref = seq
Expand Down

0 comments on commit 25898a1

Please sign in to comment.