Skip to content

getModelFromKEGG: build the global model from raven-data artefacts - #707

Merged
edkerk merged 8 commits into
develop3from
fix/kegg-model-data-704
Aug 28, 2026
Merged

getModelFromKEGG: build the global model from raven-data artefacts#707
edkerk merged 8 commits into
develop3from
fix/kegg-model-data-704

Conversation

@edkerk

@edkerk edkerk commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #704.

  • keggModel.mat was never shipped in the repository and had no working way to be regenerated, so any reconstruction for an already-annotated KEGG species failed outright.
  • getModelFromKEGG now downloads and assembles the same data from the raven-data kegg118 release: the gene-free reference model plus the ko_reaction/organism_gene_ko/rxn_flags relational tables published by the raven-toolbox Python package. Every organism's genes are joined onto the reference reactions through their shared KO ids via two sparse incidence matrices (gene-KO, KO-reaction) multiplied together — organism_gene_ko can carry millions of rows, so a per-row loop isn't viable. The assembled result is cached to keggModel.mat exactly as before, so this only costs the (slow, ~150+ MB) build once.
  • getPhylDist/keggPhylDist.mat is unaffected — that file is already committed to the repository and was never part of this issue.
  • The smaller thing noted in getKEGGModelForOrganism: keggModel.mat has no working way to obtain #704 is also fixed here: the HMM library is no longer downloaded on the annotation-only (no-FASTA) path.
  • The kegg118 release tag is no longer hardcoded anywhere: reconstruction/kegg/KEGG_VERSION.md is now the single place it's recorded, read via the new keggDataVersion. The download helper itself (fetchRavenDataAsset, replacing the KEGG-specific fetchKEGGArtefact) takes the release tag and asset name as arguments, so it also now serves getKEGGModelForOrganism's HMM library download (previously its own inline websave), and is reusable for any future raven-data asset.

Test plan

  • tSyntax, tInstallation, tReconstruction — 14 passed, 0 failed, 3 filtered (all needing real network data / a pre-existing keggModel.mat, consistent with the existing getKEGGModelForOrganismNeedsData/getPhylDistNeedsData pattern)
  • New offline unit test (buildGlobalGPRJoinsGenesThroughSharedKO) exercises the gene/KO/reaction join logic directly against a small synthetic fixture, without needing the real ~150 MB artefact set
  • Not verified against the real raven-data download in this session (no network fetch of the full artefact set attempted here)

edkerk added 2 commits August 28, 2026 09:50
findRAVENroot now validates a stored MATLAB preference against
RAVEN2.png before trusting it, instead of blindly returning a path
that may belong to a different RAVEN checkout on the same machine.

getKEGGModelForOrganism only downloads the ~100+ MB HMM library when a
FASTA file is actually supplied; the annotation-only path never uses
libraryFile, so the download was pure waste on that path.
keggModel.mat was never shipped in the repository and had no working
way to be regenerated, so any reconstruction for an already-annotated
KEGG species failed outright (issue #704).

getModelFromKEGG now downloads and assembles the same data from the
raven-data kegg118 release instead: the gene-free reference model plus
the ko_reaction/organism_gene_ko/rxn_flags relational tables published
by the raven-toolbox Python package. Every organism's genes are joined
onto the reference reactions through their shared KO ids using two
sparse incidence matrices (gene-KO, KO-reaction) multiplied together,
since organism_gene_ko can carry millions of rows and a per-row loop
isn't viable. The assembled result is cached to keggModel.mat exactly
as before, so this only costs the (slow, ~150+ MB) build once.

getPhylDist/keggPhylDist.mat is unaffected: that file is already
committed to the repository and was never part of this issue.
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Function test results

304 tests   277 ✅  1m 9s ⏱️
 25 suites   27 💤
  1 files      0 ❌

Results for commit 7f70d8d.

♻️ This comment has been updated with latest results.

edkerk added 6 commits August 28, 2026 10:21
A stored preference pointing at a directory without RAVEN2.png now
throws immediately, naming the bad path and how to fix or clear it,
rather than silently falling back to resolving the root from the
currently executing copy of RAVEN.
…sion

fetchKEGGArtefact only ever downloaded the kegg118 core bundle. Replaced
it with fetchRavenDataAsset, which takes the release tag and asset name
as arguments instead of hardcoding kegg118 --- so it can also serve the
HMM library download in getKEGGModelForOrganism (previously its own
inline websave/try-catch), and any future raven-data asset that isn't
KEGG at all.

The "kegg118" string itself now lives in exactly one place,
reconstruction/kegg/KEGG_VERSION.md, read via the new keggDataVersion.
Everywhere else that named it directly (buildGlobalKEGGModel's artefact
names, getKEGGModelForOrganism's HMM library names/URL) now reads it
from there, so a future KEGG release only needs that one file bumped.
It isn't KEGG-specific --- it downloads any raven-data release asset by
tag and file name --- so it belongs alongside downloadRavenBinaries,
which fetches from the same repository, rather than under
reconstruction/kegg/. No behaviour change.
Replaces its own inline websave/try-catch (and the now-redundant base
URL variable) with the same download-with-cache helper KEGG artefacts
and the HMM library already use, since it downloads from the same
raven-data repository. No behaviour change beyond the shared helper's
messaging.
The hard error broke CI: checkInstallation's own setpref, moments
later re-read by checkFunctionUniqueness's separate findRAVENroot
call, disagreed with RAVEN.png's presence in a way that only reproduced
on the CI runner, cascading into ~40 failing test classes. Reverted to
silently falling through to resolving the root from the executing file,
matching every prior passing run --- still validated (an invalid stored
preference is not trusted), just not fatal.

Also: RAVEN2.png was renamed to RAVEN.png upstream (#708, picked up by
merging origin/develop3); the preference-validation branch had missed
that rename since it has no equivalent on the upstream side to merge
against.
@edkerk
edkerk merged commit 7baa0d5 into develop3 Aug 28, 2026
4 checks passed
@edkerk
edkerk deleted the fix/kegg-model-data-704 branch August 28, 2026 10:00
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