Skip to content

Commit

Permalink
issue #1227 - fix c.HGVS (make it null on any error like VEP now)
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Jan 17, 2025
1 parent 37dbdf8 commit 9a9bfd6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
7 changes: 3 additions & 4 deletions annotation/management/commands/fix_annotation_sv_c_hgvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from collections import Counter

from django.core.management.base import BaseCommand
from django.db.models import Q, Func, Value, F

from annotation.models import VariantAnnotation, VariantTranscriptAnnotation, VariantAnnotationVersion, \
TranscriptVersion, defaultdict, AnnotationRun, VariantAnnotationPipelineType, AnnotationStatus
from annotation.models import VariantAnnotation, VariantTranscriptAnnotation, \
TranscriptVersion, AnnotationRun, VariantAnnotationPipelineType, AnnotationStatus
from genes.hgvs import HGVSMatcher
from snpdb.models import Variant
from snpdb.models.models_genome import GenomeBuild
Expand Down Expand Up @@ -57,7 +56,7 @@ def handle(self, *args, **options):
transcript_accession)
hgvs_c_results["ok"] += 1
except Exception as e:
hgvs_c = VariantAnnotation.SV_HGVS_ERROR_MESSAGE
hgvs_c = None # c.HGVS is ok to be blank
hgvs_c_results["error"] += 1

record.hgvs_c = hgvs_c
Expand Down
28 changes: 28 additions & 0 deletions annotation/migrations/0123_one_off_fix_annotation_sv_c_hgvs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.17 on 2025-01-17 04:00

from django.db import migrations

from manual.operations.manual_operations import ManualOperation

def _check_has_sv_annotation(apps):
AnnotationRun = apps.get_model("annotation", "AnnotationRun")

VAP_STRUCTURAL_VARIANT = 'C'
AS_FINISHED = 'F'

qs = AnnotationRun.objects.filter(pipeline_type=VAP_STRUCTURAL_VARIANT,
status=AS_FINISHED,
annotated_count__gt=0)
return qs.exists()


class Migration(migrations.Migration):

dependencies = [
('annotation', '0122_vep_gnomad_t2t'),
]

operations = [
ManualOperation(task_id=ManualOperation.task_id_manage(["fix_annotation_sv_c_hgvs"]),
test=_check_has_sv_annotation)
]
3 changes: 2 additions & 1 deletion annotation/vcf_files/bulk_vep_vcf_annotation_inserter.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,15 @@ def _add_hgvs_c(self, variant_coordinate: Optional[VariantCoordinate], transcrip
return

if transcript_accession:

try:
hgvs_c = self.hgvs_matcher.variant_coordinate_to_hgvs_variant(variant_coordinate, transcript_accession)
self._generated_hgvs_c["OK"] += 1
# TODO: Protein?? hgvs_p
except Exception as e:
logging.error("Error calculating c.HGVS for '%s'/'%s': %s",
variant_coordinate, transcript_accession, e)
hgvs_c = VariantAnnotation.SV_HGVS_ERROR_MESSAGE
hgvs_c = None # For c.HGVS - it's ok to be blank
self._generated_hgvs_c["error"] += 1

transcript_data['hgvs_c'] = hgvs_c
Expand Down

0 comments on commit 9a9bfd6

Please sign in to comment.