-
Notifications
You must be signed in to change notification settings - Fork 1
/
Script04.sh
50 lines (41 loc) · 1.38 KB
/
Script04.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
#!/bin/bash
# AUTHOR="Michael Gruenstaeudl, PhD"
# COPYRIGHT="Copyright (C) 2016-2018 $AUTHOR"
# CONTACT="[email protected]"
# VERSION="2018.04.03.1800"
# USAGE="bash Script4.sh $FINAL_ASMBLY $LOG"
########################################################################
# SUPPLEMENTARY FILE 4 #
# Bash script to automate the confirmation of IR boundaries via #
# self-blasting. #
########################################################################
# Check if sufficient commandline parameters
numArgmts=$#
if [ ! $numArgmts -eq 2 ]; then
echo "ERROR | Incorrect number of commandline parameters" >&2
exit 1
fi
# Check if input files exist
for v in "$@"; do
if [ ! -f "$v" ]; then
echo "ERROR | File not found: $v" >&2
exit 1
fi
done
# Check if dependencies exist
DEPS=(blastn)
for d in "${DEPS[@]}"; do
if ! [ -x "$(command -v $d)" ]; then
echo "Error: $d is not installed" >&2
exit 1
fi
done
# Assigning commandline arguments
FINAL_ASMBLY=$1
LOG=$2
# Logging results
echo -en "\n# SELF-BLASTING" >> $LOG
echo -e "\n# alignment length, IRa start, IRa end, IRb end, IRb start" >> $LOG
# Self-blasting
blastn -query $FINAL_ASMBLY -subject $FINAL_ASMBLY -outfmt 7 -strand 'both' | awk '{ if ($4 > 10000 && $4 < 50000) print $4, $7, $8, $9, $10}' >> $LOG
#EOF