Model adapter (Python)#

geckopy objects in geckopy.adapter.

Functions#

Function

Summary

ComplexParams

EvotuneParams

Hyperparameters for kcat tuning against experimental data.

generate_template_toml

Generate a commented TOML template for a new ecModel project.

KcatAssignmentParams

How kcats are assigned from the kcat source files (collect_kcats).

KcatStageParams

One [[kcat_assignment.stage]]: decides each reaction that is still

KeggParams

MatlabParams

Settings that only GECKO (MATLAB) reads; geckopy ignores them.

ModelAdapter

Holds the organism-specific parameters and overridable

ModelParameters

Top-level parameters for an ecModel adapter.

OkpParams

OpenKineticsPredictor settings (used by submit/fetch_open_kinetics_predictor).

resolve_adapter

Return the adapter to use, falling back to model.adapter.

resolve_param

Return an explicit value, else fall back to adapter.params.<attr>.

SourceGroupRule

One trust-tier entry in EvotuneParams.source_groups.

SpontaneousParams

Which reactions proceed without an enzyme.

UniprotParams

Reference#

ComplexParams#

EvotuneParams#

Hyperparameters for kcat tuning against experimental data.

Sources not matched by any source_groups entry fall back to the *_default fields (matching MATLAB's noKcatSource behaviour: sigma0logDefault etc. apply to every kcat first, then only ones with a recognised source get overridden by their group's value).

generate_template_toml#

generate_template_toml(*, project_name: str='my-ecmodel')

Generate a commented TOML template for a new ecModel project.

Every section of the schema is emitted, evotune kcat tuning hyperparameters included; optional fields are commented out at their defaults, so the template doubles as the reference for what can be set.

Parameters

project_name

Name written into the template's header comment.

Returns

str

The full TOML template text, ending in a newline.

KcatAssignmentParams#

How kcats are assigned from the kcat source files (collect_kcats).

KcatStageParams#

One [[kcat_assignment.stage]]: decides each reaction that is still

open, by the first listed source with a value (select) or by all listed sources with a value, weighted by their reliability (combine).

KeggParams#

MatlabParams#

Settings that only GECKO (MATLAB) reads; geckopy ignores them.

They let one model_adapter.toml configure both tools.

ModelAdapter#

Holds the organism-specific parameters and overridable

helpers for one ecModel project.

Most users don't subclass this directly: they make a folder with a model_adapter.toml and call ModelAdapter.from_folder(folder).

Subclass only when a particular organism needs custom logic (e.g. an unusual way to identify spontaneous reactions, or a bespoke gene-id mapping that the default UniProt-table-driven one can't handle).

ModelParameters#

Top-level parameters for an ecModel adapter.

OkpParams#

OpenKineticsPredictor settings (used by submit/fetch_open_kinetics_predictor).

The API key is intentionally NOT here (it is a secret): provide it as a function argument, the OKP_API_KEY environment variable, or the file <path>/data/okpApiKey.txt.

resolve_adapter#

resolve_adapter(model, adapter: Optional['ModelAdapter']=None, *, purpose: str='this function')

Return the adapter to use, falling back to model.adapter.

Parameters

model

Any object that may have an .adapter attribute (a cobra Model, an EcModel, ...). getattr is used so plain cobra.Model doesn't trip on the missing attribute.

adapter

An explicitly-passed adapter. If non-None, returned as-is (takes priority over model.adapter).

purpose

Short description of why the calling function needs an adapter; included in the error message when none can be resolved. Example: "to read params.enzyme_comp".

Returns

ModelAdapter

Either adapter (if given) or model.adapter.

Raises

ValueError

If both adapter and model.adapter are None. The message tells the caller how to fix it.

resolve_param#

resolve_param(model, explicit, attr: str, *, adapter: Optional['ModelAdapter']=None, purpose: str='this function')

Return an explicit value, else fall back to adapter.params.<attr>.

Lets a function take the single parameter it needs directly, only requiring a full ModelAdapter when the value is not supplied.

Parameters

model

Any object that may have an .adapter attribute, used as the fallback source when adapter is not given.

explicit

The caller-supplied value. If not None, it is returned as-is and no adapter is consulted at all.

attr

Name of the attribute to read off adapter.params when explicit is None.

adapter

An explicitly-passed adapter, used instead of model.adapter when resolving the fallback value.

purpose

Short description of why the calling function needs the value; forwarded to resolve_adapter for its error message.

Returns

```explicitif given, otherwisegetattr(adapter.params, attr)``.` :

SourceGroupRule#

One trust-tier entry in EvotuneParams.source_groups.

ec.source holds literal strings like "dlkcat", "brenda", and -- for OpenKineticsPredictor kcats -- the raw predictor method name (e.g. "CataPro"), not a generic "okp" tag. A rule matches a given ec.source value if it's listed in sources, or (when match_okp is True) if it equals the project's configured OKP method (OkpParams.method).

SpontaneousParams#

Which reactions proceed without an enzyme.

Both rules may be given; a reaction is spontaneous if either matches. GECKO (MATLAB) reads the same keys, so a project needs no code for this.

UniprotParams#