Repository navigation
Kcat strategies, BRENDA from toolbox-assets and GECKO 3 project upgrades - #11
Merged
Merged
Conversation
fetchBrendaAsset 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's fetchToolboxAsset into databases/brenda-2026.1-1 and unpacks them. ModelAdapter.getBrendaDBFolder gives the project's data/brenda when it exists and these files otherwise. databases/ no longer holds BRENDA files.
This was referenced Oct 17, 2026
Merged
Unit test results61 tests 61 ✅ 8s ⏱️ Results for commit b9669ed. ♻️ This comment has been updated with latest results. |
…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 sdLog10. 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 loadKcatSource 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.
convertCustomKcats writes data/customKcats.tsv as the curated kcat source file data/kcats/custom.tsv: the kcats applyCustomKcats gives the ecModel, one row per reaction keyed by conventional reaction and enzyme set. upgradeEcModel turns the protein usage and pool reactions of a GECKO 3 ecModel forward. upgradeGECKOproject lists, and with 'dryRun', false carries out, the steps from a GECKO 3 project: adapter class to model_adapter.toml, 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>/. model_adapter.toml takes project_format. The full_ecModel tutorial shows how to choose a kcat strategy.
kcatsFromHomologs searches each enzyme of a reaction with DIAMOND (RAVEN'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. extractEnzymeSubstratePairs, taken out of writeDLKcatInput, gives the substrates. The ec_tree_homologs preset combines the EC tree with homologs, and ec_tree_okp combines homologs too; updateKcatSources 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.
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. geckopy has the same (CompMetEng/geckopy#68). 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).kcatAssignmentConfiggives each stage's expandedfilesandokpMethods.combinestage. 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.model.ec.sourcereadscombined (sd=0.61, n=6), and the decisions getsdLog10. A source without parameters is an error.OKP.
readOpenKineticsPredictorOutputkeeps themax similarity to <method> training datacolumn assimilarity,kcatsFromOKPwrites it assimilarity=in the detail column, andloadKcatSourcepasses 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
kcatsFromHomologsestimates kcats from measured homologs of the model's enzymes:extractEnzymeSubstratePairs);substrates.tsvof the BRENDA files: ChEBI annotations, then MetaNetX annotations, then the name (lower case, letters, digits and+only);downloadRavenBinarieswhen 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;updateKcatSourcesgathers it.extractEnzymeSubstratePairsis the substrate rule ofwriteDLKcatInput, now a function of its own thatwriteDLKcatInputcalls.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
GECKO no longer ships BRENDA data.
fetchBrendaAssetdownloads the files of the toolbox-assets releasebrenda-2026.1-1(BRENDA 2026.1, CC BY 4.0) on first use, with RAVEN'sfetchToolboxAsset, intodatabases/brenda-2026.1-1, and unpacks them:kcat.tsv,sa.tsv,mw.tsvkcatsFromBrenda)measurements.tsvkcatsFromECTree)sequences.fasta,substrates.tsvkcatCombineParams.tsvcombinestageModelAdapter.getBrendaDBFoldergives the project'sdata/brendawhen it exists (written bygeckopy brenda-refresh) and these files otherwise. The files have the same content as thosedatabases/held.Upgrading GECKO 3 projects
convertCustomKcats(ecModel)writesdata/customKcats.tsvas the curated source filedata/kcats/custom.tsv: the kcatsapplyCustomKcatsgives 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.upgradeEcModelturns the protein usage and pool reactions of a GECKO 3 ecModel forward (#419): stoichiometry, bounds and objective coefficient change sign; models already forward are left as they are.upgradeGECKOproject(projectPath)lists, and with'dryRun', falsecarries out:model_adapter.toml(convertAdapterToToml), listing methods to carry over by hand;customKcats.tsv→data/kcats/custom.tsv;models/turned forward;project_format = 4inmodel_adapter.toml;Steps 2 and 3 need the full ecModel (
'ecModel'); without it they are listed and skipped. Originals go tolegacy/<date>/; steps already done are left out, so it can run again.model_adapter.tomltakesproject_format.keggPhylDist.matin RAVEN 3RAVEN 3 keeps
keggPhylDist.matundersrc/reconstruction/kegg.ModelAdapter.getPhylDistStructPathlooks there first, then underreconstruction/kegg(earlier RAVEN 3) andexternal/kegg(RAVEN 2).Tutorial
full_ecModelkeepsgecko_classicand gives the same ecModel as before (4834ec.rxns, sameec.kcat,ec.sourceandS); a new section explains how to choose a kcat strategy and upgrade older projects.Tests
combineTests(tc0088–tc0090)okpandec_tree_okp; errors for a method without parameters and an unknown methodecTreeTests(tc0085, tc0087)homologsTests(tc0095–tc0097)kandminIdentity; substrate matching by ChEBI annotation; the homolog presetsupgradeTests(tc0091–tc0094)convertCustomKcatskeys and overlap; the same kcats before and after conversion;upgradeEcModelboth ways;upgradeGECKOprojectdry run, run and rerunOn the yeast tutorial model, GECKO and geckopy give the same kcats, labels and uncertainties with
ec_tree_okpon the same EC-tree and OKP files, andconvertCustomKcatsgives 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,kcatsFromOKPand geckopy'skcats_from_okpwrite identical source files (4,126 rows for DLKcat, 4,205 for the others).