From 594652436a51cd1de2ce5e27b78cc56917db1663 Mon Sep 17 00:00:00 2001 From: Oliver Stolpe Date: Wed, 29 Apr 2020 17:34:08 +0200 Subject: [PATCH] Blocking upload of VCF files with GRCh38/hg38/hg19 builds for VarFish Kiosk. --- HISTORY.rst | 2 ++ variants/forms.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6f2dbad0e..e039cff52 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,12 +11,14 @@ End-User Summary - Fixed bug where some variant flags didn't color the row in filtering results after reloading the page. - Fixed upload bug in VarFish Kiosk when vcf file was too small. +- Blocking upload of VCF files with GRCh38/hg38/hg19 builds for VarFish Kiosk. Full Change List ================ - Fixed bug where some variant flags didn't color the row in filtering results after reloading the page. - Fixed upload bug in VarFish Kiosk when vcf file was too small and the file copy process didn't flush the file completely resulting in only a parly available header. +- Blocking upload of VCF files with GRCh38/hg38/hg19 builds for VarFish Kiosk. ------- v0.21.0 diff --git a/variants/forms.py b/variants/forms.py index aa331b553..1806cf8fa 100644 --- a/variants/forms.py +++ b/variants/forms.py @@ -1640,7 +1640,8 @@ def clean(self): tmp_file.flush() self.cleaned_data.get("vcf_file").seek(0) try: - vcf_samples = vcfpy.Reader.from_path(tmp_file.name).header.samples.names + vcf_header = vcfpy.Reader.from_path(tmp_file.name).header + vcf_samples = vcf_header.samples.names self.cleaned_data["vcf_index"] = vcf_samples[0] if ped_samples and set(vcf_samples) != set(ped_samples): self.add_error( @@ -1652,6 +1653,15 @@ def clean(self): self.cleaned_data["ped"] = [ "\t".join(["FAM", sample, "0", "0", "1", "2"]) for sample in vcf_samples ] + for entry in list(vcf_header.get_lines("contig")): + # GRCh38/hg38? + if entry.id in ("chr1", "1") and int(entry.length) == 248956422: + self.add_error("vcf_file", "Only GRCh37 build is supported!") + break + # hg19? + if entry.id == "chr1" and int(entry.length) == 249250621: + self.add_error("vcf_file", "Only GRCh37 build is supported!") + break except vcfpy.exceptions.VCFPyException as e: self.add_error("vcf_file", "Problem with VCF file: %s" % e)