##########################################################################################################
# Dockerfile
#
# Software:         Cell Ranger ARC
# Software Version: v0.0.1
# Description:      Dockerized version of Cell Ranger ARC
# Website:          https://github.com/Barski-lab/workflows
# Provides:         Cell Ranger ARC
# Base Image:       cumulusprod/cellranger-arc:2.0.2
# Build Cmd:        docker build --platform linux/amd64 --no-cache --rm -t biowardrobe2/cellranger-arc:v0.0.1 -f cellranger-arc-Dockerfile .
# Pull Cmd:         docker pull --platform linux/amd64 biowardrobe2/cellranger-arc:v0.0.1
# Run Cmd:          docker run --platform linux/amd64 --rm -ti biowardrobe2/cellranger-arc:v0.0.1 /bin/bash
##########################################################################################################
#
# v0.0.1 -- based on cumulusprod/cellranger-arc:2.0.2
# - Need to patch mkref file, because
#   os.access(output_parent_dir, os.W_OK) sometimes
#   returns False on NFS mount storage.
#   For the same reason we remove similar check for
#   parentname directory in utils.py.


### Base Image
FROM --platform=linux/amd64 cumulusprod/cellranger-arc:2.0.2
LABEL maintainer="misha.kotliar@gmail.com"
ENV DEBIAN_FRONTEND noninteractive


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

WORKDIR /tmp

### Installing dependencies
RUN apt-get update && \
    apt-get install vim -y && \
    sed -i 's/exit_with_message("You do not have write permissions in %s\.\\n" % output_parent_dir)/pass/' /software/cellranger-arc-2.0.2/bin/atac_gex/mkref && \
    sed -i '/if not os.access(parentname, os.W_OK)/,+2d' /software/cellranger-arc-2.0.2/external/anaconda/lib/python3.7/site-packages/tables/utils.py && \
### Cleaning
    apt-get clean && \
    apt-get purge && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && \
    strip /usr/local/bin/*; true
