SACGF / SACGF/variantgrid

Replace VG HGVS cleaning/gene-resolution with cdot equivalents

Open
#1,488 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
3
Avg merge
9h 22m
Merged PRs (30d)
40

Description

🤖 Written by Claude.

## Background

cdot now ships three utilities that overlap with existing VariantGrid HGVS code. Once a cdot release is cut that includes these, we should migrate VG to use the canonical library versions and delete the duplicated logic.

---

## cdot functions to adopt

### 1. `cdot.hgvs.clean.clean_hgvs()`

Replaces `HGVSMatcher.clean_hgvs()` in `genes/hgvs/hgvs_matcher.py`.

VG's version was the original source; cdot's is now the canonical home. The return signature differs slightly — cdot returns `(cleaned_str, list[HGVSFix])` instead of a bare string — so callers need minor adaptation, but the logic can be deleted from VG.

### 2. `cdot.hgvs.clean.get_best_transcript_version()`

Replaces the version-distance ranking inside `HGVSMatcher.filter_best_transcripts_and_converter_type_by_accession()`.

The cdot function handles the same `UP_THEN_DOWN` / `CLOSEST` / `LATEST` strategies. VG keeps only the parts specific to it: converter-type priority and ClinGen fallback ordering.

### 3. `cdot.hgvs.gene_hgvs.resolve_gene_hgvs()`

Replaces `HGVSMatcher._search_hgvs_using_gene_symbol()` / `get_gene_symbol_if_no_transcript()`.

Handles the `BRCA2:c.36del` → `NM_000059.4:c.36del` case using tag priority `MANE_Select > MANE_Plus_Clinical > RefSeq_Select > Ensembl_canonical`. Calls `data_provider.get_tx_ac_tags_for_gene(gene, genome_build)` which is already implemented in cdot's `LocalDataProvider`.

---

## Hook added in cdot: `_get_transcript_tags()`

`LocalDataProvider.get_tx_ac_tags_for_gene()` (called by `resolve_gene_hgvs()`) now delegates per-transcript tag lookup to an overridable method:

```python
def _get_transcript_tags(self, transcript_data: dict, genome_build: str) -> list[str]:
...
```

Default reads the `tag` field from the cdot JSON (e.g. `"MANE_Select,basic"`).

**VG action:** override this in `DjangoTranscriptDataProvider` (`genes/hgvs/biocommons_hgvs/data_provider.py`) to fall back to VG's MANE/canonical DB tables when the stored cdot JSON has no tag data (older imports):

```python
def _get_transcript_tags(self, transcript_data, genome_build):
tags = super()._get_transcript_tags(transcript_data, genome_build)
if not tags:
tx_ac = transcript_data.get("id", "")
# query TranscriptVersion / MANE model for tx_ac + genome_build
tags = ...
return tags
```

---

## Files to change in VG

| File | Change |
|---|---|
| `genes/hgvs/hgvs_matcher.py` | Replace `clean_hgvs()`, version-ranking, `_search_hgvs_using_gene_symbol()` |
| `genes/hgvs/biocommons_hgvs/data_provider.py` | Override `_get_transcript_tags()` |
| `snpdb/signals/variant_search.py` | Simplify `search_hgvs()` once above is in place |

---

## Prerequisite

Wait for a cdot release that includes `cdot.hgvs.clean`, `cdot.hgvs.gene_hgvs`, and the `_get_transcript_tags()` hook in `LocalDataProvider`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.