Bootstrap: docker
From: ubuntu:jammy

%labels
maintainer julie orjuela

%post
export DEBIAN_FRONTEND=noninteractive
ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime

apt update
apt install -y python3-all-dev python3-pip python3-venv jupyter
apt -y install libz-dev libbz2-dev libncurses5-dev autoconf autotools-dev curl gnuplot liblzma-dev libcrypto++-dev
apt -y install git curl less locate build-essential openssh-server
apt -y install wget unzip

apt install -y software-properties-common
apt install -y python-is-python3
apt update
apt -y install gcc
apt -y upgrade libstdc++6
apt -y dist-upgrade

pip3 install xarray dataclasses Chunk numpy pandas argparse random2 pathlib nbformat ipykernel seaborn matplotlib scikit-learn bioinfokit jupyter itables pyyaml

# SEQKIT
mkdir seqkit_2.4.0
cd seqkit_2.4.0
wget https://github.com/shenwei356/seqkit/releases/download/v2.4.0/seqkit_linux_amd64.tar.gz
tar -xzvf seqkit_linux_amd64.tar.gz
cd ..

# SEQTK 1.3
wget https://github.com/lh3/seqtk/archive/v1.3.zip
unzip v1.3.zip
cd seqtk-1.3/
make
cd ..

# Kmer GWAS v 0.3
mkdir kmer_gwas
cd kmer_gwas
wget https://github.com/voichek/kmersGWAS/releases/download/v0.3-beta/v0_3_beta.zip
unzip v0_3_beta.zip
chmod -R 755 /kmer_gwas/bin
chmod -R 755 /kmer_gwas/external_programs
cd ..

# samtools 1.10
wget https://github.com/samtools/samtools/releases/download/1.10/samtools-1.10.tar.bz2
tar xfvj samtools-1.10.tar.bz2
cd samtools-1.10
./configure
make
make install
cd ..

# BWAMEM2 version >2.2.1
wget https://github.com/bwa-mem2/bwa-mem2/releases/download/v2.2.1/bwa-mem2-2.2.1_x64-linux.tar.bz2
tar jxf bwa-mem2-2.2.1_x64-linux.tar.bz2
mv bwa-mem2-2.2.1_x64-linux bwa-mem2-2.1

# BWA version 26nov2022
git clone https://github.com/lh3/bwa.git
cd bwa; make
cd ..

# MergeTags
git clone https://github.com/Transipedia/dekupl-mergeTags.git
cd dekupl-mergeTags
make
cd ..

## Install dependance of R software
    apt -y update
    echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
    apt install -y libpng16-16 libblas3 libblas-dev liblapack-dev liblapack3 libreadline8 r-recommended r-doc-html libxml2-dev libcurl4-openssl-dev libssl-dev libmagick++-dev libcurl3-gnutls perl

## Add repository for download latest version of R
    apt install --no-install-recommends software-properties-common dirmngr
    wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
    add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

    #curl "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x51716619E084DAB9" | apt-key add -
    #apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9
    #add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/"
    #apt -y update


## Install R
    apt install -y --no-install-recommends r-base pandoc

##  add R packages from CRAN
### Install RMarkdown and TinyTeX
    R --slave -e 'install.packages(c("rmarkdown","tinytex"))'

# add R packages from bioconductor
    Rscript -e "install.packages('BiocManager')"
    Rscript -e "library(BiocManager); install('remotes')"
    Rscript -e "library(BiocManager); install('Gviz')"
    #Rscript -e "library(BiocManager); install('Biostrings')"
    Rscript -e "library(BiocManager); install('qvalue')"
    R -e "install.packages('ggplot2')"
    R -e "install.packages('optparse')"
    R -e "install.packages('plotly')"
    R -e "install.packages('yaml')"
    R -e "install.packages('BEDMatrix')"
    R -e "install.packages('pcadapt')"
    R -e "install.packages('seqRFLP')"
    R -e "install.packages('stringr')"
    R -e "install.packages('lfmm')"
    R -e "install.packages('rlist')"

%environment
export PATH=/kmer_gwas/bin:/kmer_gwas/external_programs:/samtools-1.10:/seqkit_2.4.0:/seqtk-1.3:/bwa-mem2-2.1:/bwa:/dekupl-mergeTags/:$PATH

## -0.7.17
%runscript
exec /bin/bash "$@"echo 'export GOPATH=${HOME}/go' >> ~/.bashrc && \
echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc && \
source ~/.bashrc
