Skip to content

Read the model adapter from model_adapter.toml, shared with geckopy - #1

Merged
edkerk merged 1 commit into
developfrom
feat/toml-adapter
Oct 17, 2026
Merged

edkerk merged 1 commit into
developfrom
feat/toml-adapter

Conversation

@edkerk

@edkerk edkerk commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Copied from SysBioChalmers/GECKO#486, opened by edkerk on 2026-10-15.

A project's model adapter can now be model_adapter.toml, the file geckopy reads, so one file configures GECKO and geckopy. Adapter classes keep working. See CompMetEng/raven-gecko-parity#132.

Loading

  • ModelAdapterManager.getAdapter and setDefault take the project folder, its model_adapter.toml, or an adapter class .m file as before.
  • A TOML file gives a TomlAdapter.

New functions (src/model_adapter/)

Function What it does
readAdapterToml, writeAdapterToml Read and write the TOML subset adapters use: comments, strings, numbers, booleans, arrays (also over several lines), tables and arrays of tables. Anything else stops with an error that names the line.
loadAdapterParams Maps the snake_case keys to GECKO's field names and fills geckopy's defaults, both from adapterParameters.tsv. Unknown keys are errors, as in geckopy. Paths are relative to the project folder. Evotune source groups become kcatSources and sigma0logSource.
TomlAdapter Spontaneous reactions from [spontaneous] (name_contains, file). The anaerobic and protein-content functions used during tuning from [matlab]. Parameters only GECKO uses from [matlab.params]. A project that needs more code subclasses TomlAdapter.
convertAdapterToToml Writes an existing adapter class to model_adapter.toml, keeping parameters without a geckopy name under [matlab.params]. Lists the methods it cannot carry over, with what to use instead.

Project creation: createGECKOproject writes model_adapter.toml from adapterTemplate.toml. 'adapterFormat','class' gives the class template.

Tutorials

  • full_ecModel uses model_adapter.toml; YeastGEMAdapter.m is removed. The parameters are identical, and the same 6 reactions of yeast-GEM are spontaneous.
  • light_ecModel's HumanGEMAdapter subclasses TomlAdapter and keeps getHumanGEMRootPath. The parameters are identical. All 14 reactions that data/spontaneousReactions.tsv marks are now spontaneous; the class found one.

Tests

  • test/unit_tests/adapterTomlTests.m (tc0061–tc0068) covers:
    • the reader's features and errors;
    • write and read round trips;
    • defaults and unknown keys;
    • source groups;
    • converting TestGEMAdapter and a legacy-style class and loading the result back to the same parameters;
    • spontaneous reactions;
    • a new project.
  • The new functions also read geckopy's tutorial and example adapters and ecModels' ecYeastGEM/model_adapter.toml.
  • All 60 existing unit tests pass (MATLAB R2023a, RAVEN develop3, GLPK).

geckopy accepts the [spontaneous] and [matlab] sections in CompMetEng/geckopy#61.

A project's parameters can now live in model_adapter.toml, so one file
configures GECKO and geckopy. ModelAdapterManager.getAdapter and setDefault
take the project folder or the TOML file and return a TomlAdapter; adapter
classes keep working as before.

- readAdapterToml and writeAdapterToml read and write the subset of TOML
  that adapters use, with an error naming the line for anything else.
- loadAdapterParams maps the snake_case keys to GECKO's field names and
  fills geckopy's defaults, both from adapterParameters.tsv, and rejects
  unknown keys. Evotune source groups become kcatSources and
  sigma0logSource.
- TomlAdapter takes spontaneous reactions from [spontaneous] and the
  anaerobic and protein-content functions from [matlab]; parameters only
  GECKO uses go under [matlab.params]. A class that needs more code can
  subclass TomlAdapter.
- convertAdapterToToml writes an existing adapter class to
  model_adapter.toml and lists the methods it cannot carry over.
- createGECKOproject writes model_adapter.toml by default
  ('adapterFormat','class' for the old template).
- The full_ecModel tutorial uses model_adapter.toml; HumanGEMAdapter in
  light_ecModel subclasses TomlAdapter. It now marks all 14 reactions that
  data/spontaneousReactions.tsv flags as spontaneous; the old class found
  one.

Original-commit: SysBioChalmers/GECKO@5b32cf6
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Unit test results

60 tests   60 ✅  8s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit 34052a0.

♻️ This comment has been updated with latest results.

@edkerk
edkerk force-pushed the feat/toml-adapter branch from 27ba381 to 34052a0 Compare October 16, 2026 23:52
@edkerk
edkerk merged commit e6df62a into develop Oct 17, 2026
3 checks passed
@edkerk
edkerk deleted the feat/toml-adapter branch October 17, 2026 05:34
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