-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSLURM_Snake
54 lines (46 loc) · 1.35 KB
/
SLURM_Snake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#SBATCH --account=PAS2136
#SBATCH --job-name=Download_2_Morph
#SBATCH --time=02:30:00
#
# Runs Snakemake pipeline that downloads, crops, and segments images.
# There are three required positional arguments.
# Usage:
# sbatch SLURM_Snake <WORKDIR> <INPUTCSV> <>
# - SNAKEFILE - snakefile you want to used
# - WORKDIR - Snakemake working directory - contains output files
# - INPUTCSV - Path to input CSV file specifying images to process
# Stop if a command fails (non-zero exit status)
set -e
# Verify command line arguments
WORKDIR=$1
INPUTCSV=$2
NUMJOBS=$3
# Default to running 4 jobs if not set
if [ -z "$NUMJOBS" ]
then
NUMJOBS=4
fi
# Ensures CSV path is an absolute path.
# Otherwise snakemake will look for this file within $WORKDIR.
REAL_INPUTCSV=$(realpath $INPUTCSV)
# Make sure the input CSV file exists
if [ ! -f "$REAL_INPUTCSV" ]
then
echo "ERROR: Required INPUTCSV file $INPUTCSV does not exist."
exit 1
fi
# Activate Snakemake environment
module load miniconda3/4.10.3-py37
# Activate using source per OSC instructions
source activate snakemake
# Setup Snakemake/sbatch to use same account as this job
export SBATCH_ACCOUNT=$SLURM_JOB_ACCOUNT
# Run pipeline using Snakemake
snakemake \
--jobs $NUMJOBS \
--profile slurm/ \
--use-singularity \
--directory $WORKDIR \
--config list=$REAL_INPUTCSV
chmod -R 774 $WORKDIR