#################################################################
# Dockerfile
#
# Software:         AltAnalyze
# Software Version: v0.0.7
# Description:      An automated cross-platform workflow for
#                   RNA-Seq gene, splicing and pathway analysis
# Website:          http://www.altanalyze.org
# Provides:         AltAnalyze (64f77a77fb3c947bd5eaaaf759bfac2ab0a1b498)
# Base Image:       python:2.7
# Build Cmd:        docker build --rm -t biowardrobe2/altanalyze:v0.0.7 -f altanalyze-Dockerfile .
# Pull Cmd:         docker pull biowardrobe2/altanalyze:v0.0.7
# Run Cmd:          docker run --rm -ti biowardrobe2/altanalyze:v0.0.7 /bin/bash
#################################################################
#
# v0.0.7
# - Update AltAnalyze to the latest version
# - Change BiocManager version to 1.30.18
# - Install Hs and Mm genomes
# - Do not install monocle
# - Change maintainer to myself
#
#################################################################


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

WORKDIR /tmp

ENV ALTA_VERSION "64f77a77fb3c947bd5eaaaf759bfac2ab0a1b498"
ENV ALTA_URL "https://github.com/nsalomonis/altanalyze.git"

ENV BIOC_VERSION 1.30.18
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 vim && \
### 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('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 && \
### Installing set of commonly used genomes
    python AltAnalyze.py --species Hs --update Official --version EnsMart100 --additional all && \
    python AltAnalyze.py --species Mm --update Official --version EnsMart72 --additional all && \
### Cleaning
    apt-get clean && \
    apt-get purge && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && \
    strip /usr/local/bin/*; true