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
¶
outflow
¶
as_member
¶
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
¶
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 |
required |
name
|
str
|
the field which holds the mapping, for the messages. |
required |
Returns:
| Type | Description |
|---|---|
dict[Organ, V]
|
The mapping with |
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
¶
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 |
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
¶
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 |
tissue |
Literal['none', 'organ', 'merged', 'full']
|
the tissue species: |
parts_for
¶
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 ( |
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 -> ( |
slow_pools |
tuple[SlowPool, ...]
|
the slow pools of the definition ( |
steady |
SteadyPlan | None
|
the generated steady state of the definition
( |
Boundary
dataclass
¶
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, |
outputs |
Mapping[str, str]
|
the outputs of the organ, local id -> id in the body
( |
OrganComponent
¶
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).
StandardOrgan
dataclass
¶
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 ( |
build
¶
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 |
StandardBuilder
¶
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. |
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),
(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.
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, |
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, |
steady |
str | None
|
the start of a substance with a generated steady state
( |
OrganBuilder
¶
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 ( |
|
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 |
model_definition
¶
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 |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a |
stationary_ids
¶
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.
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).
Sink
dataclass
¶
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 ( |
Apical
dataclass
¶
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
( |
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
¶
The inhibitors of the protein of a process.
Attributes:
| Name | Type | Description |
|---|---|---|
competitive |
str | None
|
|
uncompetitive |
str | None
|
|
modifiers |
tuple[str, ...]
|
the inhibitor species which the rate reads. |
FormulaParameter
¶
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
¶
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
¶
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
¶
metabolism_part
¶
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
¶
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
|
Returns:
| Type | Description |
|---|---|
str
|
The local compartment id. |
start_formula
¶
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
|
Returns:
| Type | Description |
|---|---|
str | None
|
|
str | None
|
substance without baseline, whose species start at 0. |
species_start
¶
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), |
required |
name
|
str
|
the name of the species. |
required |
Returns:
| Type | Description |
|---|---|
SpeciesStart
|
The initial assignment. |
kp_id
¶
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
|
|
str | None
|
interstitial shares, |
str | None
|
not enter the tissue of the organ. |
unbound
¶
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
|
Returns:
| Type | Description |
|---|---|
str
|
|
str
|
elsewhere ( |
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
¶
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, |
Part | None
|
apical influx. |
inhibitor_unbound
¶
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 ( |
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
|
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
¶
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
|
|
inhibitor_terms
¶
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
¶
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 |
list[tuple[str, str]]
|
of a mechanism-based inhibition. |
formula_ids
¶
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
¶
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
|
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
¶
Get the initial assignment of the parameter of a formula.
value_parameter
¶
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 |
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 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 |
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 ( |
None
|
zone
|
str | None
|
the zone of a zonated organ in which the process is placed,
|
None
|
apical
|
Apical | None
|
the apical side of the cell of a variant (the lumen of the
proximal tubule of the nephron kidney), |
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
¶
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, |
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
¶
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
¶
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
¶
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, |
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 |
Reaction
|
with the rate |
Reaction
|
reaction of the metabolism. |
process_kind
¶
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
¶
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
¶
A product of an equation, the fraction left out if it is 1.
in_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, |
required |
Returns:
| Type | Description |
|---|---|
str
|
The text, in a zone followed by |
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 sharef_int*K_int_pls/(f_int + f_cell)has no positiveK_cell_pls: the build refuses it for the reference individual of its sex, and the rule floorsK_cell_plsatK_CELL_FLOORshould 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
¶
The local ids of the constants of K_int_pls, keys of data/distribution.toml.
K_VAS
module-attribute
¶
The local id of the exchange between plasma and interstitium per organ volume.
K_CELL_FLOOR
module-attribute
¶
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
¶
The constants of data/distribution.toml by key, values with their source.
number
¶
The number of a plain float or a Value.
Raises:
| Type | Description |
|---|---|
TypeError
|
for a |
k_int_pls
¶
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 |
k_int_pls_value
¶
The interstitial to plasma coefficient of an unbound fraction.
interstitial_share
¶
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
¶
The whole-tissue Kp which a Kp gives an organ, before the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substance
|
Substance
|
the substance, with a |
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, |
Q | None
|
value of the substance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the distribution of the substance is no |
k_cell_pls
¶
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
|
|
str
|
cells together have the Kp. |
k_cell_pls_value
¶
The intracellular to plasma coefficient of the numbers, without the floor.
k_organ
¶
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, |
required |
kp
|
str
|
the id of the whole-tissue to plasma coefficient. |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
kp_floor_stages
¶
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 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
¶
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 |
str
|
the build of the sex; empty for an organ without an accepted floor. |
check_kp
¶
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, |
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
APof 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; Pis the octanol:water partition coefficient, the vegetable oil:water onelog P_vo:w = 1.115*log P - 1.35in the lipid terms of adipose;XandYare 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
¶
A base with a pKa at or above it binds to the acidic phospholipids (Yau 2020).
Composition
dataclass
¶
The composition of a tissue of the Rodgers & Rowland method.
Attributes:
| Name | Type | Description |
|---|---|---|
tissue |
str
|
the tissue of |
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
¶
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 ( |
kp_sources
¶
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
¶
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
¶
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
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if a substance which binds to the acidic phospholipids has no blood to plasma ratio. |
blood_to_plasma
¶
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
|
|
float | None
|
coefficient, |
kp_values
¶
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 |
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 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 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
¶
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
¶
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
¶
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 ( |
name |
str
|
the name of the component, the prefix of the id of the model
definition ( |
build
¶
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
¶
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
¶
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 ( |
build
¶
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
¶
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 volumeVgu = Vsi + Vlawith the volume-weighted vascular and interstitial fractions, the distribution of the small intestine (its Kp) and the share offtissueof 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 concentrationClumen_<seg>_<s>per segment, which moves on with the transitV*C/T_<seg>and from the last segment into the fecesAfeces_<s>; an oral tablet has the undissolved amountAsolid_<seg>_<s>(in the first segment the dose statePODOSE_<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 stateFED = 1slows 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 withka_<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 timesf_ka_colon_<s>(SegmentedIntestine.f_ka_colon, a substance with an oral route), a segment of the regional absorption profile of a substance timesf_ka_<seg>_<s>(RegionalAbsorption); the single lumen absorbs withka_<s>; of the absorbed flux the fractionfabs_<s>enters the body and the rest the feces (the single lumen for every substance, the segments withSegmentedIntestine.fabsfor 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 coefficientK_mu_<s>(the Kp of the small intestine, 1 without), perfused by arterial blood with its flowQmu_<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 volumeVmu_<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 concentrationCu_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
¶
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 |
fabs |
PerSubstance | None
|
the fraction of the absorbed flux which enters the body,
|
f_ka_colon |
PerSubstance | None
|
the factor of the absorption of the segments of the large
intestine (caecum to rectum), |
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 |
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 |
absorption
¶
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
¶
Get ka_<s>, fabs_<s>, f_ka_colon_<s>, the regional factors, the conversion rates, FED.
build
¶
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
¶
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 |
fabs |
PerSubstance | None
|
the fraction of the absorbed flux which enters the body, 1 if
|
regional |
RegionalAbsorption | Mapping[str, RegionalAbsorption] | None
|
refused if set (no segments). |
conversions |
Sequence[LumenConversion]
|
refused if set (no segments). |
Raises:
| Type | Description |
|---|---|
ValueError
|
for |
absorption
¶
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. |
build
¶
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
¶
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 |
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
¶
The lumen segments of the large intestine, caecum to rectum.
COLON
module-attribute
¶
The key of the group of the segments of the large intestine in a profile.
GROUPS
module-attribute
¶
The groups of segments with one shared factor of a profile, by key.
RegionalAbsorption
dataclass
¶
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 ( |
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 |
LumenConversion
dataclass
¶
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 |
segments |
Sequence[str]
|
the lumen segments it acts in, tokens of |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a substrate which is the product, no segment, an
unknown token or one twice, a negative |
check_conversions
¶
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
¶
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
¶
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
¶
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.
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
¶
The segments of the small intestine.
Segment
dataclass
¶
A lumen segment of the intestine.
Attributes:
| Name | Type | Description |
|---|---|---|
token |
str | None
|
the id token ( |
key |
str
|
the table of its data in |
region |
Organ | None
|
the organ whose tissue and blood flow its mucosa shares,
|
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). |
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
¶
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
|
frozenset()
|
colon
|
frozenset[str]
|
the substances which the large intestine absorbs with
|
frozenset()
|
regional
|
Mapping[str, frozenset[str]] | None
|
the segments of a substance which absorb with its
factor |
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. |
gut_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
¶
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
¶
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
¶
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
¶
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
|
colon |
frozenset[str]
|
the substances which the segments of the large intestine
absorb with the factor |
regional |
dict[str, frozenset[str]]
|
the segments of a substance which absorb with its factor
|
conversions |
tuple[LumenConversion, ...]
|
the conversions of a substance into another in the
lumen ( |
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>*BPwith 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 offtissueof the organ;organ_plasma,organ_tissue: the plasma leaving a standard organ and its merged tissue with a net sourcerate(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,Saturableofpkpdsim.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, thepkpdsim.pbpk.ThresholdReabsorptionof 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 shuntf_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
¶
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 substrateC, 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
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
with kinetic erythrocytes, for the intestine. |
tissue_volume
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
for the intestine or a variant of the organ. |
tissue_exchange
¶
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 ( |
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 |
organ_plasma
¶
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 ( |
required |
arterial
|
str | None
|
the arterial plasma flowing in, the baseline
|
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
organ_tissue
¶
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 ( |
required |
rate
|
str
|
the net source of the tissue (mmole/min). |
'0'
|
variants
|
Variants
|
the variants of the definition ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
renal_filtration
¶
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 ( |
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 |
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for both |
NotImplementedError
|
for a saturable reabsorption with a rate, a
clearance, a secretion or |
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); |
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 ( |
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 |
NotImplementedError
|
for a saturable reabsorption with a rate, a
clearance, a secretion or |
renal_clearance
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
for a saturable reabsorption with a clearance. |
liver_plasma
¶
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 ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
arm_vein
¶
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. |
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 flowRof the plasma leaving it (the kidney: the plasma flow less the net filtrate), the clearanceCLssand the net sourceRssof its plasma and tissue (steady_clearance,steady_rate, constants of the organ), and a saturable rateS(C) = Vss*C/(Kss + C): a closed form, the root of a quadratic withS. Every other part of the organ starts at the equilibrium with the plasma of the organ (or of its zone), a slow pool atKpslowtimes 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
¶
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
¶
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
¶
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, |
SteadyPlan
dataclass
¶
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. |
SteadyValue
dataclass
¶
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.
saturable_root
¶
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
¶
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 |
required |
kp
|
str | None
|
the tissue to plasma coefficient, |
required |
Returns:
| Type | Description |
|---|---|
str
|
The clearance |
str
|
of the plasma, |
plasma_start
¶
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 |
required |
inflow
|
str
|
the inflow concentration |
required |
clearance
|
str
|
the clearance |
required |
rate
|
str
|
the net source |
required |
saturable
|
tuple[str, str] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
tissue_start
¶
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 |
required |
rate
|
str
|
the net source of the tissue (mmole/min), |
required |
clearance
|
str
|
the clearance of the tissue (l/min), |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formula. |
linear_clearance
¶
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, |
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
¶
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
¶
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
¶
The share of the blood flow which carries the plasma concentration, in the top model.
solved_baseline
¶
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 ( |
str
|
and the formula of the baseline. |
portal_moves
¶
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
¶
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, |
expanded_size
¶
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
¶
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. |