From 6624df2ac8f0dcb16ff87e322f5a2bd173702ed1 Mon Sep 17 00:00:00 2001 From: nservant Date: Fri, 27 Aug 2021 20:01:14 +0200 Subject: [PATCH] [MODIF] update singularity --- Singularity | 153 +++++++++++++----------- scripts/install/install_dependencies.sh | 91 +++++++------- 2 files changed, 124 insertions(+), 120 deletions(-) diff --git a/Singularity b/Singularity index 4f0c65c..8f53078 100644 --- a/Singularity +++ b/Singularity @@ -1,73 +1,80 @@ -BootStrap: docker -From: ubuntu:latest - -%labels - AUTHOR Nicolas Servant - -%pre - apt-get install -y debootstrap - -%files - environment.yml /opt/environment.yml - -%post - apt-get update - apt-get install -y wget - apt-get install -y gzip - apt-get install -y bzip2 - apt-get install -y curl - apt-get install -y unzip - - ## g++ - apt-get install -y build-essential - - # install anaconda - if [ ! -d /usr/local/anaconda ]; then - wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh \ - -O ~/anaconda.sh && \ - bash ~/anaconda.sh -b -p /usr/local/anaconda && \ - rm ~/anaconda.sh - fi - - # set anaconda path - export PATH=$PATH:/usr/local/anaconda/bin - conda update conda - - conda config --add channels r - conda config --add channels defaults - conda config --add channels conda-forge - conda config --add channels bioconda - - # Let us save some space - conda clean --packages -y - - # external tools - echo "Installing conda environment ... " - conda env create -f /opt/environment.yml - echo "source activate HiC-Pro_v3.1.0" > ~/.bashrc - - # Install HiC-pro - echo "Installing latest HiC-Pro release ..." - VERSION=$(curl -s https://github.com/nservant/HiC-Pro/releases/latest | egrep -o 'v3.[0-9]*.[0-9]*') - echo "v"$VERSION".zip" | wget --base=http://github.com/nservant/HiC-Pro/archive/ -i - -O hicpro_latest.zip && unzip hicpro_latest.zip - #VERSION="devel_py3" - #echo $VERSION".zip" | wget --base=http://github.com/nservant/HiC-Pro/archive/ -i - -O hicpro_latest.zip && unzip hicpro_latest.zip - - cd $(echo HiC-Pro-$VERSION) - make configure - make install - - # Let us save some space - conda clean --packages -y - conda clean --all -y - rm -rf /usr/local/anaconda/pkgs - -%test - INSTALLED_HICPRO_VERSION=$(find /usr/local/bin -name HiC-Pro | xargs dirname) - $INSTALLED_HICPRO_VERSION/HiC-Pro -h - -%environment - export PATH=$PATH:/usr/local/anaconda/bin - INSTALLED_VERSION=$(find /usr/local/bin -name HiC-Pro | xargs dirname) - export PATH=$PATH:$INSTALLED_VERSION - export LANG=C +BootStrap: docker +From: ubuntu:latest + +%labels + AUTHOR Nicolas Servant + +%files + environment.yml /opt/environment.yml + +%environment + export LANG=en_US.utf-8 + export INSTALLED_VERSION=$(find /usr/local/bin -name HiC-Pro | xargs dirname) + export PATH=$PATH:${INSTALLED_VERSION}:${INSTALLED_VERSION}/utils/ + export PATH=/usr/local/conda/bin:$PATH + source /opt/etc/bashrc + +%post + apt-get update && \ + apt-get install -y \ + wget \ + debootstrap \ + gzip \ + bzip2 \ + curl \ + unzip \ + g++ \ + + # use bash as /bin/sh instead of dash (otherwise source /opt/etc/bashrc will not work) + echo "dash dash/sh boolean false" | debconf-set-selections + DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash + + # install miniconda + if [ ! -d /usr/local/miniconda ]; then + wget https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh -O miniconda.sh && \ + sh miniconda.sh -b -p /usr/local/conda && \ + rm miniconda.sh && \ + ln -s /usr/local/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ + find /usr/local/conda/ -follow -type f -name '*.a' -delete && \ + find /usr/local/conda/ -follow -type f -name '*.js.map' -delete && \ + /usr/local/conda/bin/conda clean -afy + fi + + # set miniconda path + export PATH=/usr/local/conda/bin:$PATH + conda update conda + conda clean --packages -y + + #bashrc + echo "#! /bin/bash\n\n" > ~/.bashrc + conda init bash + + # external tools + echo "Installing conda environment ... " + conda env create -f /opt/environment.yml -n hicpro + echo "conda activate hicpro" >> ~/.bashrc + + # Install HiC-pro + export PATH=/usr/local/conda/envs/hicpro/bin:$PATH + echo "Installing latest HiC-Pro release ..." + #VERSION=$(curl -s https://github.com/nservant/HiC-Pro/releases/latest | egrep -o 'v3.[0-9]*.[0-9]*') + VERSION="3.1.0" + echo "v"$VERSION".zip" | wget --base=http://github.com/nservant/HiC-Pro/archive/ -i - -O hicpro_latest.zip && unzip hicpro_latest.zip + + cd $(echo HiC-Pro-$VERSION) + make configure + make install + + # Let us save some space + conda clean --packages -y + conda clean --all -y + rm -rf /usr/local/miniconda/pkgs + apt-get clean + + mkdir /opt/etc/ + cp ~/.bashrc /opt/etc/bashrc + +%test + INSTALLED_HICPRO_VERSION=$(find /usr/local/bin -name HiC-Pro | xargs dirname) + ${INSTALLED_HICPRO_VERSION}/HiC-Pro -h + diff --git a/scripts/install/install_dependencies.sh b/scripts/install/install_dependencies.sh index e7ebed2..f6e4757 100755 --- a/scripts/install/install_dependencies.sh +++ b/scripts/install/install_dependencies.sh @@ -15,6 +15,8 @@ NORMAL="\\033[0;39m" RED="\\033[0;31m" BLUE="\\033[0;34m" +GREEN="\\033[0;32m" +YELLOW="\\033[1;33m" SOFT="HiC-Pro" ## 0 = @@ -68,8 +70,8 @@ function usage { exit; } -echo -e "$RED""Make sure internet connection works for your shell prompt under current user's privilege ...""$NORMAL"; -echo -e "$BLUE""Starting $SOFT installation ...""$NORMAL"; +echo -e "$YELLOW""Make sure internet connection works for your shell prompt under current user's privilege ...""$NORMAL"; +echo -e "$NORMAL""Starting $SOFT installation !""$NORMAL"; ################### Initialize ################### @@ -188,7 +190,6 @@ PREFIX_BIN=${PREFIX} if [ ! -w $PREFIX_BIN ]; then quiet=1 fi - if [[ $quiet == 0 ]]; then echo "Where should missing software prerequisites be installed ? [$PREFIX_BIN] " read ans @@ -217,63 +218,60 @@ if [ ! -w $PREFIX_BIN ]; then fi ################ Python ################### -echo "Checking dependencies ... " +echo "Checking dependencies" wasInstalled=0; -echo "Checking Python libraries ..." -python ../scripts/install/check_pythonlib.py > install_packages_check.Rout +echo -n "- Python libraries ..." +python ../scripts/install/check_pythonlib.py > check_python.log 2>&1 if [ $? == "0" ]; then - echo -e "$BLUE""The required Python libraries appear to be already installed. ""$NORMAL" + echo -e "$GREEN""OK""$NORMAL" wasInstalled=1; else - echo -e "$RED""Can not proceed without the required Python libraries, please install them and re-run""$NORMAL" + echo -e "$RED""\nCan not proceed without the required Python libraries, please install them and re-run""$NORMAL" exit 1; fi ################ R ################### - wasInstalled=0; +echo -n "- R installation ..." which R > /dev/null; if [ $? == "0" ]; then - echo "Checking R installation ..." - R CMD BATCH ../scripts/install/check_Rpackages.R > check_Rpackages.Rout + R CMD BATCH ../scripts/install/check_Rpackages.R > check_Rpackages.log check=`grep proc.time check_Rpackages.Rout`; if [ $? == "0" ]; then - echo -e "$BLUE""The required R packages appear to be already installed. ""$NORMAL" + echo -e "$GREEN""OK""$NORMAL" wasInstalled=1; fi else - echo -e "$RED""Can not proceed without R, please install and re-run""$NORMAL" + echo -e "$RED""\nCan not proceed without R, please install and re-run""$NORMAL" exit 1; fi #Install R Packages if [ $wasInstalled == 0 ]; then - echo "Installing missing R packages ..." + echo -n "\n -- Installing missing R packages ..." R CMD BATCH ../scripts/install/install_Rpackages.R install_Rpackages.Rout - R CMD BATCH ../scripts/install/check_Rpackages.R > check_Rpackages.Rout check=`grep proc.time check_Rpackages.Rout`; if [ $? == "0" ]; then - echo -e "$BLUE""R packages appear to be installed successfully""$NORMAL" + echo -e "$GREEN""OK""$NORMAL" else - echo -e "$RED""R packages NOT installed successfully. Look at the tmp/install_Rpackages.Rout for additional informations""$NORMAL"; exit 1; + echo -e "$RED""\nR packages NOT installed successfully. Look at the tmp/install_Rpackages.Rout for additional informations""$NORMAL"; exit 1; fi fi ################ Bowtie2 ################### - wasInstalled=0; +echo -n "- Bowtie2 installation ..." which bowtie2 > /dev/null; -if [ $? = "0" ]; then - echo -e "$BLUE""Bowtie2 Aligner appears to be already installed. ""$NORMAL" - wasInstalled=1; +if [ $? == "0" ]; then + echo -e "$GREEN""OK""$NORMAL" + wasInstalled=1; fi - if [ $wasInstalled == 0 ]; then - echo "Installing Bowtie2 ..." + echo -e -n "\n -- Installing Bowtie2 ..." $get bowtie2-2.3.5-source.zip http://sourceforge.net/projects/bowtie-bio/files/bowtie2/2.3.5/bowtie2-2.3.5-source.zip/download unzip bowtie2-2.3.5-source.zip cd bowtie2-2.3.5 @@ -288,31 +286,30 @@ fi if [ $wasInstalled == 0 ]; then check=`bowtie2 --version 2>&1`; if [ $? = "0" ]; then - echo -e "$BLUE""Bowtie2 Aligner appears to be installed successfully""$NORMAL" + echo -e "$GREEN""OK""$NORMAL" else - echo -e "$RED""Bowtie2 Aligner NOT installed successfully""$NORMAL"; exit 1; + echo -e "$RED""\nBowtie2 Aligner NOT installed successfully""$NORMAL"; exit 1; fi fi ################ samtools ################### wasInstalled=0; +echo -n "- Samtools installation ..." which samtools > /dev/null -if [ $? = "0" ]; then - +if [ $? == "0" ]; then samver=`samtools 2>&1 | grep Version | cut -d" " -f2` vercomp $samver "1.0" if [[ $? == 2 ]]; then - echo -e "$RED""samtools v1.0 or higher is needed [$samver detected].""NORMAL" + echo -e "$RED""\nsamtools v1.0 or higher is required [$samver detected].""NORMAL" exit 1; fi - - echo -e "$BLUE""Samtools appears to be already installed. ""$NORMAL" - wasInstalled=1; + echo -e "$GREEN""OK""$NORMAL" + wasInstalled=1; fi if [ $wasInstalled == 0 ]; then - echo "Installing samtools ..." + echo -n "\n -- Installing samtools ..." #From sources $get samtools-1.10.tar.bz2 http://sourceforge.net/projects/samtools/files/samtools/1.10/samtools-1.10.tar.bz2/download tar -xvjpf samtools-1.10.tar.bz2 @@ -327,9 +324,9 @@ fi if [ $wasInstalled == 0 ]; then check=`samtools view -h 2>&1 | grep -i options`; if [ $? = "0" ]; then - echo -e "$BLUE""samtools appears to be installed successfully""$NORMAL" + echo -e "$GREEN""OK""$NORMAL" else - echo -e "$RED""samtools NOT installed successfully""$NORMAL"; exit 1; + echo -e "$RED""\nsamtools NOT installed successfully""$NORMAL"; exit 1; fi fi @@ -337,11 +334,11 @@ fi cd .. rm -rf ./tmp -echo -e "$RED""Dependencies checked !""$NORMAL" +#echo -e "$GREEN""\nDependencies checked !""$NORMAL" ################ Create the config-system file ################### CUR_DIR=`pwd` -echo -e "$BLUE""Check $SOFT configuration ... ""$NORMAL" +echo -e "$NORMAL""\nChecking $SOFT configuration""$NORMAL" echo "#######################################################################" > config-system.txt echo "## $SOFT - System settings" >> config-system.txt @@ -354,28 +351,28 @@ echo "## using the 'which' command" >> config-system.txt echo "#######################################################################" >> config-system.txt which R > /dev/null -if [ $? = "0" ]; then +if [ $? == "0" ]; then echo "R_PATH = "`dirname $(which R)` >> config-system.txt else die "R_PATH not found. Exit." fi which bowtie2 > /dev/null -if [ $? = "0" ]; then +if [ $? == "0" ]; then echo "BOWTIE2_PATH = "`dirname $(which bowtie2)` >> config-system.txt else die "BOWTIE2_PATH not found. Exit." fi which samtools > /dev/null -if [ $? = "0" ]; then +if [ $? == "0" ]; then echo "SAMTOOLS_PATH = "`dirname $(which samtools)` >> config-system.txt else die "SAMTOOLS_PATH not found. Exit." fi which python > /dev/null -if [ $? = "0" ]; then +if [ $? == "0" ]; then echo "PYTHON_PATH = "`dirname $(which python)` >> config-system.txt else die "PYTHON_PATH not found. Exit." @@ -388,25 +385,25 @@ echo "ANNOT_DIR = ${install_dir}/annotation" >> config-system.txt ## deal with scheduler system if [ -z "$CLUSTER_SYS" ]; then - echo -e "$RED""Warning : Scheduler system not defined - Default is Torque/PBS""$NORMAL" + echo -e "$YELLOW""Warning : Scheduler system not defined - Default is Torque/PBS""$NORMAL" CLUSTER_SYS="TORQUE"; fi if [ $CLUSTER_SYS == "TORQUE" ]; then #ln -s scripts/make_torque_scripts.sh scripts/make_cluster_scripts.sh echo "CLUSTER_SCRIPT = ${install_dir}/scripts/make_torque_script.sh" >> config-system.txt - echo -e "$BLUE""Configuration for TORQUE/PBS system.""$NORMAL" + echo -n "- Configuration for TORQUE/PBS system ..." elif [ $CLUSTER_SYS == "SGE" ]; then #ln -s scripts/make_sge_scripts.sh scripts/make_cluster_scripts.sh echo "CLUSTER_SCRIPT = ${install_dir}/scripts/make_sge_script.sh" >> config-system.txt - echo -e "$BLUE""Configuration for SGE system.""$NORMAL" + echo -n "- Configuration for SGE system ..." elif [ $CLUSTER_SYS == "SLURM" ]; then #ln -s scripts/make_sge_scripts.sh scripts/make_cluster_scripts.sh echo "CLUSTER_SCRIPT = ${install_dir}/scripts/make_slurm_script.sh" >> config-system.txt - echo -e "$BLUE""Configuration for SLURM system.""$NORMAL" + echo -n "- Configuration for SLURM system ..." elif [ $CLUSTER_SYS == "LSF" ]; then #ln -s scripts/make_sge_scripts.sh scripts/make_cluster_scripts.sh echo "CLUSTER_SCRIPT = ${install_dir}/scripts/make_lsf_script.sh" >> config-system.txt - echo -e "$BLUE""Configuration for LSF system.""$NORMAL" + echo -n "- Configuration for LSF system ..." else die "$CLUSTER_SYS unknown. 'TORQUE/SGE/SLURM/LSF' systems are currently supported. Please change the CLUSTER_SYS variable and re-run the installation process. Exit." fi @@ -416,6 +413,6 @@ fi if [ ! -w $PREFIX ]; then die "Cannot install HiCPro in $PREFIX directory. Maybe missing super-user (root) permissions to write there. Please specify another directory in the config-install.txt file (PREFIX=)"; fi - -echo ; +echo -e "$GREEN""OK""$NORMAL" +echo -e "$GREEN""\ndone !""$NORMAL" ## End of dependencies check ##