# pharmacokinetics
![downloads](https://img.shields.io/pepy/dt/pharmacokinetics) ![repo-size](https://img.shields.io/github/repo-size/xyzpw/pharmacokinetics-module)
The **pharmacokinetics** package is a Python package designed to make pharmacokinetic formulas easier to calculate in your Python code.
## Usage
Some functions will use kwargs, which will allow the ability to use alternatives to values, e.g. the parameter `t12` can be used instead of `ke`, which will convert the elimination half-life to the elimination rate constant with the following formula:
$\Large{\frac{\ln2}{t^{1/2}}}$
> [!NOTE]
> Remember to make sure your units match!
### Calculating Concentrations
Calculating the concentration remaining after an elapsed time after peak concentration using the formula $C \cdot e^{-k_et}$:
```python
import pharmacokinetics as pk
pk.single_dose.calculateRemaining(initial_concentration=10, time_elapsed=4, t12=9)
```
The above code will calculate the remaining concentration of a drug that has reached peak concentration 4 hours ago with an elimination half-life of 9 hours.
The formula to this function:<br>
$10 \ mg \cdot e^{-\frac{\ln2}{9 \ h}4 \ h}=7.35 \ mg$
To calculate the concentration at any time $T$ (oral administration), the usage is:
```python
import pharmacokinetics as pk
pk.concentrationAtTime(
dose=200,
vd=0.7,
bioavailability=0.99,
t12=4.5,
t12abs=7/60,
elapsed=6
)
```
This above code follows the formula:
$\frac{F \cdot D \cdot k_a}{Vd(k_a - k_e)}(e^{-k_e \cdot t} - e^{-k_a \cdot t})$
Alternatively, `interval` can be used if the drug is taken at intervals, this will use the formula:
$\Large{\frac{F \cdot D \cdot k_a}{Vd(k_a - k_e)}(\frac{e^{-k_e \cdot t}}{1 - e^{-k_e \cdot \tau}} - \frac{e^{-k_a \cdot t}}{1 - e^{-k_a \cdot \tau}})}$
### Solving Values
Half-lives can be solved if the initial concentration, remaining concentration, and time elapsed are known:
```python
import pharmacokinetics as pk
pk.single_dose.halflifeFromDoses(
dose=15,
dose=9,
elapsed=9
)
```
Where the time elapsed is the time past since the drug has reached maximum concentration and begins the elimination phase, which will then follow the formula $C = e^{-x \cdot 9 \ h}$ where $x$ is the elimination rate constant. Solving for $x$ becomes $\frac{\ln(\frac{9}{15})}{9} = -k_e$ to get half-life we use $\frac{\ln2}{|-k_e|} = 12.2 \ h$.
### Calculating Peak Time
If a drug's absorption and elimination constants are known, the tmax can be calculated:
```python
import pharmacokinetics as pk
pk.calculateTmax(t12=9, t12abs=0.75)
```
The formula to this calculation: $\frac{1}{k_a - k_e} \ln(\frac{ka}{ke}) = \frac{\ln(\frac{k_a}{k_e})}{k_a - k_e} = T_{max}$, which results in a tmax of 2.93 hours.
## Disclaimers
This package uses real formulas, but that does not mean it is free from errors, for example, bugs and typos can result in inaccurate info.<br>
If any bugs or inaccuracies are seen, open an issue so it can be fixed.
## Developers
If you intend to install the edited package, create a wheel file:
```bash
$ pip3 install setuptools # required to build package (skip if already installed)
$ python3 -m build # builds the package to a wheel file
```
To install this, I recommend creating a virtual environment:
```bash
$ python3 -m venv .venv # creates virtual environment
$ source .venv/bin/activate # activates the virtual environment
```
Now use pip install with the file that was just created.<br>
To deactivate the virtual environment:
```bash
$ deactivate
```
### Contributing
Contributions must not break the code or change formulas.<br>
Contributions that can possibly be accepted:
- fixed typos
- fixed bugs
- new formulas (source required)
Raw data
{
"_id": null,
"home_page": "https://github.com/xyzpw/pharmacokinetics-module/",
"name": "pharmacokinetics",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pharmacokinetics, pharmacodynamics, pharmacology, pharmacy, chemistry",
"author": "xyzpw",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/c2/3f/346a474d78c55f3003990fb17351686db303c513cbeb59877c2e66ed4bca/pharmacokinetics-0.1.tar.gz",
"platform": null,
"description": "# pharmacokinetics\n![downloads](https://img.shields.io/pepy/dt/pharmacokinetics) ![repo-size](https://img.shields.io/github/repo-size/xyzpw/pharmacokinetics-module)\n\nThe **pharmacokinetics** package is a Python package designed to make pharmacokinetic formulas easier to calculate in your Python code.\n\n## Usage\nSome functions will use kwargs, which will allow the ability to use alternatives to values, e.g. the parameter `t12` can be used instead of `ke`, which will convert the elimination half-life to the elimination rate constant with the following formula:\n\n$\\Large{\\frac{\\ln2}{t^{1/2}}}$\n\n> [!NOTE]\n> Remember to make sure your units match!\n\n### Calculating Concentrations\nCalculating the concentration remaining after an elapsed time after peak concentration using the formula $C \\cdot e^{-k_et}$:\n```python\nimport pharmacokinetics as pk\npk.single_dose.calculateRemaining(initial_concentration=10, time_elapsed=4, t12=9)\n```\nThe above code will calculate the remaining concentration of a drug that has reached peak concentration 4 hours ago with an elimination half-life of 9 hours.\n\nThe formula to this function:<br>\n$10 \\ mg \\cdot e^{-\\frac{\\ln2}{9 \\ h}4 \\ h}=7.35 \\ mg$\n\nTo calculate the concentration at any time $T$ (oral administration), the usage is:\n```python\nimport pharmacokinetics as pk\npk.concentrationAtTime(\n dose=200,\n vd=0.7,\n bioavailability=0.99,\n t12=4.5,\n t12abs=7/60,\n elapsed=6\n)\n```\nThis above code follows the formula:\n\n$\\frac{F \\cdot D \\cdot k_a}{Vd(k_a - k_e)}(e^{-k_e \\cdot t} - e^{-k_a \\cdot t})$\n\nAlternatively, `interval` can be used if the drug is taken at intervals, this will use the formula:\n\n$\\Large{\\frac{F \\cdot D \\cdot k_a}{Vd(k_a - k_e)}(\\frac{e^{-k_e \\cdot t}}{1 - e^{-k_e \\cdot \\tau}} - \\frac{e^{-k_a \\cdot t}}{1 - e^{-k_a \\cdot \\tau}})}$\n\n### Solving Values\nHalf-lives can be solved if the initial concentration, remaining concentration, and time elapsed are known:\n```python\nimport pharmacokinetics as pk\npk.single_dose.halflifeFromDoses(\n dose=15,\n dose=9,\n elapsed=9\n)\n```\nWhere the time elapsed is the time past since the drug has reached maximum concentration and begins the elimination phase, which will then follow the formula $C = e^{-x \\cdot 9 \\ h}$ where $x$ is the elimination rate constant. Solving for $x$ becomes $\\frac{\\ln(\\frac{9}{15})}{9} = -k_e$ to get half-life we use $\\frac{\\ln2}{|-k_e|} = 12.2 \\ h$.\n\n### Calculating Peak Time\nIf a drug's absorption and elimination constants are known, the tmax can be calculated:\n```python\nimport pharmacokinetics as pk\npk.calculateTmax(t12=9, t12abs=0.75)\n```\nThe formula to this calculation: $\\frac{1}{k_a - k_e} \\ln(\\frac{ka}{ke}) = \\frac{\\ln(\\frac{k_a}{k_e})}{k_a - k_e} = T_{max}$, which results in a tmax of 2.93 hours.\n\n## Disclaimers\nThis package uses real formulas, but that does not mean it is free from errors, for example, bugs and typos can result in inaccurate info.<br>\nIf any bugs or inaccuracies are seen, open an issue so it can be fixed.\n\n## Developers\nIf you intend to install the edited package, create a wheel file:\n```bash\n$ pip3 install setuptools # required to build package (skip if already installed)\n$ python3 -m build # builds the package to a wheel file\n```\nTo install this, I recommend creating a virtual environment:\n```bash\n$ python3 -m venv .venv # creates virtual environment\n$ source .venv/bin/activate # activates the virtual environment\n```\nNow use pip install with the file that was just created.<br>\nTo deactivate the virtual environment:\n```bash\n$ deactivate\n```\n### Contributing\nContributions must not break the code or change formulas.<br>\nContributions that can possibly be accepted:\n- fixed typos\n- fixed bugs\n- new formulas (source required)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python tools for pharmacokinetic calculations.",
"version": "0.1",
"project_urls": {
"Homepage": "https://github.com/xyzpw/pharmacokinetics-module/"
},
"split_keywords": [
"pharmacokinetics",
" pharmacodynamics",
" pharmacology",
" pharmacy",
" chemistry"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e041ccb0fa5982472b2512e1ef0fdbb26ddd08c376bf293e491b38283a4d9733",
"md5": "ee732d51bdf2b909c6c55f2f09cbf371",
"sha256": "da33a19379f9d11e6ce9ae43561f1fe6452dc57475f60bfee8ac77faddc03dee"
},
"downloads": -1,
"filename": "pharmacokinetics-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ee732d51bdf2b909c6c55f2f09cbf371",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9309,
"upload_time": "2024-07-16T15:36:21",
"upload_time_iso_8601": "2024-07-16T15:36:21.187423Z",
"url": "https://files.pythonhosted.org/packages/e0/41/ccb0fa5982472b2512e1ef0fdbb26ddd08c376bf293e491b38283a4d9733/pharmacokinetics-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c23f346a474d78c55f3003990fb17351686db303c513cbeb59877c2e66ed4bca",
"md5": "31a808c0350d80169107f6b09016715d",
"sha256": "356c2e8391351afb719eeb56a8e034d3a6823e0d5c9b44b2f3eddc56512d42ef"
},
"downloads": -1,
"filename": "pharmacokinetics-0.1.tar.gz",
"has_sig": false,
"md5_digest": "31a808c0350d80169107f6b09016715d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7627,
"upload_time": "2024-07-16T15:36:27",
"upload_time_iso_8601": "2024-07-16T15:36:27.372034Z",
"url": "https://files.pythonhosted.org/packages/c2/3f/346a474d78c55f3003990fb17351686db303c513cbeb59877c2e66ed4bca/pharmacokinetics-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-16 15:36:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xyzpw",
"github_project": "pharmacokinetics-module",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pharmacokinetics"
}