Skip to content

Read HPO's 2023 phenotype_to_genes.txt and backfill HPO to gene relations #1862 - #1864

Open
davmlaw wants to merge 1 commit into
masterfrom
1862_phenotype_to_genes_format
Open

Read HPO's 2023 phenotype_to_genes.txt and backfill HPO to gene relations #1862#1864
davmlaw wants to merge 1 commit into
masterfrom
1862_phenotype_to_genes_format

Conversation

@davmlaw

@davmlaw davmlaw commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Addresses #1862 - every HPO term on a phenotype node warned "have no associated genes".

Cause

HPO changed phenotype_to_genes.txt in 2023 from seven columns behind a #Format: comment to five columns with a header row. load_phenotype_to_genes read it with the old column names, the source == mim2gene filter emptied the frame, and the import completed with zero relations.

Changes

  • load_phenotype_to_genes detects the format from the first line, keeps OMIM rows for either format, and raises if the frame is empty. processor_version bumped to 2.
  • OntologyBuilder(existing_import=...) writes into an existing import's partition instead of creating a new import.
  • New backfill_phenotype_to_genes command: downloads the current file (or takes --phenotype_to_genes) and loads it into the import the latest OntologyVersion already points at, so no new OntologyVersion / annotation sub-version / gene annotation build follows. Registered as a manual migration step (ontology/migrations/0028) whose test fires only when that import owns no relations.
  • Five column test fixture and a test covering format detection, the OMIM filter and the HPO -> OMIM -> HGNC path.
  • create_test_ontology_version now records imports that already exist (was masked by the seeded test database).
  • Format history noted in claude/research/ontology.md.

Verification

  • Full suite: 3290 tests OK on a freshly rebuilt --keepdb database.
  • Backfill run locally against today's HPO download: the existing import went from 0 to 533,001 relations, still one OntologyVersion, and HP:0004808 resolves to CEBPA, BRCA2, GATA2 and others. A second run is a no-op.

After deploy

Gene annotation hpo_terms / omim_terms for the existing ontology version were built without these relations; the command prints gene_annotation --latest-releases --force for rebuilding them. Phenotype nodes cache empty term lookups for a day, so a term viewed before the backfill may keep its warning until then.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BtmQtLeDUcDJz5kMdEfhhe

…o gene relations #1862

load_phenotype_to_genes only knew the old seven column file, so the 2023 format
imported as zero relations and every HPO term on a phenotype node warned it had
no associated genes. The loader now detects the format from the first line,
keeps OMIM rows for either, and raises if nothing is left.

backfill_phenotype_to_genes (registered as a manual migration step when the
latest OntologyVersion's phenotype_to_genes import owns no relations) downloads
the current file and loads it into that existing import via
OntologyBuilder(existing_import=...), so deployments gain the relations without
a new OntologyVersion, annotation sub-version or gene annotation build.

create_test_ontology_version now records imports that already exist, which was
masked by the seeded test database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant