diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b8ecc26 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +# .dockerignore +**/__pycache__ +**/*.pyc +**/*.pyo +**/*.pyd +*/*~ +.dockerignore +.git +.gitignore +tests/ +*.log +*.csv +*.json +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8399671 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim-bookworm + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Set work directory in the container +WORKDIR /app + +# Install dependencies +COPY requirements.txt /app/requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt + +# Copy the current directory contents into the container at /app +COPY . /app/ + +# Expose port +EXPOSE 8000 + +# Run the application: +CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index 7df765b..cf92b21 100644 --- a/README.md +++ b/README.md @@ -14,43 +14,108 @@ Repo for querying DITTO predictions for variants using FastAPI. Following are required: - [git](https://git-scm.com/downloads) -- python3.7+ & [python virtual environment](https://docs.python.org/3/tutorial/venv.html) -- pip3 +- python3.7+ +- [Docker](https://www.docker.com/products/docker-desktop) -## How to install +## Installing -Installation simply requires fetching the source code. - -To fetch source code, change in to directory of your choice and run: +*1.* Clone the repository - change in to directory of your choice and run: ```sh git clone https://github.com/uab-cgds-worthey/DITTO-API.git ``` -Change in to root directory and run the command below to install environment: +*2.* Navigate to the project directory ```sh -# Create an environment. Needed only the first time. -python3 -m venv ditto-api-env -source ditto-api-env/bin/activate -pip3 install -r requirements.txt +cd DITTO-API ``` -## How to run +*3.* Build the Docker image + +```sh +docker build -t ditto-api . +``` -Run the below command to activate the API +*4.* Run the Docker container ```sh -cd src -uvicorn main:app --reload +docker run -p 8000:8000 --name ditto-api ditto-api ``` -Test the app using this example as web address - +*5.* Use this link in your browser to retrieve DITTO scores + - and use this variant as example: 1-2406483-C-G +## Expected result + +DITTO will output deleterious score by Ensemble transcript. Below is the output for the above test variant. To verify +the scores, please query the variant in the [DITTO web app](https://cgds-ditto.streamlit.app/). + + +```sh +{ + "scores_by_transcript": { + "ENST00000288774.7": { + "gene": "PEX10", + "consequence": "intron_variant,splice_site_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + }, + "ENST00000447513.6": { + "gene": "PEX10", + "consequence": "intron_variant,splice_site_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + }, + "ENST00000507596.5": { + "gene": "PEX10", + "consequence": "intron_variant,splice_site_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + }, + "ENST00000510434.1": { + "gene": "PEX10", + "consequence": "2kb_downstream_variant,NMD_transcript_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + }, + "ENST00000378513.7": { + "gene": "RER1", + "consequence": "2kb_downstream_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + }, + "ENST00000605895.6": { + "gene": "RER1", + "consequence": "2kb_downstream_variant", + "chrom": "chr1", + "pos": "2406483", + "ref_base": "C", + "alt_base": "G", + "DITTO": "1.0" + } + } +} +``` + ## Contributing We welcome contributions! [See the docs for guidelines](./CONTRIBUTING.md). @@ -60,6 +125,6 @@ We welcome contributions! [See the docs for guidelines](./CONTRIBUTING.md). For issues, please send an email with clear description to |Name | Email | -------|--------| -Tarun Mamidi | -Brandon Wilk | +|------|--------| +|Tarun Mamidi | | +|Brandon Wilk | | diff --git a/src/main.py b/src/main.py index 6df1f41..b077693 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,5 @@ from fastapi import FastAPI -from utils.query import get_ditto_score, query_variant -import json +from .utils.query import get_ditto_score, query_variant # run me https://fastapi.tiangolo.com/#installation app = FastAPI() diff --git a/src/utils/query.py b/src/utils/query.py index cb7d58e..d97945b 100644 --- a/src/utils/query.py +++ b/src/utils/query.py @@ -1,8 +1,8 @@ import yaml import requests import json -from utils.parse import OCApiParser -from utils.predict import parse_and_predict +from .parse import OCApiParser +from .predict import parse_and_predict from tensorflow import keras from pathlib import Path