diff --git a/civicpy/civic.py b/civicpy/civic.py index 1567b09..ba9a93f 100644 --- a/civicpy/civic.py +++ b/civicpy/civic.py @@ -15,6 +15,7 @@ from datetime import datetime, timedelta from backports.datetime_fromisoformat import MonkeyPatch MonkeyPatch.patch_fromisoformat() +import re CACHE = dict() @@ -610,6 +611,14 @@ def hgvs_p(self): else: return '' + def sanitized_name(self): + name = self.name + regex = re.compile(r"^([A-Z]+)([0-9]+)(=)(.*)$") + match = regex.match(name) + if match is not None: + name = "".join([match.group(1), match.group(2), match.group(1), match.group(4)]) + return name + def csq(self, include_status=None): if self.csq_alt() is None: return [] @@ -628,7 +637,7 @@ def csq(self, include_status=None): str(self.coordinates.representative_transcript), self.hgvs_c(), self.hgvs_p(), - self.name, + self.sanitized_name(), str(self.id), '&'.join(map(lambda a: a.translate(special_character_table), self.variant_aliases)), '&'.join(map(lambda e: e.translate(special_character_table), self.hgvs_expressions)), @@ -667,7 +676,7 @@ def csq(self, include_status=None): str(self.coordinates.representative_transcript), self.hgvs_c(), self.hgvs_p(), - self.name, + self.sanitized_name(), str(self.id), '&'.join(map(lambda a: a.translate(special_character_table), self.variant_aliases)), '&'.join(map(lambda e: e.translate(special_character_table), self.hgvs_expressions)), diff --git a/civicpy/exports.py b/civicpy/exports.py index d91f949..0edba8a 100644 --- a/civicpy/exports.py +++ b/civicpy/exports.py @@ -205,7 +205,7 @@ def writerecords(self, with_header=True): info_dict = { 'GN': variant.gene.name, - 'VT': variant.name, + 'VT': variant.sanitized_name(), 'CSQ': ','.join(variant.csq()), }