Skip to content

Commit

Permalink
fix: hgvs/free text dup/del end positions for definite ranges (#525)
Browse files Browse the repository at this point in the history
standard residue -> interresidue conversion:
(a_b)_(c_d)-> start: models.Range([a-1, b-1]), end: models.Range([c,d])
  • Loading branch information
korikuzma authored Dec 6, 2023
1 parent 8fbbe9c commit e0a7709
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 111 deletions.
16 changes: 14 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ def genomic_dup2_38_cn(genomic_dup2_seq_loc_normalized):
def genomic_del3_dup3_loc_not_normalized():
"""Create genomic del3 dup3 sequence location"""
return {
"id": "ga4gh:SL.NbjuicGHnxcERd1t0hGkzlw93YX1p3Y7",
"id": "ga4gh:SL.-zCp7JBaKQ0niPDueJkuCgQhRIQ50hKw",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"start": [31060226, 31100350],
"end": [33274279, 33417152],
"end": [33274278, 33417151],
"type": "SequenceLocation",
}

Expand Down Expand Up @@ -536,6 +536,18 @@ def prpf8_amplification(prpf8_ncbi_seq_loc):
return models.CopyNumberChange(**params)


@pytest.fixture(scope="module")
def genomic_del3_dup3_cn_38(genomic_del3_dup3_loc_not_normalized):
"""Create test fixture copy number variation for del/dup 3 on GRCh38"""
params = {
"type": "CopyNumberCount",
"id": "ga4gh:CN.rPsK0krAHgmXhDZEw4fqymR0iDQa3UCJ",
"location": genomic_del3_dup3_loc_not_normalized,
"copies": 2,
}
return models.CopyNumberCount(**params)


def assertion_checks(normalize_response, test_variation):
"""Check that normalize_response and test_variation are equal."""
actual = normalize_response.variation.model_dump(exclude_none=True)
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/translators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1400,19 +1400,19 @@ genomic_duplication_ambiguous:
variations:
[
{
"id": "ga4gh:CX.Gq5d-uH01bgf7m703dOSfSp_29wFqpsb",
"id": "ga4gh:CX.gsV4KrWvNQ_c0UT8M31mqa0HJ-IAHL8q",
"type": "CopyNumberChange",
"location":
{
"id": "ga4gh:SL.NbjuicGHnxcERd1t0hGkzlw93YX1p3Y7",
"id": "ga4gh:SL.-zCp7JBaKQ0niPDueJkuCgQhRIQ50hKw",
"type": "SequenceLocation",
"sequenceReference":
{
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"start": [31060226, 31100350],
"end": [33274279, 33417152],
"end": [33274278, 33417151],
},
"copyChange": "efo:0030070",
},
Expand Down
56 changes: 16 additions & 40 deletions tests/test_hgvs_dup_del_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,12 @@ def genomic_dup2_free_text_cn(genomic_dup2_free_text_seq_loc):
return models.CopyNumberCount(**params)


@pytest.fixture(scope="module")
def genomic_dup3_cn(genomic_del3_dup3_loc_not_normalized):
"""Create a test fixture for genomic dup copy number count."""
params = {
"type": "CopyNumberCount",
"id": "ga4gh:CN.Ka-Wsibx4GHmHgurHCdk0W4deqZt26y4",
"location": genomic_del3_dup3_loc_not_normalized,
"copies": 2,
}
return models.CopyNumberCount(**params)


@pytest.fixture(scope="module")
def genomic_dup3_cx(genomic_del3_dup3_loc_not_normalized):
"""Create a test fixture for genomic dup copy number change."""
params = {
"type": "CopyNumberChange",
"id": "ga4gh:CX.Gq5d-uH01bgf7m703dOSfSp_29wFqpsb",
"id": "ga4gh:CX.gsV4KrWvNQ_c0UT8M31mqa0HJ-IAHL8q",
"location": genomic_del3_dup3_loc_not_normalized,
"copyChange": "efo:0030070",
}
Expand All @@ -232,13 +220,13 @@ def genomic_dup3_cx(genomic_del3_dup3_loc_not_normalized):
def genomic_dup3_free_text_subject():
"""Create test fixture for genomic dup3 free text location"""
return {
"id": "ga4gh:SL.h-0akgFon48yzCHKVdRwU5ImXRux4huN",
"id": "ga4gh:SL.OFGMAP2dUKRbBk5Q3MroJzbvcjEJQfyZ",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"start": [31147273, 31147277],
"end": [31182738, 31182740],
"end": [31182737, 31182739],
"type": "SequenceLocation",
}

Expand All @@ -248,7 +236,7 @@ def genomic_dup3_free_text_cx(genomic_dup3_free_text_subject):
"""Create a test fixture for genomic dup copy number change."""
params = {
"type": "CopyNumberChange",
"id": "ga4gh:CX.aJYe9oIrxrwI0VTkEnvC0fKIT5x-vIne",
"id": "ga4gh:CX.qf8-7kAverUttRlwQBXFPeuVq5o2-bVa",
"location": genomic_dup3_free_text_subject,
"copyChange": "efo:0030070",
}
Expand All @@ -260,7 +248,7 @@ def genomic_dup3_free_text_cn(genomic_dup3_free_text_subject):
"""Create a test fixture for genomic dup copy number count."""
params = {
"type": "CopyNumberCount",
"id": "ga4gh:CN.KXh3T716GG9uGwq9ejGmflT_67fNN8n3",
"id": "ga4gh:CN.3yNGNFGVAO5DGc0sPTThdUwTfJLPyWfM",
"location": genomic_dup3_free_text_subject,
"copies": 4,
}
Expand Down Expand Up @@ -594,36 +582,24 @@ def genomic_del3_cx(genomic_del3_dup3_loc_not_normalized):
"""Create a test fixture for genomic del copy number change."""
params = {
"type": "CopyNumberChange",
"id": "ga4gh:CX.h9krodUtVK--XmizkspBdOrptRNqrDHm",
"id": "ga4gh:CX.BWTPMUku6nwuWhULJogKyxEk64XDIYGm",
"location": genomic_del3_dup3_loc_not_normalized,
"copyChange": "efo:0030067",
}
return models.CopyNumberChange(**params)


@pytest.fixture(scope="module")
def genomic_del3_cn(genomic_del3_dup3_loc_not_normalized):
"""Create a test fixture for genomic del copy number count."""
params = {
"type": "CopyNumberCount",
"id": "ga4gh:CN.Ka-Wsibx4GHmHgurHCdk0W4deqZt26y4",
"location": genomic_del3_dup3_loc_not_normalized,
"copies": 2,
}
return models.CopyNumberCount(**params)


@pytest.fixture(scope="module")
def genomic_del3_free_text_subject():
"""Create test fixture for genomic del3 free text location"""
return {
"id": "ga4gh:SL.HMjpquCLV9iYib972N0_3tn9TvnevIga",
"id": "ga4gh:SL.5_TZXeJhFejft3jmfkqdNutVO2tenSeB",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"start": [68839264, 68839267],
"end": [68841121, 68841126],
"end": [68841120, 68841125],
"type": "SequenceLocation",
}

Expand All @@ -633,7 +609,7 @@ def genomic_del3_free_text_cx(genomic_del3_free_text_subject):
"""Create a test fixture for genomic del copy number change."""
params = {
"type": "CopyNumberChange",
"id": "ga4gh:CX.qHYL7nZaKXl-h9D7d4JvEmXDZtfV9M2A",
"id": "ga4gh:CX.SS7Ywi8yq2fb7acAdbs1a-H6ELw4QxLy",
"location": genomic_del3_free_text_subject,
"copyChange": "efo:0030067",
}
Expand All @@ -645,7 +621,7 @@ def genomic_del3_free_text_cn(genomic_del3_free_text_subject):
"""Create a test fixture for genomic del copy number count."""
params = {
"type": "CopyNumberCount",
"id": "ga4gh:CN.ESfNw8Y3Vil7UpRiV2UY-zfMoZNRchA3",
"id": "ga4gh:CN.nYr-z9MXHGx8p3hP0Wht3WDw0gju9QDL",
"location": genomic_del3_free_text_subject,
"copies": 2,
}
Expand Down Expand Up @@ -970,7 +946,7 @@ async def test_genomic_dup2(
async def test_genomic_dup3(
test_handler,
genomic_dup3_cx,
genomic_dup3_cn,
genomic_del3_dup3_cn_38,
genomic_dup3_free_text_cn,
genomic_dup3_free_text_cx,
):
Expand All @@ -982,7 +958,7 @@ async def test_genomic_dup3(
resp = await test_handler.normalize(
q, HGVSDupDelModeOption.COPY_NUMBER_COUNT, baseline_copies=1
)
assertion_checks(resp, genomic_dup3_cn)
assertion_checks(resp, genomic_del3_dup3_cn_38)

resp = await test_handler.normalize(
q,
Expand All @@ -1001,7 +977,7 @@ async def test_genomic_dup3(
resp = await test_handler.normalize(
q, HGVSDupDelModeOption.COPY_NUMBER_COUNT, baseline_copies=1
)
assertion_checks(resp, genomic_dup3_cn)
assertion_checks(resp, genomic_del3_dup3_cn_38)

resp = await test_handler.normalize(q, HGVSDupDelModeOption.COPY_NUMBER_CHANGE)
assertion_checks(resp, genomic_dup3_cx)
Expand Down Expand Up @@ -1383,7 +1359,7 @@ async def test_genomic_del2(
@pytest.mark.asyncio
async def test_genomic_del3(
test_handler,
genomic_del3_cn,
genomic_del3_dup3_cn_38,
genomic_del3_cx,
genomic_del3_free_text_cn,
genomic_del3_free_text_cx,
Expand All @@ -1396,7 +1372,7 @@ async def test_genomic_del3(
resp = await test_handler.normalize(
q, HGVSDupDelModeOption.COPY_NUMBER_COUNT, baseline_copies=3
)
assertion_checks(resp, genomic_del3_cn)
assertion_checks(resp, genomic_del3_dup3_cn_38)

resp = await test_handler.normalize(q, HGVSDupDelModeOption.COPY_NUMBER_CHANGE)
assertion_checks(resp, genomic_del3_cx)
Expand All @@ -1411,7 +1387,7 @@ async def test_genomic_del3(
resp = await test_handler.normalize(
q, HGVSDupDelModeOption.COPY_NUMBER_COUNT, baseline_copies=3
)
assertion_checks(resp, genomic_del3_cn)
assertion_checks(resp, genomic_del3_dup3_cn_38)

resp = await test_handler.normalize(q, HGVSDupDelModeOption.COPY_NUMBER_CHANGE)
assertion_checks(resp, genomic_del3_cx)
Expand Down
Loading

0 comments on commit e0a7709

Please sign in to comment.