-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutDeNovo.sh
executable file
·622 lines (502 loc) · 15.6 KB
/
AutDeNovo.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#!/bin/bash
## AutDeNovo -v 0.2.3 - 16/01/2023
## Author: Martin Kapun, based on the pipeline of TBG Loewe@Senkenberg/Frankfurt from Tilman Schell
###############################################
######### READ COMMANDLINE ARGUMENTS ##########
###############################################
for i in "$@"; do
case $i in
OutputFolder=*)
out="${i#*=}"
;;
Name=*)
name="${i#*=}"
;;
Fwd=*)
fwd="${i#*=}"
;;
Rev=*)
rev="${i#*=}"
;;
ONT=*)
ont="${i#*=}"
;;
PB=*)
pb="${i#*=}"
;;
BuscoDB=*)
busco="${i#*=}"
;;
Decont=*)
decont="${i#*=}"
;;
threads=*)
threads="${i#*=}"
;;
MinReadLen=*)
MinReadLen="${i#*=}"
;;
BaseQuality=*)
BaseQuality="${i#*=}"
;;
RAMAssembly=*)
RAMAssembly="${i#*=}"
;;
RAM=*)
RAM="${i#*=}"
;;
SmudgePlot=*)
SmudgePlot="${i#*=}"
;;
Trimmer=*)
Trimmer="${i#*=}"
;;
Racon=*)
racon="${i#*=}"
;;
*)
# unknown option
;;
esac
done
###############################################
######## TEST IF ALL PARAMETERS ARE SET #######
###############################################
help='''
********************************
************ HELP **************
********************************
AutDeNovo v. 0.02 - 23/02/2022
A typcial command line looks like this:
~/AutDeNovo.sh \ ## The script name
Name=SomeName \ ## The sample name
OutputFolder=/media/output \ ## The full path to the output folder
Fwd=/media/seq/fwd.fq.gz \ ## The full path to the raw read forward FASTQ file
Rev=/media/seq/rev.fq.gz \ ## The full path to the raw read reverse FASTQ file
ONT=Test/subset/ONT \ ## The full path to a folder containing reads generated with ONT
PB=Test/subset/PacBio \ ## The full path to a folder containing reads generated with PacBio
threads=10 \ ## The total number of cores needed [optional; default=10]
RAM=20 \ ## The total amount of RAM [in GB] reserved for all analyses except the denovo assembly [optional; default=20]
RAMAssembly=20 \ ## The total amount of RAM [in GB] reserved for the denovo assembly [optional; default=20]
Trimmer=TrimGalore \ ## The Software used for trimming Illumina data; choose one option from (Atria, FastP, Trimgalore and UrQt) [optional; default=TrimGalore]
MinReadLen=85 \ ## The minimmum read length accepted after trimming, otherwise the read pair gets discarded [optional; default=85]
BaseQuality=20 \ ## The minimmum PHRED-scaled base quality for trimming [optional; default=20]
decont=no \ ## optional decontamination with KRAKEN [default=no]
SmudgePlot=no \ ## optional estimation of ploidy with SmudgePlot [default=no]
BuscoDB=vertebrata_odb10 \ ## The BUSCO database to be used; by default it is set to "vertebrata_odb10"; see here to pick the right one: https://busco.ezlab.org/busco_v4_data.html and here: https://busco.ezlab.org/list_of_lineages.html
Please see below, which parameter is missing:
*******************************
'''
array=("atria" "trimgalore" "urqt" "fastp")
if [ -z "$name" ]; then
echo "## ${help}'Name' is missing: The name of the sample needs to be specified"
exit 1
fi
if [ -z "$out" ]; then
echo "## ${help}'OutputFolder' is missing: The full path to the output folder needs to be defined"
exit 2
fi
if [[ -z "$fwd" && !(-z "$rev" ) ]]; then
echo "## ${help}Fwd read is missing: The full path to the Illumina raw read forward FASTQ file needs to be defined"
exit 3
fi
if [[ -z "$rev" && !(-z "$fwd" ) ]]; then
echo "## ${help}Rev read: The full path to the Illumina raw read revese FASTQ file needs to be defined"
exit 4
fi
if [[ -z "$rev" && -z "$fwd" && -z "$ont" && -z "$pb" ]]; then
echo "## ${help}No input defined"
exit 4
fi
if [[ -z "$rev" && -z "$fwd" && -z "$ont" && -z "$pb" ]]; then
echo "## ${help}No input defined"
exit 4
fi
if [ -z "$Trimmer" ]; then Trimmer="Trimgalore"; fi
if [[ ! " ${array[*]} " =~ " ${Trimmer,,} " ]]; then
echo "## ${help}No correct Trimmer for Illumina data assigned; choose from: Atria, FastP, UrQt or Trimgalore "
exit 4
fi
if [ -z "$busco" ]; then busco="vertebrata_odb10"; fi
if [ -z "$decont" ]; then decont="no"; fi
if [ -z "$threads" ]; then threads="10"; fi
if [ -z "$RAM" ]; then RAM="20"; fi
if [ -z "$RAMAssembly" ]; then RAMAssembly="20"; fi
if [ -z "$SmudgePlot" ]; then SmudgePlot="no"; fi
if [ -z "$racon" ]; then racon="no"; fi
if [ -z "$MinReadLen" ]; then MinReadLen=85; fi
if [ -z "$BaseQuality" ]; then BaseQuality=20; fi
## Test which data are available
if [[ !(-z "$fwd") && -z "$ont" && -z "$pb" ]]; then
data="ILL"
elif [[ !(-z "$fwd") && !(-z "$ont") && -z "$pb" ]]; then
data="ILL_ONT"
elif [[ !(-z "$fwd") && !(-z "$pb") && -z "$ont" ]]; then
data="ILL_PB"
elif [[ !(-z "$fwd") && !(-z "$pb") && !(-z "$ont") ]]; then
data="ILL_ONT_PB"
elif [[ -z "$fwd" && !(-z "$pb") && !(-z "$ont") ]]; then
data="ONT_PB"
elif [[ -z "$fwd" && -z "$pb" && !(-z "$ont") ]]; then
data="ONT"
elif [[ -z "$fwd" && -z "$ont" && !(-z "$pb") ]]; then data="PB"; fi
echo "## Dataset consists of "$data
###############################################
######## RUN ALL STEPS IN THE PIPELINE ########
###############################################
## change to home directory of scripts
BASEDIR=$(dirname $0)
cd $BASEDIR
## (1) make folder structure
mkdir -p ${out}/data
mkdir ${out}/results
mkdir ${out}/shell
mkdir ${out}/log
mkdir ${out}/output
## (1) make copy of original reads
printf "# Copying data\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
## for Illumina data
if [[ !(-z $fwd) ]]; then
mkdir -p ${out}/data/Illumina
cp ${fwd} ${out}/data/Illumina/${name}_1.fq.gz &
cp ${rev} ${out}/data/Illumina/${name}_2.fq.gz
printf "## Illumina data copied\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
fi
## for ONT data
if [[ !(-z $ont) ]]; then
mkdir -p ${out}/data/ONT
if [[ ${ont} != *q.gz ]]; then
cat ${ont}/*q.gz >${out}/data/ONT/${name}_ont.fq.gz &
cp ${ont}/sequencing_summary.txt ${out}/data/ONT/${name}_sequencing_summary.txt
else
cat ${ont} >${out}/data/ONT/${name}_ont.fq.gz
fi
printf "## ONT data copied\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
fi
## for PacBio
if [[ !(-z $pb) ]]; then
module load Tools/samtools-1.12
mkdir -p ${out}/data/PB
if [[ ${pb} == */ ]]; then
cat ${pb}/*q.gz >>${out}/data/PB/${name}_pb.fq.gz
else
cat ${pb} >${out}/data/PB/${name}_pb.fq.gz
fi
printf "## PacBio data copied\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
fi
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
wait
###############################################
############# (1) QC and Trimming #############
printf "# Start raw QC\n" |
tee -a ${out}/shell/pipeline.sh
## Illumina data
if [[ !(-z $fwd) ]]; then
printf "## ... of Illumina data\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/fastqc.sh \
$out \
$name \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
fi
## ONT data
if [[ !(-z $ont) ]]; then
printf "## ... of ONT data\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/nanoplot.sh \
$out \
$name \
"ONT" \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
fi
## PacBio data
if [[ !(-z $pb) ]]; then
printf "## ... of PacBio data\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/nanoplot.sh \
$out \
$name \
"PB" \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
fi
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
## minimum PHRED basequality: 20
## minimum read length 75bp
## automatically detect adapter sequences
if [[ !(-z $fwd) ]]; then
printf "# Start trimming\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/trim_${Trimmer,,}.sh \
$out \
$name \
$PWD \
$threads \
$RAM \
$BaseQuality \
$MinReadLen |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
fi
if [[ $decont != "no" ]]; then
###############################################
########## (2) Detect contamination ###########
## detect human, bacterial and viral contamination in the trimmed reads, make a report and only retain the non-conmatinant reads for de-novo assembly
printf "# Start decontamination\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/kraken.sh \
$out \
$name \
$data \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
fi
##############################################
######## (3) Estimate Genome Size ############
# using Jellyfish to calculate kmer-coverage and genomoscope for formal analyses
printf "# Estimation of genomesize\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/genomesize.sh \
$out \
$name \
$data \
$decont \
$PWD \
$threads \
$RAM \
$RAMAssembly \
$SmudgePlot |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
###############################################
########### (4) Denovo assembly ###############
## denovo assembly with Spades
printf "## Starting denovo assembly\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/denovo.sh \
$out \
$name \
$data \
$decont \
$PWD \
$threads \
$RAMAssembly |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
if [[ $racon != "no" ]]; then
###############################################
########### (5) Polishing with Racon ###############
## denovo assembly with Spades
printf "## Starting polishing with Racon\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/racon.sh \
$out \
$name \
$data \
$PWD \
$threads \
$RAMAssembly \
$racon \
$decont |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
fi
###############################################
########### (6) Assembly QC ###############
## (A) QUAST analysis
printf "# Starting assembly QC with Quast\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/quast.sh \
$out \
$name \
$data \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
# (B) BUSCO analysis
printf "# Starting assembly QC with BUSCO\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/busco.sh \
$out \
$name \
$busco \
$data \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
## (C) Mapping reads
printf "# Mapping reads against reference\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/mapping.sh \
$out \
$name \
$data \
$decont \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
## (D) Blast genome against the nt database
printf "# BLASTing genome against the nt database\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/blast.sh \
$out \
$name \
$data \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
## (E) Summarize results with blobtools
printf "# Summarize with Blobtools\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
sh FullPipeline/blobtools.sh \
$out \
$name \
$busco \
$data \
$PWD \
$threads \
$RAM |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
printf "# Anlayses done!!\n# Now copying results to output folder and writing commands for HTML output\n# check ${out}/output/${name}_HTML_outputs.sh for more details\n# " |
tee -a ${out}/shell/pipeline.sh
date |
tee -a ${out}/shell/pipeline.sh
printf "########################\n\n" |
tee -a ${out}/shell/pipeline.sh
## remove index files and gzip assembly FASTA
rm -f ${out}/output/${name}_${data}.fa.*
pigz ${out}/output/${name}_${data}.fa
printf """
# ############### HTML output #####################
# # run the following commands in terminal to open Firefox and view the HTML output files
# """ >${out}/output/${name}_HTML_outputs.sh
if [[ !(-z $fwd) ]]; then
printf """
## Illumina Data - FASTQC of raw reads
firefox --new-tab ${out}/results/rawQC/${name}_Illumina_fastqc/${name}_1_fastqc.html
firefox --new-tab ${out}/results/rawQC/${name}_Illumina_fastqc/${name}_2_fastqc.html
""" >>${out}/output/${name}_HTML_outputs.sh
cp ${out}/results/rawQC/${name}_Illumina_fastqc/${name}_1_fastqc.zip ${out}/output/${name}_1_raw_Illumina_fastqc.zip &
cp ${out}/results/rawQC/${name}_Illumina_fastqc/${name}_2_fastqc.zip ${out}/output/${name}_2_raw_Illumina_fastqc.zip
printf """
## Illumina Data - FASTQC after trimming
firefox --new-tab ${out}/data/Illumina/${name}_1_val_1_fastqc.html
firefox --new-tab ${out}/data/Illumina/${name}_2_val_2_fastqc.html
""" >>${out}/output/${name}_HTML_outputs.sh
cp ${out}/data/Illumina/${name}_1_val_1_fastqc.zip ${out}/output/${name}_1_trimmed_Illumina_fastqc.zip &
cp ${out}/data/Illumina/${name}_2_val_2_fastqc.zip ${out}/output/${name}_2_trimmed_Illumina_fastqc.zip
if [[ $decont != "no" ]]; then
## kraken
cp ${out}/results/kraken_reads/${name}_Illumina_filtered.report ${out}/output/${name}_Illumina_kraken.txt
fi
fi
if [[ !(-z $ont) ]]; then
## Nanoplot
cp -r ${out}/results/rawQC/${name}_ONT_nanoplot ${out}/output/
if [[ $decont != "no" ]]; then
##kraken
cp ${out}/results/kraken_reads/${name}_ONT_filtered.report ${out}/output/${name}_ONT_kraken.txt
fi
fi
if [[ !(-z $pb) ]]; then
## Nanoplot
cp -r ${out}/results/rawQC/${name}_PB_nanoplot ${out}/output/
if [[ $decont != "no" ]]; then
##kraken
cp ${out}/results/kraken_reads/${name}_PB_filtered.report ${out}/output/${name}_PB_kraken.txt
fi
fi
## genomesize
cp -r ${out}/results/GenomeSize/${name} ${out}/output/${name}_genomesize
#cp ${out}/results/GenomeSize/${name}_smudgeplot.png ${out}/output/${name}_genomesize
##QUAST
#cp ${out}/results/AssemblyQC/Quast/report.pdf ${out}/output/${name}_quast.pdf
##BLAST
cp ${out}/results/BLAST/blastn_${name}.txt ${out}/output/${name}_blastn.txt
pigz ${out}/output/${name}_blastn.txt
## BUSCO
cp -r ${out}/results/AssemblyQC/Busco/${name}/run_${busco}/busco_sequences ${out}/output/
#blobtools
printf """
## QUAST
firefox --new-tab ${out}/results/AssemblyQC/Quast/report.html
""" >>${out}/output/${name}_HTML_outputs.sh
printf """
## Blobtools
source /opt/venv/blobtools-3.0.0/bin/activate
blobtools view \
--out ${out}/results/AssemblyQC/blobtools/out \
--interactive \
${out}/results/AssemblyQC/blobtools \
### now copy the URL that is printed in the commandline and paste it in Firefox
""" >>${out}/output/${name}_HTML_outputs.sh