Skip to content

Commit 6969800

Browse files
afrubinbencap
andauthored
Bugfix/bencap/40/multi variant transcript ids fail regex validation (#42)
Co-authored-by: Ben Capodanno <[email protected]>
1 parent d36f34e commit 6969800

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/mavehgvs/patterns/combined.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
any_variant = (
99
r"(?:(?P<target_id>[a-zA-Z0-9_.-]+):)?"
10+
+ r"(?P<variant>"
1011
+ rf"(?P<single_variant>{r'|'.join([dsv, rsv, psv])})|"
1112
+ rf"(?P<multi_variant>{r'|'.join([dmv, rmv, pmv])})"
13+
+ r")"
1214
)

tests/test_variant.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_invalid_raises_error(self) -> None:
2626
"g.88_99=",
2727
"c.43-6_595+12=",
2828
"p.Glu27fs",
29+
"NM_001301.4:c.122-6T>A",
2930
]
3031

3132
invalid_variant_strings = [
@@ -50,6 +51,7 @@ def test_invalid_raises_error(self) -> None:
5051
"p.Gly24(=)",
5152
"p.Arg12LysfsTer18",
5253
"p.Glu27fs*?",
54+
"NM_001301.4::c.122-6T>A",
5355
]
5456

5557
for s in valid_variant_strings:
@@ -155,7 +157,7 @@ def test_delins(self) -> None:
155157

156158
def test_target_identical(self) -> None:
157159
identical_variant_strings = [
158-
*[f"{prefix}.=" for prefix in tuple("gmo" "cn" "r")],
160+
*[f"{prefix}.=" for prefix in tuple("gmocnr")],
159161
"p.(=)",
160162
"c.1_3=",
161163
]
@@ -221,6 +223,7 @@ def test_creation(self):
221223
"p.[Gly18del;Glu27Trp;Ter345Lys]",
222224
"p.[Gln7_Asn19del;Glu27Trp;Ter345Lys]",
223225
"c.[1_35del;78+5_78+10del;122T>A]",
226+
"NM_002002.3:c.[1_35del;78+5_78+10del;122T>A]",
224227
]
225228

226229
invalid_variant_strings = [
@@ -230,6 +233,8 @@ def test_creation(self):
230233
"c.[1_3=;12T>A;78+5_78+10del]",
231234
"p.[Glu27fs;Arg48Lys]",
232235
"p.[Glu27fs;Arg48fs]",
236+
"NM_002002.3::c.[1_35del;78+5_78+10del;122T>A]",
237+
"NM_002002.3:c.1_35del;78+5_78+10del;122T>A",
233238
]
234239

235240
for s in variant_strings:
@@ -1004,6 +1009,11 @@ def test_components(self):
10041009
("c.1_35del", "c.78+5_78+10del", "c.122T>A"),
10051010
),
10061011
("p.Glu27Trp", ("p.Glu27Trp",)),
1012+
("NP_002002.3:p.Glu27Trp", ("NP_002002.3:p.Glu27Trp",)),
1013+
(
1014+
"NP_002002.3:p.[Glu27Trp;Lys212fs]",
1015+
("NP_002002.3:p.Glu27Trp", "NP_002002.3:p.Lys212fs"),
1016+
),
10071017
]
10081018

10091019
for s, expected_components in variant_strings:
@@ -1015,7 +1025,7 @@ def test_components(self):
10151025
# TODO: multi-variant test cases
10161026
class TestMiscProperties(unittest.TestCase):
10171027
def test_prefix(self):
1018-
variant_tuples = [(prefix, f"{prefix}.=") for prefix in tuple("gmo" "cn" "r")]
1028+
variant_tuples = [(prefix, f"{prefix}.=") for prefix in tuple("gmocnr")]
10191029

10201030
for p, s in variant_tuples:
10211031
with self.subTest(p=p, s=s):
@@ -1109,6 +1119,7 @@ def test_target_id(self):
11091119
("YFG1", "YFG1:c.122-6T>A"),
11101120
("ENST00000471181.7", "ENST00000471181.7:c.122-6T>A"),
11111121
("NM_007294.4", "NM_007294.4:c.122-6T>A"),
1122+
("NM_007294.4", "NM_007294.4:c.[122-6T>A;153C>T]"),
11121123
]
11131124

11141125
for t, s in variant_tuples:

0 commit comments

Comments
 (0)