-
Notifications
You must be signed in to change notification settings - Fork 4
/
pamir.sh
executable file
·95 lines (64 loc) · 2.33 KB
/
pamir.sh
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
#!/bin/bash
#set -e
SCRIPT_PATH="$(dirname `which $0`)/pamir"
#command -v conda && echo "Found conda, skipping checks :)" >&2 || { NO_CONDA=1; }
VERS_CHECKER="$SCRIPT_PATH/scripts/version_check.py"
ENVIRO_PATH="$SCRIPT_PATH/environment.yaml"
VERS_PATH="$SCRIPT_PATH/version"
ex(){
command -v $1 1> /dev/null 2> /dev/null
if [ "$?" -eq "1" ]
then
echo "$1... Failed, Not in PATH"
exit 1
fi
}
vx(){
printf "$1($2)..."
if [ "$3" -eq 0 ]
then
echo " OK, Version not checked."
return
fi
vers_checker_str=$(cat $ENVIRO_PATH | grep $1 | awk '{print $(NF-1)" "$(NF)}')
python $VERS_CHECKER $vers_checker_str $2
if [ $? -eq "0" ]
then
echo " OK "
else
echo " Failed, requiring $vers_checker_str"
exit 1
fi
}
CFG_PATH=$(echo $@ | sed 's/=/ /g' |awk '{for(i=1;i <= NF;i++){if($i=="--configfile"){print $(i+1)}}}')
if [ -z "$CFG_PATH" ]
then
echo "Run configuration should be provided as ./pamir.sh --configfile /path/to/config"
exit 1
fi
echo "Running Pamir ($(cat $VERS_PATH))"
ex "snakemake"
vx "snakemake" $(snakemake --version |head -n 1| sed 's/[A-Za-z\+]//g') 1
ex "samtools"
vx "samtools" $(samtools --version |head -n 1| awk '{print $2;}' | sed 's/[A-Za-z\+]//g') 1
ex "bedtools"
vx "bedtools" $( bedtools --version |head -n 1| awk '{print $2;}' | cut -d"-" -f1 | sed 's/[A-Za-z\+]//g') 1
ex "mrsfast"
vx "mrsfast" $( mrsfast --version |head -n 1| awk '{print $2;}' | sed 's/[A-Za-z\+]//g') 1
ex "bwa"
vx "bwa" $(bwa 2>&1 | grep Version | awk '{print $2}' | awk -F"-" '{print $1;}') 1
ex "RepeatMasker"
vx "repeatmasker" $(RepeatMasker | head -n1 | sed 's/[A-Za-z\+]//g' | sed 's/ -//') 0
cat $CFG_PATH | grep "blastdb:" &> /dev/null
if [ $? -eq "0" ]
then
ex "blastn"
vx "blast" $( blastn -version |head -n 1| awk '{print $2;}' | sed 's/[A-Za-z\+]//g') 1
fi
#cat $CFG_PATH | grep
if [[ "$@" == *"cluster-config"* ]]; then
mkdir -p ~/.slurm-logs
snakemake -s "${SCRIPT_PATH}/Snakefile" --config SCPA=${SCRIPT_PATH} "$@" --cluster "sbatch --parsable -J {cluster.name} -p {cluster.part} -c {cluster.c} --mem {cluster.mem} -t {cluster.time} --output '$HOME/.slurm-logs/%j.out' --error '$HOME/.slurm-logs/%j.err'";
else
snakemake -s "${SCRIPT_PATH}/Snakefile" --config SCPA=${SCRIPT_PATH} "$@";
fi