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
8 changes: 7 additions & 1 deletion src/ga4gh/vrs/extras/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@ def translate_to(self, vo: models._VariationBase, fmt: str, **kwargs) -> list[st
kwargs:
ref_seq_limit Optional(int):
If vo.state is a ReferenceLengthExpression, and `ref_seq_limit` is specified, and `fmt` is `spdi`, the reference sequence is included in the SPDI expression if it is below the limit Otherwise only the length of the reference sequence is included. If the limit is None, the reference sequence is always included. In all cases, the alt sequence is included. Default is 0 (never include reference sequence).
:raise NotImplementedError: If `fmt` is not supported
"""
t = self.to_translators[fmt]
try:
t = self.to_translators[fmt]
except KeyError as e:
msg = f"{fmt} is not supported"
raise NotImplementedError(msg) from e

return t(vo, **kwargs)

############################################################################
Expand Down
21 changes: 4 additions & 17 deletions tests/extras/test_allele_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,20 +978,7 @@ def test_normalize_microsatellite_counts(tlr, case):
)


# TODO: Readd these tests
# @pytest.mark.vcr
# def test_errors(tlr):
# with pytest.raises(ValueError):
# tlr._from_beacon("bogus")
#
# with pytest.raises(ValueError):
# tlr._from_gnomad("NM_182763.2:c.688+403C>T")
#
# with pytest.raises(ValueError):
# tlr._from_hgvs("NM_182763.2:c.688+403C>T")
#
# with pytest.raises(ValueError):
# tlr._from_hgvs("NM_182763.2:c.688_690inv")
#
# with pytest.raises(ValueError):
# tlr._from_spdi("NM_182763.2:c.688+403C>T")
@pytest.mark.vcr
def test_translate_to_invalid_fmt(tlr):
with pytest.raises(NotImplementedError, match="gnomad is not supported"):
tlr.translate_to(models.Allele.model_validate(snv_output), fmt="gnomad")
Loading