This repository has been archived by the owner on Mar 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
dunovo.sh
executable file
·79 lines (68 loc) · 1.97 KB
/
dunovo.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
#!/usr/bin/env bash
if [ x$BASH = x ] || [ ! $BASH_VERSINFO ] || [ $BASH_VERSINFO -lt 4 ]; then
echo "Error: Must use bash version 4+." >&2
exit 1
fi
set -ue
MinReadsDefault=3
QualThresDefault=25
QualFormatDefault=sanger
Usage="Usage: \$ $(basename $0) [options] families.msa.tsv dcs1.fa dcs2.fa [sscs1.fa sscs2.fa]"
function main {
# Read arguments.
if [[ $# -lt 2 ]]; then
fail "$Usage"
fi
min_reads=$MinReadsDefault
qual_thres=$QualThresDefault
qual_format=$QualFormatDefault
while getopts ":r:q:F:h" opt; do
case "$opt" in
r) min_reads=$OPTARG;;
q) qual_thres=$OPTARG;;
F) qual_format=$OPTARG;;
h) echo "$USAGE"
exit;;
esac
done
# Get positionals.
alignments="${@:$OPTIND:1}"
dcs1="${@:$OPTIND+1:1}"
dcs2="${@:$OPTIND+2:1}"
sscs1="${@:$OPTIND+3:1}"
sscs2="${@:$OPTIND+4:1}"
keep_sscs=
if [[ $sscs1 ]] && [[ $sscs2 ]]; then
keep_sscs=true
elif [[ $sscs1 ]] || [[ $sscs2 ]]; then
fail "Error: Must give both sscs1 and sscs2 or neither."
fi
# Find the actual directory this file resides in (resolving links).
if readlink -f dummy >/dev/null 2>/dev/null; then
script_path=$(readlink -f "${BASH_SOURCE[0]}")
else
script_path=$(perl -MCwd -le 'print Cwd::abs_path(shift)' "${BASH_SOURCE[0]}")
fi
script_dir=$(dirname "$script_path")
sscs_args=
if [[ $keep_sscs ]]; then
sscs_args='--sscs-file sscs.fa'
fi
# Locate outconv.py.
# In $script_dir/utils in a normal installation, $script_dir in a Conda installation.
outconv_script="$script_dir/utils/outconv.py"
if ! [[ -f "$outconv_script" ]]; then
outconv_script="$script_dir/outconv.py"
fi
python2 "$script_dir/dunovo.py" -r $min_reads -q $qual_thres -F $qual_format "$alignments" \
$sscs_args > duplex.fa
python2 "$outconv_script" duplex.fa -1 "$dcs1" -2 "$dcs2"
if [[ $keep_sscs ]]; then
python2 "$outconv_script" sscs.fa -1 "$sscs1" -2 "$sscs2"
fi
}
function fail {
echo "$@" >&2
exit 1
}
main "$@"