Skip to content

Mint pre-mapped VRS for accession-target variants #869

Description

@bencap

Summary

Mint a pre-mapped VRS allele for each accession-target variant inside validate_genomic_variant, reusing the variant object and CDOT provider it already has.

Problem

Transcript accessions (NM_/ENST) have 5' UTRs, so c.197 is not position 197 of the fetched transcript sequence. Positions have to go through a coordinate-aware mapper before SPDI conversion. Non-accession targets (#868) don't have this problem.

Proposed behavior

  • Reuse variant_obj after hgvs.validator.Validator(hdp=cdot_rest()) validates it. Don't parse or validate it again.
  • Project it to a sequence-relative position with hgvs.variantmapper.VariantMapper or AssemblyMapper, built on hdp=cdot_rest(). Don't use ga4gh.vrs's AlleleTranslator, which is hardwired to the public UTA server.
  • Fetch the sequence with cdot_rest().get_seq(TargetAccession.accession), memoized per (target, accession).
  • Pass the position and sequence through the Mint pre-mapped VRS for non-accession-target variants #868 pipeline unchanged: SPDI → _from_spdinormalize_and_identify over a LiteralSequenceDataProxy.
  • Set allele.expressions to the original HGVS string.
  • Call site: in validate_genomic_variant, after validator.validate(...) succeeds. Keep minting failures (CDOT unavailable, accession not found, projection failure) out of the validity return. They must never raise ValidationError.

Acceptance criteria

  • First, in a dev environment with cdot-rest, confirm that a transcript with a non-trivial 5' UTR projects to a sequence position that differs from its c. number.
  • For such an accession, the digest uses the offset-adjusted position.
  • CDOT fetches each (target, accession) at most once per validation pass.
  • CDOT failures (network, timeout, accession not found) and projection failures (such as an intronic variant with no resolvable sequence) raise different typed exceptions. That lets Attach minted pre-mapped VRS to created Variant rows and record the outcome #870 record them under different AnnotationFailureCategory values, and the existing EXTERNAL_API_ERROR and EXTERNAL_REFERENCE_NOT_FOUND are enough.
  • Corpus cross-check: accession variants that have a MappedVariant.pre_mapped and a clean alignment (no near_gap/at_mismatched_locus) produce matching digests. A mismatch on a flagged variant is expected.

Implementation notes

  • cdot_rest() (data_providers/services.py) is the internal service that validate_hgvs_genomic_column already calls.
  • Variant.hgvs_nt/hgvs_pro store bare edits without the accession, even for accession targets. dcd-mapping's _map_accession adds TargetAccession.accession itself.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app: backendTask implementation touches the backend

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions