diff --git a/strkit/call/call_sample.py b/strkit/call/call_sample.py index 4bb3ab3..6c222e2 100644 --- a/strkit/call/call_sample.py +++ b/strkit/call/call_sample.py @@ -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() diff --git a/strkit/call/output/vcf.py b/strkit/call/output/vcf.py index 6b23ff4..261c692 100644 --- a/strkit/call/output/vcf.py +++ b/strkit/call/output/vcf.py @@ -1,4 +1,5 @@ import functools +import logging import pathlib import pysam from os.path import commonprefix @@ -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] = [] @@ -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,