Skip to content

Commit

Permalink
fixed counting
Browse files Browse the repository at this point in the history
I wasn't chunking correctly. But now it's looking consistent
Also, I might have test coverage for cmd_exe keyboard interrupt
  • Loading branch information
ACEnglish committed Jan 5, 2025
1 parent e235e21 commit a4c7014
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions truvari/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,15 @@ def chunker(matcher, *files):
call_counts['__filtered'] += 1
continue

if entry.alleles_variant_types[1] == 'BND':
cur_chunk[f'{key}_BND'].append(entry)
continue
is_bnd = entry.alleles_variant_types[1] == 'BND'

if matcher.size_filter(entry, key=='base'):
if not is_bnd and matcher.size_filter(entry, key=='base'):
cur_chunk['__filtered'].append(entry)
call_counts['__filtered'] += 1
continue

# check symbolic, resolve if needed/possible
if matcher.params.pctseq != 0 and (entry.alleles_variant_types[-1] == 'BND' or entry.alts[0].startswith('<')):
if not is_bnd and matcher.params.pctseq != 0 and entry.alts[0].startswith('<'):
was_resolved = resolve_sv(entry,
matcher.reference,
matcher.params.dup_to_ins)
Expand All @@ -348,7 +346,11 @@ def chunker(matcher, *files):

cur_chrom = entry.chrom
cur_end = max(entry.stop, cur_end)
cur_chunk[key].append(entry)

if is_bnd:
cur_chunk[f'{key}_BND'].append(entry)
else:
cur_chunk[key].append(entry)
call_counts[key] += 1

chunk_count += 1
Expand Down
2 changes: 2 additions & 0 deletions truvari/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def cmd_exe(cmd, stdin=None, timeout=-1, cap_stderr=True, pipefail=False):
>>> ret = truvari.cmd_exe("sleep 5", pipefail=True, timeout=2/60) # Error logged is caught
>>> ret.ret_code
214
>>> import truvari
>>> ret = truvari.cmd_exe("(sleep 1 && kill -SIGINT $$) &") # Keyboard Interruptable
"""
cmd_result = namedtuple("cmd_result", "ret_code stdout stderr run_time")
t_start = time.time()
Expand Down

0 comments on commit a4c7014

Please sign in to comment.