-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblaster_local.sh
executable file
·69 lines (59 loc) · 1.41 KB
/
blaster_local.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
#!/bin/bash
# Copyright 2023 Matthieu Barba
# This program is free software under AGPLv3 license
# License terms are in the LICENSE file, or at <http://www.gnu.org/licenses/>.
# Check if parallel and blast+ are installed
if ! command -v parallel >/dev/null; then
echo "GNU parallel is required. Abort."
exit 1;
fi
if ! command -v makeblastdb >/dev/null; then
echo "Blast++ is required. Abort."
exit 1;
fi
DATA_PATH=.
DATA_FILES=*.fa*
JOBS=""
usage() {
if [ -n "$1" ]; then
echo "[ $1 ]"
fi
read -d '' help << '_EOF_' || true
usage: local_blaster.sh
Files:
-i <path> : directory path where the fasta files are
-f <path> : file descriptor for the fasta files (default: *.fa*)
-n <int> : max number of threads (default: 1)
_EOF_
echo "$help"
exit
}
export -f usage
####################################################
# Run with all parameters
while getopts "i:f:n:h" option
do
case $option in
i)
DATA_PATH=$OPTARG
;;
f)
DATA_FILES=$OPTARG
;;
n)
JOBS=$OPTARG
;;
h)
usage
;;
esac
done
if [ -z "$JOBS" ] ; then JOBS=1; fi
####################################################
cd $DATA_PATH;
# Loop through files
files=`ls $DATA_FILES`
# Prepare all blastdb
(parallel -j $JOBS makeblastdb -dbtype prot -in {} ::: $files) 1> /dev/null 2> /dev/null
# Run in parallel, like 2 nested loops all files vs all files
parallel -j 1 blaster_function.sh {1} {2} $JOBS ::: $files ::: $files || exit 1