-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblast_wrapper.sh
77 lines (69 loc) · 2.89 KB
/
blast_wrapper.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
#!/bin/bash
Usage="""
Usage: blast_to_gff_wrapper.sh -q <query file> -d <database file> -p <blast program> -o <output file>
Options:
-h : Help. What you are reading now.
-q : Query. Put the path to your query fasta here.
-d : Database. Put the path to your blast database here.
-o : Output. Put the name or path and name to your output location here. Default: blastn
-p : Program. Currently only confirmed to work with tblastn
but others should work too.
-t : Threads. Number of threads/processors you want the blast analysis to
run on. (Default: 1)
"""
OUTPUT=blast.out
THREADS=2
PROGRAM=tblastn
while getopts :q:d:o:p:t:h opt; do
case $opt in
q)
echo "-q (query) was input as $OPTARG" >&2
QUERY=$OPTARG
;;
d)
echo "-d (database) was input as $OPTARG" >&2
DATABASE=$OPTARG
;;
o)
echo "-o (output) was input as $OPTARG" >&2
OUTPUT=$OPTARG
;;
p)
echo "-p (program) was input as $OPTARG" >&2
PROGRAM=$OPTARG
;;
t)
echo "-t (threads) was input as $OPTARG" >&2
THREADS=$OPTARG
;;
l)
echo "-l (long) was triggered, long output triggered" >&2
LONG=true
;;
k)
echo "-k (keep) was triggered, blast output will be kept" >&2
KEEP=true
;;
h)
echo "$Usage"
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Type $0 -h for usage"
exit 1
;;
esac
done
if [[ $PROGRAM = "tblastn" ]] || [[ $PROGRAM = "TBLASTN" ]] && [[ $LONG = false ]] ; then
makeblastdb -dbtype prot -in $QUERY -out $QUERY
tblastn -query $QUERY -db $DATABASE -outfmt "6 qseqid sseqid pident length mismatch gapopen qlen qstart qend slen sstart send evalue bitscore" -out $OUTPUT -num_threads $THREADS
elif [[ $PROGRAM = "blastx" ]] || [[ $PROGRAM = "BLASTX" ]] && [[ $LONG = false ]] ; then
makeblastdb -dbtype prot -in $QUERY -out $QUERY
blastx -query $QUERY -db $DATABASE -outfmt "6 qseqid sseqid pident length mismatch gapopen qlen qstart qend slen sstart send evalue bitscore" -out $OUTPUT -num_threads $THREADS
elif [[ $PROGRAM = "blastn" ]] || [[ $PROGRAM = "BLASTN" ]] && [[ $LONG = false ]] ; then
makeblastdb -dbtype nucl -in $QUERY -out $QUERY
blastn -query $QUERY -db $DATABASE -outfmt "6 qseqid sseqid pident length mismatch gapopen qlen qstart qend slen sstart send evalue bitscore" -out $OUTPUT -num_threads $THREADS
else
echo "Program input incorrectly formatted. Please input blastn/BLASTN, tblastn/TBLASTN or blastx/BLASTX"
fi