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
2 changes: 1 addition & 1 deletion src/ga4gh/vrs/extras/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def _from_hgvs(
)

copies = kwargs.get("copies")
if copies:
if copies is not None:
cnv = models.CopyNumberCount(location=location, copies=copies)
else:
copy_change = kwargs.get("copy_change")
Expand Down
12 changes: 12 additions & 0 deletions tests/extras/test_cnv_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,15 @@ def test_from_hgvs_cn(tlr, hgvsexpr, copies, expected):
"""Test that _from_hgvs works correctly for copy number count"""
cn = tlr._from_hgvs(hgvsexpr, copies=copies)
assert cn.model_dump(exclude_none=True) == expected


@pytest.mark.vcr
def test_from_hgvs_cn_copies_zero(tlr):
"""Test that copies=0 produces CopyNumberCount, not CopyNumberChange.

copies=0 is a valid input (homozygous deletion), but 0 is falsy in Python
so it was previously treated as missing and fell through to CopyNumberChange.
"""
cn = tlr._from_hgvs("NC_000013.11:g.26440969_26443305del", copies=0)
assert cn.type == "CopyNumberCount"
assert cn.copies == 0
Loading