An API to compute and serve predictions of biomedical concepts associations via OpenAPI for the NCATS Translator project
Project description
Translator OpenPredict 🔮🐍 is an API to compute and serve predicted biomedical concepts associations, for the NCATS Translator project.
This service has been built from the fair-workflows/openpredict project.
Use the API 🌐
The Translator OpenPredict API serves predictions of biomedical concepts associations (e.g. disease treated by drug).
Feel free to try it at openpredict.137.120.31.102.nip.io
How to use it
The user provides a drug 💊 or a disease 🦠 identifier as a CURIE (e.g. DRUGBANK:DB00394, OMIM:246300), and choose a prediction model (only OMIM - DrugBank at the moment).
- The
/predict
call will return the list of predicted target for this entity, the labels are resolved using the Translator Name Resolver API:
{
"count": 300,
"relation": "biolink:treated_by",
"results": [
{
"score": 0.8361061489249737,
"source": {
"id": "DRUGBANK:DB00394",
"label": "beclomethasone dipropionate",
"type": "drug"
},
"target": {
"id": "OMIM:246300",
"label": "leprosy, susceptibility to, 3",
"type": "disease"
}
}
]
}
Try it at https://openpredict.137.120.31.102.nip.io/predict?entity=DRUGBANK:DB00394
- The
/query
call will return the same predictions in the ReasonerAPI format, based on a ReasonerAPI query - The
/predicates
call will return the entities and relations returned by this API (following the ReasonerAPI specifications)
Notebook example
You can find a Jupyter Notebook with examples to query the API on GitHub
Deploy your API 📦
You can also use our tools to build new classifiers, and deploy your OpenPredict API
Install OpenPredict 📥
You might want to use a virtual environment for Python 3.7 to isolate the installation:
# Create the virtual environment in your workspace
python3 -m venv .venv
# Activate it
source .venv/bin/activate
Install the latest release published on PyPI 🏷️ (or see below to run the API with Docker)
pip3 install openpredict
Package available on PyPI: https://pypi.org/project/openpredict
Train the model 🚅
Run the pipeline to train the model used by the OpenPredict API.
From a Python script:
from openpredict.openpredict_omim_drugbank import train_drug_disease_classifier
train_drug_disease_classifier()
Or using the command line:
openpredict train-model
Work in progress
model_factory =
Run the API ⚙️
The API can be run different ways:
Option 1: Run from the command line
Use the openpredict
CLI to start the API using the built classifiers:
openpredict start-api
Access the Swagger UI at http://localhost:8808
Provide the port as arguments:
openpredict start-api --port 8808
Option 2: Run from a Python script
from openpredict import openpredict_api
debug = False
openpredict_api.start_api(8808, debug)
Access the Swagger UI at http://localhost:8808
Run by default in production, set
debug = True
to run in development environments.
Option 3: Run with Docker
Running using Docker can be convenient if you just want to run the API without installing the package locally, or if it runs in production alongside other services.
Clone the repository:
git clone https://github.com/MaastrichtU-IDS/translator-openpredict.git
cd translator-openpredict
Build and start the openpredict-api
container with docker-compose 🐳
docker-compose up -d
Access the Swagger UI at http://localhost:8808
We use nginx-proxy and docker-letsencrypt-nginx-proxy-companion as reverse proxy for HTTP and HTTPS in production. You can change the proxy URL and port via environment variables
VIRTUAL_HOST
,VIRTUAL_PORT
andLETSENCRYPT_HOST
in the docker-compose.yml file.
Check the logs:
docker-compose logs
Stop the container:
docker-compose down
See also 👀
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for openpredict-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6ed30dfd2a7e7a4b32215ba5084439960993fbefcb0fe39aeb903722a79934 |
|
MD5 | 10edfea766a74aa2336313e8ae66f5a3 |
|
BLAKE2b-256 | 6ecc6b9396b6a6fe46218cacf22a8fa53a3ae2e7c977f4083c5faae1fb8671ee |