Model adapter (Python)#
geckopy objects in geckopy.adapter.
Functions#
Function |
Summary |
|---|---|
Raise |
|
Hyperparameters for kcat tuning against experimental data. |
|
The resolved parameters of |
|
Generate a commented TOML template for a new ecModel project. |
|
How kcats are assigned from the kcat source files ( |
|
One |
|
Settings that only GECKO (MATLAB) reads; geckopy ignores them. |
|
Holds the organism-specific parameters and overridable |
|
Top-level parameters for an ecModel adapter. |
|
OpenKineticsPredictor settings (used by kcats_from_okp). |
|
Return the adapter to use, falling back to |
|
Return an explicit growth rate, else |
|
Return an explicit value, else fall back to |
|
Print every adapter parameter with its value and where it comes from. |
|
One trust-tier entry in |
|
Which reactions proceed without an enzyme. |
|
Reference#
check_adapter_keys#
check_adapter_keys(data: dict, file: Path | str)
Raise ValueError for a key of model_adapter.toml that no parameter uses.
The message is <file>: unknown key <dotted.key> in model_adapter.toml.
Every table is checked: the sections, evotune.source_groups.<group>, the
kcat_assignment.stage entries and kcat_sources.<name> (see
KCAT_SOURCE_KEYS). matlab.params is free-form.
ComplexParams#
EvotuneParams#
Hyperparameters for kcat tuning against experimental data.
A kcat whose source is in no source_groups entry takes
sigma0_log_default.
format_adapter_params#
format_adapter_params(adapter: 'ModelAdapter')
The resolved parameters of adapter as text (see show_adapter_params).
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. The organism identifiers [kegg] id and [uniprot] id
are written uncommented and empty, with an example in the comment.
Parameters
project_nameName written into the template's header comment.
Returns
strThe 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]]: assigns a kcat to each reaction that is still
open, from the first listed source with a value (select) or from 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 does not support).
ModelParameters#
Top-level parameters for an ecModel adapter.
OkpParams#
OpenKineticsPredictor settings (used by kcats_from_okp).
The OKP methods are set in [kcat_sources.okp] methods.
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
modelAny object that may have an
.adapterattribute (a cobra Model, an EcModel, ...).getattris used so plaincobra.Modeldoesn't trip on the missing attribute.adapterAn explicitly-passed adapter. If non-None, returned as-is (takes priority over
model.adapter).purposeShort 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
ModelAdapterEither
adapter(if given) ormodel.adapter.
Raises
ValueErrorIf both
adapterandmodel.adapterareNone. The message tells the caller how to fix it.
resolve_gr_exp#
resolve_gr_exp(model, explicit=None, *, adapter: Optional['ModelAdapter']=None, purpose: str='this function')
Return an explicit growth rate, else adapter.params.gr_exp.
Raises
ValueErrorIf
explicitisNoneand the adapter has nogr_exp:gr_exp is not set in model_adapter.toml.resolve_adapterraises if there is no adapter either.
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
modelAny object that may have an
.adapterattribute, used as the fallback source whenadapteris not given.explicitThe caller-supplied value. If not
None, it is returned as-is and no adapter is consulted at all.attrName of the attribute to read off
adapter.paramswhenexplicitisNone.adapterAn explicitly-passed adapter, used instead of
model.adapterwhen resolving the fallback value.purposeShort description of why the calling function needs the value; forwarded to
resolve_adapterfor its error message.
Returns
```explicitif given, otherwisegetattr(adapter.params, attr)``.`
:
show_adapter_params#
show_adapter_params(adapter: 'ModelAdapter')
Print every adapter parameter with its value and where it comes from.
One line per item, in the order of adapterParameters.tsv:
<key> = <value> [<origin>]. The origin is file (set in
model_adapter.toml), default, preset <name> (given by the kcat
assignment preset) or not set (no value: <key> = [not set]).
The kcat assignment stages (kcat_assignment.stage[<i>]), the
kcat_sources.<name>.<key> settings and the evotune source groups, in
matching order with their sigma0_log, are shown as resolved.
SourceGroupRule#
One trust-tier entry in EvotuneParams.source_groups.
ec.source holds the label of the source of a kcat, such as
"custom", "brenda", "ec_tree", "dlkcat", "combined" or
"okp_kinform_h". An entry of sources matches the origin of the
label or the whole label, in either case without regard to case. An entry
ending in * is a prefix pattern on the origin: "okp_*" covers
okp_eitlem_kinetics and okp_kinform_h.
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.