#################################################################
# Dockerfile
#
# Software:         GSEApy
# Software Version: v0.0.6
# Description:      Gene Set Enrichment Analysis in Python
# Website:          https://gseapy.readthedocs.io/en/latest/index.html
# Provides:         GSEApy 0.9.18 (modified: works without Internet)
# Base Image:       python:3.7
# Build Cmd:        docker build --no-cache --rm -t biowardrobe2/gseapy:v0.0.6 -f gseapy-Dockerfile .
# Pull Cmd:         docker pull biowardrobe2/gseapy:v0.0.6
# Run Cmd:          docker run --rm -ti biowardrobe2/gseapy:v0.0.6 /bin/bash
#################################################################
#
# v0.0.6
# - support GCT v1.3 as input
#
# v0.0.5
# - updated to the latest msigdb 2022.1.Hs release
# - added new genesets
#   KEGG_2021_Human
#   Reactome_2022
#   WikiPathways_2019_Human
#
# v0.0.4
# CLS file now can be both space and tab delimited
# 
# v0.0.3
# download only gene sets from original GSEA
# 
#################################################################


### Base Image
FROM python:3.7
LABEL maintainer="misha.kotliar@gmail.com"
ENV DEBIAN_FRONTEND noninteractive

################## BEGIN INSTALLATION ######################

WORKDIR /tmp

ENV COMMIT_GSEAPY "88af566f4148cda61d7269b654ba8776ff67a188"
ENV URL_GSEAPY "https://github.com/michael-kotliar/GSEApy.git"

COPY ./scripts/gseapy_download_datasets.py /tmp/gseapy_download_datasets.py
COPY ./scripts/gsea_download_datasets.sh /tmp/gsea_download_datasets.sh

### Installing GSEApy
RUN pip install tqdm && \
    git clone ${URL_GSEAPY} && \
    cd GSEApy && \
    git checkout ${COMMIT_GSEAPY} && \
    pip install . && \
    cd .. && \
### Downloading genesets
    mkdir /opt/gseapy/ && \
    cd /opt/gseapy/ && \
    chmod +x /tmp/gsea_download_datasets.sh && \
    /tmp/gsea_download_datasets.sh && \
    python3 /tmp/gseapy_download_datasets.py --libraries KEGG_2021_Human Reactome_2022 WikiPathways_2019_Human --names KEGG_2021_Human Reactome_2022 WikiPathways_2019_Human && \
    cd /tmp && \
### Cleaning
    apt-get clean && \
    apt-get purge && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && \
    strip /usr/local/bin/*; true