diff --git a/src/ga4gh/vrs/extras/translator.py b/src/ga4gh/vrs/extras/translator.py index 1fe5e350..00da9bb1 100644 --- a/src/ga4gh/vrs/extras/translator.py +++ b/src/ga4gh/vrs/extras/translator.py @@ -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") diff --git a/tests/extras/test_cnv_translator.py b/tests/extras/test_cnv_translator.py index 723ddfd2..a7a3fa0e 100644 --- a/tests/extras/test_cnv_translator.py +++ b/tests/extras/test_cnv_translator.py @@ -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