Skip to content

Commit

Permalink
HGVS Resolution Tool: include version numbers, format message vs error
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMadBug committed Aug 22, 2023
1 parent d25d8ea commit 1f69195
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load static %}
{% load classification_tags %}
{% load js_tags %}
{% load ui_utils %}
{% load compress %}
{% load ui_help %}
{% load ui_menu_bars %}
Expand Down Expand Up @@ -49,7 +50,13 @@ <h3>HGVS Resolution Tool</h3>
<td>{{ output.variant_coordinate|dash_if_empty }}</td>
<td>{{ output.transcript_version|dash_if_empty }}</td>
<td>{% c_hgvs output.hgvs %}</td>
<td>{{ output.error|default_if_none:"" }}</td>
<td>
{% if output.is_error %}
{{ 'E' | severity_icon }} {{ output.message }}
{% elif output.message %}
<span class="text-secondary">{{ output.message }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
15 changes: 9 additions & 6 deletions classification/views/views_hgvs_resolution_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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"
Expand All @@ -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)

0 comments on commit 1f69195

Please sign in to comment.