Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions chi/library/_model_library_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def erlotinib_tumour_growth_inhibition_model(self):

return chi.PKPDModel(self._path + file_name)

def one_compartment_pk_model(self):
def one_compartment_pk_model(self, elimination_rate=True):
r"""
Returns an instantiation of a 1-compartment PK model.

Expand All @@ -62,9 +62,46 @@ def one_compartment_pk_model(self):
The drug may be either directly administered to :math:`A` or indirectly
through a dosing compartment.

:param bool elimination_rate: If True, the model uses the elimination
rate :math:`k_e` as a parameter. If False, the model uses the
clearance :math:`CL` as a parameter, which is related to the
elimination rate by :math:`CL = k_e V`.

:rtype: chi.PKPDModel
"""
file_name = 'pk_one_comp_clearance.xml'
if elimination_rate:
file_name = 'pk_one_comp.xml'
model = chi.PKPDModel(self._path + file_name)
model.set_outputs(['central.drug_concentration'])

return model

def two_compartment_pk_model(self):
r"""
Returns an instantiation of a 2-compartment PK model.

In this model the distribution of the drug is modelled by twp
compartments: 1. the central compartment; and 2. the peripheral
compartment. The drug transtions between the two compartments at the
inter-compartment clearance rate :math:`q` and is eliminated from the
central compartment at the clearance rate :math:`k_{cl}`.

.. math ::
\frac{\text{d}a_c}{\text{d}t} = -k_{cl} c_c - q c_c + q c_p
\quad \frac{\text{d}a_p}{\text{d}t} = q c_c - q c_p,

where :math:`a_c` denotes the drug amount in the central compartment
and :math:`a_p` the drug amount in the peripheral compartment. The
concentrations :math:`c_c` and :math:`c_p` are given by
:math:`c_c = \frac{a_c}{v_c}` and :math:`c_p = \frac{a_p}{v_p}`, where
:math:`v_c` and :math:`v_p` denote the effective volumes of
distribution of the drug in the compartments. `k_{cl}` and `q` denote
the clearance and inter-compartment clearance rates, respectively.

:rtype: chi.PKPDModel
"""
file_name = 'pk_one_comp.xml'
file_name = 'pk_two_comp_clearance.xml'
model = chi.PKPDModel(self._path + file_name)
model.set_outputs(['central.drug_concentration'])

Expand Down
54 changes: 54 additions & 0 deletions chi/library/model_library/pk_one_comp_clearance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model id="one_compartment_pk_model" timeUnits="hour">

<listOfUnitDefinitions>
<unitDefinition id="hour">
<listOfUnits>
<unit kind="second" exponent="1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="liter_per_hour">
<listOfUnits>
<unit kind="liter" exponent="1" scale="0" multiplier="1"/>
<unit kind="second" exponent="-1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mg">
<listOfUnits>
<unit kind="gram" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>

<listOfCompartments>
<compartment id="central" name="central" size="1" units="liter"/>
</listOfCompartments>

<listOfSpecies>
<species id="drug" name="drug" compartment="central" initialAmount="0" hasSubstanceUnits="false" substanceUnits="mg"/>
</listOfSpecies>

<listOfParameters>
<parameter id="clearance" value="1" constant="true" units="liter_per_hour"/>
</listOfParameters>

<listOfReactions>
<reaction id="central_reaction" name="central_reaction" reversible="false" fast="false">
<listOfReactants>
<speciesReference species="drug"/>
</listOfReactants>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> clearance </ci>
<ci> drug </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>

</model>
</sbml>
93 changes: 93 additions & 0 deletions chi/library/model_library/pk_two_comp_clearance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model id="two_compartment_pk_model" timeUnits="hour">

<listOfUnitDefinitions>
<unitDefinition id="hour">
<listOfUnits>
<unit kind="second" exponent="1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="liter_per_hour">
<listOfUnits>
<unit kind="liter" exponent="1" scale="0" multiplier="1"/>
<unit kind="second" exponent="-1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mg">
<listOfUnits>
<unit kind="gram" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>

<listOfCompartments>
<compartment id="central" name="central" size="1" units="liter"/>
<compartment id="peripheral" name="peripheral" size="1" units="liter"/>
</listOfCompartments>

<listOfSpecies>
<species id="drug" name="drug" compartment="central" initialAmount="0" hasSubstanceUnits="false" substanceUnits="mg"/>
<species id="drug_peripheral" name="drug_peripheral" compartment="peripheral" initialAmount="0" hasSubstanceUnits="false" substanceUnits="mg"/>
</listOfSpecies>

<listOfParameters>
<parameter id="clearance" value="1" constant="true" units="liter_per_hour"/>
<parameter id="inter_compartment_clearance" value="1" constant="true" units="liter_per_hour"/>
</listOfParameters>

<listOfReactions>
<reaction id="clearance_reaction" name="clearance_reaction" reversible="false" fast="false">
<listOfReactants>
<speciesReference species="drug"/>
</listOfReactants>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> clearance </ci>
<ci> drug </ci>
</apply>
</math>
</kineticLaw>
</reaction>

<reaction id="transition_to_peripheral_compartment" name="transition_to_peripheral_compartment" reversible="false" fast="false">
<listOfReactants>
<speciesReference species="drug"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="drug_peripheral"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> inter_compartment_clearance </ci>
<ci> drug </ci>
</apply>
</math>
</kineticLaw>
</reaction>

<reaction id="transition_to_central_compartment" name="transition_to_central_compartment" reversible="false" fast="false">
<listOfReactants>
<speciesReference species="drug_peripheral"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="drug"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> inter_compartment_clearance </ci>
<ci> drug_peripheral </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>

</model>
</sbml>
9 changes: 9 additions & 0 deletions chi/tests/test_model_library_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def test_existence_one_compartment_pk_model(self):
model = self.model_library.one_compartment_pk_model()
self.assertIsInstance(model, chi.PKPDModel)

def test_existence_one_compartment_pk_model_clearance(self):
model = self.model_library.one_compartment_pk_model(
elimination_rate=False)
self.assertIsInstance(model, chi.PKPDModel)

def test_existence_two_compartment_pk_model(self):
model = self.model_library.two_compartment_pk_model()
self.assertIsInstance(model, chi.PKPDModel)


class TestErlotinibTumourGrowthInhibitionModel(unittest.TestCase):
"""
Expand Down