Skip to content

fix(vrs_map): stop normalizing reference-identical alleles into whole-sequence deletions - #114

Merged
bencap merged 1 commit into
mavedb-devfrom
fix/bencap/ref-identical-no-normalize
Oct 19, 2026
Merged

bencap merged 1 commit into
mavedb-devfrom
fix/bencap/ref-identical-no-normalize

Conversation

@bencap

@bencap bencap commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

The mapper has been writing every reference-identical variant (p.=, c.=, g.=) as a deletion of the whole sequence. VRS normalization trims an unchanged sequence to an empty alternate and records ReferenceLengthExpression(length=0), which means "replace the whole sequence with nothing". This identifies those alleles without normalizing them.

Cause

_construct_vrs_allele builds a reference-identical allele as the full sequence with ReferenceLengthExpression(length=L, repeatSubunitLength=L), which is correct. Since 4d35a8c it then passes the allele through normalize, which turns it into length=0, sequence="", repeatSubunitLength=L over the same location. 9e430c2, which added reference-identical support, only identified them.

Found on production: mapping urn:mavedb:00001316-a-1 failed on RAF1:p.=, because MaveDB already holds the correct whole-sequence allele for NP_002871.1:p.= (ga4gh:VA.JRYlMMc2SCGXI6dQ1yGyONWLkL1wMa4d, from an older mapper) and the mapper now produced ga4gh:VA.I6QVEH85J7-ud8ewJoUHsLubJ6CVxHoq for the same HGVS. Where no older allele existed, the deletion form was stored silently: 15 alleles across 58 production score sets.

Changes

  • vrs_map._construct_vrs_allele: reference-identical alleles get identify_allele only, in both the pre-map and post-map branches.
  • tests/test_vrs_map.py: offline regression test for both branches. It asserts normalize isn't called, the state length equals the location span, and the id matches MaveDB's stored allele for NP_002871.1:p.=.

Testing

  • The new test passes, and fails without the fix.
  • In the local MaveDB dev stack (real SeqRepo), _construct_vrs_allele(["NP_002871.1:p.="], PROTEIN, None, pre_map=False) now returns the 0–648 ReferenceLengthExpression(length=648) allele with id ga4gh:VA.JRYlMMc2SCGXI6dQ1yGyONWLkL1wMa4d; before, I6QV… with length=0.
  • ruff check and ruff format --check pass. tests/test_mavedb_data.py has the same 3 respx failures locally with and without this change.

After merge this needs a release to mavedb-main and a production mapper image, then a data repair in MaveDB for the alleles already written.

…-sequence deletions

VRS normalization trims an unchanged sequence to an empty alternate and writes
ReferenceLengthExpression(length=0), which describes deleting the whole
sequence. Since 4d35a8c every p.=, c.= and g.= variant was mapped that way.
Reference-identical alleles are now identified without normalizing, as they
were when introduced in 9e430c2, which also matches the digests MaveDB already
stores for them.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 0.0%. remained the same — fix/bencap/ref-identical-no-normalize into mavedb-dev

@bencap
bencap merged commit b6c8736 into mavedb-dev Oct 19, 2026
2 checks passed
@bencap
bencap deleted the fix/bencap/ref-identical-no-normalize branch October 19, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants