Bootstrap: yum
OSVersion: 8
MirrorURL: http://dl.rockylinux.org/pub/rocky/%{OSVERSION}/BaseOS/x86_64/os/
Include: yum

%files
    Phylogeny_companion.py /opt/ 
    consense /opt/

%environment
    export PATH=/opt/usr/local/bin:$PATH
    export PATH=/opt/BMGE-1.12:$PATH
    export PATH=/opt/hmmer/bin:$PATH
    export PATH=/opt/Prodigal:$PATH
    export PATH=/opt/pplacer-Linux-v1.1.alpha17:$PATH
    export PATH=/opt/mafft-7.471-with-extensions/core:$PATH
    export PATH=/opt/muscle:$PATH
    export PATH=/opt/scafos:$PATH 
    export SCAFOS=/opt/scafos
    export PATH=/opt/ncbi-blast-2.10.0+/bin:$PATH
    #export PATH=/opt/rnammer:$PATH
    export PATH=/opt/bedtools2/bin:$PATH
    export PATH=/opt/barrnap/bin:$PATH
    export PATH=/opt/cdhit:$PATH
    export PATH=/opt/standard-RAxML:$PATH
    export PATH=/usr/local/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    export CFLAGS="-I/usr/local/include"
    export LDFLAGS="-L/usr/local/lib"
    export PATH=/opt/Mash:$PATH
    export PATH=/opt/ANIcalculator_v1:$PATH
    export PATH=/opt/ORPER:$PATH 
    export PATH=/opt/R/4.0.5/bin:$PATH  
    export PATH=/opt/CONSENSE:$PATH

%post
    #Update part
    #permission part
    chmod -R 777 /opt #chmod775 can be enough
    chmod -R 777 /root #chmod775 can be enough
    #modules
    yum install -y git
    yum install -y automake autoconf
    yum install -y make
    yum install -y zlib-devel    
    #yum install -y bzip2-devel
    yum install -y glibc-devel
    yum install -y xz-devel
    yum install -y zip unzip
    yum install -y gcc gcc-c++ make 
    yum install -y epel-release
    yum install -y cmake3
    #ln -s /usr/bin/cmake3 /usr/bin/cmake
    yum install -y rsync
    #yum install -y https://repo.ius.io/ius-release-el7.rpm
    yum install -y python3
    yum install -y wget
    yum install -y epel-release
    yum install -y boost boost-thread boost-devel
    yum install -y perl-CPAN
    yum install -y cpanminus
    yum install -y patch
    yum install -y java-11-openjdk-devel
    yum install -y capnproto
    yum install -y perl-LWP-Protocol-https    
    yum install -y tar
    yum -y install glibc-locale-source
    localedef -i en_US -f UTF-8 en_US.UTF-8
    pip3 install click
    ln -s /usr/bin/python3 /usr/bin/python    

    #capnm module + BMC
    cpanm LWP::Simple --force
    cpanm aliased --force
    cpanm Bio::MUST::Core
    cpanm Bio::MUST::Drivers
    cpanm Bio::MUST::Apps::FortyTwo

    #BMGE
    cd /opt/
    wget ftp://ftp.pasteur.fr:21/pub/gensoft/projects/BMGE/BMGE-1.12.tar.gz
    tar -xzf BMGE-1.12.tar.gz
    cd BMGE-1.12
    echo '#!/bin/sh' >> bmge.sh
    echo 'java -jar /opt/BMGE-1.12/BMGE.jar -i $1 -t $2 -h $3 -g $4 -oh $5' >> bmge.sh
    chmod a+x bmge.sh
    export PATH=/opt/BMGE-1.12:$PATH

    #Programs
    #bzip2
    wget https://sourceforge.net/projects/bzip2/files/latest/download
    mv download bzip2-1.0.6.tar.gz
    tar -xzf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
    make
    make install

    #HMMER
    dnf install perl-Perl4-CoreLibs -y
    dnf install perl-XML-Simple -y
    cd /opt
    wget http://eddylab.org/software/hmmer/hmmer-3.3.tar.gz
    tar zxf hmmer-3.3.tar.gz
    cd hmmer-3.3
    ./configure --prefix /opt/hmmer
    make
    make check
    make install

    #Prodigal
    cd /opt
    git clone https://github.com/hyattpd/Prodigal
    cd Prodigal/
    make install

    #PPlacer
    cd /opt
    wget https://github.com/matsen/pplacer/releases/download/v1.1.alpha17/pplacer-Linux-v1.1.alpha17.zip
    unzip pplacer-Linux-v1.1.alpha17.zip

    #Checkm
    #cd /opt
    #pip3 install numpy
    #pip3 install matplotlib
    #pip3 install -I pysam==0.12.0.1
    #pip3 install checkm-genome
    #mkdir checkm-data
    #cd checkm-data/
    #wget https://data.ace.uq.edu.au/public/CheckM_databases/checkm_data_2015_01_16.tar.gz
    #tar -xzf checkm_data_2015_01_16.tar.gz
    #checkm data setRoot /opt/checkm-data/

    #Mafft
    cd /opt/
    wget https://mafft.cbrc.jp/alignment/software/mafft-7.471-with-extensions-src.tgz
    gunzip -cd mafft-7.471-with-extensions-src.tgz | tar xfv -
    cd mafft-7.471-with-extensions
    cd core/
    make clean
    make
    make install

    #MUSCLE
    cd /opt/
    mkdir muscle
    cd muscle/
    wget https://www.drive5.com/muscle/downloads3.8.31/muscle3.8.31_i86linux64.tar.gz
    tar -xzf muscle3.8.31_i86linux64.tar.gz

    #Scafos
    cd /opt/
    yum install -y perl-Tk #for centos7
    #dnf --enablerepo=PowerTools install perl-Tk -y
    wget http://www.tree-puzzle.de/tree-puzzle-5.3.rc16.tar.gz
    tar -xzf tree-puzzle-5.3.rc16.tar.gz
    cd tree-puzzle-5.3.rc16
    sh ./configure --prefix=/usr/local
    make
    make install
    cd /opt/
    mkdir scafos
    cd scafos/
    wget https://megasun.bch.umontreal.ca/Software/scafos/version/scafos_src_linux.125.tgz
    tar -xzf scafos_src_linux.125.tgz
    export SCAFOS=/opt/scafos
  
    #Mummer
    cd /opt/
    wget https://github.com/mummer4/mummer/releases/download/v3.9.4alpha/mummer-3.9.4alpha.tar.gz
    tar -xzf mummer-3.9.4alpha.tar.gz
    cd mummer-3.9.4alpha
    ./configure --prefix=/usr/local
    make
    make install

    #Blast
    cd /opt/    
    wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.10.0/ncbi-blast-2.10.0+-x64-linux.tar.gz
    tar -zxvf ncbi-blast-2.10.0+-x64-linux.tar.gz

    #bedtools
    cd /opt/
    wget https://github.com/arq5x/bedtools2/releases/download/v2.29.1/bedtools-2.29.1.tar.gz
    tar -zxvf bedtools-2.29.1.tar.gz
    cd bedtools2
    make
    export PATH=/opt/bedtools2/bin:$PATH

    #barnap
    cd /opt/
    git clone https://github.com/tseemann/barrnap.git
    export PATH=/opt/barrnap/bin:$PATH

    #cd-hit
    cd /opt/
    git clone https://github.com/weizhongli/cdhit
    cd cdhit/
    make

    #RaxML
    cd /opt/
    git clone https://github.com/stamatak/standard-RAxML
    cd standard-RAxML/
    make -f Makefile.PTHREADS.gcc
    make -f Makefile.AVX.PTHREADS.gcc
    rm -f *.o

    #capnp
    cd /opt/
    curl -O https://capnproto.org/capnproto-c++-0.8.0.tar.gz
    tar zxf capnproto-c++-0.8.0.tar.gz
    cd capnproto-c++-0.8.0
    ./configure
    make -j6 check
    make install

    #GSL
    cd /opt/
    wget ftp://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz
    tar -zxvf gsl-2.6.tar.gz
    cd gsl-2.6
    ./configure
    make
    make check
    make install

    #Mash
    cd /opt/
    git clone https://github.com/marbl/Mash
    cd Mash/
    ./bootstrap.sh
    ./configure
    make
    make install

    #gANI
    cd /opt/
    wget https://ani.jgi.doe.gov/download_files/ANIcalculator_v1.tgz
    tar -xzf ANIcalculator_v1.tgz

    #dRep
    #pip3 install drep

    #R
    yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    dnf install -y dnf-plugins-core
    dnf config-manager --set-enabled powertools
    curl -O https://cdn.rstudio.com/r/centos-8/pkgs/R-4.0.5-1-1.x86_64.rpm
    yum install -y R-4.0.5-1-1.x86_64.rpm

    #treeshrink
    cd /opt/
    git clone https://github.com/uym2/TreeShrink.git
    cd TreeShrink/
    python setup.py install
    run_treeshrink.py

    #companion
    cd /opt/
    mkdir companion
    mv Phylogeny_companion.py  companion/

    #consense
    cd /opt/
    mkdir CONSENSE
    mv consense CONSENSE/

%runscript
    echo "This container contains : "
    Bio::MUST::Core 2020070 https://metacpan.org/pod/Bio::MUST::Core  
    Checkm 1.1.3 https://github.com/Ecogenomics/CheckM/wiki/Installation  
    RNAmmer 1.2 https://services.healthtech.dtu.dk/software.php  
    dRep 3.2.2 https://drep.readthedocs.io/en/latest/  
    MAFFT 7.471 https://mafft.cbrc.jp/alignment/software/source.html  
    SCaFoS 1.25 https://megasun.bch.umontreal.ca/Software/scafos/scafos_install.html  
    CD-HIT 4.8.1 http://bioinformatics.org/cd-hit/  
    raxmlHPC-PTHREADS 8.2.12 https://cme.h-its.org/exelixis/web/software/raxml/cluster.html 
    Prodigal 2.6.3 https://github.com/hyattpd/Prodigal
    treeshrink 2.3.9 https://github.com/uym2/TreeShrink

%help
    This is a container for Nextflow-ORganismPlacER (ORPER) 
 
%labels
    Author Luc Cornet
    Version v0.0.1
