Skip to content

Commit

Permalink
fix(call): handle bad allele list without crashing in VCF output
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Feb 5, 2024
1 parent 6817206 commit e936745
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion strkit/call/output/vcf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import pathlib
import pysam
from os.path import commonprefix
Expand Down Expand Up @@ -66,7 +67,12 @@ def _reversed_str(s: str) -> str:
return cat_strs(reversed(s))


def output_vcf_lines(sample_id: str, variant_file: pysam.VariantFile, results: tuple[dict, ...]):
def output_vcf_lines(
sample_id: str,
variant_file: pysam.VariantFile,
results: tuple[dict, ...],
logger: logging.Logger,
):
contig_vrs: list[pysam.VariantRecord] = []

def _write_contig_vrs():
Expand Down Expand Up @@ -113,6 +119,11 @@ def _write_contig_vrs():
seq_alleles.append(".")

start = result.get("start_adj", result["start"]) - len(ref_start_anchor)

if len(seq_alleles) < 2:
logger.error(f"{contig}:{start} - Don't have enough alleles to write record; have {seq_alleles}")
continue

vr: pysam.VariantRecord = variant_file.new_record(
contig=contig,
start=start,
Expand Down

0 comments on commit e936745

Please sign in to comment.