-
Notifications
You must be signed in to change notification settings - Fork 0
/
rundist
executable file
·77 lines (59 loc) · 2.59 KB
/
rundist
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
#!/usr/bin/env bash
# Run pipeline distributed.
# Requires one of:
# 1) RUN_DIR/config/rundist.sh
# 2) INSTALL_DIR/config/rundist.sh
#
# Where the first script found is the one used. Control is passed to the script.
# Refuse to exeucute from install directory
if [[ $(dirname $(readlink -f $0)) == $(readlink -f $(pwd)) ]]; then
echo "Attempting to execute run script from install directory, or run script was copied to the run directory. Symlink the run script to the run directory, cd to the run directory, and run from there." >&2
exit 1
fi
# Get directory where the script is located
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SITE_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SNAKEFILE="${SITE_DIR}/Snakefile"
SITE_CONFIG_DIR="${SITE_DIR}/config"
LOCAL_CONFIG_DIR="$(readlink -f config)"
# Get jobs
JOB_COUNT=$1
shift
### Pass control over to a control script ###
# Find local site's control script
LOCAL_SCRIPT="${LOCAL_CONFIG_DIR}/rundist.sh"
SITE_SCRIPT="${SITE_CONFIG_DIR}/rundist.sh"
if [[ -f ${LOCAL_SCRIPT} ]]; then
source ${LOCAL_SCRIPT}
exit 0
fi
if [[ -f ${SITE_SCRIPT} ]]; then
source ${SITE_SCRIPT}
exit 0
fi
# No control script found
echo "Missing local control script. \"rundist\" sets up the environment and passes control to a local script"
echo "(\"config/rundist.sh\" in the analysis directory if found, or \"config/rundist.sh\" in the install directory)."
echo "One of these two control scripts must be setup, and it will be sourced by this script to run the pipeline. See"
echo "comments in this \"rundist\" for an example of what the control script would do."
echo
echo "Searched local config: ${LOCAL_SCRIPT}"
echo "Searched site config: ${SITE_SCRIPT}"
exit 1
# Example control script to distribute over an SGE cluster with "config/sge.json" distributed with PAV:
# module load miniconda/4.8.3
# module load samtools/1.10
# module load minimap2/2.17
# module load ucsc/202003
# module load lra/202008
# module load htslib/1.9
#
#snakemake -s ${SNAKEFILE} -j ${JOB_COUNT} --nt --ri -k \
# --jobname "{rulename}.{jobid}" \
# --drmaa " -V -cwd -j y -o ./log -l centos=7 -pe serial {cluster.cpu} -l mfree={cluster.mem} -l disk_free={cluster.disk} -l h_rt={cluster.rt} {cluster.params} -w n -S /bin/bash" \
# -w 60 -u ${SITE_CONFIG_DIR}/sge.json "$@"