Skip to content

Commit

Permalink
Handle = in synonymous variant names
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert committed Feb 5, 2021
1 parent f528c0c commit 1a853c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions civicpy/civic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from datetime import datetime, timedelta
from backports.datetime_fromisoformat import MonkeyPatch
MonkeyPatch.patch_fromisoformat()
import re


CACHE = dict()
Expand Down Expand Up @@ -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 []
Expand All @@ -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)),
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion civicpy/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}

Expand Down

0 comments on commit 1a853c9

Please sign in to comment.