Skip to content

Assign kcats from the kcat source files, as model_adapter.toml sets - #66

Open
edkerk wants to merge 4 commits into
developfrom
feat/kcat-assignment
Open

edkerk wants to merge 4 commits into
developfrom
feat/kcat-assignment

Conversation

@edkerk

@edkerk edkerk commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Kcats are assigned from the kcat source files in data/kcats (#64), in an order that model_adapter.toml sets. GECKO has the same functions and settings (CompMetEng/GECKO#9). This is step K2 of the plan in CompMetEng/raven-gecko-parity#134.

Builds on #61 (shared model_adapter.toml) and #64 (kcat source files); the diff shows their changes until they are merged.

Functions

Function Does
collect_kcats Decides one kcat per reaction from the source files on a copy of the model; returns the decisions, a report and the copy, and writes output/<model id>_kcatDecisions.tsv (stage, source, kcat, number of values and their spread per reaction)
assign_kcats The same in place, then applies the kcat constraints. Replaces merge_kcats → apply_kcat_list → apply_custom_kcats → fill_kcats_from_isozymes → assign_standard_kcat → apply_kcat_constraints, which stay callable
update_kcat_sources Gathers the source files the configuration needs (kcats_from_brenda, kcats_from_dlkcat, kcats_from_okp) when they are missing, or when their header records other settings or another BRENDA release than asked; dry_run=True only reports

Configuration

[kcat_assignment] and [kcat_sources.<name>] in model_adapter.toml, validated by KcatAssignmentParams and KcatStageParams; adapterParameters.tsv is the same file as GECKO's.

[kcat_assignment]
preset = "gecko_median"   # the default; or gecko_classic
isozymes = true
standard = true

# instead of a preset:
[[kcat_assignment.stage]]
sources = ["custom", "database_top", "dlkcat", "database_bottom"]
top_origin_limit = 4
  • A stage decides the reactions that are still open, by the first listed source with a value (merge_kcats). Sources are source file names and the BRENDA tiers database_exact, database_top and database_bottom, which read brenda.tsv.
  • A listed source file that does not exist is reported and left out. Without data/kcats/custom.tsv, data/customKcats.tsv is applied as before.

Presets

Preset Order BRENDA value
gecko_median (default) custom → BRENDA without EC wildcards, origin 1–4 → DLKcat → other BRENDA matches (EC wildcards; specific activities, origin 5–6) median
gecko_classic custom → BRENDA without EC wildcards, origin 1–6 → DLKcat → other BRENDA matches maximum

The order of gecko_median comes from comparing each BRENDA tier with DLKcat on measured kcats hidden from the search: the BRENDA median was as close or closer at every origin without wildcards, and the maximum was further off than the median in every tier. Specific-activity matches rank below DLKcat as in #58. The figures are in CompMetEng/raven-gecko-parity#134.

Tutorial

full_ecModel uses kcats_from_brenda, kcats_from_dlkcat and assign_kcats for STEP 18–31. Its model_adapter.toml gives the gecko_median stages, and kcats_from_brenda takes the BRENDA maximum from kcat_aggregate_brenda, so the ecModel is identical to the one the previous steps gave: 4842 ec.rxns, the same ec.kcat, ec.source and stoichiometry.

Tests

tests/test_kcat_assignment.py: both presets against the chain of functions they replace, collect_kcats leaving the model unchanged, custom.tsv deciding first, stages from TOML and their errors, and update_kcat_sources gathering missing and outdated files only. The new functions are exported from geckopy and geckopy.gather_kcats and listed in docs/migrating_from_gecko_matlab.md.

GECKO (MATLAB) now reads model_adapter.toml as well. Two sections make that
possible without code in an adapter class:

- [spontaneous]: name_contains and/or file set which reactions are
  spontaneous; the default get_spontaneous_reactions reads them.
- [matlab]: settings that only GECKO reads (function names for anaerobic
  conditions and protein content, and [matlab.params]); geckopy accepts and
  ignores them.

adapterParameters.tsv, the table GECKO uses to map keys to its MATLAB
field names and defaults, is shipped here too, and a test checks it
against the schema.
Gathered kcats are written to data/kcats/<source>.tsv in the project,
keyed by conventional reaction and enzyme set rather than model.ec.rxns,
so a file stays valid when the ecModel is rebuilt and applies to full and
light models alike. GECKO reads and writes the same files.

- kcats_from_brenda, kcats_from_dlkcat and kcats_from_okp gather one source
  each, with that source's own options, and write its file. OKP keeps a
  job and a result per method, and only uses a stored result of the
  current job.
- save_kcat_source writes any kcat list; read_kcat_source reads a file;
  load_kcat_source maps a file to a model and reports rows with an invalid
  kcat, rows that fit no reaction, and rows that match only part of an
  enzyme set.
- ec_rxn_keys gives the conventional reaction and enzyme set of every
  model.ec reaction.
- fuzzy_kcat_matching takes an explicit adapter, and
  fetch_open_kinetics_predictor the file to store the result in.
collect_kcats decides one kcat per reaction from the files in data/kcats,
in the stages of [kcat_assignment] (a preset, or [[kcat_assignment.stage]]
tables), without changing the model, and writes
output/<model id>_kcatDecisions.tsv. assign_kcats applies the decisions and
the kcat constraints. update_kcat_sources gathers the source files the
configuration needs that are missing, or outdated against
[kcat_sources.<name>].

The default preset, gecko_median, orders custom kcats, the BRENDA median
of matches without EC wildcards at origins 1 to 4, DLKcat, then the other
BRENDA matches. gecko_classic keeps the GECKO 3 order with the BRENDA
maximum. The full_ecModel tutorial gives the same model as before, with
the gecko_median stages and the BRENDA maximum.
Base automatically changed from feat/kcat-source-files to develop October 17, 2026 06:29

This branch has not been deployed

No deployments
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