-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_cluster.sh
More file actions
executable file
·132 lines (113 loc) · 3.69 KB
/
submit_cluster.sh
File metadata and controls
executable file
·132 lines (113 loc) · 3.69 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#SBATCH --job-name=panforest_pipeline
#SBATCH --partition=normal
#SBATCH --time=168:00:00
#SBATCH --mem=16G
#SBATCH --cpus-per-task=4
#SBATCH --output=logs/slurm/main_%j.out
#SBATCH --error=logs/slurm/main_%j.err
# ============================================
# PanForest Pipeline - SLURM Cluster Submission
# ============================================
#
# This is the MAIN submission script that launches Snakemake
# on a SLURM cluster. Snakemake will then submit individual
# jobs for each rule according to the configuration in:
# config/cluster/slurm-config.yaml
#
# USAGE:
# sbatch submit_cluster.sh
#
# OR for dry-run:
# bash submit_cluster.sh --dry-run
#
# ============================================
set -e # Exit on error
set -u # Exit on undefined variable
# ============================================
# CONFIGURATION
# ============================================
# Number of jobs to submit simultaneously
MAX_JOBS=50
# Snakemake targets (leave empty for 'all')
TARGET=""
# Working directory (automatically set to script location)
WORKDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$WORKDIR"
# Create logs directory
mkdir -p logs/slurm
# ============================================
# LOAD MODULES
# ============================================
# Load Anaconda3 module
module load anaconda3
# Activate snakemake environment
# If you don't have a snakemake environment yet, create it with:
# conda create -n snakemake -c conda-forge -c bioconda snakemake
source activate snakemake
# ============================================
# CHECK SNAKEMAKE INSTALLATION
# ============================================
if ! command -v snakemake &> /dev/null; then
echo "ERROR: Snakemake not found in PATH"
echo "Please load the appropriate module or activate conda environment"
exit 1
fi
echo "=================================================="
echo "PanForest Pipeline - Cluster Execution"
echo "=================================================="
echo "Snakemake version: $(snakemake --version)"
echo "Working directory: $WORKDIR"
echo "Max simultaneous jobs: $MAX_JOBS"
echo "=================================================="
echo ""
# ============================================
# PARSE COMMAND LINE ARGUMENTS
# ============================================
DRY_RUN=""
if [[ "$#" -gt 0 ]] && [[ "$1" == "--dry-run" ]]; then
DRY_RUN="--dry-run"
echo "Running in DRY-RUN mode (no jobs will be submitted)"
echo ""
fi
# ============================================
# RUN SNAKEMAKE WITH CLUSTER EXECUTION
# ============================================
snakemake \
--jobs $MAX_JOBS \
--cluster-config config/cluster/slurm-config.yaml \
--cluster "sbatch \
--job-name={rule} \
--partition={cluster.partition} \
--time={cluster.time} \
--mem={cluster.mem} \
--cpus-per-task={cluster.cpus} \
--output={cluster.output} \
--error={cluster.error}" \
--latency-wait 60 \
--use-conda \
--conda-prefix .snakemake/conda \
--printshellcmds \
--reason \
--keep-going \
$DRY_RUN \
$TARGET
# ============================================
# COMPLETION MESSAGE
# ============================================
if [[ -z "$DRY_RUN" ]]; then
echo ""
echo "=================================================="
echo "Pipeline submitted successfully!"
echo "=================================================="
echo ""
echo "Monitor jobs with:"
echo " squeue -u \$USER"
echo ""
echo "Check logs in:"
echo " logs/slurm/"
echo ""
echo "Cancel all jobs:"
echo " scancel -u \$USER --name=panforest_pipeline"
echo "=================================================="
fi