bootstrap: docker
From: fedora:35

%help
    ... a container for SNP analysis tools

%post
    dnf -y update
    dnf -y install bc bzip2 bzip2-devel findutils git lftp mlocate parallel tcsh unzip zip wget which
    dnf -y install gcc-c++ make libtool automake autoconf213 autoconf meson ninja-build
    dnf -y install curl libcurl libcurl-devel ncurses ncurses-devel
    dnf -y install zlib zlib-devel libcurl libcurl-devel xz xz-devel xz-libs openssl openssl-devel
    dnf -y install hostname
    dnf -y install java-1.8.0-openjdk-headless
    dnf -y install R
    dnf -y install python3-devel python3-numpy python3-pip python3-Cython
    pip install pyfaidx multiqc click coloredlogs
    

### Read manipulation tools

    echo 'Installing SRATOOLKIT from http://www.ncbi.nlm.nih.gov/books/NBK158900/ '
    cd /opt
    wget https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.11.3/sratoolkit.2.11.3-ubuntu64.tar.gz
    tar -xzf sratoolkit.2.11.3-ubuntu64.tar.gz
    \rm  sratoolkit.2.11.3-ubuntu64.tar.gz

    echo 'Installing UMI-tools from https://github.com/CGATOxford/UMI-tools '
    pip3 install --upgrade umi-tools

    echo 'Installing HTSLIB from http://www.htslib.org/ '
    cd /opt
    git clone https://github.com/samtools/htslib.git htslib
    cd htslib
    git submodule update --init --recursive
    make && make install

    echo 'Installing SAMTOOLS from http://www.htslib.org/ '
    cd /opt
    git clone https://github.com/samtools/samtools.git samtools
    cd samtools
    autoreconf
    ./configure
    make && make install

    echo 'Installing bcftools, vcftools, and cyvcf2 '
    dnf -y install bcftools vcftools
    pip install cyvcf2
#

### Perl prerequisites

    echo 'Installing perl prerequisites: '
    dnf -y install perl-App-cpanminus
    dnf -y install perl-XML-DOM-XPath
    cpanm install BioPerl
    cpanm install Clone
    cpanm install Statistics::R
    cpanm install JSON
    cpanm install Carp
    cpanm install Sort::Naturally
    cpanm install File::Share
    cpanm install File::ShareDir::Install
    cpanm install Moose
    cpanm install Term::ProgressBar
    cpanm install Bio::DB::Fasta
    cpanm install Bio::DB::Taxonomy
    cpanm install Bio::Ontology::OntologyEngineI
    cpanm install Bio::OntologyIO::obo
    cpanm install Bio::Seq
    cpanm install Bio::SeqIO
    cpanm install Bio::Tools::CodonTable
    cpanm install Bio::Tools::GFF
#

### Utilities

    echo 'Installing AGAT from https://github.com/NBISweden/AGAT.git '
    cd /opt
    git clone https://github.com/NBISweden/AGAT.git
    cd AGAT
    perl Makefile.PL
    make
    make test
    make install

    echo 'Installing GFFRead from https://github.com/gpertea/gffread '
    cd /opt
    git clone https://github.com/gpertea/gffread
    cd gffread
    make release

    echo 'Installing bedtools from https://github.com/arq5x/bedtools2/ '
    cd /opt
    git clone https://github.com/arq5x/bedtools2.git
    cd bedtools2/
    make && make install && make clean

    echo 'Installing bedops from https://github.com/bedops '
    cd /opt
    mkdir bedops && cd bedops
    wget https://github.com/bedops/bedops/releases/download/v2.4.40/bedops_linux_x86_64-v2.4.40.tar.bz2
    tar jxvf bedops_linux_x86_64-v2.4.40.tar.bz2
    # ... creates bin directory with tool binaries; added to path below
    \rm bedops_linux_x86_64-v2.4.40.tar.bz2

    echo 'Installing gfftobed from https://github.com/jacobbierstedt/gfftobed.git '
    cd /opt
    git clone https://github.com/jacobbierstedt/gfftobed.git
    cd gfftobed
    make
    cp gfftobed /usr/local/bin

    echo 'Installing samblaster from hittps://github.com/GregoryFaust/samblaster '
    cd /opt
    git clone https://github.com/GregoryFaust/samblaster.git
    cd samblaster
    make

    echo 'Installing FastQC from http://www.bioinformatics.babraham.ac.uk/projects/fastqc/ '
    cd /opt
    wget http://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.9.zip
    unzip fastqc_v0.11.9.zip
    chmod +x FastQC/fastqc
#

### SNP analysis sofwtare

    echo 'Installing GATK v4.2.4.1 from the BROAD Institute '
    cd /opt
    wget https://github.com/broadinstitute/gatk/releases/download/4.2.4.1/gatk-4.2.4.1.zip
    unzip gatk-4.2.4.1.zip
    
    echo 'Installing SNPGenie from https://github.com/chasewnelson/SNPGenie.git '
    cd /opt
    git clone https://github.com/chasewnelson/SNPGenie.git
    
    echo 'Installing freebayes from https://github.com/freebayes/freebayes '
    cd /opt
    mkdir freebayes
    cd freebayes
    wget https://github.com/freebayes/freebayes/releases/download/v1.3.4/freebayes-1.3.4-linux-static-AMD64.gz
    gunzip freebayes-1.3.4-linux-static-AMD64.gz 
    mv freebayes-1.3.4-linux-static-AMD64 freebayes
    chmod a+x freebayes

    echo 'Installing BISCUIT from https://github.com/huishenlab/biscuit '
    cd /opt
    git clone --recursive https://github.com/huishenlab/biscuit
    cd biscuit
    # We are fixing mistakes in the code before compilation:
    cd src
    cp pileup.c pileup.cORIG
    sed -i -e "126 s/k_hchh, b_hch/k_hch, b_hch/; 147 s/k_chh, b_ch/k_ch,  b_ch/;" pileup.c
    cd ..
    make

    echo 'Installing BS-SNPer from https://github.com/hellbelly/BS-Snper '
    cd /opt
    git clone https://github.com/hellbelly/BS-Snper
    cd BS-Snper/
    sh BS-Snper.sh
#

### R and R packages

    echo 'Installing R '
    cd /opt
    dnf -y install R
    echo 'repo <- "http://ftp.ussg.iu.edu/CRAN"' > R2install
    echo 'install.packages("BiocManager", repos = repo)' >> R2install
    echo 'BiocManager::install(c("biscuiteer"), ask=FALSE)' >> R2install
    Rscript R2install
#


%environment
    export PATH=$PATH:/opt/bin:/opt/scripts

    export PATH=$PATH:/opt/sratoolkit.2.11.3-ubuntu64/bin
    export PATH=$PATH:/opt/AGAT/bin
    export PATH=$PATH:/opt/gffread
    export PATH=$PATH:/opt/bedops/bin
    export PATH=$PATH:/opt/samblaster

    export PATH=$PATH:/opt/FastQC
    export PATH=$PATH:/opt/gatk-4.2.4.1
    export PATH=$PATH:/opt/SNPGenie
    export PATH=$PATH:/opt/freebayes
    export PATH=$PATH:/opt/biscuit
    export PATH=$PATH:/opt/BS-Snper
