diff --git a/notebooks/getting_started/1_Quick_Start.ipynb b/notebooks/getting_started/1_Quick_Start.ipynb index 87e4507e..039678fb 100644 --- a/notebooks/getting_started/1_Quick_Start.ipynb +++ b/notebooks/getting_started/1_Quick_Start.ipynb @@ -181,7 +181,7 @@ } ], "source": [ - "vrs_from_spdi = translator.translate_from(\"NC_000005.10:80656509:C:TT\", \"spdi\")\n", + "vrs_from_spdi = translator.to_vrs(\"NC_000005.10:80656509:C:TT\", \"spdi\")\n", "vrs_from_spdi.model_dump(exclude_none=True)" ] }, @@ -237,7 +237,7 @@ } ], "source": [ - "vrs_from_hgvs = translator.translate_from(\"NC_000005.10:g.80656510delinsTT\", \"hgvs\")\n", + "vrs_from_hgvs = translator.to_vrs(\"NC_000005.10:g.80656510delinsTT\", \"hgvs\")\n", "vrs_from_hgvs.model_dump(exclude_none=True)" ] }, diff --git a/notebooks/getting_started/4_Exploring_the_AlleleTranslator.ipynb b/notebooks/getting_started/4_Exploring_the_AlleleTranslator.ipynb index 2ef2c400..52380e45 100644 --- a/notebooks/getting_started/4_Exploring_the_AlleleTranslator.ipynb +++ b/notebooks/getting_started/4_Exploring_the_AlleleTranslator.ipynb @@ -126,7 +126,7 @@ }, "source": [ "#### From/To HGVS\n", - "This example will translate an HGVS variant to VRS using the *AlleleTranslator* *translate_from* method." + "This example will translate an HGVS variant to VRS using the *AlleleTranslator* *to_vrs* method." ] }, { @@ -167,7 +167,7 @@ ], "source": [ "allele_translator = AlleleTranslator(data_proxy=seqrepo_dataproxy)\n", - "allele = allele_translator.translate_from(\"NC_000005.10:g.80656489C>T\", \"hgvs\")\n", + "allele = allele_translator.to_vrs(\"NC_000005.10:g.80656489C>T\", \"hgvs\")\n", "allele.model_dump(exclude_none=True)" ] }, @@ -181,7 +181,7 @@ } }, "source": [ - "The output from above is the VRS representation of the *Allele*. Using the *AlleleTranslator* *translate_to* method we can get back to the HGVS representation." + "The output from above is the VRS representation of the *Allele*. Using the *AlleleTranslator* *from_vrs* method we can get back to the HGVS representation." ] }, { @@ -211,7 +211,7 @@ } ], "source": [ - "allele_translator.translate_to(allele, \"hgvs\")" + "allele_translator.from_vrs(allele, \"hgvs\")" ] }, { @@ -267,7 +267,7 @@ } ], "source": [ - "allele = allele_translator.translate_from(\"NC_000005.9:g.79952308C>T\", \"hgvs\")\n", + "allele = allele_translator.to_vrs(\"NC_000005.9:g.79952308C>T\", \"hgvs\")\n", "allele.model_dump(exclude_none=True)" ] }, @@ -298,7 +298,7 @@ } ], "source": [ - "allele_translator.translate_to(allele, \"hgvs\")" + "allele_translator.from_vrs(allele, \"hgvs\")" ] }, { @@ -352,7 +352,7 @@ } ], "source": [ - "allele = allele_translator.translate_from(\"NC_000005.10:80656488:C:T\",\"spdi\")\n", + "allele = allele_translator.to_vrs(\"NC_000005.10:80656488:C:T\",\"spdi\")\n", "allele.model_dump(exclude_none=True)" ] }, @@ -383,7 +383,7 @@ } ], "source": [ - "allele_translator.translate_to(allele, \"spdi\")" + "allele_translator.from_vrs(allele, \"spdi\")" ] }, { @@ -397,7 +397,7 @@ }, "source": [ "#### From gnomAD style VCF\n", - "For variants represented in the gnomad nomenclature, the *AlleleTranslator* currently only supports *translate_from* to convert to VRS. *translate_to* is not yet supported." + "For variants represented in the gnomad nomenclature, the *AlleleTranslator* currently only supports *to_vrs* to convert to VRS. *from_vrs* is not yet supported." ] }, { @@ -437,7 +437,7 @@ } ], "source": [ - "allele = allele_translator.translate_from(\"5-80656489-C-T\", \"gnomad\")\n", + "allele = allele_translator.to_vrs(\"5-80656489-C-T\", \"gnomad\")\n", "allele.model_dump(exclude_none=True)" ] } diff --git a/notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb b/notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb index f98abf2c..ca64b7cb 100644 --- a/notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb +++ b/notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb @@ -148,7 +148,7 @@ } }, "source": [ - "This example depicts a *CopyNumberChange* representing a deletion, or copy number loss. The Experimental Factor Ontology code specifying the type of copy number change is passed as a keyword argument \"copy_change\" to *translate_from*. This variant can be viewed in [ClinVar](https://www.ncbi.nlm.nih.gov/clinvar/variation/984438)." + "This example depicts a *CopyNumberChange* representing a deletion, or copy number loss. The Experimental Factor Ontology code specifying the type of copy number change is passed as a keyword argument \"copy_change\" to *to_vrs*. This variant can be viewed in [ClinVar](https://www.ncbi.nlm.nih.gov/clinvar/variation/984438)." ] }, { @@ -189,7 +189,7 @@ ], "source": [ "cnv_translator = CnvTranslator(data_proxy=seqrepo_dataproxy)\n", - "cnc = cnv_translator.translate_from(\"NC_000014.9:g.45002867_45015056del\", \"hgvs\", copy_change=\"loss\")\n", + "cnc = cnv_translator.to_vrs(\"NC_000014.9:g.45002867_45015056del\", \"hgvs\", copy_change=\"loss\")\n", "cnc.model_dump(exclude_none=True)" ] }, @@ -243,7 +243,7 @@ } ], "source": [ - "cnx = cnv_translator.translate_from(\"NC_000009.12:g.75502958_76045032dup\", \"hgvs\", copy_change=\"gain\")\n", + "cnx = cnv_translator.to_vrs(\"NC_000009.12:g.75502958_76045032dup\", \"hgvs\", copy_change=\"gain\")\n", "cnx.model_dump(exclude_none=True)" ] }, @@ -270,7 +270,7 @@ } }, "source": [ - "This example depicts a *CopyNumberCount* with a copy number gain. With copy number count variation, the \"copies\" keyword argument is passed to *translate_from* with the appropriate \"EFO\" ontology code. This variant can be viewed in [ClinVar](https://www.ncbi.nlm.nih.gov/clinvar/variation/2579174/)." + "This example depicts a *CopyNumberCount* with a copy number gain. With copy number count variation, the \"copies\" keyword argument is passed to *to_vrs* with the appropriate \"EFO\" ontology code. This variant can be viewed in [ClinVar](https://www.ncbi.nlm.nih.gov/clinvar/variation/2579174/)." ] }, { @@ -310,7 +310,7 @@ } ], "source": [ - "cnc = cnv_translator.translate_from(\"NC_000004.12:g.85624_57073230dup\", \"hgvs\", copies=\"3\")\n", + "cnc = cnv_translator.to_vrs(\"NC_000004.12:g.85624_57073230dup\", \"hgvs\", copies=\"3\")\n", "cnc.model_dump(exclude_none=True)" ] }, @@ -364,7 +364,7 @@ } ], "source": [ - "cnc = cnv_translator.translate_from(\"NC_000021.9:g.46111353_46119948del\", \"hgvs\", copies=\"1\")\n", + "cnc = cnv_translator.to_vrs(\"NC_000021.9:g.46111353_46119948del\", \"hgvs\", copies=\"1\")\n", "cnc.model_dump(exclude_none=True)" ] } diff --git a/notebooks/getting_started/6_Upcoming_features.ipynb b/notebooks/getting_started/6_Upcoming_features.ipynb index 54bef10c..47e3c7b1 100644 --- a/notebooks/getting_started/6_Upcoming_features.ipynb +++ b/notebooks/getting_started/6_Upcoming_features.ipynb @@ -164,7 +164,7 @@ } ], "source": [ - "allele = translator.translate_from(\"NC_000005.10:80656509:C:TT\", \"spdi\")\n", + "allele = translator.to_vrs(\"NC_000005.10:80656509:C:TT\", \"spdi\")\n", "allele.model_dump(exclude_none=True)" ] }, diff --git a/notebooks/getting_started/7_Uncertain_Range_HGVS.ipynb b/notebooks/getting_started/7_Uncertain_Range_HGVS.ipynb index d9c11e84..3612ed9c 100644 --- a/notebooks/getting_started/7_Uncertain_Range_HGVS.ipynb +++ b/notebooks/getting_started/7_Uncertain_Range_HGVS.ipynb @@ -113,7 +113,7 @@ } ], "source": [ - "cnc = cnv_tlr.translate_from(\n", + "cnc = cnv_tlr.to_vrs(\n", " \"NC_000019.9:g.(11211022_11213339)_(11217364_11218067)dup\", \"hgvs\"\n", ")\n", "cnc.model_dump(exclude_none=True)" @@ -178,7 +178,7 @@ } ], "source": [ - "cnc = cnv_tlr.translate_from(\n", + "cnc = cnv_tlr.to_vrs(\n", " \"NC_000002.12:g.(?_202376935)_(202377551_202464808)del\", \"hgvs\"\n", ")\n", "cnc.model_dump(exclude_none=True)" @@ -235,7 +235,7 @@ } ], "source": [ - "cnc = cnv_tlr.translate_from(\n", + "cnc = cnv_tlr.to_vrs(\n", " \"NC_000017.11:g.(?_58709859)_(58734342_?)del\", \"hgvs\"\n", ")\n", "cnc.model_dump(exclude_none=True)" @@ -286,7 +286,7 @@ } ], "source": [ - "cn = cnv_tlr.translate_from(\n", + "cn = cnv_tlr.to_vrs(\n", " \"NC_000019.9:g.(11211022_11213339)_(11217364_11218067)dup\",\n", " \"hgvs\",\n", " copies=3,\n", @@ -301,7 +301,7 @@ "source": [ "## Example 5 — VRS → HGVS (round-trip)\n", "\n", - "A VRS `Allele` whose `SequenceLocation` has `Range` bounds can be serialized back to uncertain-range HGVS via `AlleleTranslator.translate_to`. Here we build the Allele directly (since `from_hgvs` on the Allele path refuses uncertain ranges) and confirm it round-trips." + "A VRS `Allele` whose `SequenceLocation` has `Range` bounds can be serialized back to uncertain-range HGVS via `AlleleTranslator.from_vrs`. Here we build the Allele directly (since `from_hgvs` on the Allele path refuses uncertain ranges) and confirm it round-trips." ] }, { @@ -339,7 +339,7 @@ " ),\n", " state=models.LiteralSequenceExpression(sequence=models.sequenceString(root=\"\")),\n", ")\n", - "allele_tlr.translate_to(allele, \"hgvs\")" + "allele_tlr.from_vrs(allele, \"hgvs\")" ] }, { @@ -375,7 +375,7 @@ ], "source": [ "try:\n", - " allele_tlr.translate_from(\n", + " allele_tlr.to_vrs(\n", " \"NC_000019.9:g.(11211022_11213339)_(11217364_11218067)dup\", \"hgvs\"\n", " )\n", "except ValueError as err:\n", diff --git a/src/ga4gh/vrs/extras/translator.py b/src/ga4gh/vrs/extras/translator.py index c903d4d2..b35f9f45 100644 --- a/src/ga4gh/vrs/extras/translator.py +++ b/src/ga4gh/vrs/extras/translator.py @@ -48,7 +48,7 @@ class _Translator(ABC): # noqa: B024 Translates various variation formats to and from GA4GH VRS models - All `from_` methods follow this pattern: + Private `_from_*` parsers follow this pattern: * If the argument does not appear to be an appropriate type, None is returned * Otherwise, the argument is expected to be of the correct type. If an error occurs during processing, an exception is raised. @@ -71,14 +71,21 @@ def __init__( identify: bool = True, rle_seq_limit: int | None = 50, ) -> None: + """Initialize shared translation settings and format dispatch dictionaries. + + :param data_proxy: Sequence data provider used during translation. + :param default_assembly_name: Default assembly for inputs without an assembly. + :param identify: Whether to assign GA4GH identifiers to translated objects. + :param rle_seq_limit: Maximum RLE sequence length to include, or None for no limit. + """ self.default_assembly_name = default_assembly_name self.data_proxy = data_proxy self.identify = identify self.rle_seq_limit = rle_seq_limit - self.from_translators: dict[str, VariationFromStrProtocol] = {} - self.to_translators: dict[str, VariationToStrProtocol] = {} + self.to_vrs_translators: dict[str, VariationFromStrProtocol] = {} + self.from_vrs_translators: dict[str, VariationToStrProtocol] = {} - def translate_from( + def to_vrs( self, var: str, fmt: str | None = None, **kwargs ) -> models._VariationBase: """Translate variation `var` to VRS object @@ -86,7 +93,7 @@ def translate_from( If `fmt` is None, guess the appropriate format and return the variant. If `fmt` is specified, try only that format. - See also notes about `from_` and `to_` methods. + See the class notes about private `_from_*` parsers. kwargs: For CnvTranslator @@ -111,7 +118,7 @@ def translate_from( """ if fmt: try: - t = self.from_translators[fmt] + t = self.to_vrs_translators[fmt] except KeyError as e: msg = f"{fmt} is not supported" raise NotImplementedError(msg) from e @@ -122,16 +129,16 @@ def translate_from( raise ValueError(msg) return o - for t in self.from_translators.values(): + for t in self.to_vrs_translators.values(): o = t(var, **kwargs) if o: return o - formats = list(self.from_translators.keys()) + formats = list(self.to_vrs_translators.keys()) msg = f"Unable to parse data as {', '.join(formats)}" raise ValueError(msg) - def translate_to(self, vo: models._VariationBase, fmt: str, **kwargs) -> list[str]: + def from_vrs(self, vo: models._VariationBase, fmt: str, **kwargs) -> list[str]: """Translate vrs object `vo` to named format `fmt` kwargs: @@ -140,7 +147,7 @@ def translate_to(self, vo: models._VariationBase, fmt: str, **kwargs) -> list[st :raise NotImplementedError: If `fmt` is not supported """ try: - t = self.to_translators[fmt] + t = self.from_vrs_translators[fmt] except KeyError as e: msg = f"{fmt} is not supported" raise NotImplementedError(msg) from e @@ -179,14 +186,14 @@ def __init__( """Initialize AlleleTranslator class""" super().__init__(data_proxy, default_assembly_name, identify) - self.from_translators = { + self.to_vrs_translators = { "gnomad": self._from_gnomad, "hgvs": self._from_hgvs, "spdi": self._from_spdi, "vrs": self._from_vrs, } - self.to_translators = { + self.from_vrs_translators = { "hgvs": self._to_hgvs, "spdi": self._to_spdi, } @@ -481,7 +488,7 @@ def __init__( ) -> None: """Initialize CnvTranslator class""" super().__init__(data_proxy, default_assembly_name, identify) - self.from_translators = { + self.to_vrs_translators = { "hgvs": self._from_hgvs, } diff --git a/tests/extras/test_allele_translator.py b/tests/extras/test_allele_translator.py index 2e4d3dff..30dffd45 100644 --- a/tests/extras/test_allele_translator.py +++ b/tests/extras/test_allele_translator.py @@ -312,12 +312,12 @@ def test_rle_round_trip_gnomad_spdi(tlr): gnomad = inp["gnomad"] spdi = inp["spdi"] expected_dict = inp["expected_allele"] - allele_gnomad = tlr.translate_from(gnomad, fmt="gnomad", rle_seq_limit=None) + allele_gnomad = tlr.to_vrs(gnomad, fmt="gnomad", rle_seq_limit=None) assert allele_gnomad.model_dump(exclude_none=True) == expected_dict - allele_spdi = tlr.translate_from(spdi, fmt="spdi", rle_seq_limit=None) + allele_spdi = tlr.to_vrs(spdi, fmt="spdi", rle_seq_limit=None) assert allele_spdi.model_dump(exclude_none=True) == expected_dict - allele_gnomad_to_spdi = tlr.translate_to( + allele_gnomad_to_spdi = tlr.from_vrs( allele_gnomad, fmt="spdi", ref_seq_limit=None ) assert len(allele_gnomad_to_spdi) == 1 @@ -328,12 +328,12 @@ def test_from_invalid(tlr): with pytest.raises( ValueError, match="Unable to parse data as gnomad, hgvs, spdi, vrs" ): - tlr.translate_from("BRAF amplication") + tlr.to_vrs("BRAF amplication") with pytest.raises( ValueError, match="Unable to parse data as gnomad, hgvs, spdi, vrs" ): - tlr.translate_from("BRAF amplication", assembly_name="GRCh37") + tlr.to_vrs("BRAF amplication", assembly_name="GRCh37") @pytest.mark.parametrize( @@ -348,7 +348,7 @@ def test_from_invalid(tlr): 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) + tlr.to_vrs(expr, fmt=fmt) @pytest.mark.vcr @@ -426,7 +426,7 @@ def test_from_gnomad(tlr): assert str(e.value) == error_msg with pytest.raises(DataProxyValidationError) as e: - tlr.translate_from(invalid_var, fmt="gnomad") + tlr.to_vrs(invalid_var, fmt="gnomad") assert str(e.value) == error_msg # require_validation set to False @@ -509,8 +509,8 @@ def test_from_spdi(tlr): def test_to_spdi(tlr): # do_normalize defaults to true spdiexpr = snv_inputs["spdi"] - allele = tlr.translate_from(spdiexpr, "spdi") - to_spdi = tlr.translate_to(allele, "spdi") + allele = tlr.to_vrs(spdiexpr, "spdi") + to_spdi = tlr.from_vrs(allele, "spdi") assert len(to_spdi) == 1 assert spdiexpr == to_spdi[0] @@ -520,15 +520,15 @@ def test_to_spdi_with_ref(tlr): spdi_expr_no_ref = "NC_000019.10:44908821:1:T" spdi_expr_with_ref = "NC_000019.10:44908821:C:T" - allele_no_ref = tlr.translate_from(spdi_expr_no_ref, "spdi") - allele_with_ref = tlr.translate_from(spdi_expr_with_ref, "spdi") + allele_no_ref = tlr.to_vrs(spdi_expr_no_ref, "spdi") + allele_with_ref = tlr.to_vrs(spdi_expr_with_ref, "spdi") assert allele_no_ref == allele_with_ref - to_spdi_no_ref = tlr.translate_to(allele_no_ref, "spdi", ref_seq_limit=0) + to_spdi_no_ref = tlr.from_vrs(allele_no_ref, "spdi", ref_seq_limit=0) assert len(to_spdi_no_ref) == 1 assert spdi_expr_no_ref == to_spdi_no_ref[0] - to_spdi_with_ref = tlr.translate_to(allele_with_ref, "spdi", ref_seq_limit=None) + to_spdi_with_ref = tlr.from_vrs(allele_with_ref, "spdi", ref_seq_limit=None) assert len(to_spdi_with_ref) == 1 assert spdi_expr_with_ref == to_spdi_with_ref[0] @@ -736,10 +736,10 @@ def test_to_spdi_with_ref(tlr): @pytest.mark.vcr def test_hgvs(tlr, hgvsexpr, expected): # do_normalize defaults to true - allele = tlr.translate_from(hgvsexpr, "hgvs") + allele = tlr.to_vrs(hgvsexpr, "hgvs") assert allele.model_dump(exclude_none=True) == expected - to_hgvs = tlr.translate_to(allele, "hgvs") + to_hgvs = tlr.from_vrs(allele, "hgvs") assert (hgvsexpr in to_hgvs) or ( hgvs_tests_to_hgvs_map.get(hgvsexpr, hgvsexpr) in to_hgvs ) @@ -772,25 +772,23 @@ def test_rle_seq_limit(tlr): input_hgvs_expr = "NC_000013.11:g.32331043_32331094dup" # use default rle_seq_limit - allele_no_seq = tlr.translate_from(input_hgvs_expr, fmt="hgvs") + allele_no_seq = tlr.to_vrs(input_hgvs_expr, fmt="hgvs") assert allele_no_seq.model_dump(exclude_none=True) == a_dict with pytest.raises( AttributeError, match="'NoneType' object has no attribute 'root'" ): - tlr.translate_to(allele_no_seq, "hgvs") + tlr.from_vrs(allele_no_seq, "hgvs") # set rle_seq_limit to None - allele_with_seq = tlr.translate_from( - input_hgvs_expr, fmt="hgvs", rle_seq_limit=None - ) + allele_with_seq = tlr.to_vrs(input_hgvs_expr, fmt="hgvs", rle_seq_limit=None) a_dict_with_seq = a_dict.copy() a_dict_with_seq["state"]["sequence"] = ( "TTTAGTTGAACTACAGGTTTTTTTGTTGTTGTTGTTTTGATTTTTTTTTTTTTTTAGTTGAACTACAGGTTTTTTTGTTGTTGTTGTTTTGATTTTTTTTTTTT" ) assert allele_with_seq.model_dump(exclude_none=True) == a_dict_with_seq - output_hgvs_expr = tlr.translate_to(allele_with_seq, "hgvs") + output_hgvs_expr = tlr.from_vrs(allele_with_seq, "hgvs") assert output_hgvs_expr == [input_hgvs_expr] @@ -812,7 +810,7 @@ def test_to_hgvs_iri_ref_keyerror(tlr): with pytest.raises(KeyError) as e: # even though the seqrefs.jsonc#/NM_181798.1 is a valid iri-reference for json schema, it is not yet handled here # we have to add functionality to address the handling of iri-references in the future - tlr.translate_to(iri_vo, "hgvs") + tlr.from_vrs(iri_vo, "hgvs") assert str(e.value) == "'ga4gh:seqrefs.jsonc#/NM_181798.1'" @@ -854,7 +852,7 @@ def test_reference_allele_rle(tlr): assert allele_spdi.model_dump(exclude_none=True) == expected # Test round-trip to SPDI - to_spdi = tlr.translate_to(allele_spdi, "spdi", ref_seq_limit=None) + to_spdi = tlr.from_vrs(allele_spdi, "spdi", ref_seq_limit=None) assert len(to_spdi) == 1 assert to_spdi[0] == spdi_ref_allele @@ -956,17 +954,13 @@ def test_normalize_microsatellite_counts(tlr, case): For identity: keep input coordinates (930089-930152) with repeatSubunitLength=63 """ # Test HGVS format - allele_hgvs = tlr.translate_from( - case["hgvs"], "hgvs", normalize=True, rle_seq_limit=100 - ) + allele_hgvs = tlr.to_vrs(case["hgvs"], "hgvs", normalize=True, rle_seq_limit=100) assert allele_hgvs.model_dump(exclude_none=True) == case["expected"], ( f"HGVS failed: {case['description']}" ) # Test SPDI format - allele_spdi = tlr.translate_from( - case["spdi"], "spdi", normalize=True, rle_seq_limit=100 - ) + allele_spdi = tlr.to_vrs(case["spdi"], "spdi", normalize=True, rle_seq_limit=100) assert allele_spdi.model_dump(exclude_none=True) == case["expected"], ( f"SPDI failed: {case['description']}" ) @@ -975,7 +969,7 @@ def test_normalize_microsatellite_counts(tlr, case): @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") + tlr.from_vrs(models.Allele.model_validate(snv_output), fmt="gnomad") def test_from_vrs_dict(): @@ -987,7 +981,7 @@ def test_from_vrs_dict(): tlr = AlleleTranslator(data_proxy=None, identify=False) # valid VRS dict translates to a VRS object (previously raised TypeError) - allele = tlr.translate_from(snv_output, fmt="vrs") + allele = tlr.to_vrs(snv_output, fmt="vrs") assert isinstance(allele, models.Allele) assert allele.type == "Allele" assert allele.location.start == snv_output["location"]["start"] @@ -1016,7 +1010,7 @@ def test_from_vrs_non_variation_type(case): """ tlr = AlleleTranslator(data_proxy=None, identify=False) with pytest.raises(ValidationError) as e: - tlr.translate_from({"type": case["type"]}, fmt="vrs") + tlr.to_vrs({"type": case["type"]}, fmt="vrs") assert e.value.errors()[0]["type"] == "union_tag_invalid" @@ -1045,6 +1039,6 @@ def test_to_hgvs_uncertain_range(tlr): ), state=models.LiteralSequenceExpression(sequence=models.sequenceString(root="")), ) - assert tlr.translate_to(allele, "hgvs") == [ + assert tlr.from_vrs(allele, "hgvs") == [ "NC_000002.12:g.(?_202376935)_(202377551_202464808)del" ]