forked from artic-network/fieldbioinformatics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-runner.sh
executable file
·169 lines (144 loc) · 4.53 KB
/
test-runner.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash
set -e
#
# test-runner.sh runs a the entire ARTIC field bioinformatics pipeline using a small set
# of data (the Mayinga barcode from an Ebola amplicon library sequenced on a flongle).
#
# full data available: http://artic.s3.climb.ac.uk/run-folders/EBOV_Amplicons_flongle.tar.gz
#
# usage:
# ./test-runner.sh [medaka|nanopolish]
#
# specify either medaka or nanopolish to run the respective workflow of the pipeline
#
###########################################################################################
# Setup the data, commands and the testing function.
# data
inputData="./20190830_1509_MN22126_AAQ411_9efc5448"
primerSchemes="../test-data/primer-schemes"
primerScheme="IturiEBOV/V1"
prefix="ebov-mayinga"
barcode="03"
threads=2
downloadCmd="wget http://artic.s3.climb.ac.uk/run-folders/EBOV_Amplicons_flongle.tar.gz"
extractCmd="tar -vxzf EBOV_Amplicons_flongle.tar.gz"
# pipeline commands
## nanopolish workflow specific
gatherCmd_n="artic gather \
--min-length 400 \
--max-length 800 \
--prefix ${prefix} \
--directory ${inputData} \
--fast5-directory ${inputData}/fast5_pass"
demuxCmd_n="artic demultiplex \
--threads ${threads} \
${prefix}_fastq_pass.fastq"
minionCmd_n="artic minion \
--normalise 200 \
--threads ${threads} \
--scheme-directory ${primerSchemes} \
--read-file ${prefix}_fastq_pass-NB${barcode}.fastq \
--fast5-directory ${inputData}/fast5_pass \
--sequencing-summary ${inputData}/lab-on-an-ssd_20190830_160932_AAQ411_minion_sequencing_run_EBOV_Amplicons_flongle_sequencing_summary.txt \
${primerScheme} \
${prefix}"
## medaka workflow specific
gatherCmd_m="artic gather \
--min-length 400 \
--max-length 800 \
--prefix ${prefix} \
--directory ${inputData} \
--no-fast5s"
demuxCmd_m="artic demultiplex \
--threads ${threads} \
${prefix}_fastq_pass.fastq"
guppyplexCmd_m="artic guppyplex \
--min-length 400 \
--max-length 800 \
--prefix ${prefix} \
--directory ./ \
--output ${prefix}_guppyplex_fastq_pass-NB${barcode}.fastq"
minionCmd_m="artic minion \
--normalise 200 \
--threads ${threads} \
--scheme-directory ${primerSchemes} \
--read-file ${prefix}_guppyplex_fastq_pass-NB${barcode}.fastq \
--medaka \
--medaka-model r941_min_high_g351 \
${primerScheme} \
${prefix}"
# colours
NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
# cmdTester is function to run a command and check for failure
function cmdTester {
echo "###########################################################################################"
echo -e "${BLUE}Running:${NC} $*"
echo
"$@"
echo
local status=$?
if [ $status -ne 0 ]
then
echo -e "${RED}FAIL${NC}" >&2
exit $status
else
echo -e "${GREEN}PASS${NC}" >&2
fi
echo
return
}
###########################################################################################
# Run the tests.
# check that nanopolish or medaka is specified
if [ "$1" == "nanopolish" ] || [ "$1" == "medaka" ]; then
echo -e "${BLUE}Starting tests...${NC}"
echo -e "${BLUE} - using the $1 workflow${NC}"
echo
else
echo "please specify medaka or nanopolish"
echo "./test-runner.sh [medaka|nanopolish]"
exit 1
fi
# setup a tmp directory to work in
mkdir tmp && cd tmp || exit
# download the data
echo "downloading the test data..."
cmdTester $downloadCmd
cmdTester $extractCmd
# run the correct workflow
echo "running the pipeline..."
if [ "$1" == "nanopolish" ]
then
# collect the reads
cmdTester $gatherCmd_n
# demultiplex
cmdTester $demuxCmd_n
# run the core pipeline with nanopolish
cmdTester $minionCmd_n
else
# collect the reads
cmdTester $gatherCmd_m
# demultiplex
cmdTester $demuxCmd_m
# guppyplex
cmdTester $guppyplexCmd_m
# run the core pipeline with medaka
cmdTester $minionCmd_m
fi
###########################################################################################
# Check the output and clean up.
# check output created
echo -e "${BLUE}Checking output...${NC}"
if test -f "${prefix}.consensus.fasta"
then
echo -e "${GREEN} - consensus found${NC}"
else
echo -e "${RED} - no consensus found${NC}"
exit 1
fi
# cleanup
cd .. && rm -r tmp
echo -e "${BLUE}Done.${NC}"