Skip to content

Commit

Permalink
speed shortcuts
Browse files Browse the repository at this point in the history
collapse - use available information to find out if a call can stop
being compared to its chunk early
bench - calculating all comparisons for every pair is useful for
ensuring full annotations are available on every compared call and
debugging and developers. But its slow. The `--short` option will
now stop comparing early and saves ~50% of bench runtime. This might
become the `--fullanno` option later.
matching - Don't pull alt '*' alleles.
  • Loading branch information
ACEnglish committed Feb 10, 2024
1 parent 2b5e921 commit d424140
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion truvari/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def parse_args(args):
help="Output directory")
parser.add_argument("-f", "--reference", type=str, default=None,
help="Fasta used to call variants. Turns on reference context sequence comparison")
parser.add_argument("--short", action="store_true",
help="Short circuit comparisions. Faster, but fewer annotations")
parser.add_argument("--debug", action="store_true", default=False,
help="Verbose logging")

Expand Down Expand Up @@ -751,7 +753,7 @@ def bench_main(cmdargs):
matcher = truvari.Matcher(args)

m_bench = Bench(matcher, args.base, args.comp, args.output,
args.includebed, args.extend, args.debug, True)
args.includebed, args.extend, args.debug, True, args.short)
output = m_bench.run()

logging.info("Stats: %s", json.dumps(output.stats_box, indent=4))
Expand Down
4 changes: 4 additions & 0 deletions truvari/collapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def collapse_chunk(chunk, matcher):
mat.state = False
if mat.state:
m_collap.matches.append(mat)
elif mat.sizesim is not None and mat.sizesim < matcher.params.pctsize:
# Can we do this? The sort tells us that we're going through most->least
# similar size. So the next one will only be worse...
break

# Does this collap need to go into a previous collap?
if not matcher.chain or not chain_collapse(m_collap, ret, matcher):
Expand Down
2 changes: 1 addition & 1 deletion truvari/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def filter_call(self, entry, base=False):
Returns True if the call should be filtered
Base has different filtering requirements, so let the method know
"""
if self.params.check_monref and entry.alts is None: # ignore monomorphic reference
if self.params.check_monref and entry.alts in (None, '*'): # ignore monomorphic reference
return True

if self.params.check_multi and len(entry.alts) > 1:
Expand Down

0 comments on commit d424140

Please sign in to comment.