Skip to content

Commit 6c32886

Browse files
authored
feat: add deprecation warning for beacon translation (#578)
close #568 * One of the Beacon leads (@mbaudis) requested this to be removed since it does not follow the standard, for now we will add a deprecation message and remove this in v3. * Added `typing_extensions` as an `extras` dep
1 parent b9d9887 commit 6c32886

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ extras = [
5353
"dill~=0.3.7",
5454
"click",
5555
"pysam==0.23.0", # pinned pending https://github.com/ga4gh/vrs-python/issues/560
56+
"typing_extensions",
5657
]
5758
dev = [
5859
# tests

src/ga4gh/vrs/extras/translator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from collections.abc import Mapping
1212
from typing import Protocol
1313

14+
from typing_extensions import deprecated
15+
1416
from ga4gh.core import ga4gh_identify
1517
from ga4gh.vrs import models, normalize
1618
from ga4gh.vrs.dataproxy import SequenceProxy, _DataProxy
@@ -213,6 +215,7 @@ def _create_allele(self, values: dict, **kwargs) -> models.Allele:
213215
allele = models.Allele(location=location, state=state)
214216
return self._post_process_imported_allele(allele, **kwargs)
215217

218+
@deprecated("This method does not match the Beacon spec and will be removed in v3.")
216219
def _from_beacon(self, beacon_expr: str, **kwargs) -> models.Allele | None:
217220
"""Parse beacon expression into VRS Allele
218221

tests/extras/test_allele_translator.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,21 @@ def test_from_invalid(tlr):
335335
@pytest.mark.vcr
336336
def test_from_beacon(tlr):
337337
do_normalize = False
338-
assert (
339-
tlr._from_beacon(snv_inputs["beacon"], do_normalize=do_normalize).model_dump(
340-
exclude_none=True
338+
with pytest.deprecated_call():
339+
assert (
340+
tlr._from_beacon(
341+
snv_inputs["beacon"], do_normalize=do_normalize
342+
).model_dump(exclude_none=True)
343+
== snv_output
341344
)
342-
== snv_output
343-
)
344-
assert (
345-
tlr._from_beacon(mito_inputs["beacon"], do_normalize=do_normalize).model_dump(
346-
exclude_none=True
345+
346+
with pytest.deprecated_call():
347+
assert (
348+
tlr._from_beacon(
349+
mito_inputs["beacon"], do_normalize=do_normalize
350+
).model_dump(exclude_none=True)
351+
== mito_output
347352
)
348-
== mito_output
349-
)
350353

351354

352355
@pytest.mark.vcr

0 commit comments

Comments
 (0)