Skip to content

webapp

The default web app of a model: pages of its doses, its diseases and its scans.

The factory of a model writes its web app with its models (sbmlsim.webapp, sbmlsim.project.Project.create_models). A model which declares its own panels and app shows them; every other model of pkpdsim shows the app of default_app, which is built from what the model and its simulation experiments state, so it needs nothing written by hand:

  • the readouts: one small panel per output which the experiments with data compare with their studies, the observables of their fit mappings (READOUTS at most, the most compared first), in their units of the model (a concentration in uM and an amount in umol);
  • the page dose: a knob of the dose of every route and substance the experiments with data dose (PODOSE_<s>, IVDOSE_<s>, ... of DOSE_TARGETS, DOSE_KNOBS at most, the most studied first), a range from 0 to the largest studied dose with the studied doses as its stops, the most studied dose of the first route as its default;
  • the page protocol: the doses repeated by a dosing protocol (sbmlsim.panel.PanelDosing), a choice of the interval (a single dose, once, twice or three times daily, INTERVALS) and the days of the dosing, over PROTOCOL_DAYS days;
  • a page per disease the model is studied in, the subjects of its studies (pkpdsim.metadata.Health of the metadata of the fit mappings) or a scan of its parameter: the classes of the renal function, of liver cirrhosis and of heart failure as a choice knob, the classes its experiments simulate (the maps renal_map, cirrhosis_map and cardiac_map of the base of its experiments, e.g. the renal functions of the classes of the GFR at the healthy GFR of the model) on the parameter of the model (f_renal_function or KI__f_renal_function, CP_severity or f_cirrhosis, HF_severity or f_cardiac_function);
  • a page per other scan of the scan experiments of the model (their scan_map, e.g. the body weight) as a range knob over the scanned range.

Every page shows the readouts as small panels (AppPage.size) under the knobs it shares, the dose knobs on every page, and the app names the variants of the model (the builds of the sexes), which a reader switches between.

DOSE_TARGETS module-attribute

DOSE_TARGETS = re.compile(
    "^(PO|IV|SOL|IM|SC|REC|INH)DOSE_(\\w+)$"
)

The parameters of a dose of a substance of a model.

LOBE_TARGETS module-attribute

LOBE_TARGETS = (
    ("g_po_", "open", "ligated"),
    ("g_ha_", "open", "ligated"),
    ("f_present_", "in place", "resected"),
)

The interventions on a lobe of the liver: the prefix of the parameter and the labels of its two states, in place first.

A lobe is portally ligated, arterially ligated or resected, which is a value of one parameter each (pkpdsim.pbpk.interventions), so each is a choice of the lobe page of an app of a model with lobes.

default_app

default_app(model, sbml)

Get the default panels and app of a model, see the module.

Parameters:

Name Type Description Default
model PKPDModel

the model.

required
sbml Path

the SBML of its default variant, which the factory just wrote.

required

Returns:

Type Description
dict[str, Panel]

The panels by their id and the app; the panels of Project.default_panels

App | None

and no app for a model whose experiments state no readout.

default_variant_panels

default_variant_panels(model, panels, variants)

Get the default panels of the builds of the other sexes, see the module.

The panels of default_app are the ones of the default build. The classes of a renal impairment are the renal functions at the healthy GFR of a build (ScaledRenalMap), so the build of another sex gets the panels of the page of the disease with the classes at its own healthy GFR; every other panel is the same in every build.

Parameters:

Name Type Description Default
model PKPDModel

the model.

required
panels Mapping[str, Panel]

the panels of default_app by their id.

required
variants Mapping[str, Path]

the SBML file of every variant, the default first.

required

Returns:

Type Description
dict[str, dict[str, Panel]]

The panels of a variant by its name and the id of the panel, only the

dict[str, dict[str, Panel]]

panels which differ from the ones of the default build.

body_figure

body_figure(
    svg,
    sbml,
    *,
    simulation,
    title,
    credit="",
    substances=None,
    knobs=(),
    readouts=None,
)

The panels of the body figure of a model, one per place of its drawing.

write_readouts declares what the model reports at every clickable place of the interactive body figure (<svg stem>.readouts.json, the contract figurereadouts/1) and sbmlsim.panel_figure.panels_from_figure turns that pair into one panel per place. Those ids are a proposal and not a declaration: they are the ids of the id scheme, the drawing shows every organ of the library while a model has the organs of its substances, and the readouts of the library are the ids a model has to request (PBPKDefinition.readouts). So the panels are restricted to the entities of the build, which is why this lives in pkpdsim: it is the package which writes the figure and the model, so it can read the ids back instead of asking a consumer to keep a list of what its model lacks.

The curves are labelled as the panels of an app label theirs, the compartment alone where the panel names one substance and the substance beside it where it draws several (_labelled).

Parameters:

Name Type Description Default
svg Path

the drawing of the interactive figure, as write_readouts wrote it.

required
sbml Path

the flat build of the model whose entities the ids are checked against.

required
simulation PanelSimulation

the simulation of every panel, the one of the app.

required
title str

the title of the figure.

required
credit str

the credit line under the figure.

''
substances Mapping[str, str] | None

the short name of a substance by the name the readouts give it ({"hydroxy-glimepiride (M1)": "M1"}), for the curves of a panel which draws several.

None
knobs Sequence[Knob]

the controls of the app, which every panel it shows carries; a simulation whose derived targets read a knob can only be evaluated on a panel which has it.

()
readouts Path | None

the sidecar, <svg stem>.readouts.json beside the drawing by default.

None

Returns:

Type Description
dict[str, Panel]

The panels by their key, the figure, and the keys whose readouts the

AppFigure

build has not, which select nothing and stay decorations of the

tuple[str, ...]

drawing.

Raises:

Type Description
FileNotFoundError

a path which does not exist.