#################################################################
# Dockerfile
#
# Software:         DESeq, DESeq2
# Software Version: 1.22.1 1.10.1
# Description:      R package to run differential analysis
# Website:          https://www.bioconductor.org/packages/3.2/bioc/html/DESeq.html
#                   https://www.bioconductor.org/packages/3.2/bioc/html/DESeq2.html
# Provides:         DESeq, DESeq2
# Base Image:       biowardrobe2/scidap-addons:v0.0.6
# Build Cmd:        docker build --rm -t biowardrobe2/deseq:v0.0.1 -f deseq-Dockerfile .
# Pull Cmd:         docker pull biowardrobe2/deseq:v0.0.1
# Run Cmd:          docker run --rm -ti biowardrobe2/deseq:v0.0.1
#################################################################
# DESeq and DESeq2 versions depend on Bioconductor version.
# For biowardrobe2/scidap-addons:v0.0.6 Bioconductor 3.2 is used,
# so there is no way to set version for DESeq other than 1.22.1 and
# for DESeq2 other than 1.10.1.
# Latest RcppArmadillo (DeSeq2 dependency) requires R >= 3.3.0,
# so 0.6.500.4.0 version is used instead.
#################################################################


### Base Image
FROM biowardrobe2/scidap-addons:v0.0.6
MAINTAINER Michael Kotliar "misha.kotliar@gmail.com"
ENV DEBIAN_FRONTEND noninteractive


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

WORKDIR /tmp

ENV VERSION_RCPPARMADILLO 0.6.500.4.0
ENV URL_RCPPARMADILLO "https://cran.r-project.org/src/contrib/Archive/RcppArmadillo/RcppArmadillo_${VERSION_RCPPARMADILLO}.tar.gz"

COPY ./scripts/install_from_source.R /tmp/install_from_source.R
COPY ./scripts/install_from_bioconductor.R /tmp/install_from_bioconductor.R

### Installing dependencies
RUN apt-get update && \
    apt-get install libxml2-dev -y && \

### Installing RcppArmadillo from source
    Rscript /tmp/install_from_source.R "${URL_RCPPARMADILLO}" && \

### Installing DeSeq & DeSeq2 packages from Bioconductor
    Rscript /tmp/install_from_bioconductor.R DESeq && \
    Rscript /tmp/install_from_bioconductor.R DESeq2 && \

### Cleaning
    apt-get clean && \
    apt-get purge && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && \
    strip /usr/local/bin/*; true
