Skip to content
Snippets Groups Projects
Commit d95472b6 authored by Blaise Li's avatar Blaise Li
Browse files

Attempts to make the pipelines slurm-compatible.

parent fec62b53
No related branches found
No related tags found
No related merge requests found
...@@ -10,11 +10,13 @@ endif ...@@ -10,11 +10,13 @@ endif
all: run_pipeline all: run_pipeline
install: run_pipeline run_pipeline.sh workflows_shell.sh install: run_pipeline run_pipeline.sh workflows_shell.sh wrap_in_container.sh cluster_config.json
sudo install -d $(PREFIX)_$(VERSION)/bin sudo install -d $(PREFIX)_$(VERSION)/bin
sudo install run_pipeline $(PREFIX)_$(VERSION)/bin/. sudo install run_pipeline $(PREFIX)_$(VERSION)/bin/.
sudo install run_pipeline.sh $(PREFIX)_$(VERSION)/bin/. sudo install run_pipeline.sh $(PREFIX)_$(VERSION)/bin/.
sudo install workflows_shell.sh $(PREFIX)_$(VERSION)/bin/. sudo install workflows_shell.sh $(PREFIX)_$(VERSION)/bin/.
sudo install wrap_in_container.sh $(PREFIX)_$(VERSION)/bin/.
sudo install cluster_config.json $(PREFIX)_$(VERSION)/bin/.
for datatype in sRNA-seq small_RNA-seq RNA-seq GRO-seq PRO-seq Degradome-seq Ribo-seq iCLIP-seq iCLIP; \ for datatype in sRNA-seq small_RNA-seq RNA-seq GRO-seq PRO-seq Degradome-seq Ribo-seq iCLIP-seq iCLIP; \
do \ do \
sudo ln -sf $(PREFIX)_$(VERSION)/bin/run_pipeline.sh $(PREFIX)_$(VERSION)/bin/run_$${datatype}_pipeline; \ sudo ln -sf $(PREFIX)_$(VERSION)/bin/run_pipeline.sh $(PREFIX)_$(VERSION)/bin/run_$${datatype}_pipeline; \
...@@ -22,11 +24,13 @@ install: run_pipeline run_pipeline.sh workflows_shell.sh ...@@ -22,11 +24,13 @@ install: run_pipeline run_pipeline.sh workflows_shell.sh
sudo ln -sfn $(PREFIX)_$(VERSION) $(PREFIX) sudo ln -sfn $(PREFIX)_$(VERSION) $(PREFIX)
# To test before replacing "prod" version in $(PREFIX) # To test before replacing "prod" version in $(PREFIX)
install_test: run_pipeline run_pipeline.sh workflows_shell.sh install_test: run_pipeline run_pipeline.sh workflows_shell.sh wrap_in_container.sh cluster_config.json
sudo install -d $(TEST_PREFIX)_$(VERSION)/bin sudo install -d $(TEST_PREFIX)_$(VERSION)/bin
sudo install run_pipeline $(TEST_PREFIX)_$(VERSION)/bin/. sudo install run_pipeline $(TEST_PREFIX)_$(VERSION)/bin/.
sudo install run_pipeline.sh $(TEST_PREFIX)_$(VERSION)/bin/. sudo install run_pipeline.sh $(TEST_PREFIX)_$(VERSION)/bin/.
sudo install workflows_shell.sh $(TEST_PREFIX)_$(VERSION)/bin/. sudo install workflows_shell.sh $(TEST_PREFIX)_$(VERSION)/bin/.
sudo install wrap_in_container.sh $(TEST_PREFIX)_$(VERSION)/bin/.
sudo install cluster_config.json $(TEST_PREFIX)_$(VERSION)/bin/.
for datatype in sRNA-seq small_RNA-seq RNA-seq GRO-seq PRO-seq Degradome-seq Ribo-seq iCLIP-seq iCLIP; \ for datatype in sRNA-seq small_RNA-seq RNA-seq GRO-seq PRO-seq Degradome-seq Ribo-seq iCLIP-seq iCLIP; \
do \ do \
sudo ln -sf $(TEST_PREFIX)_$(VERSION)/bin/run_pipeline.sh $(TEST_PREFIX)_$(VERSION)/bin/run_$${datatype}_pipeline; \ sudo ln -sf $(TEST_PREFIX)_$(VERSION)/bin/run_pipeline.sh $(TEST_PREFIX)_$(VERSION)/bin/run_$${datatype}_pipeline; \
......
{
"__default__" :
{
"ram" : "20G"
},
"multiqc" :
{
"ram" : "20G"
},
"star_mapping_pass1" :
{
"ram" : "32G"
},
"star_mapping_pass2" :
{
"ram" : "50G"
},
"star_index" :
{
"ram" : "60G"
},
"bowtie2" :
{
"ram" : "30G"
},
"bowtie2_index" :
{
"ram" : "60G"
},
"kallisto_quant" :
{
"ram" : "30G"
},
"kallisto_index" :
{
"ram" : "60G"
},
"minimap2" :
{
"ram" : "30G"
},
"mark_duplicates":
{
"ram" : "30G"
}
}
...@@ -54,6 +54,8 @@ SCRIPT=$(readlink -f "${0}") ...@@ -54,6 +54,8 @@ SCRIPT=$(readlink -f "${0}")
# Absolute path this script is in # Absolute path this script is in
BASEDIR=$(dirname "${SCRIPT}") BASEDIR=$(dirname "${SCRIPT}")
container="${BASEDIR}/run_pipeline" container="${BASEDIR}/run_pipeline"
wrapper="${BASEDIR}/wrap_in_container.sh"
cluster_config="${BASEDIR}/cluster_config.json"
# Do we have singularity? # Do we have singularity?
...@@ -72,6 +74,16 @@ then ...@@ -72,6 +74,16 @@ then
fi fi
fi fi
if [ ! -e ${wrapper} ]
then
error_exit "The wrapper script ${wrapper} was not found."
fi
if [ ! -e ${cluster_config} ]
then
error_exit "The cluster configuration ${cluster_config} was not found."
fi
if [ ! -e ${container} ] if [ ! -e ${container} ]
then then
if [ -e ${BASEDIR}/run_pipeline.def ] if [ -e ${BASEDIR}/run_pipeline.def ]
...@@ -79,7 +91,7 @@ then ...@@ -79,7 +91,7 @@ then
echo "The container was not found. Trying to build it. This may take quite some time and requires sudoer's rights." echo "The container was not found. Trying to build it. This may take quite some time and requires sudoer's rights."
sudo singularity build ${BASEDIR}/run_pipeline ${BASEDIR}/run_pipeline.def || error_exit "The container could not be built." sudo singularity build ${BASEDIR}/run_pipeline ${BASEDIR}/run_pipeline.def || error_exit "The container could not be built."
else else
error_exit "The container was not found, nor a definition file to build it." error_exit "The container ${container} was not found, nor a definition file to build it."
fi fi
fi fi
...@@ -98,9 +110,11 @@ fi ...@@ -98,9 +110,11 @@ fi
[[ ${QOS} ]] || QOS="normal" [[ ${QOS} ]] || QOS="normal"
[[ ${PART} ]] || PART="common" [[ ${PART} ]] || PART="common"
cluster_opts="--cluster \\\'sbatch --mem={cluster.ram} --cpus-per-task={threads} --job-name={rule}-{wildcards} --qos=${QOS} --part=${PART} ${wrapper} ${container}\\\' --cluster-config ${cluster_config}"
#cluster_opts="--cores 20 --cluster \'sbatch --mem={cluster.ram} --cpus-per-task={threads} --job-name={rule}-{wildcards} --qos=${QOS} --part=${PART} --mpi=none\' -j 300" #cluster_opts="--cores 20 --cluster \'sbatch --mem={cluster.ram} --cpus-per-task={threads} --job-name={rule}-{wildcards} --qos=${QOS} --part=${PART} --mpi=none\' -j 300"
#cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /var/run/munge -B /pasteur ${container} ${PROGNAME} ${pipeline_config} ${cluster_opts} --cluster-config ${cluster_config}" #cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /var/run/munge -B /pasteur ${container} ${PROGNAME} ${pipeline_config} ${cluster_opts} --cluster-config ${cluster_config}"
cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /var/run/munge -B /pasteur ${container} ${PROGNAME} $@" #cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /var/run/munge -B /pasteur ${container} ${PROGNAME} $@"
cmd="APPTAINERENV_USER=${USER} apptainer run -B /opt/hpc/slurm -B /var/run/munge -B /pasteur ${container} ${PROGNAME} $@ ${cluster_opts}"
# This script can be called from various symbolic links. # This script can be called from various symbolic links.
# The name of the link determines which snakefile to use. # The name of the link determines which snakefile to use.
...@@ -112,4 +126,7 @@ cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /va ...@@ -112,4 +126,7 @@ cmd="APPTAINERENV_USER=${USER} apptainer run --cleanenv -B /opt/hpc/slurm -B /va
# so that it finds the Genome configuration and gene lists # so that it finds the Genome configuration and gene lists
# that are expected to be in a specific location there. # that are expected to be in a specific location there.
# singularity run -B /pasteur -B /run/shm:/run/shm ${container} ${PROGNAME} $@ # singularity run -B /pasteur -B /run/shm:/run/shm ${container} ${PROGNAME} $@
[[ $(hostname) = "pisa" ]] && SINGULARITYENV_USER=${USER} singularity run --cleanenv -B /pasteur -B /run/shm:/run/shm ${container} ${PROGNAME} $@ || sbatch --qos=${QOS} --part=${PART} --wrap="${cmd}" #[[ $(hostname) = "pisa" ]] && SINGULARITYENV_USER=${USER} singularity run --cleanenv -B /pasteur -B /run/shm:/run/shm ${container} ${PROGNAME} $@ || sbatch --qos=${QOS} --part=${PART} --wrap="${cmd}"
[[ $(hostname) = "pisa" ]] && SINGULARITYENV_USER=${USER} singularity run -B /pasteur -B /run/shm:/run/shm ${container} ${PROGNAME} $@ || sbatch --qos=${QOS} --part=${PART} --wrap="${cmd}"
exit 0
#!/bin/bash -l
# Copyright (C) 2024 Blaise Li
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# http://linuxcommand.org/wss0150.php
PROGNAME=$(basename "${0}")
function error_exit
{
# ----------------------------------------------------------------
# Function for exit due to fatal program error
# Accepts 1 argument:
# string containing descriptive error message
# ----------------------------------------------------------------
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}
# https://stackoverflow.com/a/1638397/1878788
# Absolute path to this script
SCRIPT=$(readlink -f "${0}")
# Absolute path this script is in
BASEDIR=$(dirname "${SCRIPT}")
#container="${BASEDIR}/run_pipeline"
container=${1}
shift
echo "(${PROGNAME}) BASEDIR: ${BASEDIR}"
echo "(${PROGNAME}) container: ${container}"
# Do we have singularity?
apptainer --version 2> /dev/null && have_singularity=1
if [ ! ${have_singularity} ]
then
install_doc="https://sylabs.io/guides/3.4/user-guide/quick_start.html#quick-installation-steps"
# Do we have an environment modules system?
module --version 2> /dev/null && have_modules=1
if [ ${have_modules} ]
then
module load apptainer || error_exit "singularity is needed to run the pipelines (see ${install_doc})"
else
error_exit "singularity is needed to run the pipelines (see ${install_doc})"
fi
fi
echo "${PROGNAME} found apptainer"
if [ ! -e ${container} ]
then
if [ -e ${BASEDIR}/run_pipeline.def ]
then
echo "The container was not found. Trying to build it. This may take quite some time and requires sudoer's rights."
apptainer build ${BASEDIR}/run_pipeline ${BASEDIR}/run_pipeline.def || error_exit "The container could not be built."
else
error_exit "The container was not found, nor a definition file to build it."
fi
fi
echo "${PROGNAME} found ${container}"
APPTAINERENV_USER=${USER} apptainer exec -B /pasteur ${container} $@
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment