Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ga4gh/vrs/extras/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _from_beacon(self, beacon_expr: str, **kwargs) -> models.Allele | None:
if not isinstance(beacon_expr, str):
return None

m = self.beacon_re.match(beacon_expr.replace(" ", ""))
m = self.beacon_re.fullmatch(beacon_expr.replace(" ", ""))
if not m:
return None

Expand Down Expand Up @@ -321,7 +321,7 @@ def _from_gnomad(self, gnomad_expr: str, **kwargs) -> models.Allele | None:
"""
if not isinstance(gnomad_expr, str):
return None
m = self.gnomad_re.match(gnomad_expr)
m = self.gnomad_re.fullmatch(gnomad_expr)
if not m:
return None

Expand Down Expand Up @@ -395,7 +395,7 @@ def _from_spdi(self, spdi_expr: str, **kwargs) -> models.Allele | None:
if not isinstance(spdi_expr, str):
return None

m = self.spdi_re.match(spdi_expr)
m = self.spdi_re.fullmatch(spdi_expr)
if not m:
return None

Expand Down
16 changes: 16 additions & 0 deletions tests/extras/test_allele_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ def test_from_invalid(tlr):
tlr.translate_from("BRAF amplication", assembly_name="GRCh37")


@pytest.mark.parametrize(
("expr", "fmt"),
[
# multi-allelic gnomAD-style input must not be truncated to its first ALT
("1-55516888-G-GA,GT", "gnomad"),
("19-44908822-C-T;foo", "gnomad"),
("NC_000019.10:44908821:1:T:extra", "spdi"),
("19 : 44908822 C > T,G", "beacon"),
],
)
def test_from_trailing_input_rejected(tlr, expr, fmt):
"""Expressions with trailing content must be rejected, not partially parsed"""
with pytest.raises(ValueError, match=f"Unable to parse data as {fmt}"):
tlr.translate_from(expr, fmt=fmt)


@pytest.mark.vcr
def test_from_beacon(tlr):
do_normalize = False
Expand Down
Loading