From 1f691958edd7b9406fe3ee38e39184646a375bdc Mon Sep 17 00:00:00 2001 From: TheMadBug Date: Tue, 22 Aug 2023 15:28:05 +1000 Subject: [PATCH] HGVS Resolution Tool: include version numbers, format message vs error --- .../classification/hgvs_resolution_tool.html | 9 ++++++++- .../views/views_hgvs_resolution_tool.py | 15 +++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/classification/templates/classification/hgvs_resolution_tool.html b/classification/templates/classification/hgvs_resolution_tool.html index deef0a05b..8322bf4ae 100644 --- a/classification/templates/classification/hgvs_resolution_tool.html +++ b/classification/templates/classification/hgvs_resolution_tool.html @@ -3,6 +3,7 @@ {% load static %} {% load classification_tags %} {% load js_tags %} +{% load ui_utils %} {% load compress %} {% load ui_help %} {% load ui_menu_bars %} @@ -49,7 +50,13 @@

HGVS Resolution Tool

{{ output.variant_coordinate|dash_if_empty }} {{ output.transcript_version|dash_if_empty }} {% c_hgvs output.hgvs %} - {{ output.error|default_if_none:"" }} + + {% if output.is_error %} + {{ 'E' | severity_icon }} {{ output.message }} + {% elif output.message %} + {{ output.message }} + {% endif %} + {% endfor %} diff --git a/classification/views/views_hgvs_resolution_tool.py b/classification/views/views_hgvs_resolution_tool.py index 3dbda9303..d955ace91 100644 --- a/classification/views/views_hgvs_resolution_tool.py +++ b/classification/views/views_hgvs_resolution_tool.py @@ -29,13 +29,17 @@ class MatcherOutput: variant_coordinate: Optional[VariantCoordinate] = None transcript_version: Optional[TranscriptParts] = None hgvs: Optional[str] = None - error: Optional[str] = None + message: Optional[str] = None @property def explicit_variant_coordinate(self): if vc := self.variant_coordinate: return vc.explicit_reference() + @property + def is_error(self): + return not self.hgvs + class MatcherOutputs: @@ -91,13 +95,12 @@ def hgvs_resolution_tool(request: HttpRequest): output.transcript_version = tv.as_parts if v := resolved_variant.variant: output.variant_coordinate = v.coordinate - output.error = iai.message + output.message = iai.message - use_matchers = [(HGVSConverterType.PYHGVS, "pyhgvs"), (HGVSConverterType.BIOCOMMONS_HGVS, "biocommons")] - for matcher_id, matcher_name in use_matchers: + for matcher_id in [HGVSConverterType.PYHGVS, HGVSConverterType.BIOCOMMONS_HGVS]: matcher = HGVSMatcher(genome_build, hgvs_converter_type=matcher_id) - output = MatcherOutput(matcher_name=matcher_name) + output = MatcherOutput(matcher_name=matcher.hgvs_converter.description()) all_output.append(output) stage = "Basic Parsing" @@ -118,7 +121,7 @@ def hgvs_resolution_tool(request: HttpRequest): output.hgvs = variant_details.format() except Exception as ex: - output.error = stage + ": " + str(ex) + output.message = stage + ": " + str(ex) return render(request, "classification/hgvs_resolution_tool.html", context)