Annotation import loads every transcript version for the build: an 11 minute wait to load one variant's result
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
This issue has not been assessed yet.
Description
🤖 Written by Claude
When an annotation run loads its VEP results into the database, the importer first builds a lookup of every transcript version for the build and consortium (annotation/vcf_files/bulk_vep_vcf_annotation_inserter.py:BulkVEPVCFAnnotationInserter.transcript_versions_by_id, which calls genes/models/models_gene.py:TranscriptVersion.transcript_versions_by_id). It does this once per run, whatever the run's size, to turn each transcript accession in the VEP output into a TranscriptVersion pk.
Seen on a test deployment: a GRCh38 run with a single variant took 11 minutes to load its result. The time went on that one query, reading from disk with a cold cache. The same step took 1 minute on GRCh37 and under a second on T2T. Nothing failed, but a classification import that creates one new variant waits that long for its annotation.
Why it is slow
-
It loads far more than it needs. VEP only reports transcripts from the annotation version's gene annotation release, and on the RefSeq builds the release is about a third of the transcript versions we hold:
Build All transcript versions (build + consortium) In the gene annotation release GRCh37 (RefSeq) 201,945 82,466 GRCh38 (RefSeq) 542,377 178,369 T2T (Ensembl) 238,489 236,037 -
Each row needs a read from the
genes_transcriptversiontable itself (about 5 GB, as each row carries its cdot JSON), because no index holdstranscript_id,versionandidtogether. With a cold cache that is one slow disk read per transcript version.
The release is enough. Each VariantAnnotationVersion is tied to one GeneAnnotationRelease, the specific RefSeq or Ensembl release VEP was run with, so VEP's output can only name transcript versions in that release (ReleaseTranscriptVersion). The mitochondrial "fake" transcripts the importer matches (the 13 coding ones, fake-rna-ND4 and so on) are in the release too; the 24 tRNA/rRNA ones are not, and VEP reports nothing the importer links to them.
Ideas to try
Look at the size of the annotation run and pick a strategy to suit. Try a few and measure, cold and warm:
- Very small runs: look up each transcript version as it is needed.
- Medium runs: read a batch of VEP records, collect the transcript accessions in it, and fetch them in one query with
__in=. - Huge runs: load the gene annotation release's transcript versions up front (the fake ones the importer needs are in it).
Index: adding id to the unique (transcript_id, version, genome_build_id) index (INCLUDE (id)) would let all three strategies answer from the index without reading the table. Decide this alongside the strategies, as it may make some of them unnecessary.
The gene lookup next to it (gene_identifiers) loads every gene version for the build the same way, so it is worth a look while there.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SACGF/variantgrid
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
SACGF/variantgrid#2964 · 1 comment ·
Maintainers usually reply within 1 day
-
Genome build now duplicated in "imported as" on allele pagePossibly taken @TheMadBug claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
SACGF/variantgrid#2950 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
SACGF/variantgrid#2865 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SACGF/variantgrid#2647 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
SACGF/variantgrid#2341 · 3 comments ·
Maintainers usually reply within 1 day
All issues in SACGF/variantgrid
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day