Skip to content

Commit

Permalink
fix: fix run_pipeline.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
boasvdp committed Sep 9, 2024
1 parent 523a157 commit e6dbab7
Showing 1 changed file with 74 additions and 19 deletions.
93 changes: 74 additions & 19 deletions run_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@

set -euo pipefail

set -x

#----------------------------------------------#
# User parameters
if [ ! -z "${1}" ] || [ ! -z "${2}" ] #|| [ ! -z "${irods_input_projectID}" ]
if [ ! -z "${1}" ] || [ ! -z "${2}" ] || [ ! -z "${irods_input_projectID}" ]
then
input_dir="${1}"
output_dir="${2}"
# PROJECT_NAME="${irods_input_projectID}"
PROJECT_NAME="${irods_input_projectID}"
EXCLUSION_FILE=""
else
echo "One of the parameters is missing, make sure there is an input directory, output directory and project name(param 1, 2 or irods_input_projectID)."
exit 1
fi

set +u
#check if there is an exclusion file, if so change the parameter
if [ ! -z "${irods_input_sequencing__run_id}" ] && [ -f "/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.exclude" ]
then
EXCLUSION_FILE="/data/BioGrid/NGSlab/sample_sheets/${irods_input_sequencing__run_id}.exclude"
fi
set -u

if [ ! -d "${input_dir}" ] || [ ! -d "${output_dir}" ]
then
echo "The input directory $input_dir, output directory $output_dir or fastq dir ${input_dir}/clean_fastq does not exist"
Expand All @@ -23,29 +34,50 @@ else
fi

#----------------------------------------------#
# Create/update necessary environments
PATH_MAMBA_YAML="envs/mamba.yaml"
PATH_MASTER_YAML="envs/juno_variant_typing.yaml"
MAMBA_NAME=$(head -n 1 ${PATH_MAMBA_YAML} | cut -f2 -d ' ')
MASTER_NAME=$(head -n 1 ${PATH_MASTER_YAML} | cut -f2 -d ' ')
## make sure conda works

echo -e "\nUpdating necessary environments to run the pipeline..."

# Removing strict mode because it sometimes breaks the code for
# activating an environment and for testing whether some variables
# are set or not
set +euo pipefail
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/mnt/miniconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/mnt/miniconda/etc/profile.d/conda.sh" ]; then
. "/mnt/miniconda/etc/profile.d/conda.sh"
else
export PATH="/mnt/miniconda/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<export -f conda
export -f __conda_activate
export -f __conda_reactivate
export -f __conda_hashr

conda env update -f "${PATH_MAMBA_YAML}"
source activate "${MAMBA_NAME}"

mamba env update -f "${PATH_MASTER_YAML}"
#----------------------------------------------#
# Create the environment

source activate "${MASTER_NAME}"
# we can use the base installation of mamba to create the environment.
# Swapping to a parent env is not necessary anymore.
mamba env create -f envs/juno_variant_typing.yaml --name pipeline_env
conda activate pipeline_env

#----------------------------------------------#
# Run the pipeline

case $PROJECT_NAME in
adhoc)
SPECIES="NotProvided"
;;
myco|myco_kncv)
SPECIES="Mycobacterium_tuberculosis"
;;
*)
SPECIES="NotProvided"
;;
esac

echo -e "\nRun pipeline..."

if [ ! -z ${irods_runsheet_sys__runsheet__lsf_queue} ]; then
Expand All @@ -54,9 +86,32 @@ else
QUEUE="bio"
fi

set -euo pipefail
# Setting up the tmpdir for singularity as the current directory (default is /tmp but it gets full easily)
# Containers will use it for storing tmp files when building a container
export SINGULARITY_TMPDIR="$(pwd)"

python template.py --queue "${QUEUE}" -i "${input_dir}" -o "${output_dir}"
#without exclusion file
if [ "${EXCLUSION_FILE}" == "" ]
then
python juno_variant_typing.py \
--queue "${QUEUE}" \
-i "${input_dir}" \
-o "${output_dir}" \
-s "${SPECIES}" \
--prefix "/mnt/db/juno/sing_containers"

result=$?
else
python juno_variant_typing.py \
--queue "${QUEUE}" \
-i "${input_dir}" \
-o "${output_dir}" \
-s "${SPECIES}" \
--prefix "/mnt/db/juno/sing_containers" \
-ex "${EXCLUSION_FILE}"

result=$?
fi

result=$?

Expand Down

0 comments on commit e6dbab7

Please sign in to comment.