Search preview HGVS code: variant HGVS row to annotation, resolved c.HGVS lookup onto ImportedAlleleInfo

Open
#2,825 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, databases

Research direction

Read classification/signals/classification_search.py, annotation/canonical_annotation.py, and the ImportedAlleleInfo model near column_name_for_build; trace the preview receivers and the existing tests in classification/tests/test_classification_search.py. Move the annotation helpers and tests, put the resolved HGVS lookup and build cache guard on the model, then split the preview receivers as described. Done when the existing search preview tests pass unchanged, including the T2T case.

Written by the indexing model from the issue text.

Description

Refactoring

🤖 Written by Claude

Came out of reviewing #2824 (for #2821). classification/signals/classification_search.py holds the classification search receiver, the search-preview receivers for Allele / Variant / OntologyTerm, and the HGVS code those previews use. Two pieces of that HGVS code have a better home. No behaviour change intended.

1. The variant's own HGVS row belongs in annotation

_variant_hgvs_extra and _variant_location_summary read only annotation data: the canonical c.HGVS, the g.HGVS, and consequence / distance / symbol for the "3709bp upstream of X" line. They sit in the classification file because the classification preview falls back to them when no classification supplies a c.HGVS.

  • Move them beside annotation/canonical_annotation.py:get_canonical_c_hgvs, which they already call.
  • Keep them as a plain helper the classification receiver calls. PreviewData._summary_external (library/preview_request.py) concatenates every receiver's rows, so a separate preview_extra_signal receiver in annotation could not tell that the classification receiver had already supplied c.HGVS rows, and the fallback would become duplicate rows.
  • The _variant_location_summary tests in classification/tests/test_classification_search.py move with it.
2. The resolved c.HGVS / p.HGVS lookup belongs on the model

_allele_preview_classifications_extra builds the distinct (c_hgvs, p_hgvs) pairs for a build from the cached ResolvedVariantInfo columns. That is a query about resolved HGVS per build: a method next to ImportedAlleleInfo.column_name_for_build that returns an empty list for a build with no cached columns would leave the receiver to format rows only.

It would also give the "is this build cached?" guard one home. It is currently written three ways:

  • classification/views/classification_datatables.py (render_hgvs) catches the ValueError from column_name_for_build.
  • classification/views/classification_grouping_datatables.py (genome_build_prefs) filters by ImportedAlleleInfo.supported_genome_builds().
  • The search preview checks in ImportedAlleleInfo.supported_genome_builds() inline (#2824).

One place to change when #1973 widens the supported builds.

3. Smaller, same file
  • classification_qs_to_extras is imported by genes/signals/gene_symbol_search.py, so genes imports from classification.signals, which is above it in the app layering. The GeneSymbol preview receiver that needs it could live in classification/signals/.
  • Split the preview receivers out of the search file, following snpdb/signals/variant_zygosity_preview_extra.py (e.g. classification/signals/classification_preview_extra.py).
Testing

Refactor only: existing search preview tests pass unchanged, including the T2T case added in #2824.

Dominant language
Python
Stars
31
Forks
4
Avg merge
4h 52m
Merged PRs (30d)
183

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SACGF/variantgrid

All issues in SACGF/variantgrid

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.