Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pgdurand/BeeDeeM
Browse files Browse the repository at this point in the history
  • Loading branch information
pgdurand committed Mar 10, 2023
2 parents 4554f98 + b2f9f57 commit bc7e290
Showing 1 changed file with 103 additions and 21 deletions.
124 changes: 103 additions & 21 deletions singularity/test_container.sh
Original file line number Diff line number Diff line change
@@ -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.4.sif Singularity
#
# 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 update on Dec 2022
# P. Durand (SeBiMER, Ifremer), last updated on March 2023
# #############################################################################

# Sample config for Slurm; adapt partition to your cluster configuration
#SBATCH -p fast
Expand All @@ -24,8 +29,13 @@
#PBS -l mem=4g
#PBS -l ncpus=2

# #############################################################################

# ###
# Section 1: prepare BeeDeeM test suite

# Version of BeeDeeM to test
BDM_VERSION=4.7.4
BDM_VERSION=4.7.6
# Default working directory to test BeeDeeM Singularity image.
# Il will be overriden below, given host platform
BDM_SCRATCH_DIR=/tmp
Expand Down Expand Up @@ -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 == *"datarmor"* ]]; then
echo "running on DATARMOR using PBS Pro scheduler"
if [[ $hname == *"data"* ]]; then
echo "running on Ifremer using PBS Pro scheduler"
source /etc/profile.d/modules.sh
module purge
module load singularity/3.4.1
Expand All @@ -84,19 +98,24 @@ 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
else
echo "Cannot figure out which job scheduler is available."
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."
Expand All @@ -115,33 +134,96 @@ 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_"

#rm -rf $BDM_BANKS_DIR
mkdir -p $BDM_BANKS_DIR
#rm -rf $BDM_WORK_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,MEROPS_PepUnits"
# ###
# Section 6: start tests

# Now, let's start a simple installation
echo "Start simple bank installation"
echo "Look at processing with:"
echo "tail -f $BDM_WORK_DIR/log"
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
echo "FAILED. Review log file: $BDM_WORK_DIR/log"
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

singularity run \
${BDM_BINDS} \
${BDM_SINGULITY_IMG} \
bdm install -desc ${DESCRIPTOR} >& ${BDM_WORK_DIR}/log 2>&1
# 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 "###############################################################################"
echo "# Start BeeDeeM-Tools test suite"
mkdir -p $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
Expand Down

0 comments on commit bc7e290

Please sign in to comment.