Skip to content

Commit

Permalink
fix(call): error message + skip if SNV has <2 alleles (VCF out)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Feb 12, 2024
1 parent 502f056 commit 45ad954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion strkit/call/call_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def call_sample(

# - write partial results to VCF if we're writing a VCF
if vf is not None:
output_vcf_lines(params, sample_id_str, vf, results)
output_vcf_lines(params, sample_id_str, vf, results, logger)

last_qsize = qsize
qsize = locus_queue.qsize()
Expand Down
6 changes: 6 additions & 0 deletions strkit/call/output/vcf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import logging
import pathlib
import pysam
from os.path import commonprefix
Expand Down Expand Up @@ -84,6 +85,7 @@ def output_vcf_lines(
sample_id: str,
variant_file: pysam.VariantFile,
results: tuple[dict, ...],
logger: logging.Logger,
):
contig_vrs: list[pysam.VariantRecord] = []

Expand Down Expand Up @@ -166,6 +168,10 @@ def _write_contig_vrs():
snv_alleles = (ref, *snv_alts)
snv_pos = snv["pos"]

if len(snv_alleles) < 2:
logger.error(f"Error while writing VCF: SNV ({snv_id}) at {contig}:{snv_pos+1} has no alts")
continue

snv_vr = variant_file.new_record(
contig=contig,
id=snv_id,
Expand Down

0 comments on commit 45ad954

Please sign in to comment.