Skip to content

Commit

Permalink
Merge pull request #2 from uab-cgds-worthey/docker
Browse files Browse the repository at this point in the history
Docker version
  • Loading branch information
tkmamidi authored Feb 8, 2024
2 parents f393450 + e916d61 commit 998aaff
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 24 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .dockerignore
**/__pycache__
**/*.pyc
**/*.pyo
**/*.pyd
*/*~
.dockerignore
.git
.gitignore
tests/
*.log
*.csv
*.json
*.md
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
105 changes: 85 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- markdown-link-check-disable -->
<http://localhost:8000/docs>
<!-- markdown-link-check-enable -->
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/).
<!-- markdown-link-check-enable -->

```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).
Expand All @@ -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 | <[email protected]>
Brandon Wilk | <[email protected]>
|------|--------|
|Tarun Mamidi | <[email protected]>|
|Brandon Wilk | <[email protected]>|
3 changes: 1 addition & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/utils/query.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 998aaff

Please sign in to comment.