#################################################################
# Dockerfile
#
# Software:         AltAnalyze
# Software Version: v0.0.6
# Description:      An automated cross-platform workflow for
#                   RNA-Seq gene, splicing and pathway analysis
# Website:          http://www.altanalyze.org
# Provides:         AltAnalyze (ef5eb90215ea0d40327d8d92380abfcde19ab98e)
# Base Image:       python:2.7
# Build Cmd:        docker build --rm -t biowardrobe2/altanalyze:v0.0.6 -f altanalyze-Dockerfile .
# Pull Cmd:         docker pull biowardrobe2/altanalyze:v0.0.6
# Run Cmd:          docker run --rm -ti biowardrobe2/altanalyze:v0.0.6 /bin/bash
#################################################################


FROM python:2.7
LABEL maintainer="haysb91@gmail.com"
ENV DEBIAN_FRONTEND noninteractive

WORKDIR /tmp

ENV ALTA_VERSION "77957cd1a59ace5d8a144ce517c8013b4081640e"
ENV ALTA_URL "https://github.com/nsalomonis/altanalyze.git"

ENV BIOC_VERSION 1.30.16
ENV BIOC_URL "https://cran.r-project.org/src/contrib/BiocManager_${BIOC_VERSION}.tar.gz"

COPY ./requirements/altanalyze_requirements.txt altanalyze_requirements.txt
COPY ./scripts/install_from_source.R /tmp/install_from_source.R


### Installing Ubuntu packages
RUN apt-get update && \
    apt-get install -y libcairo2-dev pkg-config r-base && \
### Installing Python packages
    pip install -r altanalyze_requirements.txt && \
### Installing R packages
    Rscript /tmp/install_from_source.R "${BIOC_URL}" && \
    R -e "BiocManager::install(c('monocle'))" && \
    R -e "BiocManager::install(c('affy'))" && \
    R -e "BiocManager::install(c('gcrma'))" && \
    R -e "BiocManager::install(c('sva'))" && \
    R -e "BiocManager::install(c('Biobase'))" && \
    R -e "BiocManager::install(c('hopach'))" && \
    R -e "BiocManager::install(c('jtk-cycle'))" && \
### Installing AltAnalyze (remove .git to make AltAnalyze smaller)
    cd /opt && \
    git clone ${ALTA_URL} && \
    cd altanalyze && \
    git checkout ${ALTA_VERSION} && \
    rm -rf .git && \
### Cleaning
    apt-get clean && \
    apt-get purge && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && \
    strip /usr/local/bin/*; true