Repository navigation
Kcat strategies, BRENDA from toolbox-assets and GECKO 3 project upgrades - #68
Merged
Merged
Conversation
fetch_brenda_asset downloads the files of the toolbox-assets release brenda-2026.1-1 (kcat, sa, mw and measurements, and on request sequences, substrates and combination parameters) with raven-toolbox's checksummed download, and unpacks them in its cache. ModelAdapter.get_brenda_db_folder gives the project's data/brenda when it exists and these files otherwise. The wheel no longer carries BRENDA files, so the build hook that compressed them is gone.
…ault A combine stage gives each open reaction the precision-weighted mean of its sources' values, each corrected for the source's bias and weighted by 1 / its error variance for the source's evidence (EC tree: measurements and EC level; OKP method: similarity to its training sequences), with an uncertainty for a new measurement. The parameters are kcatCombineParams.tsv of the BRENDA files. model.ec.source reads 'combined (sd=..., n=...)' and the decisions get sd_log10. okp in a stage stands for the OKP methods of [kcat_sources.okp] methods. OKP results keep the similarity to the method's training data, written as similarity= in the detail column, and load_kcat_source passes the detail on. Presets: brenda_ec_tree combines the OKP methods for the reactions without an EC number instead of using DLKcat; ec_tree_okp combines the EC tree with the OKP methods; okp uses the OKP methods only.
convert_custom_kcats writes data/customKcats.tsv as the curated kcat source file data/kcats/custom.tsv: the kcats apply_custom_kcats gives the ecModel, one row per reaction keyed by conventional reaction and enzyme set. upgrade_ec_model turns the protein usage and pool reactions of a GECKO 3 ecModel forward. upgrade_project (geckopy upgrade) lists, and with dry_run=False carries out, the steps from a GECKO 3 project: custom kcats, stored predictions to source files, saved ecModels, project_format = 4; it lists script lines that call renamed or replaced functions. Originals go to legacy/<date>/. kcats_from_brenda downloads PhylDist.mat when missing. model_adapter.toml takes project_format. The full_ecModel tutorial shows how to choose a kcat strategy.
kcats_from_homologs searches each enzyme of a reaction with DIAMOND (raven-toolbox's) against the sequences of the BRENDA measurements (at least 40% identity, 80% coverage of both), and takes the identity-weighted mean of the medians of up to 10 homologs measured on the reaction's substrate, matched by InChIKey through ChEBI or MetaNetX annotations, or else the name. It writes data/kcats/homologs.tsv with the nearest identity and the number of homologs in the detail column. extract_enzyme_substrate_pairs gives the substrates and now their met_id. The ec_tree_homologs preset combines the EC tree with homologs, and ec_tree_okp combines homologs too; update_kcat_sources gathers homologs.tsv.
When a homolog at 95% identity or more was measured on the substrate, the homolog estimate is the median of those homologs alone, and the combination gives it the exact bin of kcatCombineParams.tsv: no bias and the smallest error variance, an assumption, as the benchmark the other bins were fitted on hides such homologs. The detail column writes the identity with three decimals, as DIAMOND reports it, so that it falls in the right bin.
…yme-substrate pair OpenKineticsPredictor names the method TurNup. CatPred and TurNup take the substrates (and products) of a whole reaction, so the default OKP methods are the eight pair-based ones with combination parameters, and asking for CatPred or TurNup per pair is an error.
makeEcModel puts it in metNotes. As a separate notes key it was written as a nested map, which RAVEN's readYAMLmodel cannot read, so GECKO could not load an ecModel that geckopy saved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kcat strategies for different users, BRENDA from toolbox-assets, and upgrades of GECKO 3 projects. GECKO has the same (CompMetEng/GECKO#11). The plan is
docs/kcat-strategies.mdin CompMetEng/raven-gecko-parity#134.Kcat strategies
Presets (
[kcat_assignment] presetinmodel_adapter.toml):brenda_ec_tree(default)ec_tree_homologsec_tree_okpokpgecko_median,gecko_classicA single method is a stage:
sources = ["custom", "okp_catapro"].okpin a stage stands for the OpenKineticsPredictor methods of[kcat_sources.okp] methods(default: the eight methods that predict per enzyme–substrate pair and have combination parameters: CataPro, DLKcat, EITLEM, KinForm-H, KinForm-L, OmniESI, OmniESI-O2DENet and UniKP; CatRange has no parameters, and CatPred and TurNup need the whole reaction, so asking for them per pair is an error).update_kcat_sourcesgathers each method's file.combinestage (geckopy.gather_kcats.combine_kcats). Each open reaction gets the precision-weighted mean of its sources' log10 values, each corrected for the source's bias and weighted by 1 / its error variance; both depend on the source's evidence for the reaction:ec_treeec4:1-2…ec4:>100), or the deepest EC level with measurements (ec3,ec2)okp_<method><40,40-60,60-80,>80%)homologsThe uncertainty for a new measurement is
sqrt(1 / Σ(1/variance) + 0.48²), scaled so the 80% interval covers 80% of the measurements the parameters were fitted on. The parameters (kcatCombineParams.tsv, in the BRENDA asset) were fitted on the kcat benchmark's development split; on its 3,095 development pairscombine_kcatsgives the benchmark's own combination to 6×10⁻⁷ log10.ec.sourcereadscombined (sd=0.61, n=6), and the decisions getsd_log10. A source without parameters is an error.OKP.
parse_okp_outputkeeps themax similarity to <method> training datacolumn assimilarity,kcats_from_okpwrites it assimilarity=in the detail column, andload_kcat_sourcepasses the detail on.Why. Against measured kcats hidden from the sources (the enzyme's own measurements and those of sequences at ≥ 95% identity hidden):
Homologs
kcats_from_homologsestimates kcats from measured homologs of the model's enzymes:extract_enzyme_substrate_pairs);substrates.tsvof the BRENDA files: ChEBI annotations, then MetaNetX annotations, then the name (lower case, letters, digits and+only);resolve_binary, downloaded when missing) againstsequences.fastaof the BRENDA files: at least 40% identity, 80% coverage of both sequences;exactbin ofkcatCombineParams.tsv(bias 0, the smallest error variance). That bin is an assumption, stated in the file: the benchmark the other bins were fitted on hides homologs above 95% identity. On the yeast tutorial model 73 homolog values come from an identical sequence.The values go to
data/kcats/homologs.tsv, withidentity=(nearest homolog, three decimals as DIAMOND reports it) andn=(homologs used) in the detail column;update_kcat_sourcesgathers it.extract_enzyme_substrate_pairsalso returns each substrate'smet_id.DIAMOND gives the same homologs as the MMseqs2 search of the kcat benchmark: on the development split 99% of the hits are shared, identities agree within ±0.003, and the homolog estimate and its combination with the EC tree are as close to the hidden measurements (DIAMOND minus MMseqs2 +0.002 log10, −0.001 to +0.007). The estimate equals the benchmark's homolog strategy on its 1,863 development pairs with a homolog. On the yeast tutorial model, homologs give values for 352 reactions in 8 s, and GECKO and geckopy write the same 418 rows (the kcats agree to the last binary digit). With BRENDA alone, homologs add little to the EC tree (−0.002 log10, not significant), so they are in
ec_tree_homologsandec_tree_okp, not in the default.BRENDA files from toolbox-assets
geckopy no longer ships BRENDA data.
fetch_brenda_assetdownloads the files of the toolbox-assets releasebrenda-2026.1-1(BRENDA 2026.1, CC BY 4.0) on first use, with raven-toolbox'sensure_data_file(SHA-256 checked, cached), and unpacks them in the cache:kcat.tsv,sa.tsv,mw.tsvkcats_from_brenda)measurements.tsvkcats_from_ec_tree)sequences.fasta,substrates.tsvkcatCombineParams.tsvcombinestageModelAdapter.get_brenda_db_foldergives the project'sdata/brendawhen it exists (written bygeckopy brenda-refresh) and these files otherwise. Processes that download or unpack the same file at once use each other's result. The wheel carries no BRENDA files, so the build hook that compressed them is gone.kcats_from_brendadownloadsPhylDist.matwhen the project has none.Upgrading GECKO 3 projects (
geckopy.upgrade)convert_custom_kcats(ec_model)writesdata/customKcats.tsvas the curated source filedata/kcats/custom.tsv: the kcatsapply_custom_kcatsgives the ecModel, including which of two overlapping entries wins, one row per reaction keyed by conventional reaction and enzyme set.custom.tsvalso applies to light ecModels.upgrade_ec_modelturns the protein usage and pool reactions of a GECKO 3 ecModel forward;load_ec_modelalready does this for the files it reads.upgrade_project(path)andgeckopy upgrade <folder> [--apply] [--ec-model FILE]list, and carry out:customKcats.tsv→data/kcats/custom.tsv;models/rewritten in the forward direction;project_format = 4inmodel_adapter.toml;Steps 1 and 2 need the full ecModel; without it they are listed and skipped. The adapter-class step is GECKO's. Originals go to
legacy/<date>/; steps already done are left out, so it can run again.model_adapter.tomltakesproject_format.Tutorial
full_ecModelgives the same ecModel as before (4842ec.rxns, sameec.kcat,ec.sourceand stoichiometry); a new section explains how to choose a kcat strategy and upgrade older projects.ecModels GECKO can read
The enzyme and pool pseudometabolites carry their description as RAVEN's metabolite note (
notes: Enzyme-usage pseudometabolite), asmakeEcModelwrites it. As a separate notes key it was saved as a nested map, which RAVEN'sreadYAMLmodelrejects, so GECKO could not load an ecModel saved by geckopy.Tests
tests/test_combine_kcats.py: evidence bins; a hand-computed combination; theokpandec_tree_okppresets; errors.tests/test_ec_tree.py: the BRENDA release download; the default preset's order.tests/test_homologs.py: a fixture of known identities (an exact copy, an 80% copy, an unrelated sequence), shared with GECKO: the estimate,kandmin_identity; compact names; substrate matching by ChEBI, MetaNetX and name; the homolog presets.tests/test_make_ec_model.py: the pseudometabolites' notes in the saved YAML.tests/test_upgrade.py: conversion keys and overlap; the same kcats before and after conversion;upgrade_ec_model;upgrade_projectdry run, run, rerun andgeckopy upgrade.On the yeast tutorial model, geckopy and GECKO give the same kcats, labels and uncertainties with
ec_tree_okpon the same EC-tree and OKP files, andconvert_custom_kcatsgives the same 219 rows in both tools and the same kcats ascustomKcats.tsv. On ecYeastGEM 9.1.1 with real OpenKineticsPredictor results of the eight default methods,kcats_from_okpand GECKO'skcatsFromOKPwrite identical source files (4,126 rows for DLKcat, 4,205 for the others), GECKO reading the model saved by geckopy. The suite passes from an empty cache with eight parallel workers.