forked from xuzhougeng/myscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheblastn.sh
83 lines (68 loc) · 1.33 KB
/
eblastn.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
#!/usr/bin/bash
set -e
set -u
set -o pipefail
function usage {
echo -e "Usage: $0 -t 20 -f 6 -w 21 target.fa query.fa"
echo -e "Use option -h | --help for more information"
}
function help {
usage;
echo
echo "Simple BLASTN Wrapper"
echo "---------------"
echo "OPTIONS"
echo
echo " -t|--thread thread"
echo " -f|--outfmt blastn output format"
echo " -w|--wordsize minimum word size to initialize a alignment"
echo "[-h|--help]: help"
}
if [ $# -lt 1 ]
then
usage
exit
fi
for arg in "$@"; do
shift
case "$arg" in
"--thread") set -- "$@" "-t" ;;
"--outfmt") set -- "$@" "-f" ;;
"--wordsize") set -- "$@" "-w" ;;
"--help") set -- "$@" "-h" ;;
*) set -- "$@" $arg
esac
done
THREAD=20
OUTFMT=6
WORDSIZE=21
while getopts ":t:w:f:ch" OPT
do
case $OPT in
t) THREAD=$OPTARG;;
f) OUTFMT=$OPTARG;;
w) WORDSIZE=$OPTARG;;
h) help ;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
if [ $# -lt 2 ]
then
usage
exit
fi
TARGET=$1
QUERY=$2
if [ ! -f $TARGET.nsq ]; then
makeblastdb -in $TARGET -dbtype nucl
fi
blastn -query $QUERY -db $TARGET -outfmt $OUTFMT -num_threads $THREAD -word_size $WORDSIZE