Skip to content

Commit

Permalink
faster --gt
Browse files Browse the repository at this point in the history
`.allele_indices` is slightly faster than the `["GT"]`. Also added a
short circuit where `--gt` doesn't need to be checked if pair of
variants already determined to be non-matching
  • Loading branch information
ACEnglish committed Dec 19, 2023
1 parent 64b1fa7 commit c688f64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions truvari/collapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def collapse_chunk(chunk, matcher):
short_circuit=True)
if matcher.hap and not hap_resolve(m_collap.entry, candidate):
mat.state = False
if matcher.gt and not gt_resolve(m_collap.entry, candidate):
if mat.state and matcher.gt and not gt_resolve(m_collap.entry, candidate):
mat.state = False
if mat.state:
m_collap.matches.append(mat)
Expand Down Expand Up @@ -302,8 +302,8 @@ def compat_phase(a, b):
return False

for sample in entryA.samples:
gtA = entryA.samples[sample]["GT"]
gtB = entryB.samples[sample]["GT"]
gtA = entryA.samples[sample].allele_indices
gtB = entryB.samples[sample].allele_indices
if (gtA == (1, 1) and None not in gtB) \
or (gtB == (1, 1) and None not in gtA):
return False
Expand Down
2 changes: 1 addition & 1 deletion truvari/phab.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections import defaultdict

import pysam
from pysam import bcftools, samtools
from pysam import samtools
from intervaltree import IntervalTree
from pywfa.align import WavefrontAligner # pylint: disable=no-name-in-module
import truvari
Expand Down

0 comments on commit c688f64

Please sign in to comment.