Skip to content

pbpk organs

The organs of the PBPK library: the standard organ, its parts and coefficients, the placement of the chemistry, the Kp methods and the organ variants, see Standard organ and Organ variants.

organs

Organs, blood pools and the parts of an organ: the topology of the body.

PORTAL_ORGANS module-attribute

PORTAL_ORGANS = frozenset(
    {
        Organ.STOMACH,
        Organ.SMALL_INTESTINE,
        Organ.LARGE_INTESTINE,
        Organ.SPLEEN,
        Organ.PANCREAS,
    }
)

The organs which drain into the portal vein.

SYSTEMIC_ORGANS module-attribute

SYSTEMIC_ORGANS = (
    frozenset(Organ)
    - PORTAL_ORGANS
    - {Organ.LUNG, Organ.LIVER}
)

The organs in parallel between arterial and venous pool.

Organ

Bases: StrEnum

The organs of the whole-body model, by their id prefix.

Pool

Bases: StrEnum

The blood pools of the whole-body model.

Part

Bases: StrEnum

The parts of an organ (compartments and their species).

inflow

inflow(organ)

The pools which supply an organ.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Type Description
Pool

The pools: arterial and portal for the liver, venous for the lung,

...

arterial for all others.

outflow

outflow(organ)

The pool into which an organ drains.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Type Description
Pool

Portal for the portal organs, arterial for the lung, venous for all others.

as_member

as_member(enum, value, name)

Get the member of an enum given as member, value or name.

A definition written in a script or a notebook may give an organ or the sex as text: the value ("ad", "female") or the name in any case ("adipose", "FEMALE").

Parameters:

Name Type Description Default
enum type[E]

the enum.

required
value object

the member, its value or its name.

required
name str

the field which holds the value, for the message.

required

Returns:

Type Description
E

The member.

Raises:

Type Description
ValueError

if the value is no member, value or name of the enum, naming the field and the allowed values.

as_organ_keys

as_organ_keys(mapping, name)

Get a mapping by organ from a mapping whose keys are organs or their texts.

Parameters:

Name Type Description Default
mapping Mapping[Any, V]

the mapping, its keys Organ members, values or names.

required
name str

the field which holds the mapping, for the messages.

required

Returns:

Type Description
dict[Organ, V]

The mapping with Organ keys, in the order of the given one.

Raises:

Type Description
ValueError

if the value is no mapping, if a key is no organ or if two keys name the same organ.

as_organs

as_organs(organs, name)

Get a set of organs from a collection of organs or their texts.

Parameters:

Name Type Description Default
organs Iterable[object]

a set, frozenset, list or tuple of Organ members, values or names.

required
name str

the field which holds the organs, for the messages.

required

Returns:

Type Description
frozenset[Organ]

The organs.

Raises:

Type Description
ValueError

if the value is no such collection or an element is no organ.

parts

The collapsing of the parts of a substance in an organ.

Parts dataclass

Parts(blood_cells, flow_carrier, tissue)

The parts which are built for a substance in an organ.

Attributes:

Name Type Description
blood_cells bool

a blood cell species is built (kinetic erythrocytes).

flow_carrier Literal['plasma', 'blood_bp']

what the blood flows carry, the plasma concentration or the blood concentration BP*C_p (erythrocytes in equilibrium).

tissue Literal['none', 'organ', 'merged', 'full']

the tissue species: none (vascular only), organ (one species for the whole organ, flow-limited), merged (interstitial and intracellular merged, finite exchange) or full (interstitial and intracellular species).

parts_for

parts_for(substance, organ, chemistry)

Get the parts of a substance in an organ.

The collapsing table of the spec: the flags of the substance and the chemistry of the organ decide, so only what is needed is built. A transport of the substance in the organ (basolateral, or an apical process) forces the full form, also when the substance has no distribution or does not enter the organ. A product of a metabolism gets no tissue by this, it is placed in the plasma part.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ.

required
chemistry Sequence[Metabolism | Transport | CustomReaction]

the processes of the definition (of all organs).

required

Returns:

Type Description
Parts

The parts.

organ

The organ components: their interface and the standard organ.

An organ component builds the comp model definition of one organ and its boundary to the body. The standard organ (PK-Sim 4-compartment structure, Willmann 2005, Schmitt 2008) has the parts

plasma          V*f_vas*(1-HCT)    Cpl
blood cells     V*f_vas*HCT        Cbc   (kinetic erythrocytes)
interstitial    V*f_int            Cis   (full form)
intracellular   V*(1-f_vas-f_int)  Cic   (full form)
tissue          V*(1-f_vas)        Cti   (merged tissue)
organ           V                  Cor   (flow-limited)

of which only the parts a substance needs are built (parts_for). Every species is a concentration, every reaction an amount per time. The organ owns its inflow from the arterial pool (and the portal vein for the liver) and its outflow into the venous pool (the portal vein for the portal organs, the arterial pool for the lung); it reads every element of the body (volumes, flows, hematocrit, fractions, substance parameters, pool and sink species) through a port, and Boundary.replacements names the element of the body which replaces it. The Kp of a substance is the whole-tissue (interstitial + intracellular) to plasma coefficient in every form.

The liver has a portosystemic shunt, the fraction f_shunt of its arterial and portal inflow which flows past it into the venous pool, and a functional fraction f_functional of its tissue, which scales the tissue volumes and the capacity of its processes (both inputs of the top model, healthy 0 and 1). The kidney filters the unbound afferent (arterial) plasma concentration of a substance with urinary excretion into the urine, J_gfr = fu*GFR*Car*(1 - f_reabsorbed); the plasma leaving the kidney lacks the net filtrate at the outflow concentration, Qki*(1-HCT)*Cout - fu*GFR*(1 - f_reabsorbed)*Cout, so the filtration clearance of the arterial plasma is fu*GFR*(1 - f_reabsorbed) and a secretion clears the plasma flow less the filtrate. A saturable reabsorption (ThresholdReabsorption) replaces the constant fraction by the fraction 1/(1 + (fu*C/reab_threshold)^reab_n)^(1/reab_n) at the concentration of each term (Car in the filtration, Cout in the outflow). Its metabolism and transport (the tubular processes) run with the tubular capacity 1 - f_tubular + f_tubular*f_renal_function, which follows the renal function (the intact nephron hypothesis, f_tubular 1). The kidney exposes the urinary excretion rate Rurine_<s>, the sum of its fluxes into the urine, as an output.

The volumes of the parts, the coefficients and the exchanges depend on parameters only and are constants with initial assignments (they follow a change of the body before a simulation, not during it); only what reads a species is an assignment rule: the outflow concentrations and the unbound concentrations of the tissue parts Cu_<part>_<s> (observers).

The elements (inputs with their ports, compartments, species, rules, constants) are collected by pkpdsim.pbpk.organ_builder.OrganBuilder, which the variants reuse. The standard organ is one well-stirred zone; the zonated liver (pkpdsim.pbpk.variants.liver_zonated) builds the same parts, flows and exchanges in each of its zones, which the blood flows through in series.

OrganContext dataclass

OrganContext(
    organ,
    substances,
    parts,
    chemistry,
    inhibitions,
    inductions,
    sex,
    routes=(),
    top=dict(),
    slow_pools=(),
    steady=None,
)

What an organ component is built from.

Attributes:

Name Type Description
organ Organ

the organ.

substances tuple[Substance, ...]

the substances of the definition.

parts Mapping[str, Parts]

the parts of the organ by substance id.

chemistry tuple[Metabolism | Transport | CustomReaction, ...]

the processes of the definition.

inhibitions tuple[tuple[str, Inhibition], ...]

the inhibitions as (inhibitor id, inhibition).

inductions tuple[tuple[str, Induction], ...]

the inductions as (inducer id, induction).

sex Sex

the sex of the build, whose reference individual the checks of the organ use (distribution.check_kp).

routes tuple[Route, ...]

the routes of administration (the intestine applies the oral doses).

top Mapping[str, tuple[str, UnitType]]

the parameters and compartments of the top model which exist when the organs are built, id -> (parameter or compartment, unit): the ids a Formula of the organ may read, through an input port each.

slow_pools tuple[SlowPool, ...]

the slow pools of the definition (SlowPool); the standard organ builds those of its organ.

steady SteadyPlan | None

the generated steady state of the definition (pkpdsim.pbpk.stationary.steady_plan): the species of its substances start at their steady state, None for none.

Boundary dataclass

Boundary(replacements, outputs)

What an organ component exposes to the body.

Attributes:

Name Type Description
replacements Mapping[str, str]

the elements of the body which replace an element of the organ, local id -> id in the body: organ volume, flows, HCT, fractions, substance parameters, pool and sink species and their compartments.

outputs Mapping[str, str]

the outputs of the organ, local id -> id in the body (Cout_<s> -> Cout_<o>_<s>).

OrganComponent

Bases: Protocol

An organ of the body, the standard one or a variant.

name property

name

The name of the component (variant).

build

build(ctx)

Build the model of the organ and its boundary.

GutComponent

Bases: OrganComponent, Protocol

An intestine which replaces several organs with one submodel (GU).

The segmented and the single lumen intestine replace small and large intestine: they receive the arterial inflow of both and drain into the portal vein, own the intestinal lumen, apply the oral doses and take the bile; the body gets the parameters they read from it (body_objects).

replaces property

replaces

The organs the component replaces, the small intestine first.

body_objects

body_objects(definition)

Get the parameters of the top model which the component reads.

StandardOrgan dataclass

StandardOrgan(name='standard')

The standard organ with the collapsing of its parts.

Attributes:

Name Type Description
name str

the name of the component, the prefix of the id of the model definition (standard_li).

build

build(ctx)

Build the model of the organ and its boundary.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the organ.

required

Returns:

Type Description
tuple[ModelDefinition, Boundary]

The model definition and the boundary.

Raises:

Type Description
ValueError

if a substance cannot be built in the organ: a Kp not above the interstitial share in the full form, an exchange without ftissue, a process which cannot be placed.

StandardBuilder

StandardBuilder(ctx, name)

Bases: OrganBuilder

The SBML objects of one standard organ: its parts, flows, exchanges and chemistry.

The organ is one well-stirred zone with the ids without zone. A zonated organ gives its zones (zones): the blood flows from the pools into the first zone, from each zone into the next and from the last one into the pool (the outflow concentration is that of the last zone); every zone has the parts of the organ with the share f_zone (1/n) of their volumes and of the passive exchanges, with the coefficients of the organ. The intestine variants derive from it for the intestinal wall.

Attributes:

Name Type Description
zones tuple[str, ...]

the zones of a zonated organ in the order of the blood flow, none for the organ without zones.

build

build()

Build the model definition and the boundary.

organ_builder

The elements of an organ component: the base of the standard organ and its variants.

An organ component builds a comp model definition whose elements of the body (volumes, flows, hematocrit, fractions, substance parameters, pool and sink species) are inputs with a port, which the body replaces (replacements), and whose outputs replace parameters of the top model (outputs). OrganBuilder collects the elements of one organ by id and creates each element once: the inputs, the compartments and species of the organ, the rules (for what reads a species), the initial assignments (for what depends on parameters only), the constants with their provenance, the reactions and the activity of the proteins of its processes. The standard organ and the variants derive from it and add their kinetics.

A protein of a process of the organ has the base activity f_<protein>, a constant of the organ (1, set by genotype and the experiments); in the liver the impairment multiplies it by the input fimp_<protein> (pkpdsim.pbpk.impairment). When a substance of the definition inactivates it (mechanism-based) or induces it, the organ has the turnover state E_<protein>, the amount of the protein relative to its baseline (initially 1),

dE/dt = kdeg*(1 + sum Emax*I/(EC50 + I)) - kdeg*E - sum kinact*I/(KI + I)*E

(Mayhew 2000, Almond 2009, Fahmi 2008), with the unbound concentration I of the inhibitor or inducer in the cell (intracellular, else the equivalent tissue part, else plasma) and the degradation rate kdeg_<protein> of the organ; the rates of the protein are multiplied by E_<protein>. The constants of the interactions (Ki, Kiu, kinact, Emax, EC50) are parameters of the body, read through a port.

ONE module-attribute

ONE = '1 dimensionless'

The number one in a formula.

CAPACITY module-attribute

CAPACITY = "Not a physical volume: the plasma-equivalent capacity of the blood of a substance with erythrocytes in equilibrium, the vascular volume times the blood to plasma ratio, so that the plasma concentration in it gives the amount in the blood."

The notes of a capacity of the blood.

COMPARTMENT_KINDS module-attribute

COMPARTMENT_KINDS = {
    Part.PLASMA: "plasma",
    Part.BLOOD_CELLS: "blood_cells",
    Part.INTERSTITIAL: "interstitial",
    Part.INTRACELLULAR: "intracellular",
    Part.TISSUE: "tissue",
    Part.ORGAN: "organ",
}

The kind (pkpdsim.pbpk.annotation) of the compartment of a part of an organ.

Start

Bases: NamedTuple

The start of a species of an endogenous substance, built with the model definition.

Attributes:

Name Type Description
sid str

the id of the species.

substance Substance

the substance.

part Part | None

the part of the species, whose coefficient the start at the equilibrium with the baseline reads, None for coefficient.

coefficient str | None

the coefficient of a species of no part (the mucosa, a slow pool) at the equilibrium with the baseline.

zone str | None

the zone of the species, None for an organ without zones.

steady str | None

the start of a substance with a generated steady state (pkpdsim.pbpk.stationary) which the organ knows when it records it, None for the start of its part (OrganBuilder._steady_start).

OrganBuilder

OrganBuilder(ctx, name)

The SBML elements of one organ, collected by id, and its boundary.

Attributes:

Name Type Description
ctx

the context of the organ.

organ

the organ.

name

the name of the component, the prefix of the id of the model definition (standard_li).

replacements dict[str, str]

the elements of the body which replace an input, local id -> id in the body.

outputs dict[str, str]

the outputs of the organ, local id -> id in the body.

Start the collection of the elements of an organ.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the organ.

required
name str

the name of the component.

required

v property

v

The organ volume.

hct property

hct

The hematocrit.

f_vas property

f_vas

The vascular fraction of the organ volume.

f_int property

f_int

The interstitial fraction of the organ volume.

model_definition

model_definition(notes)

Get the model definition of the collected elements.

Parameters:

Name Type Description Default
notes str

the notes of the model definition.

required

Returns:

Type Description
ModelDefinition

The model definition <name>_<organ>.

Raises:

Type Description
ValueError

if a Formula of the organ reads an id which is no parameter or compartment of the top model, or an element of the organ which is no input, a custom reaction reads an id which is neither an element of the organ nor a parameter or compartment of the top model, or a formula of the organ (RateOf, REST) reads an id which is no constant of the organ.

stationary_ids

stationary_ids(p)

Get the ids which the declared steady state of a custom reaction reads.

A Formula of the rate, the formulas of a Saturable; "linear" reads the rate law, none for none.

label

label(organ)

Get the organ in a name, small intestine.

placement

The placement of the chemistry in the parts of the standard organ.

A process of the chemistry acts in one part of the organ: a metabolism in the part which holds the tissue of its substrate (intracellular in the full form, the merged tissue, the whole organ when flow-limited, the plasma without tissue), a transport across the membrane of the cell (basolateral between interstitium and cell, apical between cell and the sink of the organ: bile, urine or the intestinal lumen; the standard kidney has no uptake from the cumulative urine), a custom reaction in the part it names.

Every rate acts on the unbound concentration of its part and is an amount per time: the Vmax of a process is per litre of organ, so the whole organ has the capacity Vmax * V<o>; the clearance k of a first order process is per litre of organ as well (FirstOrder.per_volume, the default, 1/min), so the whole organ has k * V<o> as with a Vmax; with per_volume=False it is the clearance of the whole organ (l/min). The activity f_<protein> of its protein multiplies the rate (times the turnover state E_<protein> when a substance of the definition inactivates or induces the protein). The organ may give a factor of its capacity, which multiplies the rate of every metabolism and transport as well: the functional fraction f_functional of the liver, the share of the capacity in the functional tissue, and the tubular capacity of the kidney, which follows the renal function f_renal_function (the intact nephron hypothesis); a custom reaction states its rate itself and is not scaled.

The reversible inhibitors of the protein enter the rate of every process of the protein with their unbound concentration I in the compartment from which the process takes its substrate (the part of the substrate of a metabolism, the interstitium of a basolateral influx, the cell of an efflux, the sink of an apical influx): the inhibitor species of the same part, else of the equivalent tissue part, else plasma. With the competitive sum c = sum I/Ki (competitive, mixed with its competitive constant, noncompetitive, and mechanism-based inhibition with Ki = KI) and the uncompetitive sum u = sum I/Kiu (uncompetitive, mixed, noncompetitive), the rate laws of mutually exclusive inhibitors (Segel 1975) are

MM           Vmax*V*C / (Km*(1 + c) + C*(1 + u))
Hill         Vmax*V/(1 + u) * x^n / (1 + x^n),  x = C/(Km*(1 + c)/(1 + u))
first order  k*C / (1 + c), per volume k*V*C / (1 + c)

i.e. Vmax_app = Vmax/(1 + u) and Km_app = Km*(1 + c)/(1 + u); the first order rate is the limit C << Km, which an uncompetitive inhibitor does not change.

A zonated organ (pkpdsim.pbpk.variants.liver_zonated) places every metabolism and transport into the parts of each of its zones (zone), with the ids of the zone (Cti_z1_<s>, DRG2M_z1) and the share of the zone of the capacity of the organ (capacity); the apical sink is that of the organ.

A constant of a process given as RateOf is the initial assignment <p>_Vmax = <p>_Vmax_ratio * <other>_Vmax over local ids of the organ (OrganFormulaParameter). A metabolism whose product fractions are values or the remainder REST has them as the constants f_<p>_<s> of the organ: its reaction consumes the substrate, and one reaction per product forms the product with its fraction of the rate (<p>_to_<s>, rate f_<p>_<s> * <p>), so the products are formed by the fractions which a fit or an experiment sets; numbers which sum to 1 are the stoichiometry of the one reaction.

A variant with a lumen of its own on the apical side of the cell gives it (Apical): the nephron kidney (pkpdsim.pbpk.variants.kidney_nephron) places the apical transport between the cells of the kidney and the lumen of the proximal tubule, an efflux secretes into it, an influx reabsorbs from it (with the inhibitors of its protein in the lumen).

ONE module-attribute

ONE = '1 dimensionless'

The number one in a formula.

Sink dataclass

Sink(species, compartment, amount)

The apical sink of an organ for a substance.

Attributes:

Name Type Description
species str

the id of the sink species (top model).

compartment str

the id of its compartment (top model).

amount bool

the species is an amount (hasOnlySubstanceUnits), not a concentration.

Apical dataclass

Apical(name, species)

The apical side of the cell of a variant, instead of the sink of the organ.

Attributes:

Name Type Description
name str

the apical compartment in words, for the notes (lumen of the proximal tubule).

species Callable[[str], str]

the local id of the species of a substance (by its id) on the apical side; its concentration is unbound (a lumen without proteins).

SpeciesStart

Bases: InitialAssignment

The initial assignment of a species of an endogenous substance (start_formula).

It stays an initial assignment when it reads a dynamic quantity (pkpdsim.pbpk.builder): the species starts once, its reactions change it afterwards.

Inhibitors dataclass

Inhibitors(
    competitive=None, uncompetitive=None, modifiers=()
)

The inhibitors of the protein of a process.

Attributes:

Name Type Description
competitive str | None

(1 + sum I/Ki) of the competitive part (competitive, mixed, noncompetitive, mechanism-based with Ki = KI), None without one.

uncompetitive str | None

(1 + sum I/Kiu) of the uncompetitive part (uncompetitive, mixed with Kiu, noncompetitive with Kiu = Ki), None without one.

modifiers tuple[str, ...]

the inhibitor species which the rate reads.

FormulaParameter

FormulaParameter(pid, formula, name, sbo, notes)

Bases: Parameter

A constant parameter whose value is a Formula over ids of the top model.

The parameter has no value; the build gives it the initial assignment of the formula (formula_assignment): the top model in its objects, an organ in its assignments, with an input port for every id of the top model the formula reads (OrganBuilder.model_definition).

Attributes:

Name Type Description
formula

the formula.

Create the parameter of a formula.

OrganFormulaParameter

OrganFormulaParameter(
    pid, expression, reads, unit, name, sbo, notes
)

Bases: Parameter

A constant of an organ whose value is a formula over other constants of the organ.

The capacity of a process which is a ratio of another (RateOf, <p>_Vmax_ratio * <other>_Vmax) and the remainder of the product fractions of a metabolism (REST, 1 - f_<p>_<a> - ...): the parameter has no value, the organ gives it the initial assignment of the formula (OrganBuilder.model_definition) and refuses an id of the formula which is no constant of the organ.

Attributes:

Name Type Description
expression

the formula (SBML L3 infix) over local ids of the organ.

reads

the local ids of the formula.

Create the parameter of a formula of the organ.

apical_sink

apical_sink(organ, s)

Get the apical sink of an organ: bile, urine or the intestinal lumen.

The lumen Clumen_<s> of a standard small intestine is an element of the body which the body has not: the intestine variants, which own the lumen, place the apical transport of the small intestine themselves, and the builder refuses it with the standard intestine.

Parameters:

Name Type Description Default
organ Organ

the organ.

required
s str

the substance id.

required

Returns:

Type Description
Sink

The sink species of the substance and its compartment.

Raises:

Type Description
ValueError

if the organ has no apical sink.

built_parts

built_parts(parts)

Get the parts of an organ which hold a species of a substance.

Parameters:

Name Type Description Default
parts Parts

the parts of the substance in the organ.

required

Returns:

Type Description
tuple[Part, ...]

The parts with a species of the substance.

metabolism_part

metabolism_part(parts)

Get the part in which a substance is metabolized: the part of its tissue.

Parameters:

Name Type Description Default
parts Parts

the parts of the substance in the organ.

required

Returns:

Type Description
Part

Intracellular (full form), the merged tissue, the whole organ

Part

(flow-limited) or plasma (no tissue).

species_compartment

species_compartment(part, s, parts, zone=None)

Get the local compartment of the species of a substance in a part.

The plasma species of a substance with erythrocytes in equilibrium lives in the vascular volume times the blood to plasma ratio (Vpl_<s>), so that it holds the amount of the blood; every other species lives in the compartment of its part.

Parameters:

Name Type Description Default
part Part

the part.

required
s str

the substance id.

required
parts Parts

the parts of the substance in the organ.

required
zone str | None

the zone of a zonated organ, None for the organ.

None

Returns:

Type Description
str

The local compartment id.

start_formula

start_formula(substance, coefficient=None)

Get the initial concentration of a species of an endogenous substance, as formula.

The species of a substance with a baseline start at the equilibrium of their exchange with plasma: the plasma at the baseline, every other part at the baseline times its coefficient to plasma (Kbc, Kp, K_int_pls, K_cell_pls, K_or, K_mu).

Parameters:

Name Type Description Default
substance Substance

the substance.

required
coefficient str | None

the coefficient of the part to plasma at the equilibrium of its exchange (an id), None for plasma.

None

Returns:

Type Description
str | None

baseline_<s> or <coefficient> * baseline_<s>; None for a

str | None

substance without baseline, whose species start at 0.

species_start

species_start(sid, formula, name)

Get the start of a species of an endogenous substance, with a name and an SBO term.

Parameters:

Name Type Description Default
sid str

the id of the species.

required
formula str

the initial concentration (mM), start_formula.

required
name str

the name of the species.

required

Returns:

Type Description
SpeciesStart

The initial assignment.

kp_id

kp_id(substance, organ)

Get the id of the whole tissue to plasma coefficient of a substance in an organ.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ.

required

Returns:

Type Description
str | None

Kp_<o>_<s> for an organ with an override, a Kp method or the

str | None

interstitial shares, Kp_<s> otherwise, None if the substance does

str | None

not enter the tissue of the organ.

unbound

unbound(part, substance, organ, zone=None)

Get the unbound concentration of a substance in a part, as formula.

Parameters:

Name Type Description Default
part Part

the part.

required
substance Substance

the substance.

required
organ Organ

the organ.

required
zone str | None

the zone of a zonated organ, None for the organ.

None

Returns:

Type Description
str

fu*C in plasma, fu/K*C with the coefficient of the part to plasma

str

elsewhere (K_int_pls, K_cell_pls, Kp, K_or).

Raises:

Type Description
ValueError

for the blood cells, or the merged tissue of a substance which does not enter the tissue of the organ.

process_source

process_source(process, parts)

Get the part from which a process takes its substrate.

Parameters:

Name Type Description Default
process Metabolism | Transport

the metabolism or transport.

required
parts Mapping[str, Parts]

the parts of the substances in the organ by substance id.

required

Returns:

Type Description
Part | None

The part of the substrate of a metabolism, the interstitium of a

Part | None

basolateral influx, the cell of an efflux, None for the sink of an

Part | None

apical influx.

inhibitor_unbound

inhibitor_unbound(
    source, inhibitor, organ, parts, zone=None
)

Get the unbound concentration of an inhibitor where a process takes its substrate.

Parameters:

Name Type Description Default
source Part | None

the part of the substrate (process_source), None for the apical sink.

required
inhibitor Substance

the inhibiting (or inducing) substance.

required
organ Organ

the organ.

required
parts Mapping[str, Parts]

the parts of the substances in the organ by substance id.

required
zone str | None

the zone of a zonated organ, None for the organ.

None

Returns:

Type Description
str

The unbound concentration (formula) of the inhibitor species of the

str

same part, else of the equivalent tissue part, else of plasma; the

str

concentration of the inhibitor in the sink of an apical influx.

has_turnover

has_turnover(protein, ctx)

Check whether a protein has a turnover state.

A protein has one when a substance of the definition inactivates it (mechanism-based) or induces it.

Parameters:

Name Type Description Default
protein str

the protein id.

required
ctx OrganContext

the context of the organ.

required

Returns:

Type Description
bool

True if the protein needs the state E_<protein>.

inhibitor_terms

inhibitor_terms(process, ctx, site)

Get the competitive and the uncompetitive terms of the inhibitors of a process.

Parameters:

Name Type Description Default
process Metabolism | Transport

the metabolism or transport.

required
ctx OrganContext

the context of the organ.

required
site Callable[[Substance], tuple[str, str]]

the species of an inhibitor where the process takes its substrate and its unbound concentration (formula).

required

Returns:

Type Description
Inhibitors

The terms of the inhibitors of the protein of the process.

inhibition_parameters

inhibition_parameters(sid, inh)

Get the ids of the constants of an inhibition and their quantity.

Parameters:

Name Type Description Default
sid str

the inhibitor id.

required
inh Inhibition

the inhibition.

required

Returns:

Type Description
list[tuple[str, str]]

(id, field of Inhibition) of Ki, and Kiu of a mixed, kinact

list[tuple[str, str]]

of a mechanism-based inhibition.

formula_ids

formula_ids(expression)

Get the ids a formula reads (SBML L3 infix), time for the simulation time.

The units of its numbers (1 per_min) and the names of its functions are no ids.

Raises:

Type Description
ValueError

if the formula cannot be parsed.

formula_problems

formula_problems(where, expression, top)

Check the ids of a formula against the elements of the top model.

Parameters:

Name Type Description Default
where str

what the formula belongs to, the start of a problem.

required
expression str

the formula.

required
top Mapping[str, tuple[str, object]]

the elements of the top model, id -> (kind, unit), with the kinds parameter, compartment, species and variable.

required

Returns:

Type Description
list[str]

The problems: the ids which are no element of the top model, the ids

list[str]

of species and of variables (observers, outputs, elements with a

list[str]

rule), which change during the simulation.

formula_assignment

formula_assignment(p)

Get the initial assignment of the parameter of a formula.

value_parameter

value_parameter(pid, q, unit, name, sbo, text='')

Get a constant parameter of a number with its provenance.

Parameters:

Name Type Description Default
pid str

the id of the parameter.

required
q Q

the number, plain (in unit) or a Value with unit and source, or a Formula (a FormulaParameter, the notes name the formula).

required
unit UnitDefinition

the unit of a plain number.

required
name str

the name of the parameter.

required
sbo str

the SBO term.

required
text str

the description of the parameter.

''

Returns:

Type Description
Parameter

The parameter, the citation of the source in the notes and the

Parameter

uncertainty of a fitted value.

place

place(
    process,
    ctx,
    parts,
    capacity=None,
    zone=None,
    apical=None,
)

Place a process of the chemistry in the parts of the standard organ.

The reactions reference the ids of the standard organ (species, fu_<s>, the coefficients of the parts, V<o>, f_<protein>, the sink species), which the organ creates; in a zone the ids of the zone.

Parameters:

Name Type Description Default
process Metabolism | Transport | CustomReaction

the process, of the organ of ctx.

required
ctx OrganContext

the context of the organ.

required
parts Mapping[str, Parts]

the parts of the substances in the organ by substance id.

required
capacity str | None

the factor (formula) of the capacity of the organ which multiplies the rate of a metabolism or a transport: the functional fraction (f_functional of the liver), in a zone times the share of the zone, the tubular capacity of the kidney (with f_renal_function); None for none. A custom reaction states its rate itself and is not scaled.

None
zone str | None

the zone of a zonated organ in which the process is placed, None for the organ.

None
apical Apical | None

the apical side of the cell of a variant (the lumen of the proximal tubule of the nephron kidney), None for the sink of the organ.

None

Returns:

Type Description
list[Reaction]

The reactions of the process.

Raises:

Type Description
ValueError

if the process is of another organ, transports a substance without interstitial and intracellular species, is apical in an organ without sink, is an apical influx from the urine of the standard kidney, acts in a part which is not built, or is a custom reaction in a zone (its rate is that of the whole organ).

rate_law

rate_law(process, ctx, cu, capacity, inhibitors)

Get the rate law of a process on the unbound concentration cu.

The activity of the protein (with its turnover state) and the factor of the capacity of the organ capacity multiply it; the inhibitors of the protein enter as the competitive and uncompetitive sums (module docstring). A first order clearance per volume is multiplied by the organ volume, as a Vmax.

Parameters:

Name Type Description Default
process Metabolism | Transport

the metabolism or transport.

required
ctx OrganContext

the context of the organ.

required
cu str

the unbound concentration (formula) the process acts on.

required
capacity str | None

the factor (formula) of the capacity, None for none.

required
inhibitors Inhibitors

the terms of the inhibitors of the protein.

required

Returns:

Type Description
tuple[str, list[Parameter]]

The rate (mmole/min) and the parameters of the process.

fractions_are_constants

fractions_are_constants(process)

Get whether the product fractions of a metabolism are constants of the organ.

A Value or the remainder REST makes every fraction a constant f_<p>_<s>; numbers are the stoichiometry of the reaction.

fraction_parameters

fraction_parameters(process, organ)

The constants of the product fractions of a metabolism, f_<p>_<s>.

A number or a Value is a constant with its provenance (and the uncertainty of a fit), the remainder REST the initial assignment 1 - f_<p>_<a> - ... of the fractions of the other products.

product_reaction

product_reaction(
    process,
    product,
    species,
    compartment,
    zone,
    organ,
    segment=None,
)

The formation of a product of a metabolism with its fraction of the rate.

Parameters:

Name Type Description Default
process Metabolism

the metabolism, whose product fractions are constants.

required
product str

the id of the product.

required
species str

the species of the product which it forms.

required
compartment str

the compartment of the species.

required
zone str | None

the zone or the segment of the metabolism, None for the organ.

required
organ Organ

the organ.

required
segment str | None

the segment of the annotation (the mucosa of the intestine).

None

Returns:

Type Description
Reaction

The reaction <p>_to_<s> (in a zone or segment <p>_to_<s>_<zone>)

Reaction

with the rate f_<p>_<s> * <p>, the fraction times the rate of the

Reaction

reaction of the metabolism.

process_kind

process_kind(process, organ)

Get the kind (pkpdsim.pbpk.annotation) of the reaction of a process.

Parameters:

Name Type Description Default
process Metabolism | Transport

the metabolism or transport.

required
organ Organ

the organ of the process.

required

Returns:

Type Description
str

The kind: a metabolism (in the intestine the gut metabolism, else

str

linear or saturable), or a transport (the apical efflux of the liver

str

into the bile is the biliary excretion, of the kidney into the urine

str

the renal secretion, the apical influx of the kidney the

str

reabsorption and of the intestine the absorption).

with_modifiers

with_modifiers(equation, modifiers)

An equation with the inhibitor species which its rate reads as modifiers.

A species of the equation itself (an inhibitor of its own process) is not repeated.

stoichiometry

stoichiometry(fraction, species)

A product of an equation, the fraction left out if it is 1.

in_zone

in_zone(text, zone)

Get a name or a note of an element, in a zone with the zone.

Parameters:

Name Type Description Default
text str

the name or note.

required
zone str | None

the zone of a zonated organ, None for the organ.

required

Returns:

Type Description
str

The text, in a zone followed by , zone <zone>.

distribution

The coefficients of the distribution between plasma and tissue in the standard organ.

The Kp of a substance is the whole-tissue (interstitial + intracellular) to plasma coefficient in every form of the organ:

  • full form: the interstitial to plasma coefficient follows from fu (Schmitt 2008), K_int_pls = (f_water_int + r_protein_int_pls*(1/fu - f_water_pls))*fu, and the intracellular one is derived so that both together have the Kp, K_cell_pls = (Kp*(f_int + f_cell) - f_int*K_int_pls)/f_cell. A Kp at or below the interstitial share f_int*K_int_pls/(f_int + f_cell) has no positive K_cell_pls: the build refuses it for the reference individual of its sex, and the rule floors K_cell_pls at K_CELL_FLOOR should a fit or another individual reach it (the interstitial share is the lower bound of a fitted Kp). The fu of chronic kidney disease raises the share at a fixed Kp: the build warns (KCellFloorWarning) when the share exceeds the Kp at the fu of a CKD stage (kp_floor_stages), where the floor holds;
  • flow-limited organ: K_or = (Vpl + Vbc*Kbc + Vti*Kp)/V, the organ to plasma coefficient of the well-stirred organ.

The interstitial share f_int*K_int_pls/(1 - f_vas) of the reference individual of the sex of the build (interstitial_share) is the Kp of an extracellular substance, Kp(interstitial=...) scales it in every organ.

Every formula is written once as a template, which gives the SBML rule (with ids) and the number (with values) alike.

INTERSTITIAL module-attribute

INTERSTITIAL = (
    "f_water_int",
    "f_water_pls",
    "r_protein_int_pls",
)

The local ids of the constants of K_int_pls, keys of data/distribution.toml.

K_VAS module-attribute

K_VAS = 'k_vas'

The local id of the exchange between plasma and interstitium per organ volume.

K_CELL_FLOOR module-attribute

K_CELL_FLOOR = 1e-06

The lower bound of K_cell_pls in the rule, against a Kp below the interstitial share.

KCellFloorWarning

Bases: UserWarning

A Kp of the full form below the interstitial share at the fu of a CKD stage.

constants cached

constants()

The constants of data/distribution.toml by key, values with their source.

constant

constant(key)

The parameter of a constant of data/distribution.toml, with its source.

number

number(q)

The number of a plain float or a Value.

Raises:

Type Description
TypeError

for a Formula, which has no number before the simulation.

k_int_pls

k_int_pls(fu)

The rule of the interstitial to plasma coefficient (Schmitt 2008).

Parameters:

Name Type Description Default
fu str

the id of the unbound fraction in plasma.

required

Returns:

Type Description
str

The formula with the ids of INTERSTITIAL.

k_int_pls_value

k_int_pls_value(fu)

The interstitial to plasma coefficient of an unbound fraction.

interstitial_share

interstitial_share(organ, fu, sex)

The interstitial share of the whole tissue of an organ.

f_int*K_int_pls(fu)/(1 - f_vas), the Kp of a substance which reaches the whole interstitial fluid of the organ and not its cells, with the vascular and interstitial fractions of the reference individual of the sex (physiology.reference_fractions): the lower bound of the Kp of the full form (check_kp) and the coefficients of Kp(interstitial=...) of a build of the sex.

f_int/(1 - f_vas) is the interstitial fraction of the tissue without blood (Fint of Schmitt 2008, one value per tissue and not per sex), so the shares of the sexes agree to the rounding of the tabulated f_int (4 significant digits, a relative difference below 5e-4); the vascular fraction of the sex (its blood) does not enter the share.

Parameters:

Name Type Description Default
organ Organ

the organ.

required
fu float

the fraction unbound in plasma.

required
sex Sex

the sex of the build, no default: a female build reads the female share.

required

Returns:

Type Description
float

The interstitial share (dimensionless).

kp_of_organ

kp_of_organ(substance, organ, sex)

The whole-tissue Kp which a Kp gives an organ, before the simulation.

Parameters:

Name Type Description Default
substance Substance

the substance, with a Kp as distribution.

required
organ Organ

the organ.

required
sex Sex

the sex of the build, whose interstitial share a scale multiplies.

required

Returns:

Type Description
Q | None

The override of the organ, else the scale times the interstitial share

Q | None

(a number, None for a scale or an fu which is a Formula), else the

Q | None

value of the substance.

Raises:

Type Description
ValueError

if the distribution of the substance is no Kp.

k_cell_pls

k_cell_pls(kp, k_int, f_vas, f_int)

The rule of the intracellular to plasma coefficient, floored at K_CELL_FLOOR.

Parameters:

Name Type Description Default
kp str

the id of the whole-tissue to plasma coefficient.

required
k_int str

the id of the interstitial to plasma coefficient.

required
f_vas str

the id of the vascular fraction of the organ volume.

required
f_int str

the id of the interstitial fraction of the organ volume.

required

Returns:

Type Description
str

piecewise(K, K > floor, floor) with K such that interstitium and

str

cells together have the Kp.

k_cell_pls_value

k_cell_pls_value(kp, fu, f_vas, f_int)

The intracellular to plasma coefficient of the numbers, without the floor.

k_organ

k_organ(f_vas, vascular, kp)

The rule of the organ to plasma coefficient of the flow-limited organ.

Parameters:

Name Type Description Default
f_vas str

the id of the vascular fraction of the organ volume.

required
vascular str

the capacity of the blood relative to its plasma, 1 - HCT (no erythrocyte distribution) or BP (erythrocytes in equilibrium), as formula.

required
kp str

the id of the whole-tissue to plasma coefficient.

required

Returns:

Type Description
str

f_vas*vascular + (1 - f_vas)*Kp, i.e. (Vpl + Vbc*Kbc + Vti*Kp)/V.

kp_floor_stages

kp_floor_stages(substance, organ, sex)

Get the CKD stages at whose fu the interstitial share exceeds the Kp of the full form.

The Kp of an organ is a number of the build, the interstitial to plasma coefficient K_int_pls follows the fu of the individual: at the fu of a stage of chronic kidney disease (impairment.ckd_unbound_fractions, the CKD profile of the binding) the share f_int*K_int_pls/(f_int + f_cell) of the reference individual of the sex can exceed a Kp which the build accepts at the reference fu (the metabolites of torasemide in the kidney: Kp 0.08 against the share 0.0746 at the reference fu). There the rule floors K_cell_pls at K_CELL_FLOOR.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ of the full form.

required
sex Sex

the sex of the build.

required

Returns:

Type Description
list[tuple[str, float, float]]

(stage, fu, share) of every such stage, in the order of the stages;

list[tuple[str, float, float]]

empty without a numeric Kp or a change of fu in CKD.

warn_kp_floor

warn_kp_floor(substance, organ, sex)

Warn when the cell partition of the full form is floored in chronic kidney disease.

The build calls it for every organ of the full form with a Kp (kp_floor_stages); a model may accept the floor, so it is no refusal: an organ in ckd_floor of the distribution (Kp, KpMethod), with its reason, is not warned of.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ.

required
sex Sex

the sex of the build.

required

Warns:

Type Description
KCellFloorWarning

naming the substance, the organ, the stages with their fu and share, the sex and what the floor does.

kp_floor_notes

kp_floor_notes(substance, organ, sex)

Get the notes of an accepted floor of the cell partition in an organ.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ of the full form.

required
sex Sex

the sex of the build.

required

Returns:

Type Description
str

The reason of ckd_floor with the stages at which the floor holds in

str

the build of the sex; empty for an organ without an accepted floor.

check_kp

check_kp(substance, organ, sex)

Check that the Kp of a substance leaves a positive K_cell_pls in an organ.

The check uses the fractions of the reference individual of the sex of the build and the fu of the definition; the Kp of a method is computed for the sex (its reference hematocrit) and checked with the factor of the method. A build of the other sex is checked when it is built.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ.

required
sex Sex

the sex of the build.

required

Raises:

Type Description
ValueError

if the Kp is not above the interstitial share of the whole tissue, f_int*K_int_pls/(f_int + f_cell).

kp

The tissue to plasma coefficients of the Kp methods.

A Kp method computes the whole-tissue (interstitial + intracellular) to plasma coefficient of every organ when the model is built (KpMethod of a substance). The builder writes one Kp_<o>_<s> per organ, an initial assignment fKp_<s> * value with the factor fKp_<s> of the method, so that a fit scales every coefficient at once.

Rodgers & Rowland (Rodgers, Leahy & Rowland 2005 for moderate-to-strong bases, Rodgers & Rowland 2006 for acids, very weak bases, neutrals and zwitterions) predict the tissue to unbound plasma coefficient Kpu (Kp = Kpu * fu) in the form stated by Yau 2020 (eqs. 1 to 5), from the composition of data/tissue_composition.toml:

  • moderate-to-strong bases (a basic pKa >= 7), electrostatic binding to the acidic phospholipids AP of the tissue (eq. 1), Kpu = X*f_iw/Y + f_ew + (P*f_nl + (0.3*P + 0.7)*f_np)/Y + Ka_AP*AP*(X - 1)/Y, with the affinity from the erythrocytes (eqs. 3, 5), Kpu_bc = (HCT - 1 + BP)/(fu*HCT), `Ka_AP = (Kpu_bc - X_bcf_iw_bc/Y - (Pf_nl_bc + (0.3*P + 0.7)*f_np_bc)/Y)
  • Y/(AP_bc*(X_bc - 1))`;
  • acids, very weak bases and zwitterions (albumin) and neutrals (lipoproteins), binding to the extracellular protein PR (eqs. 2, 4), Kpu = X*f_iw/Y + f_ew + (P*f_nl + (0.3*P + 0.7)*f_np)/Y + Ka_PR*[PR]_T, Ka_PR*[PR]_T = (1/fu - 1 - (P*f_nl_p + (0.3*P + 0.7)*f_np_p)/Y) * [PR]_T/[PR]_P;
  • P is the octanol:water partition coefficient, the vegetable oil:water one log P_vo:w = 1.115*log P - 1.35 in the lipid terms of adipose; X and Y are the ionisation terms of intracellular water and plasma, 1 + 10^(pKa - pH) for a base, 1 + 10^(pH - pKa) for an acid, 1 for a neutral; a negative affinity is set to zero (Yau 2020, citing Rodgers & Rowland 2006).

Choices of the library (not verified against the 2005/2006 papers, which were not accessible): several pKa of an acid or a base give the ionisation of successive dissociation, 1 + 10^(pH - pKa1) + 10^(2*pH - pKa1 - pKa2) for an acid (pKa ascending) and 1 + 10^(pKa1 - pH) + 10^(pKa1 + pKa2 - 2*pH) for a base (pKa descending); a zwitterion (pka = (acidic, basic)) has 1 + 10^(pH - pKa_acid) + 10^(pKa_base - pH) and binds to the acidic phospholipids if its basic pKa is >= 7, to albumin otherwise.

The method applies the rat tissue composition to human tissues (Rodgers & Rowland 2007, Coutinho 2024; the acidic phospholipids and the erythrocytes of Utsey 2020); the inputs are the substance's reference fu (Binding.fu), its blood to plasma ratio (Erythrocytes.bp, or 1 - HCT + HCT*kbc) and the reference hematocrit of the sex. The coefficients are numbers of the build: a change of fu by an impairment (the binding factor of pkpdsim.pbpk.impairment) or of the hematocrit does not recompute them.

A limitation of the full form (Mode.PERMEABILITY): its interstitium binds the substance as K_int_pls of Schmitt 2008 (pkpdsim.pbpk.distribution), not as the albumin ratio of Rodgers & Rowland. For a highly bound, hydrophilic acid (e.g. fu 0.01, pKa 4, logP 1) the Kp of adipose (albumin ratio 0.049) lies below the interstitial share, the full form would need K_cell_pls <= 0 and the build refuses it (distribution.check_kp); such a substance uses the merged tissue or the perfusion-limited organ.

AP_PKA module-attribute

AP_PKA = 7.0

A base with a pKa at or above it binds to the acidic phospholipids (Yau 2020).

Composition dataclass

Composition(
    tissue,
    f_ew,
    f_iw,
    f_nl,
    f_np,
    albumin,
    lipoprotein,
    ap,
    sources=(),
)

The composition of a tissue of the Rodgers & Rowland method.

Attributes:

Name Type Description
tissue str

the tissue of data/tissue_composition.toml.

f_ew float

the fractional volume of extracellular water.

f_iw float

the fractional volume of intracellular water.

f_nl float

the fractional volume of neutral lipids.

f_np float

the fractional volume of neutral phospholipids.

albumin float

the tissue to plasma ratio of albumin.

lipoprotein float

the tissue to plasma ratio of lipoproteins.

ap float

the acidic phospholipids (mg/g tissue).

sources tuple[str, ...]

the keys of the sources of the numbers.

composition

composition(organ)

Get the composition of the tissue of an organ.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Type Description
Composition

The composition of its tissue, a surrogate tissue for an organ

Composition

without data of its own ([organs] of the data file).

kp_sources

kp_sources(organ)

Get the keys of the sources of the Rodgers & Rowland Kp of an organ.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Type Description
str

The equations (Yau 2020), the composition of the tissue, the choice of

...

the tissue, plasma and erythrocytes.

binds_phospholipids

binds_phospholipids(method)

Whether a substance binds to the acidic phospholipids (eq. 1 of Yau 2020).

Parameters:

Name Type Description Default
method KpMethod

the Kp method of the substance.

required

Returns:

Type Description
bool

True for a base with a pKa >= 7 and a zwitterion with a basic pKa >= 7.

rodgers_rowland

rodgers_rowland(
    substance, organ, fu, bp, hct, *, tissue=None
)

Get the whole-tissue to plasma coefficient of Rodgers & Rowland.

Parameters:

Name Type Description Default
substance KpMethod

the Kp method of the substance (logP, pKa, compound).

required
organ Organ

the organ.

required
fu float

the fraction unbound in plasma.

required
bp float | None

the blood to plasma ratio, required for a substance which binds to the acidic phospholipids.

required
hct float

the hematocrit.

required
tissue Composition | None

the composition, the tissue of the organ by default.

None

Returns:

Type Description
float

Kp = Kpu * fu, without the factor of the method.

Raises:

Type Description
ValueError

if a substance which binds to the acidic phospholipids has no blood to plasma ratio.

blood_to_plasma

blood_to_plasma(substance, hct)

Get the blood to plasma ratio of a substance at a hematocrit.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
hct float

the hematocrit.

required

Returns:

Type Description
float | None

bp of the erythrocytes, 1 - HCT + HCT*kbc of a blood cell to plasma

float | None

coefficient, None without erythrocyte distribution.

kp_values

kp_values(substance, sex)

Get the coefficients of the Kp method of a substance for the organs it enters.

Parameters:

Name Type Description Default
substance Substance

the substance, with a KpMethod as distribution.

required
sex Sex

the sex of the model, whose reference hematocrit enters the affinity of a base to the acidic phospholipids.

required

Returns:

Type Description
dict[Organ, Value]

The whole-tissue to plasma coefficient of every organ the substance

dict[Organ, Value]

enters, without the factor of the method, with its inputs as notes.

Raises:

Type Description
ValueError

if the distribution of the substance is no Kp method.

check_kp_method

check_kp_method(substance)

Check the Kp method of a substance.

Parameters:

Name Type Description Default
substance Substance

the substance.

required

Returns:

Type Description
list[str]

The problems: the number of pKa values of the compound type, a missing

list[str]

blood to plasma ratio of a substance which binds to the acidic

list[str]

phospholipids.

variants

The registry of the organ variants.

A variant is an OrganComponent registered under a name for an organ; a definition selects it by name (Variants(organs={Organ.LIVER: "zonated"})) or gives a component (ZonatedLiver(n_zones=4, profiles=...)). Every organ has the standard organ (standard); the liver has the zonated liver (zonated, 8 zones placed by volume); the kidney has the nephron kidney (nephron, filtration into the segments of the tubule); the intestine has the segmented intestine (segmented, the default) and the single lumen (single_lumen), which replace small and large intestine with one submodel GU.

DEFAULTS module-attribute

DEFAULTS = {Organ.SMALL_INTESTINE: 'segmented'}

The variant of an organ without a choice of the definition, standard otherwise.

register

register(organ, name, component)

Register a variant of an organ under a name.

Parameters:

Name Type Description Default
organ Organ

the organ.

required
name str

the name of the variant.

required
component OrganComponent

the component.

required

Raises:

Type Description
ValueError

if the organ has a variant of the name already.

names

names(organ)

Get the names of the variants of an organ.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Type Description
list[str]

The sorted names.

lookup

lookup(organ, name)

Get the variant of an organ by name.

Parameters:

Name Type Description Default
organ Organ

the organ.

required
name str

the name of the variant.

required

Returns:

Type Description
OrganComponent

The component.

Raises:

Type Description
ValueError

if the organ has no variant of the name, naming the organ, the name and the variants of the organ.

variants.liver_zonated

The zonated liver: the sinusoid from periportal to pericentral in zones.

ZonatedLiver builds the liver as n zones in series along the sinusoid, from the periportal zone z1 to the pericentral zone z<n>, the pattern of the sinusoidal unit of the zonation models of pkdb_models (misc/zonation): a chain of the same compartments, the chemistry placed into the cells of every zone. Its boundary is that of the standard liver (StandardOrgan): the same inputs (volumes, flows, HCT, fractions, substance parameters, pool and sink species) and the same outputs, the concentrations of the plasma (and the kinetic blood cells) leaving the liver Cout_<s>, so the hepatic and the arm vein observers are those of the standard liver.

Every zone has the parts of the standard liver which a substance needs (pkpdsim.pbpk.parts), with the share f_zone = 1/n of their volumes and of the passive exchanges of the liver and the coefficients of the liver (Kp, K_int_pls, K_cell_pls, K_or), so the zones together have the capacity and the exchange of the standard liver. The blood (plasma and kinetic blood cells) flows from the hepatic artery and the portal vein into the first zone, from each zone into the next (J_sin_<zone>_<part>_<s>) and from the last one into the venous pool; the portosystemic shunt f_shunt bypasses all zones and the functional fraction f_functional scales the tissue of every zone and the capacity of every process, as in the standard liver. The species, compartments, unbound concentrations (observers), exchanges and processes of a zone carry the zone in their ids: Cpl_z1_<s>, Vti_z1, Cu_ti_z1_<s>, J_ti_z1_<s>, DRG2M_z1.

Every metabolism and transport of the liver is placed into every zone (pkpdsim.pbpk.placement.place), with the share w_<zone> of the capacity of the liver: by volume f_zone, or by the profile of its protein (profiles, the relative abundance p_<key>_<zone> per zone, e.g. a pericentral CYP3A4), w = p*V_zone/sum(p*V_zone) = p/sum(p), so that the total capacity Vmax*V (k of a first order process) is that of the standard liver. A metabolism with a profile takes the profile of that name, any other process the profile of its protein, if there is one. The inhibitors act inline in every zone with their unbound concentration in the zone; the bile is the sink of all zones. A protein which a substance inactivates or induces has one turnover state E_<protein> for the liver (as the intestine), driven by the unbound concentration in the cells of the zones weighted by the placement of the protein: exact for the same concentration in every zone, the mean of the zones along a gradient. A custom reaction states its rate for the whole liver and is not split over the zones: the zonated liver refuses it.

The zones are well-stirred tanks in series. With one zone the zonated liver is the standard liver. With n zones and linear kinetics the availability of a flow-limited liver at steady state is (1 + x/n)^-n with x = fu*CLint/(Q*BP) instead of the well-stirred 1/(1 + x): with the same intrinsic clearance the zonated liver extracts more, the difference of the extraction is about x/2*(1 - 1/n) of it (second order in x), and for large n it approaches the parallel tube, exp(-x).

ZonatedLiver dataclass

ZonatedLiver(n_zones=8, profiles=dict(), name='zonated')

The liver as zones in series along the sinusoid.

Attributes:

Name Type Description
n_zones int

the number of zones, periportal to pericentral.

profiles Mapping[str, Sequence[float]]

the relative abundance of a protein in each zone, from the periportal to the pericentral zone (n_zones values, not all 0), by the id of the protein or the profile of a metabolism; the processes of a protein without a profile are placed by volume.

name str

the name of the component, the prefix of the id of the model definition (zonated_li).

build

build(ctx)

Build the model of the liver and its boundary.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the liver.

required

Returns:

Type Description
tuple[ModelDefinition, Boundary]

The model definition and the boundary of the standard liver.

Raises:

Type Description
ValueError

if the organ is not the liver, a process cannot be placed (a custom reaction, a metabolism with a profile the liver does not give), the processes of a protein have different profiles, a profile is used by no process, or the standard liver refuses a substance.

ZonatedBuilder

ZonatedBuilder(ctx, liver)

Bases: StandardBuilder

The SBML objects of the zonated liver: the standard liver in zones and its chemistry.

Start the collection of the elements of the zonated liver.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the liver.

required
liver ZonatedLiver

the component.

required

Raises:

Type Description
ValueError

for another organ than the liver, or a process the zonated liver cannot place.

variants.kidney_nephron

The nephron kidney: glomerular filtration into the tubule and its segments.

NephronKidney builds the kidney with the tubule of the nephron. The unbound afferent (arterial) plasma concentration is filtered into the lumen of the proximal tubule, fu*GFR*Car, and the tubular fluid flows through the lumens of the segments in series, proximal tubule pt, loop of Henle lh, distal tubule dt and collecting duct cd; the collecting duct drains into the urine Aurine_<s>. Every segment reabsorbs water: the flow leaving a segment is the fraction f_tub_<seg> of the GFR (Scotcher 2016), so the tubular flows follow the GFR of the individual and the renal function. The drug moves with the fluid, GFR*f_tub_<seg>*Ctub_<seg>_<s> out of a segment, and concentrates as the water is reabsorbed (the filtrate has no proteins, the lumen concentration is unbound).

The lumens are well-stirred compartments of constant volume (Vtub_<seg>, Huang 2018, both kidneys). They are lumen, not tissue: they are not carved out of the kidney volume, the blood and the tissue of the kidney keep the volumes of the standard kidney and the tubule adds its fluid (about 0.12 l) to the kidney.

Without secretion and reabsorption every filtered molecule reaches the urine: at steady state the flow out of every segment equals the flow into it, so the urinary excretion is the filtration fu*GFR*Car of the standard kidney, whatever the volumes and the flows of the segments; the tubule delays the excretion by minutes. The glomerulus filters the afferent (arterial) plasma and the plasma leaving the kidney lacks the net filtrate, as in the standard kidney: at steady state the reabsorption from the collecting duct returns the fraction reabsorbed, so the circulation sees the standard kidney.

The fraction reabsorbed of a filtered substance (f_reabsorbed_<s> of Excretion.fraction_reabsorbed) is an empirical passive reabsorption at the end of the collecting duct: that fraction of the drug leaving it returns into the plasma of the kidney (J_reab_<s>), the rest is urine, so the renal clearance without transport is fu*GFR*(1 - f_reabsorbed) as in the standard kidney. With secretion the fraction acts on the secreted drug as well, the lumped (fu*GFR + CL_sec)*(1 - F_reabs) of the literature. A threshold reabsorption (Excretion.reabsorption, ThresholdReabsorption) returns the fraction of the standard kidney at the afferent plasma of the flow out of the collecting duct, up to the filtered load: min(GFR*f_tub_cd*Ctub_cd, fu*GFR*Car)*f(Car) with f(Car) = 1/(1 + (fu*|Car|/reab_threshold)^reab_n)^(1/reab_n) (Car_<s> a modifier). It never exceeds the filtration, also with a secretion into the tubule (the secreted drug leaves into the urine), and at steady state without a secretion the circulation sees the standard kidney. A reabsorption by a transporter is an apical influx instead.

The chemistry of the kidney is placed by membrane: a metabolism in the cells of the kidney and a basolateral transport between interstitium and cells as in the standard kidney; an apical transport between the cells and the lumen of the proximal tubule, an efflux secretes into it, an influx reabsorbs from it on the lumen concentration (the inhibitors of its protein act from the lumen of the proximal tubule). A custom reaction states its rate for a part of the standard kidney: the nephron kidney refuses it. Every metabolism and transport runs with the tubular capacity of the standard kidney, 1 - f_tubular + f_tubular*f_renal_function. A substance has the species of the tubule when it is filtered, transported apically in the kidney or inhibits the protein of an apical influx of the kidney.

The blood side (perfusion, tissue distribution, blood cells, the unbound observers, the outflow concentrations Cout_<s>) is the code of the standard kidney (StandardBuilder), and the boundary is that of the standard kidney: the same inputs replaced by the same elements of the body and the same outputs. A substance which is secreted but not filtered reads the GFR in addition, for the flow of the tubule.

NephronKidney dataclass

NephronKidney(name='nephron')

The kidney with glomerular filtration into the segments of the tubule.

Attributes:

Name Type Description
name str

the name of the component, the prefix of the id of the model definition (nephron_ki).

build

build(ctx)

Build the model of the kidney and its boundary.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the kidney.

required

Returns:

Type Description
tuple[ModelDefinition, Boundary]

The model definition and the boundary of the standard kidney.

Raises:

Type Description
ValueError

if the organ is not the kidney, a process cannot be placed (a custom reaction), or the standard kidney refuses a substance.

NephronBuilder

NephronBuilder(ctx, name)

Bases: StandardBuilder

The SBML objects of the nephron kidney: the standard kidney, the tubule and its chemistry.

Start the collection of the elements of the nephron kidney.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the kidney.

required
name str

the name of the component.

required

Raises:

Type Description
ValueError

for another organ than the kidney, or a custom reaction of the kidney.

variants.intestine

The intestine variants: the segmented intestine and the single lumen.

Both replace small and large intestine with one submodel (GU, the id of the small intestine for every intestine variant, ids.submodel) with the boundary of the standard organs on the blood side: the arterial inflow of both organs, Qgu = Qsi + Qla, drains into the portal vein. The output Cout_si_<s> is the plasma leaving the wall; the venous blood of the mucosa enters the portal vein directly. Their parts:

  • the intestinal wall, the standard organ (StandardBuilder) of the volume Vgu = Vsi + Vla with the volume-weighted vascular and interstitial fractions, the distribution of the small intestine (its Kp) and the share of ftissue of its tissue volume;
  • the lumen segments: stomach, duodenum, upper and lower jejunum, upper and lower ileum, caecum, colon ascendens, transversum, descendens, sigmoid and rectum (segmented, Thelen 2011), or one lumen, the fluid of the small intestine (single_lumen); a substance which reaches the lumen (oral route, biliary excretion, transport into the lumen) has the dissolved concentration Clumen_<seg>_<s> per segment, which moves on with the transit V*C/T_<seg> and from the last segment into the feces Afeces_<s>; an oral tablet has the undissolved amount Asolid_<seg>_<s> (in the first segment the dose state PODOSE_<s>), which dissolves with the dissolution of its formulation (pkpdsim.pbpk.routes) and moves with the transit too; the bile drains into the duodenum (the single lumen); the fed state FED = 1 slows the gastric emptying (the stomach transit time of the fed state);
  • the absorption: ka_<s> (1/hr) is the absorption rate constant of the small intestine, a segment absorbs with ka_<s> * f_area_<seg> (the mucosal surface per lumen volume relative to the small intestine; the stomach does not absorb), a segment of the large intestine optionally times f_ka_colon_<s> (SegmentedIntestine.f_ka_colon, a substance with an oral route), a segment of the regional absorption profile of a substance times f_ka_<seg>_<s> (RegionalAbsorption); the single lumen absorbs with ka_<s>; of the absorbed flux the fraction fabs_<s> enters the body and the rest the feces (the single lumen for every substance, the segments with SegmentedIntestine.fabs for a substance with an oral route);
  • the mucosa (enterocytes) per intestinal segment, Cmu_<seg>_<s>, only for a substance with chemistry of the intestine (substrate, product, transported substance, inhibitor or inducer of a protein of a process of the small intestine): flow-limited with the mucosa to plasma coefficient K_mu_<s> (the Kp of the small intestine, 1 without), perfused by arterial blood with its flow Qmu_<seg> = f_mucosa_flow * Q<region> * share (the mucosa fraction of the blood flow of its region, small or large intestine, times the transit share of the segment in the region; the wall gets the rest) and draining into the portal vein; the absorbed drug enters it; its volume Vmu_<seg> is carved out of the tissue of the wall of that substance (V<part>_wall), so wall and mucosa together have the capacity of the wall of a substance without mucosa; the unbound concentration Cu_mu_<seg>_<s> is an observer. Without such chemistry the substance has no mucosa species and is absorbed into the plasma of the wall.

The chemistry of the small intestine is placed into the mucosa segments by the relative expression of its protein (CYP3A4 of the data) times the mucosa volume, the sum kept: the Vmax of a process stays per litre of small intestine (Vmax * Vsi for the whole intestine, as in the standard organ), a segment has the weight w_<protein>_<seg>; a protein without expression data (or a process without protein) is placed by mucosa volume over the segments of the small intestine, the organ of the process. Apical efflux moves the drug from the mucosa into the lumen of the segment, apical influx back. A protein which a substance inactivates or induces has one turnover state E_<protein> for the intestine, driven by the unbound mucosa concentration weighted by the placement weights of the protein.

The bile of every substance drains: of a substance with lumen species into the duodenum (the single lumen), of any other into the feces.

A conversion in the lumen (LumenConversion, the segmented intestine) converts a dissolved substance into another in chosen segments, first order with kconv_<s>_<m> (1/hr); the product gets lumen species.

PerSubstance

PerSubstance = Q | Mapping[str, Q]

One value for every oral substance, or a mapping from substance id to value.

SegmentedIntestine dataclass

SegmentedIntestine(
    name="segmented",
    ka=None,
    fabs=None,
    f_ka_colon=None,
    regional=None,
    conversions=(),
)

The segmented intestine (Thelen 2011), the default intestine.

Every segment but the stomach absorbs with ka_<s> * f_area_<seg>. Two optional factors change it, for every substance with an oral route (a model fits the parameter of its substance): fabs sends the fraction 1 - fabs_<s> of the absorbed flux of every segment into the feces (incomplete absorption with a fast onset), f_ka_colon scales the absorption of the segments of the large intestine (a substance absorbed less in the colon). Without them the model has neither parameter, nor has a substance without an oral route (its ka_<s> is 0): it keeps the absorption ka_<s> * f_area_<seg> and has no reaction J_feces_<seg>_<s>. Unlike SingleLumen, whose fabs=None is fabs_<s> = 1 for every substance, None creates no parameter.

regional gives a substance with an oral route the regional absorption profile (RegionalAbsorption), a factor f_ka_<seg>_<s> of the absorption of a segment; conversions convert a substance into another in the lumen (LumenConversion). Neither creates an element unless set.

Attributes:

Name Type Description
name str

the name of the component.

ka PerSubstance | None

the absorption rate constant of a substance with an oral route, the default of the data if None; a mapping from substance id gives each substance its own (a substance missing from it has the default, a substance without oral route may be in it).

fabs PerSubstance | None

the fraction of the absorbed flux which enters the body, fabs_<s> of a substance with an oral route; none (all of it) if None; a mapping gives it only to the substances in it.

f_ka_colon PerSubstance | None

the factor of the absorption of the segments of the large intestine (caecum to rectum), f_ka_colon_<s> of a substance with an oral route; none (1) if None; a mapping gives it only to the substances in it. The shorthand of the group colon of a regional profile, RegionalAbsorption({"colon": x}), which makes the same parameter.

regional RegionalAbsorption | Mapping[str, RegionalAbsorption] | None

the regional absorption profile of every substance with an oral route, or a mapping from substance id to the profile of the substances in it; none (every factor 1) if None, the default (no generic profile, see RegionalAbsorption). A substance with f_ka_colon may have a profile of the small intestine only.

conversions Sequence[LumenConversion]

the conversions in the lumen.

Raises:

Type Description
ValueError

(on build) for a key of a mapping which is no substance of the definition, or of fabs, f_ka_colon or regional a substance without an oral route; for a substance with both f_ka_colon and a factor of the large intestine; for a conversion of a substance which is no substance of the definition or never reaches the lumen, or two conversions of the same substrate and product.

replaces property

replaces

The organs the intestine replaces: small and large intestine.

absorption

absorption(definition)

Get the absorbed substances with the options of their absorption.

The substances of absorbed_substances with what the model gives each of them (_resolve, as the build): fraction absorbed (fabs_<s>), colon factor (f_ka_colon_<s>) and the regional factors of segments (f_ka_<seg>_<s>), factor of ile2 for one segment, factors of ile2, asc for several.

Parameters:

Name Type Description Default
definition PBPKDefinition

the definition.

required

Returns:

Type Description
dict[str, tuple[str, ...]]

The options by substance id, in the order of the substances.

body_objects

body_objects(definition)

Get ka_<s>, fabs_<s>, f_ka_colon_<s>, the regional factors, the conversion rates, FED.

build

build(ctx)

Build the model of the intestine and its boundary.

Raises:

Type Description
ValueError

for chemistry the intestine cannot place: a process of the large intestine, a custom reaction, a basolateral transport of the mucosa; a conversion of a substance which never reaches the lumen.

SingleLumen dataclass

SingleLumen(
    name="single_lumen",
    ka=None,
    fabs=None,
    regional=None,
    conversions=(),
)

The single intestinal lumen with first order absorption.

The first order absorption of most current models: one lumen (the fluid of the small intestine) with the transit into the feces, absorption with ka_<s>, of which the fraction fabs_<s> enters the body. The lumen keeps a physiological transit t_lumen into the feces, so the fraction of a solution which enters the body is fabs*ka/(ka + 1/t_lumen): the fitted absorption and fraction absorbed of the hand-written models, which had no transit, do not port unchanged (a refit is expected).

fabs_<s> is a parameter of every substance, 1 if fabs=None (unlike SegmentedIntestine, which creates it only when set and only for the substances with an oral route).

The single lumen has no segments: a regional absorption profile and the conversions in the lumen need the segmented intestine, regional and conversions are refused with that message.

Attributes:

Name Type Description
name str

the name of the component.

ka PerSubstance | None

the absorption rate constant of a substance with an oral route, the default of the data if None; a mapping from substance id gives each substance its own (the others have the default).

fabs PerSubstance | None

the fraction of the absorbed flux which enters the body, 1 if None; in a mapping a substance missing from it has 1.

regional RegionalAbsorption | Mapping[str, RegionalAbsorption] | None

refused if set (no segments).

conversions Sequence[LumenConversion]

refused if set (no segments).

Raises:

Type Description
ValueError

for regional or conversions; (on build) for a key of a mapping which is no substance of the definition.

replaces property

replaces

The organs the intestine replaces: small and large intestine.

absorption

absorption(definition)

Get the absorbed substances with the options of their absorption.

The substances of absorbed_substances, fraction absorbed for a substance whose fabs_<s> the model gives (every substance has one, 1 unless fabs sets it).

Parameters:

Name Type Description Default
definition PBPKDefinition

the definition.

required

Returns:

Type Description
dict[str, tuple[str, ...]]

The options by substance id, in the order of the substances.

body_objects

body_objects(definition)

Get ka_<s> and fabs_<s> of every substance.

build

build(ctx)

Build the model of the intestine and its boundary.

Raises:

Type Description
ValueError

for chemistry the intestine cannot place, or a key of a mapping which is no substance.

absorbed_substances

absorbed_substances(definition, ka)

Get the substances which the intestine absorbs, ka_<s> of the definition.

Every substance with an oral route, and a substance which a mapping ka names (also without oral route: the reabsorption after biliary excretion); every other substance has ka_<s> = 0.

Parameters:

Name Type Description Default
definition PBPKDefinition

the definition.

required
ka PerSubstance | None

the ka of the intestine variant.

required

Returns:

Type Description
list[str]

The ids, in the order of the substances.

variants.lumen_options

The options of the lumen of the segmented intestine: regional absorption and conversions.

RegionalAbsorption is the regional absorption profile of a substance, a factor of the absorption ka_<s>*f_area_<seg> per segment or per group of segments (colon, caecum to rectum, the parameter f_ka_colon_<s>, of which SegmentedIntestine.f_ka_colon is the shorthand); LumenConversion converts a substance into another in chosen lumen segments, first order. Both are options of pkpdsim.pbpk.variants.intestine.SegmentedIntestine; the builders of the intestine (gut, gut_lumen) read them here.

ABSORBING module-attribute

ABSORBING = tuple(
    t for t in ids.GUT_SEGMENTS if t != "st"
)

The lumen segments which absorb: every segment but the stomach.

LARGE module-attribute

LARGE = tuple(t for t in ABSORBING if t not in SMALL)

The lumen segments of the large intestine, caecum to rectum.

COLON module-attribute

COLON = 'colon'

The key of the group of the segments of the large intestine in a profile.

GROUPS module-attribute

GROUPS = {COLON: LARGE}

The groups of segments with one shared factor of a profile, by key.

RegionalAbsorption dataclass

RegionalAbsorption(factors)

The regional absorption profile of a substance in the segmented intestine.

A factor of a segment multiplies its absorption ka_<s>*f_area_<seg>: the permeability of the segment relative to the small intestine, which ka_<s> describes (the area factor holds the mucosal surface per lumen volume, Helander 2014). A factor is a parameter of the top model: of a segment f_ka_<seg>_<s>; of the group colon (GROUPS, the segments of the large intestine, caecum to rectum) one shared f_ka_colon_<s>, which SegmentedIntestine.f_ka_colon is the shorthand of. A segment missing from the profile has none (1).

There is no generic default profile: the colonic absorption relative to the small intestine depends on the substance, high for a highly permeable drug (BCS class I, relative colonic bioavailability above 70 %) and low for a drug of low permeability (BCS III and IV, below 50 %; Tannergren 2009, 42 drugs), so the default is no factor (1). A substance whose regional absorption is measured (an intubation or a capsule released in a segment, Byon2018 for apixaban) takes its own profile.

Attributes:

Name Type Description
factors Mapping[str, Q]

the factor of a segment by its token (du to rec, not the stomach, which does not absorb) or of a group by its key (colon): a number or a Value (dimensionless), not negative.

Raises:

Type Description
ValueError

for no segment, the stomach, an unknown token, a segment given by itself and in its group, a negative factor or a Value which is not dimensionless.

segments property

segments

The segments with a factor of their own (no group).

covers

covers(tokens)

Whether the profile has a factor of one of the segments, its own or of its group.

LumenConversion dataclass

LumenConversion(substrate, product, k, segments)

A first order conversion of a substance into another in the lumen.

In every segment of the conversion the dissolved substrate converts into the product, J_conv_<seg>_<s>_<m> = kconv_<s>_<m>/60*Vlumen_<seg>*Clumen_<seg>_<s>, one mole of product per mole of substrate: a chemical conversion (the cyclization of creatine to creatinine in the acid of the stomach), a hydrolysis of a prodrug or a bacterial conversion in the colon. The undissolved drug of a tablet does not convert. The product gets the lumen species, transit and absorption of the intestine (its ka_<m> is 0 without an oral route, unless SegmentedIntestine.ka gives it one).

A solution in the stomach, a conversion in the stomach only: the stomach does not absorb, so the converted fraction of the dose is f = k*T/(1 + k*T) with k = kconv/60 (1/min) and the transit time of the stomach T (T_st, fasted 22.79 min), and kconv = 60*f/((1 - f)*T); the transit time of the stomach of the condition (fed, the factor of chronic kidney disease) is the id T_st_eff of the top model (ids.T_STOMACH), which a Formula of k reads. An immediate-release tablet with the first order dissolution Ka_dis_<s> (1/hr, without the factors f_dis_fed_<s> and f_dis_release_<s>) converts only the part which dissolves in the stomach, g = kd*T/(1 + kd*T) with kd = Ka_dis/60 (1/min), so f = g*k*T/(1 + k*T); the fasted transit time, the fed state has T_st_fed. Over several segments without absorption the drug survives each with 1/(1 + k*T_seg).

Attributes:

Name Type Description
substrate str

the id of the converted substance, which reaches the lumen (an oral route, biliary excretion, a transport of the intestine or the product of another conversion).

product str

the id of the formed substance.

k Q

the rate constant (1/hr, the unit of ka_<s>), the parameter kconv_<s>_<m> of the top model, not negative.

segments Sequence[str]

the lumen segments it acts in, tokens of ids.GUT_SEGMENTS (st the stomach to rec the rectum).

Raises:

Type Description
ValueError

for a substrate which is the product, no segment, an unknown token or one twice, a negative k or a Value which is not in 1/hr.

check_conversions

check_conversions(conversions, sids)

Check the substances of the conversions and that none is given twice.

Raises:

Type Description
ValueError

for a substance which is no substance of the definition, or two conversions of the same ids.

converted

converted(conversions, luminal)

The products of the conversions, which reach the lumen by them.

A product is the substrate of a further conversion in a chain.

Raises:

Type Description
ValueError

for a conversion whose substrate never reaches the lumen.

segment_factor_objects

segment_factor_objects(definition, profiles)

The factors f_ka_<seg>_<s> of the segments of the profiles (not the groups).

In the order of the substances and the segments.

conversion_objects

conversion_objects(conversions)

The rate constants kconv_<s>_<m> of the conversions.

Annotated with the organ of their segments (none for the stomach or both regions).

variants.segments

The lumen segments of the segmented intestine: their data and geometry.

The segments of Thelen 2011 in the order of the transit, each with its table in data/intestine_human.toml; the share of an intestinal segment in its region (small or large intestine) is its share of the transit time of the region, by which the mucosa gets its tissue volume and blood flow. The single lumen is one segment, the fluid of the small intestine.

DATA module-attribute

DATA = 'intestine_human'

The data file of the intestine.

SEGMENTS module-attribute

SEGMENTS = dict(
    zip(
        ids.GUT_SEGMENTS,
        (
            "stomach",
            "duodenum",
            "upper_jejunum",
            "lower_jejunum",
            "upper_ileum",
            "lower_ileum",
            "caecum",
            "colon_ascendens",
            "colon_transversum",
            "colon_descendens",
            "colon_sigmoid",
            "rectum",
        ),
        strict=True,
    )
)

The data table of every lumen segment by its id token.

SMALL module-attribute

SMALL = ('du', 'jej1', 'jej2', 'ile1', 'ile2')

The segments of the small intestine.

Segment dataclass

Segment(token, key, region, share, absorbs)

A lumen segment of the intestine.

Attributes:

Name Type Description
token str | None

the id token (du), None for the single lumen.

key str

the table of its data in data/intestine_human.toml.

region Organ | None

the organ whose tissue and blood flow its mucosa shares, None without mucosa (the stomach).

share float

the share of the segment in its region (the transit share).

absorbs bool

the segment absorbs (with the area factor of the data).

label property

label

The segment in names, upper jejunum.

segments

segments()

Get the lumen segments of the segmented intestine.

The share of a segment in its region is its share of the transit time of the region (small intestine, large intestine).

Returns:

Type Description
tuple[Segment, ...]

The segments in the order of the transit.

single_lumen

single_lumen()

The one segment of the single lumen.

variants.gut

The builder of the intestine variants: wall, mucosa and chemistry.

GutBuilder builds the submodel GU of the segmented intestine and of the single lumen (pkpdsim.pbpk.variants.intestine): the wall is the standard organ of small and large intestine, the lumen that of LumenBuilder, the mucosa and the chemistry of the small intestine are placed here.

GUT_ORGANS module-attribute

GUT_ORGANS = (Organ.SMALL_INTESTINE, Organ.LARGE_INTESTINE)

The organs the intestine variants replace.

GutBuilder

GutBuilder(
    ctx,
    name,
    segments,
    *,
    single,
    fabs=frozenset(),
    colon=frozenset(),
    regional=None,
    conversions=(),
)

Bases: LumenBuilder

The SBML objects of the intestine: wall, lumen segments, mucosa and chemistry.

Start the collection of the elements of the intestine.

The wall is the standard organ without the chemistry of the intestine, which goes into the mucosa.

Parameters:

Name Type Description Default
ctx OrganContext

the context of the small intestine.

required
name str

the name of the component.

required
segments tuple[Segment, ...]

the lumen segments.

required
single bool

the single lumen.

required
fabs frozenset[str]

the substances of which the segments absorb the fraction fabs_<s>, the rest goes into the feces.

frozenset()
colon frozenset[str]

the substances which the large intestine absorbs with f_ka_colon_<s>.

frozenset()
regional Mapping[str, frozenset[str]] | None

the segments of a substance which absorb with its factor f_ka_<seg>_<s>, by substance.

None
conversions tuple[LumenConversion, ...]

the conversions in the lumen.

()

Raises:

Type Description
ValueError

for chemistry the intestine cannot place, a distribution of the large intestine, or a conversion of a substance which never reaches the lumen.

v property

v

The volume of the intestine, Vsi + Vla.

f_vas property

f_vas

The vascular fraction of the intestine.

f_int property

f_int

The interstitial fraction of the intestine.

build

build()

Build the model definition and the boundary.

gut_chemistry

gut_chemistry(chemistry)

Get the processes of the intestine (its mucosa) and the others.

Parameters:

Name Type Description Default
chemistry Sequence[Metabolism | Transport | CustomReaction]

the processes of the definition.

required

Returns:

Type Description
list[Metabolism | Transport]

The processes of the small intestine, placed into the mucosa, and

tuple[Metabolism | Transport | CustomReaction, ...]

the processes of every other organ.

Raises:

Type Description
ValueError

for a process of the large intestine, a custom reaction or a basolateral transport of the intestine.

wall_parts

wall_parts(substance, chemistry)

Get the parts of a substance in the wall of the intestine.

The wall is the standard organ of the small intestine without the processes of the intestine, which are in the mucosa.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
chemistry Sequence[Metabolism | Transport | CustomReaction]

the processes of the definition.

required

Returns:

Type Description
Parts

The parts of the substance in the wall.

bile_substances

bile_substances(substances, chemistry)

Get the substances excreted into the bile, which drains into the lumen.

An apical efflux transport of the liver, or a custom reaction which names the bile of the substance (ids.bile) in its equation.

Parameters:

Name Type Description Default
substances Iterable[Substance]

the substances of the definition.

required
chemistry Sequence[Metabolism | Transport | CustomReaction]

the processes of the definition.

required

Returns:

Type Description
set[str]

The ids of the substances.

luminal_substances

luminal_substances(
    substances, chemistry, routes, conversions=()
)

Get the substances which reach the lumen of the intestine.

A substance with an oral route, excreted into the bile (bile_substances), transported by the intestine, an inhibitor of an influx transporter of the intestine, and the products of the conversions in the lumen of these.

Parameters:

Name Type Description Default
substances Sequence[Substance]

the substances of the definition.

required
chemistry Sequence[Metabolism | Transport | CustomReaction]

the processes of the definition.

required
routes Iterable[Route]

the routes of the definition.

required
conversions Sequence[LumenConversion]

the conversions in the lumen.

()

Returns:

Type Description
set[str]

The ids of the substances.

Raises:

Type Description
ValueError

for chemistry the intestine cannot place, or a conversion of a substance which never reaches the lumen.

variants.gut_lumen

The lumen of the intestine variants: transit, dissolution, absorption, bile, doses.

LumenBuilder adds the lumen segments to the standard organ of the intestinal wall; pkpdsim.pbpk.variants.gut.GutBuilder derives from it and sets the attributes (the segments, the substances which reach the lumen, the mucosa) before it builds.

LumenBuilder

LumenBuilder(ctx, name)

Bases: StandardBuilder

The lumen segments of the intestine on top of the standard organ of the wall.

Attributes:

Name Type Description
segments tuple[Segment, ...]

the lumen segments in the order of the transit.

single bool

the single lumen (absorption without area factor, no fed state).

fabs frozenset[str]

the substances of which the segments absorb the fraction fabs_<s> of their absorbed flux into the body, the rest into the feces.

colon frozenset[str]

the substances which the segments of the large intestine absorb with the factor f_ka_colon_<s>.

regional dict[str, frozenset[str]]

the segments of a substance which absorb with its factor f_ka_<seg>_<s> (RegionalAbsorption), by substance.

conversions tuple[LumenConversion, ...]

the conversions of a substance into another in the lumen (LumenConversion).

oral dict[tuple[str, str], Route]

the oral routes by (kind, substance).

bile set[str]

the substances excreted into the bile.

luminal set[str]

the substances which reach the lumen.

mucosal set[str]

the substances with mucosa species.

steady_state

The steady state of the equations of the library, as formulas.

A model whose custom reactions declare their rates at the steady state (CustomReaction.stationary) gets every start generated by the library (pkpdsim.pbpk.stationary); these functions remain for what a model writes itself: a rate which balances its substance at a given baseline (a supply), a constant of a mechanism derived from the steady state of an organ (a capacity), and the starts of a model without declarations.

An endogenous substance starts at the equilibrium of every part with its baseline (Substance.baseline), which is stationary without production and elimination. An organ with a production or an elimination of the chemistry (a custom reaction) is at another steady state: the plasma leaving it carries the production, its tissue holds more than Kp times its plasma, the kidney plasma lacks the secretion. A model gives such an organ its steady state as the starts of its species (PBPKDefinition.starts); these functions return the formulas of the steady state of the equations the library builds, over ids of the top model, so that the model does not restate them:

  • plasma_flow: the flow which carries the substance through an organ, Q<o>*(1 - HCT), Q<o>*BP with erythrocytes in equilibrium;
  • tissue_volume: the volume of the merged tissue of an organ, Vti, where a custom reaction states its rate per litre of tissue;
  • tissue_exchange: the exchange of the merged tissue with the plasma, PS*fu, the share of ftissue of the organ;
  • organ_plasma, organ_tissue: the plasma leaving a standard organ and its merged tissue with a net source rate (mmole/min) and a clearance of the plasma;
  • renal_filtration, kidney_plasma, kidney_arterial, renal_clearance: the net filtrate of the kidney, the kidney plasma with a secretion (a clearance of the kidney plasma and a saturable secretion, Saturable of pkpdsim.pbpk.chemistry, the root of a quadratic) at a given arterial plasma or a given renal elimination, the arterial plasma of a kidney plasma, and the renal clearance of the arterial plasma (glomerulus and tubule in series); a saturable reabsorption of the filtrate (Excretion.reabsorption, the pkpdsim.pbpk.ThresholdReabsorption of the substance) has the net filtrate of the arterial plasma and, without another process of the kidney, the kidney plasma at the arterial plasma;
  • liver_plasma: the liver plasma, fed by the hepatic artery and the portal vein past the shunt f_shunt, with a source of the liver;
  • arm_vein: the mix of the venous outflows of the arm vein of a preset.

Every formula is the steady state of an organ at a given inflow (the arterial plasma, the baseline by default): the standard organ is linear in its species at a fixed inflow, so it is a closed form. The formulas read the same ids as the equations of the organs (the flows, HCT, BP_<s>, fu_<s>, GFR, f_reabsorbed_<s> (reab_threshold_<s>, reab_n_<s>), the coefficients Kp, ftissue_<s>, Vti_total_ref_<s>, the organ volume and its vascular fraction, f_shunt, f_functional), so they follow a change of the individual before the simulation, and the tests of the library check them against the equations of every organ variant they apply to. Where no closed form applies, a function raises NotImplementedError naming the reason: kinetic erythrocytes, the full form and the flow-limited organ, an exchange of the organ of its own (ps), the intestine (it refuses custom reactions, its parts start at the equilibrium), the nephron kidney (its tubule starts empty, not at its steady state) and a source in the zonated liver (it refuses custom reactions). The functions of an organ which has variants take the variants of the definition (variants=, required), so a model with a variant never gets the formula of the standard organ silently. Every function which takes an inflow names it arterial (and portal for the liver).

Saturable dataclass

Saturable(vmax, km)

A Michaelis-Menten rate of a plasma species, vmax*C/(km + C).

The formulas have two scopes, by where the class is used:

  • the steady state of a custom reaction (CustomReaction.stationary): its rate law is the saturable rate of the plasma species of its substrate C, so its organ starts at the root of a quadratic; the formulas read the ids of the organ, as the rate law (Vti, the parameters of the reaction) and constants of the top model;
  • an argument of the formulas of pkpdsim.pbpk.steady_state (a saturable secretion of the kidney plasma, which a model writes into a parameter of the definition): the formulas read the ids of the top model only.

Attributes:

Name Type Description
vmax str

the capacity of the whole organ (mmole/min), a formula.

km str

the Michaelis constant (mM), a formula.

plasma_flow

plasma_flow(substance, organ, *, variants)

Get the flow which carries the substance through an organ [l/min].

Q<o>*(1 - HCT), the plasma flow, or Q<o>*BP_<s> with erythrocytes in equilibrium (the plasma species carries the blood); the liver is perfused by (1 - f_shunt)*Qh. The flows of the variants of the liver and the kidney are those of the standard organ.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ, not the intestine.

required
variants Variants

the variants of the definition (PBPKDefinition.variants), required.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
NotImplementedError

with kinetic erythrocytes, for the intestine.

tissue_volume

tissue_volume(organ, *, variants)

Get the volume of the merged tissue of a standard organ, Vti [l].

V<o>*(1 - f_vas_<o>), of the liver times f_functional: the local compartment Vti of the organ as a formula of the top model, e.g. for the rate of a custom reaction per litre of tissue at the steady state.

Parameters:

Name Type Description Default
organ Organ

the organ, a standard organ, not the intestine.

required
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant is refused.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
NotImplementedError

for the intestine or a variant of the organ.

tissue_exchange

tissue_exchange(substance, organ, *, variants)

Get the exchange of the merged tissue of an organ with its plasma, PS*fu [l/min].

The share of the whole-body exchange ftissue_<s> by the tissue volume of the organ (of the liver times f_functional) relative to the reference tissue volume, times the fraction unbound: the exchange PS*fu*(Cpl - Cti/Kp) of the merged tissue (Mode.TISSUE).

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ, a standard organ, not the intestine.

required
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant is refused.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
ValueError

if the substance does not enter the tissue of the organ.

NotImplementedError

for another mode than Mode.TISSUE, an exchange of the organ of its own (ps), the intestine or a variant of the organ.

organ_plasma

organ_plasma(
    substance,
    organ,
    *,
    arterial=None,
    rate="0",
    clearance="0",
    variants,
)

Get the plasma leaving a standard organ at its steady state [mM].

The organ takes F*Cin (plasma_flow) and the net source rate of its chemistry (mmole/min, into the plasma or the tissue: at the steady state the tissue passes it on), and loses F*Cpl and clearance*Cpl (a first order elimination of its plasma): Cpl = (F*Cin + rate)/(F + clearance).

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ, not the kidney or the liver (kidney_plasma, liver_plasma) or the intestine.

required
arterial str | None

the arterial plasma flowing in, the baseline baseline_<s> by default.

None
rate str

the net source of the organ at the steady state (mmole/min), negative for an uptake.

'0'
clearance str

the clearance of the plasma of the organ (l/min).

'0'
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant without a closed steady state is refused.

required

Returns:

Type Description
str

The formula.

organ_tissue

organ_tissue(
    substance, organ, plasma, *, rate="0", variants
)

Get the merged tissue of an organ at its steady state [mM].

With the source rate of the tissue (mmole/min) the exchange PS*fu*(Cpl - Cti/Kp) passes it to the plasma: Cti = Kp*(Cpl + rate/(PS*fu)), Kp*Cpl without.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
organ Organ

the organ.

required
plasma str

the plasma of the organ at the steady state (organ_plasma, kidney_plasma, liver_plasma).

required
rate str

the net source of the tissue (mmole/min).

'0'
variants Variants

the variants of the definition (PBPKDefinition.variants), required; a tissue of the zonated liver (every zone) without a source.

required

Returns:

Type Description
str

The formula.

renal_filtration

renal_filtration(substance, *, arterial=None, variants)

Get the net filtered plasma flow of the kidney, fu*GFR*(1 - f_reabsorbed) [l/min].

With a saturable reabsorption (Excretion.reabsorption) the reabsorbed fraction is that of the arterial plasma Car, fu*GFR*(1 - 1/(1 + (fu*Car/reab_threshold)^reab_n)^(1/reab_n)).

Parameters:

Name Type Description Default
substance Substance

the substance, with urinary excretion.

required
arterial str | None

the arterial plasma of a saturable reabsorption, the baseline by default; a constant fraction does not read it.

None
variants Variants

the variants of the definition (PBPKDefinition.variants), required: the nephron kidney is refused.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
ValueError

for a substance without urinary excretion.

NotImplementedError

for the nephron kidney.

kidney_plasma

kidney_plasma(
    substance,
    *,
    arterial=None,
    eliminated=None,
    rate="0",
    clearance="0",
    secretion=None,
    variants,
)

Get the plasma of the kidney at its steady state [mM].

The glomerulus filters the arterial plasma, the plasma leaving the kidney lacks the net filtrate G (renal_filtration, 0 without urinary excretion), a secretion clears the kidney plasma (clearance, l/min, and a saturable secretion, S(C) = vmax*C/(km + C)) and a source returns rate into it (a reabsorption): with R = F - G

R*(Car - C) + rate = clearance*C + S(C).

With a saturable reabsorption (Excretion.reabsorption) the net filtrate depends on the concentration: without another process of the kidney its plasma is the arterial plasma (the filtration of Car and the outflow lacking the net filtrate of C balance at C = Car); a rate, a clearance, a secretion or a given elimination have no closed form and are refused.

The kidney plasma C follows from the arterial plasma Car, or from the amount the kidney eliminates into the urine (eliminated, mmole/min): E = G*Car + clearance*C + S(C) - rate, the production of an endogenous substance which only the kidney excretes, whose arterial plasma is unknown (kidney_arterial gives it). Without secretion the formula is linear in C; with it C is the positive root of a quadratic.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
arterial str | None

the arterial plasma, the baseline by default.

None
eliminated str | None

the net excretion of the kidney into the urine at the steady state (mmole/min), instead of arterial.

None
rate str

the net source of the kidney (mmole/min).

'0'
clearance str

the first order clearance of the kidney plasma (l/min).

'0'
secretion Saturable | None

a saturable secretion of the kidney plasma.

None
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant without a closed steady state is refused.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
ValueError

for both arterial and eliminated, or eliminated without an elimination of the kidney.

NotImplementedError

for a saturable reabsorption with a rate, a clearance, a secretion or eliminated.

kidney_arterial

kidney_arterial(
    substance,
    plasma,
    *,
    eliminated=None,
    rate="0",
    clearance="0",
    secretion=None,
    variants,
)

Get the arterial plasma whose kidney plasma at the steady state is plasma [mM].

The inverse of kidney_plasma: Car = C + (clearance*C + S(C) - rate)/R with the flow past the filtrate R = F - G. With the net excretion of the kidney into the urine (eliminated, the E of kidney_plasma) it is Car = (E + R*C)/F whatever the secretion, which reads the kidney plasma once: the baseline of an endogenous substance which only the kidney excretes, from the kidney plasma of its elimination, whose formula the many starts of the substance read (the load time of a model grows with every copy of a large formula).

Parameters:

Name Type Description Default
substance Substance

the substance.

required
plasma str

the kidney plasma at the steady state.

required
eliminated str | None

the net excretion of the kidney into the urine at the steady state (mmole/min); rate, clearance and secretion are then not needed.

None
rate str

the net source of the kidney (mmole/min).

'0'
clearance str

the first order clearance of the kidney plasma (l/min).

'0'
secretion Saturable | None

a saturable secretion of the kidney plasma.

None
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant without a closed steady state is refused.

required

Returns:

Type Description
str

The formula.

With a saturable reabsorption and no other process of the kidney the arterial plasma is the kidney plasma; a rate, a clearance, a secretion or eliminated are refused (see kidney_plasma).

Raises:

Type Description
ValueError

for eliminated together with a rate, a clearance or a secretion.

NotImplementedError

for a saturable reabsorption with a rate, a clearance, a secretion or eliminated.

renal_clearance

renal_clearance(
    substance, *, clearance="0", arterial=None, variants
)

Get the renal clearance of the arterial plasma at the steady state [l/min].

The filtration and a secretion of the kidney plasma (clearance) in series: G + (F - G)*CL/(F - G + CL). With a saturable reabsorption the clearance is the net filtered plasma flow at the arterial plasma (renal_filtration), without a secretion.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
clearance str

the clearance of the kidney plasma (l/min).

'0'
arterial str | None

the arterial plasma of a saturable reabsorption, the baseline by default; a constant fraction does not read it.

None
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant without a closed steady state is refused.

required

Returns:

Type Description
str

The formula.

Raises:

Type Description
NotImplementedError

for a saturable reabsorption with a clearance.

liver_plasma

liver_plasma(
    substance,
    *,
    arterial=None,
    portal=None,
    rate="0",
    clearance="0",
    variants,
)

Get the plasma of the liver at its steady state [mM].

The liver is perfused by (1 - f_shunt) of the hepatic artery and the portal vein and drains (1 - f_shunt)*Qh; a source rate of the liver (mmole/min) leaves with it and a clearance of its plasma (l/min) removes a part: Cpl = ((1 - f_shunt)*(Qha*Car + Qpo*Cpo)*c + rate)/((1 - f_shunt)*Qh*c + clearance) with the carrier c (plasma_flow). The zonated liver (no source and no clearance, it refuses custom reactions) has the same plasma in every zone.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
arterial str | None

the arterial plasma, the baseline by default.

None
portal str | None

the portal plasma, the baseline by default (the portal organs without a source).

None
rate str

the net source of the liver (mmole/min).

'0'
clearance str

the clearance of the liver plasma (l/min).

'0'
variants Variants

the variants of the definition (PBPKDefinition.variants), required: a variant without a closed steady state is refused.

required

Returns:

Type Description
str

The formula.

arm_vein

arm_vein(substance, preset, outflows, *, arterial=None)

Get the plasma of the arm vein of a preset at the steady state [mM].

The mix sum w_arm_<site>*C_<site> of the venous outflows of the organs (and the arterial plasma) of the preset (PBPKDefinition.arm_vein); an organ not in outflows and the arterial plasma are at the baseline.

Parameters:

Name Type Description Default
substance Substance

the substance.

required
preset str

the preset of the arm vein, e.g. pksim_default.

required
outflows Mapping[Organ, str]

the plasma leaving the organs at the steady state.

required
arterial str | None

the arterial plasma, the baseline by default.

None

Returns:

Type Description
str

The formula.

stationary

The generated steady state of the substances with a declared steady state.

A custom reaction may declare its rate at the steady state (CustomReaction.stationary): a Formula of the rate, "linear" for a rate law which is linear in its substrate (a first order clearance), or Saturable(vmax, km) for a Michaelis-Menten rate of a plasma species. A substance which a declared reaction moves has a generated steady state: the builder starts every species of it at the steady state of the equations of the library with the declared rates, so that a model writes only what the library cannot know (the start of a pool of a custom species, the rates of its own mechanisms) and every simulation starts stationary.

The steady state is that of the circulation of the standard topology at a given arterial plasma Car:

  • an organ takes its inflow (the arterial pool, the venous pool for the lung, the mix of the hepatic artery and the portal vein past the shunt for the liver) and its declared rates; with the tissue at its steady state (Cti = Kp*(PS*fu*Cpl + r_ti)/(PS*fu + Kp*cl_ti)) its plasma obeys (R + CLss)*C + S(C) = R*Cin + Rss, with the flow R of the plasma leaving it (the kidney: the plasma flow less the net filtrate), the clearance CLss and the net source Rss of its plasma and tissue (steady_clearance, steady_rate, constants of the organ), and a saturable rate S(C) = Vss*C/(Kss + C): a closed form, the root of a quadratic with S. Every other part of the organ starts at the equilibrium with the plasma of the organ (or of its zone), a slow pool at Kpslow times its source (the tissue or the plasma), the tubule of the nephron kidney at the flow of the filtrate (fu*Car/f_tub_<seg>), the mucosa of the intestine at the equilibrium with the arterial plasma. The starts read the species of the inflow, so each is a short formula of its organ, and every parameter which an experiment sets before the simulation (an activity of the organ, an individual) is seen by them.
  • the portal vein starts at the mix of the organs which drain into it, the venous pool at the inflow of the lung which gives the arterial plasma (the arterial plasma itself when the lung moves nothing), the arterial pool at the baseline.

The arterial plasma is the baseline of the substance (Substance.baseline): a substance with a baseline is pinned, its declared rates must balance at the baseline (the model derives the rate which closes the balance, e.g. a supply, from the baseline). A substance without a baseline is solved: the library solves the mass balance of the body for the arterial plasma and writes the baseline (baseline_<s>): every organ eliminates L = lambda*Cin - sigma of its inflow (lambda = G + R*CLss/(R + CLss), sigma = R*Rss/(R + CLss)), the portal organs lower the inflow of the liver, the lung eliminates at the arterial plasma, and the sum is 0; a saturable process of one systemic organ makes it the root of a quadratic in the plasma of that organ. The organs give their constants to the top model as outputs (CLss_<o>_<s>, ...), so the baseline follows every parameter of an organ set before the simulation.

Where no closed form exists the build is refused with the reason: a custom reaction which moves the substance without a declaration, a process of the library which moves it (but the uptake from the empty lumen), kinetic erythrocytes, a declared process in an organ part without a closed form (the full form, the flow-limited organ, the blood cells, a slow pool), a linear transfer between two parts of the substance, a threshold reabsorption with another process of the kidney or without a baseline, and of a solved substance a saturable process outside the systemic organs, two saturable processes or no elimination.

BASELINE_SIZE_LIMIT module-attribute

BASELINE_SIZE_LIMIT = 20000

The expanded size (nodes) of a solved baseline above which the build warns.

roadrunner inlines every initial assignment a start reads, without memoizing it: every species of the substance compiles a copy of the expanded baseline (a parameter in between is inlined as well, it is no cheaper). The baseline of creatinine expands to about 3,800 nodes (the model about 220,000, 4 s at LLJIT O0); a solved saturable process of a body which also eliminates in the liver and a portal organ reached 31,000 nodes and 1.2 million in the model (37 s at O0).

IMBALANCE_LIMIT module-attribute

IMBALANCE_LIMIT = 1e-09

The relative rate (1/min) of the venous pool of a pinned substance at the start above which the build warns that its declared rates do not balance at its baseline; a balanced start is stationary to the rounding (about 1e-16).

OrganSteady dataclass

OrganSteady(
    sources=dict(), clearances=dict(), saturable=None
)

The declared steady state of a substance in an organ: what its custom reactions move.

Formulas of the organ (they read its elements, the parameters of the reactions, the species of other substances and constants of the top model).

Attributes:

Name Type Description
sources Mapping[Part, tuple[str, ...]]

the rates into the plasma and the tissue at the steady state (mmole/min, signed: a sink is negative), by part.

clearances Mapping[Part, tuple[str, ...]]

the first order clearances (l/min) of the plasma and the tissue, by part.

saturable Saturable | None

the saturable rate of the plasma, vmax with the stoichiometry of the reaction.

has_clearance property

has_clearance

Whether the plasma has a clearance at the steady state (CLss).

has_rate property

has_rate

Whether the plasma has a net source at the steady state (Rss).

SteadyPlan dataclass

SteadyPlan(
    solved=frozenset(), pinned=frozenset(), organs=dict()
)

The generated steady state of a definition (steady_plan).

Attributes:

Name Type Description
solved frozenset[str]

the substances without a baseline, whose arterial plasma the library solves and writes as their baseline.

pinned frozenset[str]

the substances with a baseline, the arterial plasma of their steady state.

organs Mapping[tuple[Organ, str], OrganSteady]

the declared steady state by organ and substance id, of the organs where a declared reaction moves the substance.

substances property

substances

The substances with a generated steady state.

of

of(organ, sid)

The declared steady state of a substance in an organ, None for none.

SteadyValue dataclass

SteadyValue(sid, formula, unit, name, kind, notes)

A constant of the top model of the generated steady state.

Attributes:

Name Type Description
sid str

the id.

formula str

the formula over ids of the top model.

unit UnitDefinition

the unit.

name str

the name.

kind str

the kind of its annotation.

notes str

the notes.

SteadyStateWarning

Bases: UserWarning

A generated steady state which loads slowly or does not balance.

terms

terms(*parts)

The sum of the terms which are not 0, each in parentheses; 0 for none.

saturable_root

saturable_root(a, vmax, km, d)

The positive root C of a*C + vmax*C/(km + C) = d.

a*C^2 + b*C - d*km = 0 with b = a*km + vmax - d, in the form 2*d*km/(b + sqrt(b^2 + 4*a*d*km)), which has no cancellation for b >= 0 and no division by a (a may be 0, then C = d*km/(vmax - d)).

reduced

reduced(steady, ps_fu, kp)

Get the clearance and the net source of the plasma with the tissue at its steady state.

The tissue exchanges PS*fu*(Cpl - Cti/Kp) with the plasma and has the source r_ti and the clearance cl_ti, so at its steady state it passes r_ti*PS*fu/(PS*fu + Kp*cl_ti) to the plasma and clears cl_ti*Kp*PS*fu/(PS*fu + Kp*cl_ti) of it.

Parameters:

Name Type Description Default
steady OrganSteady

the declared steady state of the substance in the organ.

required
ps_fu str | None

the exchange PS*fu of the merged tissue, None without one.

required
kp str | None

the tissue to plasma coefficient, None without a tissue.

required

Returns:

Type Description
str

The clearance CLss (l/min) and the net source Rss (mmole/min)

str

of the plasma, 0 for none.

plasma_start

plasma_start(flow, inflow, clearance, rate, saturable=None)

Get the plasma of an organ at its steady state [mM].

(R + CLss)*C + S(C) = R*Cin + Rss: C = (R*Cin + Rss)/(R + CLss), the root of a quadratic with a saturable rate S(C) = vmax*C/(km + C), the inflow itself without any process.

Parameters:

Name Type Description Default
flow str

the flow R of the plasma leaving the organ (l/min).

required
inflow str

the inflow concentration Cin.

required
clearance str

the clearance CLss (l/min), 0 for none.

required
rate str

the net source Rss (mmole/min), 0 for none.

required
saturable tuple[str, str] | None

vmax and km of a saturable rate of the plasma.

None

Returns:

Type Description
str

The formula.

tissue_start

tissue_start(kp, plasma, ps_fu, rate, clearance)

Get the merged tissue of an organ at its steady state [mM].

Cti = Kp*(PS*fu*Cpl + r_ti)/(PS*fu + Kp*cl_ti), Kp*Cpl without a process of the tissue.

Parameters:

Name Type Description Default
kp str

the tissue to plasma coefficient.

required
plasma str

the plasma of the organ (its species).

required
ps_fu str | None

the exchange PS*fu.

required
rate str

the net source of the tissue (mmole/min), 0 for none.

required
clearance str

the clearance of the tissue (l/min), 0 for none.

required

Returns:

Type Description
str

The formula.

linear_clearance

linear_clearance(formula, species)

Get the clearance of a rate law which is linear in a species.

The rate law k*C (a product with the species as one factor, or the numerator of a quotient) with the species C once: the clearance is the rate law without the factor, k (l/min for a rate in mmole/min of a concentration in mM).

Parameters:

Name Type Description Default
formula str

the rate law (SBML L3 infix).

required
species str

the id of the species.

required

Returns:

Type Description
str | None

The clearance, None if the rate law is not linear in the species

str | None

(it reads it more than once, in a sum, a denominator, a function or

str | None

a negation, or not at all).

steady_plan

steady_plan(definition)

Get the generated steady state of a definition, refusing what has no closed form.

Parameters:

Name Type Description Default
definition PBPKDefinition

the definition.

required

Returns:

Type Description
SteadyPlan

The plan, empty without a declared steady state.

Raises:

Type Description
ValueError

naming every reason why the steady state of a substance has no closed form (see the module).

organ_exports

organ_exports(plan, organ, s)

Get the constants of the steady state which an organ gives to the top model.

The clearance CLss_<s>, the net source Rss_<s> and the saturable Vss_<s>, Kss_<s> of the plasma of the organ, which it has, as CLss_<o>_<s>, ...: of every organ of a solved substance (the solve of the arterial plasma), of the lung of every substance (the venous pool).

Parameters:

Name Type Description Default
plan SteadyPlan

the plan.

required
organ Organ

the organ.

required
s str

the substance id.

required

Returns:

Type Description
dict[str, str]

The outputs, local id -> id of the top model.

carrier

carrier(s)

The share of the blood flow which carries the plasma concentration, in the top model.

solved_baseline

solved_baseline(s, plan, organs)

Get the arterial plasma of the steady state of a solved substance, its baseline.

The sum of the eliminations of the organs is 0: sum lambda_o*Cin_o - sigma_o = 0, the inflow of the liver lowered by the eliminations of the portal organs (Cin_li = Car - sum L_p/(Qh*c)), the lung at the arterial plasma; with a saturable process of a systemic organ k the rest of the body gives Car = (Rss + R_k*C_k)/(CLss + F_k) and C_k is the root of a*C + q*S(C) = d with q = (CLss + F_k)/R_k, a = CLss + G_k + q*CLss_k and d = Rss + q*Rss_k.

Parameters:

Name Type Description Default
s Substance

the substance, without baseline.

required
plan SteadyPlan

the plan.

required
organs Iterable[Organ]

the built organs (the intestine of a variant has no process of the substance).

required

Returns:

Type Description
list[SteadyValue]

The constants of the top model (CLss_<s>, Rss_<s>, Css_<o>_<s>)

str

and the formula of the baseline.

portal_moves

portal_moves(plan, s, gut=())

Whether an organ which drains into the portal vein moves the substance.

Without, the portal vein starts at the arterial plasma, and so does the inflow of the liver.

Parameters:

Name Type Description Default
plan SteadyPlan

the plan.

required
s str

the substance id.

required
gut Iterable[Organ]

the organs which the intestine of a variant replaces (it moves nothing).

()

pool_start

pool_start(s, plan, pool, organs, gut=())

Get the start of a blood pool of a substance with a generated steady state.

The arterial pool at the baseline (None, the start of the library); the portal vein at the mix of the organs which drain into it (the organs of the intestine of a variant at the arterial plasma, it moves nothing), the arterial plasma when no portal organ moves the substance; the venous pool at the inflow of the lung whose plasma is the arterial plasma, Car + (CLss*Car + S(Car) - Rss)/F with the constants of the lung, the arterial plasma when the lung moves nothing.

Parameters:

Name Type Description Default
s Substance

the substance.

required
plan SteadyPlan

the plan.

required
pool Pool

the pool.

required
organs Iterable[Organ]

the built organs.

required
gut Iterable[Organ]

the organs which the intestine of a variant replaces, the small intestine included.

()

Returns:

Type Description
str | None

The formula, None for the start of the library.

expanded_size

expanded_size(model, sid)

Get the size of the expanded initial value of an id (nodes of its math tree).

Every id the math reads which has an initial assignment or an assignment rule is replaced by its own expanded math, as roadrunner compiles it; every other id and number counts one.

Parameters:

Name Type Description Default
model Model

the flat model.

required
sid str

the id.

required

Returns:

Type Description
int

The number of nodes.

check_built

check_built(plan, flat_path)

Warn about a generated steady state of a built model which loads slowly or does not balance.

A solved baseline whose expansion exceeds BASELINE_SIZE_LIMIT: every start reads it, give the substance a baseline (pinned) or fewer declared organs. A pinned substance whose venous pool moves at the start of the reference individual (IMBALANCE_LIMIT): its declared rates do not balance at its baseline by the net rate of the venous pool (mmole/min), the model derives the rate which closes the balance (e.g. a supply) from the baseline (the formulas of pkpdsim.pbpk.steady_state).

Parameters:

Name Type Description Default
plan SteadyPlan

the plan of the definition.

required
flat_path Path

the flat model.

required

Warns:

Type Description
SteadyStateWarning

naming the substance and the size or the imbalance.