Mechanism files
A mechanism file declares the reactions of the model and their rate laws, per protein of the network. PhosKinTime
ships one file per model family in models/; a run may name its own file instead, for another type of
post-translational modification (PTM) or other rate laws. From the file and the network, PhosKinTime builds the run's
SBML model. Every simulation, fit, profile, posterior and export uses that SBML model.
Tutorial 01. Model creation walks through a file, the SBML model built from it, and a file of your own. The ODE system of each shipped family, generated from its SBML model, is on the Model equations pages.
The shipped files
| file | family (model code) | per protein |
|---|---|---|
models/distributive.toml |
distributive (0) |
mRNA R, protein P, one form X per site; each site is modified from P and returns to P |
models/sequential.toml |
sequential (1) |
mRNA R, protein P, a chain P → X₁ → X₂ → … in residue order; X_j has j sites modified |
models/combinatorial.toml |
combinatorial (2) |
mRNA R, one form M_m per modification pattern m (a bit mask over the sites; M₀ is unmodified) |
models/saturation.toml |
saturation (4) |
as distributive, with saturating translation C·R/(1+R) and modification S·P/(1+P) |
models/examples/acetylation_mm.toml |
distributive (0) |
example: lysine acetylation with saturating deacetylation E·X/(1+X) |
The family fixes the state layout: which species exist and how the observables are read from them (the site fold change of a distributive model is X; that of a combinatorial model is the sum over the patterns with the site set). The file fixes the reactions between those species and their rate laws.
What the file does not declare
The network part is the same for every mechanism. PhosKinTime builds it from the inputs
(phoskintime.networkmodel.exchange.sbml.make_plan):
- the kinase drives K_k(t) = c_k · PCHIP(kinase fold changes), with the fitted gains c_k;
- the inflow of each site, S = W · K, where W holds the KinOpt weights of the site's kinases;
- the TF input of each target gene from the TFOpt weights and the TF proteins, and the synthesis rate
synth, which is A modulated by that input throughtf_scale; - the per-protein parameters A, B, C, D, E, the per-site Dp, and the initial state of every species.
The file uses these as symbols in its rate laws. It cannot add parameters, species or observables.
Using a file in a run
[networkmodel]
mechanism = "models/examples/acetylation_mm.toml"
[networkmodel.models]
default_model = "distributive" # must be the file's family
- Empty
mechanism(the default) usesmodels/<default_model>.toml. - A relative path resolves against the config file's folder first, then the working directory, then the repository root.
- A file whose family is not
default_modelis refused. - The command line takes
--mechanism <file>. - The library takes
api.problem(config, ["--mechanism", file]), which builds the estimation problem without fitting. - When
mechanismis set, the run records the file and its sha256 inmodel_spec/spec.json, and a rebuild of the run (profiles, posterior, exports) fails if the file has changed since. A run with an emptymechanismrecords no file; the SBML model's notes name the built-in file and its sha256.
Format phoskintime-mechanism/1
format = "phoskintime-mechanism/1"
[mechanism]
name = "distributive"
family = "distributive" # distributive | sequential | combinatorial | saturation
doc = "mRNA -> protein -> one form per modified site (distributive)"
[ptm]
name = "phosphorylation"
modification = "phosphorylation" # reaction kind of the forward step
demodification = "dephosphorylation" # reaction kind of the reverse step
[[reactions]]
kind = "phosphorylation"
per = "site"
reactants = ["P"]
products = ["X"]
modifiers = "site_kinases"
rate = "{S} * {P}"
reversible_if_signed_drive = true
sbo = "SBO:0000216"
go = "GO:0006468"
[[reactions]] keys
| key | meaning |
|---|---|
kind |
an identifier; the SBML reaction id is rx_<kind>_<label> and its name <kind> <label> |
per |
the scope the reaction is repeated over: protein, site (distributive, sequential, saturation), or state and state_site (combinatorial) |
when |
state_site only, and required there: bit_clear (the site is unmodified in the pattern) or bit_set |
reactants, products |
lists of species symbols of the scope |
modifiers |
"regulators" (the protein's TF regulators), "site_kinases" (the site's kinases) or a list of species symbols |
rate |
an SBML Level 3 infix formula with {symbol} placeholders of the scope |
reversible_if_signed_drive |
true: the SBML reaction is marked reversible when the site's fitted drive S is negative somewhere |
sbo, go |
the reaction's SBO term and GO biological process (annotations in the SBML model) |
Symbols per scope
| scope | symbols |
|---|---|
protein |
gene, R, A, B, C, D, E, synth, and P (not combinatorial) or M0 (combinatorial: the unmodified pattern) |
site |
the protein symbols, site, X (the site's form), S (its inflow), Dp, prev (sequential: the previous form of the chain; otherwise P) |
state |
the protein symbols, m (the pattern index), M (its form), D_state (D plus the Dp of the pattern's modified sites) |
state_site |
the state symbols, site, S, Dp, M_to (the pattern with the site's bit flipped) |
The species symbols are R, P, M0, X, prev, M and M_to; the others are parameters, assignments or
labels.
What the loader refuses
phoskintime.networkmodel.mechanism.load raises MechanismError, naming the file and the reaction, for:
- an unknown key, a
formatother thanphoskintime-mechanism/1, or an unknown family; - a missing or empty
[ptm]entry; - a scope that the family does not have, or
whenmissing or misplaced; - an unknown symbol in a rate;
- a species in a rate that the reaction does not list as reactant, product or modifier;
- two reactions of the same kind in the same scope;
- a file with no reaction of the
[ptm]modification kind whose modifiers are"site_kinases". The kinases' inflow S must drive the modification.
Writing your own file
- Copy the shipped file of the family you want, e.g.
models/distributive.toml. - Change
[mechanism] name, and[ptm]for another modification type. Rename the modification and demodification reactions'kindto match. - Change the rate laws. Each rate may use only the symbols of its scope, and every species it uses must be listed in the reaction.
- Load it to check it:
python -c "from phoskintime.networkmodel import mechanism; print(mechanism.load('my_model.toml'))". - Set
mechanismanddefault_modelin the config, then runphoskintime validatebefore the fit.
The site data are compared with the forms of the file's family whatever PTM the file names. For another PTM type, the site table (input1) holds that PTM's sites, and the kinase network (input2) holds the enzymes that add it.
Python interface
| name | use |
|---|---|
load(path) |
load and check a file; returns a Mechanism (name, family, model_code, ptm, reactions, path, sha256, doc) |
builtin(model_code) |
PhosKinTime's own file of a model code |
for_run(path, model_code) |
the file of a run: path, or the built-in file when empty; refuses another family |
resolve_path(value, config_path) |
the absolute path of [networkmodel] mechanism |
SYMBOLS, SPECIES, FAMILIES, MODELS_DIR |
the symbols per scope, the species symbols, the families with their model codes, the models/ folder |