/pkpdapp

A web application for modeling the distribution and effects of drugs.

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

PKPDApp logo

Unit tests on multiple python versions Unit tests on multiple operating systems codecov

PKPDApp

PKPDApp is an open source web-based application to explore, analyse and model the pharmacokinetics and pharmacodynamics of chemical compounds. The app is currently under heavy development, however a preliminary version is being deployed with Heroku and can be found under https://pkpdapp.herokuapp.com/.

Installation - development

If you are interested in developing PKPDApp with us, or just run the app locally, you can clone the repository and follow the installation instructions below.

Django backend

  1. Install sundials, python dev libraries and rabbitmq server

    • Ubuntu-latest:
    apt-get install libsundials-dev python3-dev rabbitmq-server

    Note: if you are in WSL then the rabbitmq server will not automatically start, you can start it manually using sudo -u rabbitmq rabbitmq-server

    • MacOS-latest:
    brew install sundials rabbitmq

    Note: to restart rabbitmq after an upgrade: brew services restart rabbitmq

    • Windows-latest: Sundials will be installed automatically by installing the app.
  2. Set environment variables

  • Edit the .env file in the root of the repository and edit the following environment variables to correspond to your particular setup. The most important variables to alter are those corresponding to secret keys and passwords, others you can probably leave as-is.
  1. Install requirements
  • Create a new virtual environment (optional) then install the requirements
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
  1. Create database
cd pkpdapp
python manage.py migrate
  1. Run RabbitMQ
celery -A pkpdapp worker --loglevel=INFO
  1. Run local server
python manage.py runserver
  1. (Optional) Create admin user
python manage.py createsuperuser

React frontend

Running the frontend will require a local installation of Node.js. On Ubuntu 20.04 LTS, for example, you can install using snap

sudo snap install node --classic

It is also useful to install the yarn package manager

npm install --global yarn

Navigate to the frontend/ directory and install the Node.js dependencies

cd frontend
yarn install

You can run the frontend using

yarn start

You should be able to see the pkpd web app at 127.0.0.1:3000.

Installation - production

Alternatively you can build a docker image and run the image inside the container with commands below.

$ docker-compose build
$ docker-compose up

You should be able to see the web application at 127.0.0.1.

Code testing

We run a range of tests each time a commit is pushed to an open pull request using Github Actions. Passing these tests is prerequisite for merging a pull request. Some of these can be run locally as described below:

  • copyright tests: python run-tests.py --copyright
  • code style: flake8
  • unit tests: python manage.py test runs everything; to run a single test in a file (say) called test_models.py use python manage.py test pkpdapp.tests.test_models
  • code coverage tests: can't be done locally

Running the cache

Install the cache using

$ sudo apt install memcached

Run memcached using

$ memcached -p 11211

License

PKPDApp is fully open source. For more information about its license, see LICENSE.md.