drug-simulator is a program designed to simulate drug concentrations in real time using user-prompted values.
![](https://private-user-images.githubusercontent.com/76017734/356851157-b872064c-1b9d-4672-b9b1-14f071c28b62.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4NDE3NzIsIm5iZiI6MTcyNTg0MTQ3MiwicGF0aCI6Ii83NjAxNzczNC8zNTY4NTExNTctYjg3MjA2NGMtMWI5ZC00NjcyLWI5YjEtMTRmMDcxYzI4YjYyLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA5VDAwMjQzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRjMGQwZjBiMGQxMjJjNzY4M2I2ZWU4OGI0YTg5NWNjYTFkZmQ0YzQwZTdhZDM4MGMxNzYyODU0MzI3NjU0MjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FUD41GWRMOtPad2YRvh87jIecBjSsbj8SA3av07PbEM)
The program prompts for values which will be used to calculate and display drug concentrations in real time to the terminal.
Several options can be used which effect these results, such as route of administration.
Executing the script:
$ python3 drug-simulator.py
Or add execution perms:
$ chmod +x drug-simulator.py
Which will allow you to run it via:
$ ./drug-simulator.py
Run help to see additional usage:
$ ./drug-simulator.py --help
Upon running the script, required values will be prompted for input. Given that the script was run without additional arguments, the simulation assumes IV bolus, which will prompt the following values:
dose:
half-life:
The default time unit is seconds, to change this, type in the unit after the time digit, e.g. "9 hours" or "9h" for 9 hours.
Dose units can also be used.
The simulation will begin upon entering the last required value.
Different routes of administration can be simulated with the roa
argument:
$ ./drug-simulator.py --roa route
IV bolus will be used by default.
Changing the route of administration will also alter the values required to begin the simulation.
In this case, the following prompts will be displayed:
dose:
bioavailability:
absorption half-life:
half-life:
Delayed release drugs can be simulated where a specific fraction of the drug is released instantly and some time before the next dose. For example, Adderall XR has 50% of the beads release instantly, and the other half is intended to release 4 hours later.
$ ./drug-simulator.py --roa oral-dr --dr 4h --irfrac 0.5 --msg "adderall xr"
Additionally, dr-max
can be used to display the highest concentration achieved since the simulation has started:
$ ./drug-simulator.py --roa oral-dr --dr 4h --irfrac 0.5 --dr-max
Prodrug/active drug concentrations can be estimated using oral route of administration:
$ ./drug-simulator.py --roa oral-prodrug -f 0.964 --prodrug 0.297 --msg vyvanse
Note
The active drug concentration are estimates and not precise!
The lagtime feature can be used to start a countdown before the absorption phase begins, this can account for the time it takes a drug to reach the systemic circulation, e.g. pill ingesting.
For example, water takes 2–5 minutes to reach plasma after ingestion.
$ ./drug-simulator.py --roa oral --dose "80 mg" --lagtime 2m --msg "caffeine from coffee"
The simulation can be started assuming administration occurred prior to the simulation commencement.
Start at a specific time:
$ ./drug-simulator.py --time 0554
$ ./drug-simulator.py --time "5:54 am"
Administration at a specific date:
$ ./drug-simulator.py --date "20240808 1922"
$ ./drug-simulator.py --date "08/08/2024 7:22 pm"
Elapsed time since administration:
# 72 hours post-dose
$ ./drug-simulator.py --elapsed 7200
These options will take into account lagtime
if it is used.
Custom messages can be used, for example, if you have multiple simulations running and want to keep track of each:
$ ./drug-simulator.py --msg "anything can go here"
Pharmacokinetic information can be stored in a json file to prevent user-input prompts:
$ ./drug-simulator.py --file pharmacokinetic_example
Tip
".json" is optional
For any typos, bugs, or inaccuracies found, report this in issues.
Code contributions might be accepted if they do not include:
- changes to formulas
- major changes
- changes to usage
https://en.wikipedia.org/wiki/Pharmacokinetics
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3351614/