Skip to content

Commit

Permalink
Small changes to variant formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
lnrekerle committed Jul 24, 2024
1 parent 178f55f commit 2444221
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
5 changes: 2 additions & 3 deletions src/genophenocorr/view/_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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."
27 changes: 1 addition & 26 deletions tests/model/test_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
24 changes: 24 additions & 0 deletions tests/view/test_formatter.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2444221

Please sign in to comment.