From 7e2ca3286080990181a85064ce9f6b9914afc3c4 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Mon, 8 Jul 2024 13:14:28 +0930 Subject: [PATCH] issue #1090 VEP minor release changes (git hash) cause VEPVersionMismatchError --- .../0108_one_off_vep_version_major_only.py | 26 +++++++++++++++++++ annotation/vep_annotation.py | 12 +++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 annotation/migrations/0108_one_off_vep_version_major_only.py diff --git a/annotation/migrations/0108_one_off_vep_version_major_only.py b/annotation/migrations/0108_one_off_vep_version_major_only.py new file mode 100644 index 000000000..51d15ce79 --- /dev/null +++ b/annotation/migrations/0108_one_off_vep_version_major_only.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.10 on 2024-07-08 03:35 + +from django.db import migrations + + +def _major_version(version_str) -> str: + return version_str.split(".")[0] + + +def _one_off_vep_version_major_only(apps, schema_editor): + VariantAnnotationVersion = apps.get_model('annotation', 'VariantAnnotationVersion') + + for vav in VariantAnnotationVersion.objects.all(): + vav.ensembl = _major_version(vav.ensembl) + vav.ensembl_io = _major_version(vav.ensembl_io) + vav.save() + + +class Migration(migrations.Migration): + dependencies = [ + ('annotation', '0107_one_off_change_hgvs_g_too_long_message'), + ] + + operations = [ + migrations.RunPython(_one_off_vep_version_major_only) + ] diff --git a/annotation/vep_annotation.py b/annotation/vep_annotation.py index dd53e43aa..cf01da529 100644 --- a/annotation/vep_annotation.py +++ b/annotation/vep_annotation.py @@ -236,14 +236,22 @@ def get_vep_version(genome_build: GenomeBuild, annotation_consortium): def vep_dict_to_variant_annotation_version_kwargs(vep_config, vep_version_dict: dict) -> dict: - def vep_int_version(vep_string_version): + def _vep_int_version(vep_string_version): m = re.match(r"v(\d+)", vep_string_version) return int(m.group(1)) + # We strip off the hash ie '110.73b02d8' -> '110' so that we can re-use annotation + # if VEP do a minor bugfix change to their releases etc + def _major_version(version_str) -> str: + return version_str.split(".")[0] + + FIELD_CONVERSION = { - "vep": vep_int_version, + "vep": _vep_int_version, "cosmic": int, "dbsnp": int, + "ensembl": _major_version, + "ensembl_io": _major_version, } FIELD_LOOKUP = {