fix: validate reference allele stated in HGVS expressions - #655
Open
developer-rpai wants to merge 1 commit into
Open
developer-rpai wants to merge 1 commit into
developer-rpai wants to merge 1 commit into
Conversation
The HGVS parser preserves the input reference allele (e.g. the C in NM_006087.3:c.900C>A), but the translator never checked it against the reference sequence, so an incorrect reference allele silently produced a plausible-but-wrong VRS Allele (ga4gh#364). extract_allele_values now validates the stated reference allele against the data proxy (default require_validation=True), mirroring the existing gnomAD translator behavior. require_validation=False keeps the legacy behavior (mismatch only logged). Adds hermetic regression tests and the VCR cassette interactions the new lookups require.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #364.
HGVS-to-VRS translation silently accepted an incorrect reference allele:
NM_006087.3:c.900C>Aproduced a plausible-looking VRS Allele even though the true reference base is G (per the ClinGen Allele Registry: "IncorrectReferenceAllele ... given=C, found=G", independently confirmed against NCBI RefSeq: with the CDS annotated at 373..1707, c.900 maps to n.1272, and NM_006087.3 n.1272 is G).Root cause
The HGVS parser preserves the stated reference allele (
sv.posedit.edit.ref), butHgvsTools.extract_allele_values()never inspected it, so a wrong reference flowed straight into the emitted Allele. The gnomAD translator path already validated reference alleles viaDataProxy.validate_ref_seq(); the HGVS path did not.Change
HgvsTools.extract_allele_values()acceptsrequire_validation: bool = True. After any c.->n. mapping, when the HGVS expression states a reference allele (e.g. theCinc.900C>A, or deleted bases ing.44908822delC), it is validated against the reference sequence, raisingDataProxyValidationErroron mismatch; withrequire_validation=Falsethe mismatch is only logged.AlleleTranslator._from_hgvs()passesrequire_validationthrough, so the existingtranslate_from(..., require_validation=False)escape hatch now applies to HGVS input too.Tests
tests/extras/test_allele_translator.py(no UTA/seqrepo network needed): the exact issue variant raises by default; a del-with-ref mismatch raises; correct-reference controls (substitution and deletion-with-ref) still translate;require_validation=Falsereturns the allele with a logged warning; edits without a stated ref skip validation.src/fix reverted, the two "raises" tests fail (pristine code emits the Allele); with the fix, all 5 pass.test_from_hgvsand thetest_hgvssubstitution cases. Ground truth for the added interactions was cross-checked against the repo's own previously recorded cassettes and NCBI RefSeq.checkandformat --checkpass on all touched files.Limitations
test_from_hgvs,test_hgvs) could not be executed in this environment (no UTA or seqrepo access). Cassette completeness was verified by replaying the fixed code path against the recorded cassettes with the session-scoped cache shared, but CI is the authoritative check.test_vrs_normalize.pyfailures (VCR cassette mismatches) occur identically with and without this change.Related: #151 (maintainer discussion supports validating supplied reference alleles and raising rather than emitting invalid objects).