From 24442211ec711b7b5cf0add0abb6e1521bd99a5e Mon Sep 17 00:00:00 2001 From: Lauren Rekerle Date: Wed, 24 Jul 2024 11:54:26 -0500 Subject: [PATCH] Small changes to variant formatter --- src/genophenocorr/view/_formatter.py | 5 ++--- tests/model/test_variant.py | 27 +-------------------------- tests/view/test_formatter.py | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 tests/view/test_formatter.py diff --git a/src/genophenocorr/view/_formatter.py b/src/genophenocorr/view/_formatter.py index a9a225bf..dab9f971 100644 --- a/src/genophenocorr/view/_formatter.py +++ b/src/genophenocorr/view/_formatter.py @@ -13,8 +13,7 @@ def format_as_string(self, item: T) -> str: to more easily read the item in tables or other visualizers. Args: - item (T): a genophenocorr class - tx_id (typing.Optional[str]): The desired transcript ID, if not the MANE transcript + item (T): an element to be formatted Returns: str: a human readable string @@ -32,7 +31,6 @@ def format_as_string(self, item: Variant) -> str: """ Args: item (Variant): An object of class `Variant` representing a variant. - tx_id (typing.Optional[str]): The transcript ID, needed if using a transcript other than the MANE transcript. Returns: str: A human readable string for the variant. @@ -48,4 +46,5 @@ def format_as_string(self, item: Variant) -> str: elif item.variant_coordinates.variant_key is not None: return item.variant_coordinates.variant_key else: + # To be reevaluated return f"Variant {item} has no string format." \ No newline at end of file diff --git a/tests/model/test_variant.py b/tests/model/test_variant.py index c6f8329c..484bbd6a 100644 --- a/tests/model/test_variant.py +++ b/tests/model/test_variant.py @@ -3,17 +3,8 @@ import typing from genophenocorr.model import Variant, Cohort -from genophenocorr.view import VariantFormatter - class TestVariant: - - @pytest.fixture - def test_cohort( - self, - suox_cohort: Cohort - ) -> Cohort: - return suox_cohort @pytest.fixture def some_variant( @@ -36,20 +27,4 @@ def test_get_hgvs_cdna_by_tx( ): hgvs = some_variant.get_hgvs_cdna_by_tx_id(transcript_id=tx_id) - assert hgvs == expected - - @pytest.mark.parametrize( - "variant, expected", - [ - ('12_56004525_56004525_A_G', "NM_001032386.2:c.1136A>G"), - ] - ) - def test_variant_formatter( - self, - variant: str, - expected: str, - test_cohort: Cohort - ): - var = test_cohort.get_variant_by_key(variant) - formatter = VariantFormatter() - assert formatter.format_as_string(var) == expected + assert hgvs == expected \ No newline at end of file diff --git a/tests/view/test_formatter.py b/tests/view/test_formatter.py new file mode 100644 index 00000000..45842a2c --- /dev/null +++ b/tests/view/test_formatter.py @@ -0,0 +1,24 @@ +import pytest + +import typing + +from genophenocorr.model import Cohort +from genophenocorr.view import VariantFormatter + +class TestFormatter: + + @pytest.mark.parametrize( + "variant, expected", + [ + ('12_56004525_56004525_A_G', "NM_001032386.2:c.1136A>G"), + ] + ) + def test_variant_formatter( + self, + variant: str, + expected: str, + suox_cohort: Cohort + ): + var = suox_cohort.get_variant_by_key(variant) + formatter = VariantFormatter() + assert formatter.format_as_string(var) == expected \ No newline at end of file