Skip to content

Commit

Permalink
Merge branch 'master' into update-login-page-logos
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaell committed Jul 30, 2021
2 parents 7483be3 + 10d07fb commit dbc8ca2
Show file tree
Hide file tree
Showing 21 changed files with 405 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Expand Up @@ -17,6 +17,6 @@ tests
scripts

# Docker
Dockerfile
docker-compose.yml
Dockerfile*
docker-compose.*yml
volumes
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- API returning case data for a given institute: `/api/v1/institutes/<institute_id>/cases`
- Added GMS and Lund university hospital to login page
- Made display of Swedac logo configurable
- Support for displaying custom images in case view

### Fixed
- Updated IGV to v2.8.5 to solve missing gene labels on some zoom levels
Expand Down
65 changes: 51 additions & 14 deletions Dockerfile
@@ -1,24 +1,61 @@
FROM python:3.8-alpine3.12
###########
# BUILDER #
###########
FROM python:3.8.1-slim as builder

LABEL base_image="python:3.8-alpine3.12"
WORKDIR /usr/src/app

# Set build variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends autoconf automake \
build-essential gcc libbz2-dev libcairo2 libcurl4-gnutls-dev \
libffi-dev libgdk-pixbuf2.0-0 liblzma-dev libpango-1.0-0 \
libpangocairo-1.0-0 libssl-dev make python3-cffi python3-dev \
python3-pip python3-wheel shared-mime-info zlib1g-dev \
openssl ca-certificates gcc wget git

# Copy app
COPY . /usr/src/app
RUN pip install --upgrade pip && \
pip wheel --no-cache-dir --no-deps \
--wheel-dir /usr/src/app/wheels \
Cython gunicorn && \
pip wheel --no-cache-dir \
--wheel-dir /usr/src/app/wheels \
--editable .[coverage]


#########
# FINAL #
#########

FROM python:3.8.1-slim

LABEL base_image="python:3.8.1-slim"
LABEL about.home="https://github.com/Clinical-Genomics/scout"
LABEL about.documentation="https://clinical-genomics.github.io/scout"
LABEL about.tags="WGS,WES,Rare diseases,VCF,variants,SNP,Next generation sequencing"
LABEL about.license="MIT License (MIT)"

# Install required libs
RUN apk update
RUN apk --no-cache add make automake gcc g++ linux-headers libffi-dev zlib-dev \
jpeg-dev libressl-dev cairo-dev pango-dev gdk-pixbuf ttf-freefont bash
RUN pip install numpy Cython

# Run app on non-root user
RUN useradd -m worker && mkdir -p /home/worker/app
WORKDIR /home/worker/app
COPY . /home/worker/app

# Install scout app
RUN pip install -e .
# Copy pyhon wheels and install scout
COPY --from=builder /usr/src/app/wheels /wheels
RUN apt-get update && \
apt-get install -y libgdk-pixbuf2.0-0 libpango-1.0-0 \
libcairo2 libpangocairo-1.0-0 ssh sshfs && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir /wheels/* && \
rm -rf /var/lib/apt/lists/* /wheels

COPY . /home/worker/app

# Run commands as non-root user
RUN adduser -D worker
RUN chown worker:worker -R /home/worker
# Run app on non-root user
RUN chown -R worker:worker /home/worker/app
USER worker
97 changes: 97 additions & 0 deletions containers/development/docker-compose-chanjo-report.yml
@@ -0,0 +1,97 @@
# Docker-compose file containing Scout demo and a running chanjo-report instance
# 1) Move this file under scout/
# 2) edit scout config file and add these lines:
# SQLALCHEMY_DATABASE_URI = "mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test" ?
# REPORT_LANGUAGE = "en" # or 'sv'
version: '3'
# usage:
# (sudo) docker-compose up -d
# (sudo) docker-compose down
services:
# mongodb is used by Scout
mongodb:
image: mvertes/alpine-mongo
container_name: mongodb
ports:
- '27013:27017'
expose:
- '27017'
networks:
- custom-net

# MariaDB is used by Chanjo
mariadb:
container_name: mariadb
image: mariadb:latest
restart: 'always'
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=chanjo4_test
- MYSQL_USER=chanjoUser
- MYSQL_PASSWORD=chanjoPassword
healthcheck: # Wait for the service to be ready before accepting incoming connections
test: "mysql --user=chanjoUser --password=chanjoPassword --execute \"SHOW DATABASES;\""
timeout: 10s
retries: 20
networks:
- custom-net

# Set up chanjo database and load some demo data
chanjo-cli:
container_name: chanjo-cli
image: clinicalgenomics/chanjo
depends_on:
mariadb:
condition: service_healthy # DB_URI=mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test
networks:
- custom-net
command: bash -c "
chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test db setup --reset
&& chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test init --auto demodata
&& chanjo --config demodata/chanjo.yaml link demodata/hgnc.grch37p13.exons.bed
&& chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test load -n sample1 --group-name test_group -g test_group chanjo/init/demo-files/sample1.coverage.bed
&& chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test load -n sample2 --group-name test_group -g test_group chanjo/init/demo-files/sample2.coverage.bed
&& chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test load -n sample3 --group-name test_group -g test_group chanjo/init/demo-files/sample3.coverage.bed"

# Start the chanjo-report app
chanjo-report:
container_name: chanjo-report
expose:
- '5000'
ports:
- '4000:5000'
image: clinicalgenomics/chanjo-report
depends_on:
- mariadb
- chanjo-cli
networks:
- custom-net
entrypoint: sh -c "chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo4_test report --render html"

# Start the scout app containing demo data
scout-web:
image: clinicalgenomics/scout:latest
container_name: scout-web
expose:
- '5000'
ports:
- '5000:5000'
command: bash -c "
scout --host mongodb setup demo
&& scout --host mongodb --demo serve --host 0.0.0.0"
volumes:
- ./scout:/home/worker/app/scout
- ./volumes/scout/data:/home/worker/data
depends_on:
- mongodb
- chanjo-report
networks:
- custom-net

networks:
custom-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.21.0.0/24
56 changes: 54 additions & 2 deletions docker-compose.yml
Expand Up @@ -35,19 +35,71 @@ services:
- '5000'
ports:
- '5000:5000'
command: scout --host mongodb --demo serve --host 0.0.0.0
environment:
- SCOUT_CONFIG=/home/worker/app/scout/server/config.py
command: gunicorn --bind 0.0.0.0:5000 scout.server.auto:app
volumes:
- ./scout:/home/worker/app/scout
- ./volumes/scout/data:/home/worker/data
networks:
- scout-net
depends_on:
- mongodb
- mariadb

mariadb:
image: mariadb:latest
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=chanjoUser
- MYSQL_PASSWORD=chanjoPassword
- MYSQL_DATABASE=chanjo
volumes:
- ./volumes/mariadb/data:/var/lib/mysql
healthcheck: # Wait for the service to be ready before accepting incoming connections
test: "mysql --user=chanjoUser --password=chanjoPassword --execute \"SHOW DATABASES;\""
timeout: 10s
retries: 20
networks:
- scout-net
restart: unless-stopped

chanjo-cli:
build: chanjo
environment:
- SQLALCHEMY_DATABASE_URI=mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo
depends_on:
- mariadb
volumes:
- ./volumes/chanjo:/data
- ./chanjo/chanjo:/home/worker/app/chanjo
networks:
- scout-net
restart: unless-stopped

chanjo-report:
build: chanjo-report
environment:
- SQLALCHEMY_DATABASE_URI=mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo
expose:
- '5000'
ports:
- '4000:5000'
volumes:
- ./volumes/chanjo:/data
- ./chanjo-report/chanjo_report:/home/worker/app/chanjo_report
depends_on:
- mariadb
- chanjo-cli
networks:
- scout-net
command: sh -c "chanjo -d mysql+pymysql://chanjoUser:chanjoPassword@mariadb/chanjo report --render html"
restart: unless-stopped

networks:
scout-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.21.0.0/24
- subnet: 172.30.0.0/24
26 changes: 26 additions & 0 deletions docs/admin-guide/loading.md
Expand Up @@ -86,6 +86,32 @@ human_genome_build: 37

```

#### Adding custom images to a case

Scout can display custom images as new panels on the case view which could be used to display analysis results from a seperate pipeline. The custom images are defined in the case config file and stored in the database. Scout currently supports `gif`, `jpeg`, `png` and `svg` images.

One or more images constitute a group and are rendered together in a accordion-type UI elemment named after the group. The fields `title`, `description` and `path` are mandatory. The image size can be defined with the optional parameters `widht` and `height`. If you dont specify a unit its going to default to use pixels as unit. *Note*: adding images larger than 16mb are not reccomended as it might degrade the performance.

``` yaml

custom_images:
group_one:
- title: <string> title of image [mandatory]
description: <string> replacement description of image [mandatory]
width: <string> 500px
height: <string> 100px
path: <string> scout/demo/images/custom_images/640x480_one.png [mandatory]
- title: <string> A jpg image [mandatory]
description: <string> A very good description [mandatory]
width: <string> 500px
path: <string> scout/demo/images/custom_images/640x480_two.jpg [mandatory]
group_two:
- title: <string> A SVG image [mandatory]
description: <string> Another very good description
path: <string> scout/demo/images/custom_images/640x480_three.svg [mandatory]

```

### Load case from CLI without config

Cases can be loaded without config file, in that case the user needs to specify a ped file and optionally one or several VCF files. An example could look like
Expand Down
1 change: 1 addition & 0 deletions scout/adapter/mongo/case.py
Expand Up @@ -753,6 +753,7 @@ def update_case(self, case_obj, keep_date=False):
"analysis_date": case_obj["analysis_date"],
"chromograph_image_files": case_obj.get("chromograph_image_files"),
"chromograph_prefixes": case_obj.get("chromograph_prefixes"),
"custom_images": case_obj.get("custom_images"),
"cnv_report": case_obj.get("cnv_report"),
"coverage_qc_report": case_obj.get("coverage_qc_report"),
"delivery_report": case_obj.get("delivery_report"),
Expand Down
2 changes: 2 additions & 0 deletions scout/build/case.py
Expand Up @@ -255,6 +255,8 @@ def build_case(case_data, adapter):
case_obj["chromograph_image_files"] = case_data.get("chromograph_image_files")
case_obj["chromograph_prefixes"] = case_data.get("chromograph_prefixes")

case_obj["custom_images"] = case_data.get("custom_images", {})

for custom_report in CUSTOM_CASE_REPORTS:
if custom_report in case_data:
case_obj[custom_report] = case_data.get(custom_report)
Expand Down
16 changes: 16 additions & 0 deletions scout/demo/643594.config.yaml
Expand Up @@ -62,6 +62,22 @@ samples:
mt_bam: scout/demo/reduced_mt.bam
vcf2cytosure: scout/demo/ADM1059A3.test.cgh

custom_images:
section_one:
- title: A png image
description: A very good description
width: 500
height: 100
path: scout/demo/images/custom_images/640x480_one.png
- title: A jpg image
description: A very good description
width: 500
path: scout/demo/images/custom_images/640x480_two.jpg
section_two:
- title: A SVG image
description: Another very good description
path: scout/demo/images/custom_images/640x480_three.svg

vcf_snv: scout/demo/643594.clinical.vcf.gz
vcf_sv: scout/demo/643594.clinical.SV.vcf.gz
vcf_str: scout/demo/643594.clinical.str.stranger.vcf.gz
Expand Down
Binary file added scout/demo/images/custom_images/640x480_one.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scout/demo/images/custom_images/640x480_three.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scout/demo/images/custom_images/640x480_two.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dbc8ca2

Please sign in to comment.