From b2f9f57f56c1708b072400f9c64f3dd02b28f6ac Mon Sep 17 00:00:00 2001 From: galaxy Date: Thu, 9 Mar 2023 08:13:06 +0000 Subject: [PATCH] enhance test suite to test all BeeDeeM and BeeDeeM-Tools commands --- singularity/test_container.sh | 103 ++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 12 deletions(-) diff --git a/singularity/test_container.sh b/singularity/test_container.sh index 14354af..e887069 100755 --- a/singularity/test_container.sh +++ b/singularity/test_container.sh @@ -1,15 +1,20 @@ #!/usr/bin/env bash -# Test script for BeeDeeM singularity container +# ############################################################################# +# Test script for BeeDeeM singularity container. +# # How to? +# # Step 1: build image with: singularity build -f beedeem-4.7.6.sif Singularity # (update version to match BDM_VERSION variable, below) +# # Step 2: test with either # a. ./test_container.sh # b. qsub test_container.sh (PBS Pro) # c. srun test_container.sh (slurm, direct execution) # # P. Durand (SeBiMER, Ifremer), last updated on March 2023 +# ############################################################################# # Sample config for Slurm; adapt partition to your cluster configuration #SBATCH -p fast @@ -24,6 +29,11 @@ #PBS -l mem=4g #PBS -l ncpus=2 +# ############################################################################# + +# ### +# Section 1: prepare BeeDeeM test suite + # Version of BeeDeeM to test BDM_VERSION=4.7.6 # Default working directory to test BeeDeeM Singularity image. @@ -71,11 +81,15 @@ function downloadFile(){ eval $CMD && return 0 || return 1 } +# ### +# Section 2: prepare environement depending on host +# BeeDeeM devel team used to work on two clusters, one from +# Ifremer (Brest, France), one from Station Biologique (Roscoff, France) # Depending on host platform, load singularity env if hasCommand qstat; then hname=$(hostname) if [[ $hname == *"data"* ]]; then - echo "running on DATARMOR using PBS Pro scheduler" + echo "running on Ifremer using PBS Pro scheduler" source /etc/profile.d/modules.sh module purge module load singularity/3.4.1 @@ -84,7 +98,7 @@ if hasCommand qstat; then elif hasCommand sbatch; then hname=$(hostname -A) if [[ $hname == *"roscoff"* ]]; then - echo "running on ABiMS using SLURM scheduler" + echo "running on SBR using SLURM scheduler" BDM_PLATFORM="abims" BDM_SCRATCH_DIR=$HOME fi @@ -93,11 +107,15 @@ else echo " Execute BeeDeeM directly on THIS computer" fi + # Configure BeeDeeM banks and working directories BDM_SCRATCH_DIR="$BDM_SCRATCH_DIR/test_beedeem" BDM_BANKS_DIR="$BDM_SCRATCH_DIR/banks" BDM_WORK_DIR="$BDM_SCRATCH_DIR/working" +# ### +# Section 3: prepare SIngularity container + # Check existence of the BeeDeeM image if [ ! -e "$BDM_SING_IMG_HOME/$BDM_SING_IMG_NAME" ]; then echo "WARN: $BDM_SING_IMG_HOME/$BDM_SING_IMG_NAME not found." @@ -116,24 +134,38 @@ fi # Configure Singularity runner BDM_BINDS="--bind ${BDM_WORK_DIR} --bind ${BDM_BANKS_DIR}" BDM_SINGULITY_IMG="$BDM_SING_IMG_HOME/$BDM_SING_IMG_NAME" + +# ### +# Section 4: prepare tests # For debugging if neeeded: dump all BDM_XXX variables ( set -o posix ; set ) | grep "BDM_" - mkdir -p $BDM_BANKS_DIR mkdir -p $BDM_WORK_DIR -# Prepare env variables to be used by BeeDeeM inside the container (mandatory) + +# ### +# Section 5: prepare env variables to be used by BeeDeeM inside the container +# These 3 KL_ variables are mandatory to use BeeDeeM + +# KL_JRE_ARGS sets Java Runtime variables (memory and tmpdir) and BeeDeeM log type (none|console|file) export KL_JRE_ARGS="-Xms128M -Xmx2048M -Djava.io.tmpdir=${BDM_WORK_DIR} -DKL_LOG_TYPE=console" +# KL_WORKING_DIR sets the working directory of BeeDeeM (place to store tmp files at runtime) export KL_WORKING_DIR=${BDM_WORK_DIR} +# KL_mirror__path sets the directory where BeeDeeM installs banks export KL_mirror__path=${BDM_BANKS_DIR} -# Set the banks to install -# These are '.dsc' files located in BeeDeeM image at path /opt/beedeem/conf/descriptors -DESCRIPTOR="SwissProt_human,PDB_proteins" +# ### +# Section 6: start tests # Now, let's start a simple installation -echo "1/2 - Start BeeDeeM test bank installation" -singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} install.sh -desc ${DESCRIPTOR} +echo "###############################################################################" +echo "# Start BeeDeeM test bank installation" +# These are '.dsc' files located in BeeDeeM image at path /opt/beedeem/conf/descriptors +DESCRIPTOR="SwissProt_human,PDB_proteins" +#DESCRIPTOR="SwissProt_human" +CMD="singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} install.sh -desc ${DESCRIPTOR}" +echo $CMD +eval $CMD if [ $? -eq 0 ]; then echo "SUCCESS" else @@ -141,10 +173,57 @@ else exit 1 fi +# Plast vs SwissProt DB (contains annotations) +echo "###############################################################################" +echo "# Run annotated PLAST using SwissProt human previously installed" +CMD="plast.sh -p plastp -i /opt/beedeem-tools/data/query.fa -d $BDM_BANKS_DIR/p/SwissProt_human/current/SwissProt_human/SwissProt_human00 -o $KL_WORKING_DIR/query_vs_SW.xml -a 4 -maxhits 10 -maxhsps 1 -e 1e-5 -F F" +CMD="singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} $CMD" +echo $CMD +eval $CMD +if [ $? != 0 ]; then + echo "FAILED" + exit 1 +else + echo "SUCCESS" +fi + +# Annotate PLAST result and prepare file for BlastViewer (zml format) +# see https://github.com/pgdurand/BlastViewer +echo "###############################################################################" +echo "# Annotate results" +CMD="annotate.sh -i $KL_WORKING_DIR/query_vs_SW.xml -o $KL_WORKING_DIR/query_vs_SW.zml -type full -writer zml" +CMD="singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} $CMD" +echo $CMD +eval $CMD +if [ $? != 0 ]; then + echo "FAILED" + exit 1 +else + echo "SUCCESS" +fi + +# Dump previous annotated results as CSV file +# you may use dumpcsh.h to get help on CSV format +echo "###############################################################################" +echo "# Dump annotated PLAST results as CSV file" +CMD="dumpcsv.sh -i $KL_WORKING_DIR/query_vs_SW.zml -f zml -o $KL_WORKING_DIR/query_vs_SW.csv" +CMD="singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} $CMD" +echo $CMD +eval $CMD +if [ $? != 0 ]; then + echo "FAILED" + exit 1 +else + echo "SUCCESS" +fi + # BeeDeeM-Tools full test suite -echo "2/2 - Start BeeDeeM-Tools test suite" +echo "###############################################################################" +echo "# Start BeeDeeM-Tools test suite" mkdir -p $BDM_WORK_DIR/bdm-tools -singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} /opt/beedeem-tools/test.sh -w $BDM_WORK_DIR/bdm-tools +CMD="singularity run ${BDM_BINDS} ${BDM_SINGULITY_IMG} /opt/beedeem-tools/test.sh -w $BDM_WORK_DIR/bdm-tools" +echo $CMD +eval $CMD if [ $? -eq 0 ]; then echo "SUCCESS" else