-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasm4pg
More file actions
executable file
·107 lines (103 loc) · 3.76 KB
/
asm4pg
File metadata and controls
executable file
·107 lines (103 loc) · 3.76 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
#!/bin/bash
#SBATCH --cpus-per-task=5
#SBATCH -o slurm_logs/asm4pg_slurm_log_%j.log
#SBATCH -e slurm_logs/asm4pg_slurm_log_%j.log
#SBATCH --time=80:00:00
#SBATCH -J asm4pg
#SBATCH --mem=10G
#SBATCH --ntasks=1
# Written by Lucien Piat at INRAe
# Use this script to run asm4pg on a HPC
# Verify arguments
if [ $# -lt 1 ] || [ "$1" == "help" ]; then
echo "Use this script to run asm4pg"
echo ""
echo "Usage: asm4pg [dry|run|local-run|dag|rulegraph|unlock] [additional snakemake args]"
echo " dry - run in dry-run mode"
echo " run - run the workflow with SLURM"
echo " local-run - run the workflow localy (on a single node)"
echo " dag - generate the directed acyclic graph for the workflow"
echo " rulegraph - generate the rulegraph for the workflow"
echo " unlock - Unlock the directory if snakemake crashed"
exit 1
fi
echo "Welcome to Asm4pg! Make sure .config/masterconfig.yaml is correctly edited for this run."
MEM_MB=$(free -m | awk '/^Mem:/{print $2}')
#######################
# Update line 48 with your cluster if not on cbib or genotoul
#######################
echo '🔹 Asm4pg -> Activating execution environment'
case "${SLURM_SUBMIT_HOST:-$(hostname)}" in
**geno**)
echo '🔹 Asm4pg -> Identified genotoul cluster'
module purge
module load containers/Apptainer/1.2.5
source activate wf_env
;;
**bb8**)
echo '🔹 Asm4pg -> Identified cbib cluster, use the local-run on cbib'
module purge
module load miniconda/3
eval "$(conda shell.bash hook)"
conda activate wf_env
MEM_MB=${SLURM_MEM_PER_NODE:-204800}
;;
*)
echo '🔹 Asm4pg -> Unkown host, or local run (if not configure this file line 48)'
;;
esac
run_snakemake() {
local option="$1"
shift # Remove the first argument, keep the rest
local extra_args="$@" # Collect the rest of the arguments
echo '🔹 Asm4pg -> Starting Snakemake workflow'
case "$option" in
dry)
snakemake -c $(nproc) --dry-run --rerun-incomplete $extra_args
;;
touch)
snakemake -c $(nproc) --touch $extra_args
;;
dag)
snakemake -c $(nproc) --dag $extra_args > dag.dot
if [ $? -eq 0 ]; then
echo "✅ Asm4pg -> DAG has been successfully generated as dag.dot"
else
echo "❌ Asm4pg -> Error: Failed to generate DAG."
exit 1
fi
;;
rulegraph)
snakemake -c $(nproc) --rulegraph $extra_args > rulegraph.dot
if [ $? -eq 0 ]; then
echo "✅ Asm4pg -> Rulegraph has been successfully generated as rulegraph.dot"
else
echo "❌ Asm4pg -> Error: Failed to generate Rulegraph."
exit 1
fi
;;
unlock)
snakemake -c $(nproc) --unlock $extra_args
if [ $? -eq 0 ]; then
echo "✅ Asm4pg -> Unlocked"
else
echo "❌ Asm4pg -> Error: Failed to Unlocked"
exit 1
fi
;;
run)
snakemake --workflow-profile ./.config/snakemake/profiles/slurm --rerun-incomplete $extra_args
;;
local-run)
SNG_BIND=$(pwd)
echo "🔹 Asm4pg -> Using $MEM_MB Mb of memory"
snakemake --use-singularity --singularity-args "-B $SNG_BIND" -j $(nproc) --rerun-incomplete --resources mem_mb=$MEM_MB $extra_args
;;
*)
echo "Invalid option: $option"
echo "Usage: asm4pg [dry|run|local-run|dag|rulegraph|unlock] [additional snakemake args]"
exit 1
;;
esac
}
run_snakemake "$@"