#################################################################
# Dockerfile
#
# Software:         RSEM  [BOWTIE  BOWTIE2  STAR    R      ]
# Software Version: 1.3.0 [1.2.0   2.3.0    2.5.3a  3.2.3-4]
# Description:      RSEM toolkit for BioWardrobe
# Website:          http://deweylab.github.io/RSEM/README.html
#                   http://bowtie-bio.sourceforge.net/index.shtml
#                   http://bowtie-bio.sourceforge.net/bowtie2/index.shtml
#                   https://github.com/alexdobin/STAR
#                   https://scidap.com/
# Provides:         rsem, STAR, bowtie, bowtie2
# Base Image:       biowardrobe2/scidap:v0.0.2
# Build Cmd:        docker build --rm -t biowardrobe2/rsem:v1.3.0 -f rsem-Dockerfile .
# Pull Cmd:         docker pull biowardrobe2/rsem:v1.3.0
# Run Cmd:          docker run --rm -ti biowardrobe2/rsem:v1.3.0 rsem-calculate-expression --help
#################################################################

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

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

WORKDIR /tmp

ENV VERSION_RSEM 1.3.0
ENV URL_RSEM "https://github.com/deweylab/rsem/archive/v${VERSION_RSEM}.tar.gz"

ENV VERSION_STAR 2.5.3a
ENV URL_STAR "https://github.com/alexdobin/STAR/archive/${VERSION_STAR}.tar.gz"

ENV VERSION_BOWTIE 1.2.0
ENV URL_BOWTIE "https://github.com/BenLangmead/bowtie/archive/v${VERSION_BOWTIE}.tar.gz"

ENV VERSION_BOWTIE2 2.3.0
ENV URL_BOWTIE2 "https://github.com/BenLangmead/bowtie2/archive/v${VERSION_BOWTIE2}.tar.gz"

ENV VERSION_R 3.2.3-4



### Installing STAR

RUN wget -q -O - $URL_STAR | tar -zxv && \
    cd STAR-${VERSION_STAR}/source && \
    make -j 4 && \
    cd .. && \
    cp ./bin/Linux_x86_64_static/STAR /usr/local/bin/ && \
    cd .. && \
    rm -rf ./STAR-${VERSION_STAR} && \

### Installing libtbb for bowtie & bowtie2, perl-doc for RSEM
    apt-get update && apt-get install -y libtbb-dev && apt-get install -y perl-doc && \

### Installing bowtie

    wget -q -O - $URL_BOWTIE | tar -zxv && \
    cd bowtie-${VERSION_BOWTIE} && \
    make -j 4 && \
    cd .. && \
    cp ./bowtie-${VERSION_BOWTIE}/bowtie /usr/local/bin/ && \
    cp ./bowtie-${VERSION_BOWTIE}/bowtie-* /usr/local/bin/ && \
    rm -rf ./bowtie-${VERSION_BOWTIE} && \

### Installing bowtie2

    wget -q -O - $URL_BOWTIE2 | tar -zxv && \
    cd bowtie2-${VERSION_BOWTIE2} && \
    make -j 4 && \
    cd .. && \
    cp ./bowtie2-${VERSION_BOWTIE2}/bowtie2 /usr/local/bin/ && \
    cp ./bowtie2-${VERSION_BOWTIE2}/bowtie2-* /usr/local/bin/ && \
    rm -rf ./bowtie2-${VERSION_BOWTIE2} && \

### Installing R

    apt-get -y install r-base="${VERSION_R}" && \

### Installing RSEM

    wget -q -O - $URL_RSEM | tar -zxv && \
    cd RSEM-${VERSION_RSEM} && \
    make -j 4 && \
    make install && \
    make ebseq && \
    cp rsem-generate-ngvector rsem-run-ebseq rsem-control-fdr /usr/local/bin && \
    cd .. && \
    rm -rf ./RSEM-${VERSION_RSEM} && \

    strip /usr/local/bin/*; true
