forked from nf-core/eager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
3629 lines (2958 loc) · 167 KB
/
main.nf
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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env nextflow
/*
============================================================================================================
nf-core/eager
============================================================================================================
EAGER Analysis Pipeline. Started 2018-06-05
#### Homepage / Documentation
https://github.com/nf-core/eager
#### Authors
For a list of authors and contributors, see: https://github.com/nf-core/eager/tree/dev#authors-alphabetical
============================================================================================================
*/
def helpMessage() {
log.info nfcoreHeader()
log.info"""
=========================================
eager v${workflow.manifest.version}
=========================================
Usage:
The typical command for running the pipeline is as follows:
nextflow run nf-core/eager -profile <docker/singularity/conda> --reads'*_R{1,2}.fastq.gz' --fasta '<your_reference>.fasta'
Mandatory arguments:
-profile [str] Configuration profile to use. Can use multiple (comma separated). Ask system administrator if unsure.
Available: conda, docker, singularity, test, awsbatch, <institute> and more
Input
--input [file] Either paths or URLs to FASTQ/BAM data (must be surrounded with quotes). Indicate multiple files with wildcards (*). For paired end data, the path must use '{1,2}' notation to specify read pairs.
OR
A path to a TSV file (ending .tsv) containing file paths and sequencing/sample metadata. Allows for merging of multiple lanes/libraries/samples. Please see documentation for template.
--udg_type [str] Specify here if you have UDG treated libraries, Set to 'half' for partial treatment, or 'full' for UDG. If not set, libraries are assumed to have no UDG treatment ('none'). Not required for TSV input. Default: ${params.udg_type}
--single_stranded [bool] Specifies that libraries are single stranded. Only effects MaltExtract and genotyping pileupCaller. Not required for TSV input.
--single_end [bool] Specifies that the input is single end reads. Not required for TSV input.
--colour_chemistry [num] Specifies what Illumina sequencing chemistry was used. Used to inform whether to poly-G trim if turned on (see below). Not required for TSV input. Options: 2, 4. Default: ${params.colour_chemistry}
--bam [bool] Specifies that the input is in BAM format. Not required for TSV input.
Additional Options:
--snpcapture_bed [file] If library result of SNP capture, path to BED file containing SNPs positions on reference genome.
--run_convertinputbam [bool] Turns on conversion of an input BAM file into FASTQ format to allow re-preprocessing (e.g. AdapterRemoval etc.).
References
--fasta [file] Path or URL to a FASTA reference file (required if not iGenome reference). File suffixes can be: '.fa', '.fn', '.fna', '.fasta'
--genome [str] Name of iGenomes reference (required if not FASTA reference).
--bwa_index [dir] Path to directory containing pre-made BWA indices (i.e. everything before the endings '.amb' '.ann' '.bwt'. Most likely the same path as --fasta). If not supplied will be made for you.
--bt2_index [dir] Path to directory containing pre-made Bowtie2 indices (i.e. everything before the endings e.g. '.1.bt2', '.2.bt2', '.rev.1.bt2'. Most likely the same value as --fasta). If not supplied will be made for you.
--fasta_index [file] Path to samtools FASTA index (typically ending in '.fai').
--seq_dict [file] Path to picard sequence dictionary file (typically ending in '.dict').
--large_ref [bool] Specify to generate more recent '.csi' BAM indices. If your reference genome is larger than 3.5GB, this is recommended due to more efficient data handling with the '.csi' format over the older '.bai'.
--save_reference [bool] Turns on saving reference genome indices for later re-usage.
Output options:
--outdir [dir] The output directory where the results will be saved. Default: ${params.outdir}
-w [dir] The directory where intermediate files will be stored. Recommended: '<outdir>/work/'
Skipping Skip any of the mentioned steps.
--skip_fastqc [bool] Skips both pre- and post-Adapter Removal FastQC steps.
--skip_adapterremoval [bool]
--skip_preseq [bool]
--skip_deduplication [bool]
--skip_damage_calculation [bool]
--skip_qualimap [bool]
Complexity Filtering
--complexity_filter_poly_g [bool] Turn on running poly-G removal on FASTQ files. Will only be performed on 2 colour chemistry machine sequenced libraries.
--complexity_filter_poly_g_min [num] Specify length of poly-g min for clipping to be performed. Default: ${params.complexity_filter_poly_g_min}
Clipping / Merging
--clip_forward_adaptor [str] Specify adapter sequence to be clipped off (forward strand). Default: '${params.clip_forward_adaptor}'
--clip_reverse_adaptor [str] Specify adapter sequence to be clipped off (reverse strand). Default: '${params.clip_reverse_adaptor}'
--clip_readlength [num] Specify read minimum length to be kept for downstream analysis. Default: ${params.clip_readlength}
--clip_min_read_quality [num] Specify minimum base quality for trimming off bases. Default: ${params.clip_min_read_quality}
--min_adap_overlap [num] Specify minimum adapter overlap: Default: ${params.min_adap_overlap}
--skip_collapse [bool] Skip merging forward and reverse reads together. Only applicable for paired-end libraries.
--skip_trim [bool] Skip adapter and quality trimming
--preserve5p [bool] Skip 5p quality base trimming (n, score, window) of 5 prime end.
--mergedonly [bool] Only use merged reads downstream (un-merged reads and singletons are discarded).
Mapping
--mapper [str] Specify which mapper to use. Options: 'bwaaln', 'bwamem', 'circularmapper', 'bowtie2'. Default: '${params.mapper}'
--bwaalnn [num] Specify the -n parameter for BWA aln, i.e. amount of allowed mismatches in alignments. Default: ${params.bwaalnn}
--bwaalnk [num] Specify the -k parameter for BWA aln, i.e. maximum edit distance allowed in a seed. Default: ${params.bwaalnk}
--bwaalnl [num] Specify the -l parameter for BWA aln, i.e. length of seeds to be used. Set to 1024 for whole read. Default: ${params.bwaalnl}
--circularextension [num] Specify the number of bases to extend reference by (circularmapper only). Default: ${params.circularextension}
--circulartarget [chr] Specify the FASTA header of the target chromosome to extend(circularmapper only). Default: '${params.circulartarget}'
--circularfilter [bool] Turn on to remove reads that did not map to the circularised genome (circularmapper only).
--bt2_alignmode [str] Specify the bowtie2 alignment mode. Options: 'local', 'end-to-end'. Default: '${params.bt2_alignmode}'
--bt2_sensitivity [str] Specify the level of sensitivity for the bowtie2 alignment mode. Options: 'no-preset', 'very-fast', 'fast', 'sensitive', 'very-sensitive'. Default: '${params.bt2_sensitivity}'
--bt2n [num] Specify the -N parameter for bowtie2 (mismatches in seed). This will override defaults from alignmode/sensitivity. Default: ${params.bt2n}
--bt2l [num] Specify the -L parameter for bowtie2 (length of seed substrings). This will override defaults from alignmode/sensitivity. Default: ${params.bt2l}
--bt2_trim5 [num] Specify number of bases to trim off from 5' (left) end of read before alignment. Default: ${params.bt2_trim5}
--bt2_trim3 [num] Specify number of bases to trim off from 3' (right) end of read before alignment. Default: ${params.bt2_trim3}
Host removal
--hostremoval_input_fastq [bool] Turn on creating pre-Adapter Removal FASTQ files without reads that mapped to reference (e.g. for public upload of privacy sensitive non-host data)
--hostremoval_mode [str] Host DNA Removal mode. Remove mapped reads completely from FASTQ (remove) or just mask mapped reads sequence by N (replace). Default: '${params.hostremoval_mode}'
BAM Filtering
--run_bam_filtering [bool] Turn on filtering of mapping quality, read lengths, or unmapped reads of BAM files.
--bam_mapping_quality_threshold [num] Minimum mapping quality for reads filter. Default: ${params.bam_mapping_quality_threshold}
--bam_filter_minreadlength [num] Specify minimum read length to be kept after mapping.
--bam_unmapped_type [str] Defines whether to discard all unmapped reads, keep both mapped and unmapped together, or save as bam and/or only fastq format Options: 'discard', 'bam', 'keep', 'fastq', 'both'. Default: '${params.bam_unmapped_type}'
DeDuplication
--dedupper [str] Deduplication method to use. Options: 'markduplicates', 'dedup'. Default: '${params.dedupper}'
--dedup_all_merged [bool] Turn on treating all reads as merged reads.
Library Complexity Estimation
--preseq_step_size [num] Specify the step size of Preseq. Default: ${params.preseq_step_size}
(aDNA) Damage Analysis
--damageprofiler_length [num] Specify length filter for DamageProfiler. Default: ${params.damageprofiler_length}
--damageprofiler_threshold [num] Specify number of bases of each read to consider for DamageProfiler calculations. Default: ${params.damageprofiler_threshold}
--damageprofiler_yaxis [float] Specify the maximum misincorporation frequency that should be displayed on damage plot. Set to 0 to 'autoscale'. Default: ${params.damageprofiler_yaxis}
--run_mapdamage_rescaling Turn on damage rescaling of BAM files using mapDamage2 to probabilistically remove damage.
--rescale_length_5p Length of read for mapDamage2 to rescale from 5p end. Default: ${params.rescale_length_5p}
--rescale_length_3p Length of read for mapDamage2 to rescale from 5p end. Default: ${params.rescale_length_3p}
--run_pmdtools [bool] Turn on PMDtools
--pmdtools_range [num] Specify range of bases for PMDTools. Default: ${params.pmdtools_range}
--pmdtools_threshold [num] Specify PMDScore threshold for PMDTools. Default: ${params.pmdtools_threshold}
--pmdtools_reference_mask [file] Specify a path to reference mask for PMDTools.
--pmdtools_max_reads [num] Specify the maximum number of reads to consider for metrics generation. Default: ${params.pmdtools_max_reads}
Annotation Statistics
--run_bedtools_coverage [bool] Turn on ability to calculate no. reads, depth and breadth coverage of features in reference.
--anno_file [file] Path to GFF or BED file containing positions of features in reference file (--fasta). Path should be enclosed in quotes.
BAM Trimming
--run_trim_bam [bool] Turn on BAM trimming. Will only run on full-UDG or half-UDG libraries.
--bamutils_clip_half_udg_left [num] Specify the number of bases to clip off reads from 'left' end of read for half-UDG libraries. Default: ${params.bamutils_clip_half_udg_left}
--bamutils_clip_half_udg_right [num] Specify the number of bases to clip off reads from 'right' end of read for half-UDG libraries. Default: ${params.bamutils_clip_half_udg_right}
--bamutils_clip_none_udg_left [num] Specify the number of bases to clip off reads from 'left' end of read for non-UDG libraries. Default: ${params.bamutils_clip_none_udg_left}
--bamutils_clip_none_udg_right [num] Specify the number of bases to clip off reads from 'right' end of read for non-UDG libraries. Default: ${params.bamutils_clip_none_udg_right}
--bamutils_softclip [bool] Turn on using softclip instead of hard masking.
Genotyping
--run_genotyping [bool] Turn on genotyping of BAM files.
--genotyping_tool [str] Specify which genotyper to use either GATK UnifiedGenotyper, GATK HaplotypeCaller, Freebayes, or pileupCaller. Options: 'ug', 'hc', 'freebayes', 'pileupcaller', 'angsd'.
--genotyping_source [str] Specify which input BAM to use for genotyping. Options: 'raw', 'trimmed', 'pmd', 'rescaled'. Default: '${params.genotyping_source}'
--gatk_call_conf [num] Specify GATK phred-scaled confidence threshold. Default: ${params.gatk_call_conf}
--gatk_ploidy [num] Specify GATK organism ploidy. Default: ${params.gatk_ploidy}
--gatk_downsample [num] Maximum depth coverage allowed for genotyping before down-sampling is turned on. Default: ${params.gatk_downsample}
--gatk_dbsnp [file] Specify VCF file for output VCF SNP annotation. Optional. Gzip not accepted.
--gatk_hc_out_mode [str] Specify GATK output mode. Options: 'EMIT_VARIANTS_ONLY', 'EMIT_ALL_CONFIDENT_SITES', 'EMIT_ALL_ACTIVE_SITES'. Default: '${params.gatk_hc_out_mode}'
--gatk_hc_emitrefconf [str] Specify HaplotypeCaller mode for emitting reference confidence calls . Options: 'NONE', 'BP_RESOLUTION', 'GVCF'. Default: '${params.gatk_hc_emitrefconf}'
--gatk_ug_out_mode [str] Specify GATK output mode. Options: 'EMIT_VARIANTS_ONLY', 'EMIT_ALL_CONFIDENT_SITES', 'EMIT_ALL_SITES'. Default: '${params.gatk_ug_out_mode}'
--gatk_ug_genotype_model [str] Specify UnifiedGenotyper likelihood model. Options: 'SNP', 'INDEL', 'BOTH', 'GENERALPLOIDYSNP', 'GENERALPLOIDYINDEL'. Default: '${params.gatk_ug_genotype_model}'
--gatk_ug_keep_realign_bam [bool] Specify to keep the BAM output of re-alignment around variants from GATK UnifiedGenotyper.
--gatk_ug_defaultbasequalities [num] Supply a default base quality if a read is missing a base quality score. Setting to -1 turns this off.
--freebayes_C [num] Specify minimum required supporting observations to consider a variant. Default: ${params.freebayes_C}
--freebayes_g [num] Specify to skip over regions of high depth by discarding alignments overlapping positions where total read depth is greater than specified in --freebayes_C. Default: ${params.freebayes_g}
--freebayes_p [num] Specify ploidy of sample in FreeBayes. Default: ${params.freebayes_p}
--pileupcaller_bedfile [file] Specify path to SNP panel in bed format for pileupCaller.
--pileupcaller_snpfile [file] Specify path to SNP panel in EIGENSTRAT format for pileupCaller.
--pileupcaller_method [str] Specify calling method to use. Options: 'randomHaploid', 'randomDiploid', 'majorityCall'. Default: '${params.pileupcaller_method}'
--pileupcaller_transitions_mode [str] Specify the calling mode for transitions. Options: 'AllSites', 'TransitionsMissing', 'SkipTransitions'. Default: '${params.pileupcaller_transitions_mode}'
--angsd_glmodel [str] Specify which ANGSD genotyping likelihood model to use. Options: 'samtools', 'gatk', 'soapsnp', 'syk'. Default: '${params.angsd_glmodel}'
--angsd_glformat [str] Specify which output type to output ANGSD genotyping likelihood results: Options: 'text', 'binary', 'binary_three', 'beagle'. Default: '${params.angsd_glformat}'
--angsd_createfasta [bool] Turn on creation of FASTA from ANGSD genotyping likelhoood.
--angsd_fastamethod [str] Specify which genotype type of 'base calling' to use for ANGSD FASTA generation. Options: 'random', 'common'. Default: '${params.angsd_fastamethod}'
Consensus Sequence Generation
--run_vcf2genome [bool] Turns on ability to create a consensus sequence FASTA file based on a UnifiedGenotyper VCF file and the original reference (only considers SNPs).
--vcf2genome_outfile [str] Specify name of the output FASTA file containing the consensus sequence. Do not include `.vcf` in the file name. Default: '<input_vcf>'
--vcf2genome_header [str] Specify the header name of the consensus sequence entry within the FASTA file. Default: '<input_vcf>'
--vcf2genome_minc [num] Minimum depth coverage required for a call to be included (else N will be called). Default: ${params.vcf2genome_minc}
--vcf2genome_minq [num] Minimum genotyping quality of a call to be called. Else N will be called. Default: ${params.vcf2genome_minq}
--vcf2genome_minfreq [float] Minimum fraction of reads supporting a call to be included. Else N will be called. Default: ${params.vcf2genome_minfreq}
SNP Table Generation
--run_multivcfanalyzer [bool] Turn on MultiVCFAnalyzer. Note: This currently only supports diploid GATK UnifiedGenotyper input.
--write_allele_frequencies [bool] Turn on writing write allele frequencies in the SNP table.
--min_genotype_quality [num] Specify the minimum genotyping quality threshold for a SNP to be called. Default: ${params.min_genotype_quality}
--min_base_coverage [num] Specify the minimum number of reads a position needs to be covered to be considered for base calling. Default: ${params.min_base_coverage}
--min_allele_freq_hom [float] Specify the minimum allele frequency that a base requires to be considered a 'homozygous' call. Default: ${params.min_allele_freq_hom}
--min_allele_freq_het [float] Specify the minimum allele frequency that a base requires to be considered a 'heterozygous' call. Default: ${params.min_allele_freq_het}
--additional_vcf_files [file] Specify paths to additional pre-made VCF files to be included in the SNP table generation. Use wildcard(s) for multiple files. Optional.
--reference_gff_annotations [file] Specify path to the reference genome annotations in '.gff' format. Optional.
--reference_gff_exclude [file] Specify path to the positions to be excluded in '.gff' format. Optional.
--snp_eff_results [file] Specify path to the output file from SNP effect analysis in '.txt' format. Optional.
Mitochondrial to Nuclear Ratio
--run_mtnucratio [bool] Turn on mitochondrial to nuclear ratio calculation.
--mtnucratio_header [str] Specify the name of the reference FASTA entry corresponding to the mitochondrial genome (up to the first space). Default: '${params.mtnucratio_header}'
Sex Determination
--run_sexdeterrmine [bool] Turn on sex determination for human reference genomes.
--sexdeterrmine_bedfile [file] Specify path to SNP panel in bed format for error bar calculation. Optional (see documentation).
Nuclear Contamination for Human DNA
--run_nuclear_contamination [bool] Turn on nuclear contamination estimation for human reference genomes.
--contamination_chrom_name [str] The name of the X chromosome in your bam or FASTA header. 'X' for hs37d5, 'chrX' for HG19. Default: '${params.contamination_chrom_name}'
Metagenomic Screening
--metagenomic_complexity_filter Turn on removal of low-sequence complexity reads for metagenomic screening with bbduk.
--metagenomic_complexity_entropy Specify the entropy threshold that under which a sequencing read will be complexity filtered out. This should be between 0-1. Default: '${params.metagenomic_complexity_entropy}'
--run_metagenomic_screening [bool] Turn on metagenomic screening module for reference-unmapped reads
--metagenomic_tool [str] Specify which classifier to use. Options: 'malt', 'kraken'. Default: '${params.contamination_chrom_name}'
--database [dir] Specify path to classifer database directory. For Kraken2 this can also be a `.tar.gz` of the directory.
--metagenomic_min_support_reads [num] Specify a minimum number of reads a taxon of sample total is required to have to be retained. Not compatible with . Default: ${params.metagenomic_min_support_reads}
--percent_identity [num] Percent identity value threshold for MALT. Default: ${params.percent_identity}
--malt_mode [str] Specify which alignment method to use for MALT. Options: 'Unknown', 'BlastN', 'BlastP', 'BlastX', 'Classifier'. Default: '${params.malt_mode}'
--malt_alignment_mode [str] Specify alignment method for MALT. Options: 'Local', 'SemiGlobal'. Default: '${params.malt_alignment_mode}'
--malt_top_percent [num] Specify the percent for LCA algorithm for MALT (see MEGAN6 CE manual). Default: ${params.malt_top_percent}
--malt_min_support_mode [str] Specify whether to use percent or raw number of reads for minimum support required for taxon to be retained for MALT. Options: 'percent', 'reads'. Default: '${params.malt_min_support_mode}'
--malt_min_support_percent [num] Specify the minimum percentage of reads a taxon of sample total is required to have to be retained for MALT. Default: Default: ${params.malt_min_support_percent}
--malt_max_queries [num] Specify the maximium number of queries a read can have for MALT. Default: ${params.malt_max_queries}
--malt_memory_mode [str] Specify the memory load method. Do not use 'map' with GPFS file systems for MALT as can be very slow. Options: 'load', 'page', 'map'. Default: '${params.malt_memory_mode}'
--malt_sam_output [bool] Specify to also produce SAM alignment files. Note this includes both aligned and unaligned reads, and are gzipped. Note this will result in very large file sizes.
Metagenomic Authentication
--run_maltextract [bool] Turn on MaltExtract for MALT aDNA characteristics authentication
--maltextract_taxon_list [file] Path to a txt file with taxa of interest (one taxon per row, NCBI taxonomy name format)
--maltextract_ncbifiles [dir] Path to directory containing containing NCBI resource files (ncbi.tre and ncbi.map; avaliable: https://github.com/rhuebler/HOPS/)
--maltextract_filter [str] Specify which MaltExtract filter to use. Options: 'def_anc', 'ancient', 'default', 'crawl', 'scan', 'srna', 'assignment'. Default: '${params.maltextract_filter}'
--maltextract_toppercent [num] Specify percent of top alignments to use. Default: ${params.maltextract_toppercent}
--maltextract_destackingoff [bool] Turn off destacking.
--maltextract_downsamplingoff [bool] Turn off downsampling.
--maltextract_duplicateremovaloff [bool] Turn off duplicate removal.
--maltextract_matches [bool] Turn on exporting alignments of hits in BLAST format.
--maltextract_megansummary [bool] Turn on export of MEGAN summary files.
--maltextract_percentidentity [num] Minimum percent identity alignments are required to have to be reported. Recommended to set same as MALT parameter. Default: ${params.maltextract_percentidentity}
--maltextract_topalignment [int] Turn on using top alignments per read after filtering.
Other options:
-name [str] Name for the pipeline run. If not specified, Nextflow will automatically generate a random mnemonic.
--max_memory [str] Memory limit for each step of pipeline. Should be in form e.g. --max_memory '8.GB'. Default: '${params.max_memory}'
--max_time [str] Time limit for each step of the pipeline. Should be in form e.g. --max_time '2.h'. Default: '${params.max_time}'
--max_cpus [str] Maximum number of CPUs to use for each step of the pipeline. Should be in form e.g. Default: '${params.max_cpus}'
--publish_dir_mode [str] Mode for publishing results in the output directory. Available: symlink, rellink, link, copy, copyNoFollow, move. Default: '${params.publish_dir_mode}'
--email [email] Set this parameter to your e-mail address to get a summary e-mail with details of the run sent to you when the workflow exits
--email_on_fail [email] Same as --email, except only send mail if the workflow is not successful
--plaintext_email [email] Receive plain text emails rather than HTML
--max_multiqc_email_size [str] Threshold size for MultiQC report to be attached in notification email. If file generated by pipeline exceeds the threshold, it will not be attached (Default: 25MB)
AWSBatch options:
--awsqueue [str] The AWSBatch JobQueue that needs to be set when running on AWSBatch
--awsregion [str] The AWS Region for your AWS Batch job to run on
--awscli [str] Path to the AWS CLI tool
For a full list and more information of available parameters, consider the documentation (https://github.com/nf-core/eager/).
""".stripIndent()
}
///////////////////////////////////////////////////////////////////////////////
/* -- SET UP CONFIGURATION VARIABLES -- */
///////////////////////////////////////////////////////////////////////////////
// Show help message
params.help = false
if (params.help){
helpMessage()
exit 0
}
// Small console separator to make it easier to read errors after launch
println ""
////////////////////////////////////////////////////
/* -- VALIDATE INPUTS -- */
////////////////////////////////////////////////////
/**FASTA input handling
**/
if (params.fasta) {
file(params.fasta, checkIfExists: true)
lastPath = params.fasta.lastIndexOf(File.separator)
lastExt = params.fasta.lastIndexOf(".")
fasta_base = params.fasta.substring(lastPath+1)
index_base = params.fasta.substring(lastPath+1,lastExt)
if (params.fasta.endsWith('.gz')) {
fasta_base = params.fasta.substring(lastPath+1,lastExt)
index_base = fasta_base.substring(0,fasta_base.lastIndexOf("."))
}
} else {
exit 1, "[nf-core/eager] error: please specify --fasta with the path to your reference"
}
// Validate reference inputs
if("${params.fasta}".endsWith(".gz")){
process unzip_reference{
tag "${zipped_fasta}"
input:
path zipped_fasta from file(params.fasta) // path doesn't like it if a string of an object is not prefaced with a root dir (/), so use file() to resolve string before parsing to `path`
output:
path "$unzip" into ch_fasta into ch_fasta_for_bwaindex,ch_fasta_for_bt2index,ch_fasta_for_faidx,ch_fasta_for_seqdict,ch_fasta_for_circulargenerator,ch_fasta_for_circularmapper,ch_fasta_for_damageprofiler,ch_fasta_for_qualimap,ch_fasta_for_pmdtools,ch_fasta_for_genotyping_ug,ch_fasta_for_genotyping_hc,ch_fasta_for_genotyping_freebayes,ch_fasta_for_genotyping_pileupcaller,ch_fasta_for_vcf2genome,ch_fasta_for_multivcfanalyzer,ch_fasta_for_genotyping_angsd,ch_fasta_for_damagerescaling
script:
unzip = zipped_fasta.toString() - '.gz'
"""
pigz -f -d -p ${task.cpus} $zipped_fasta
"""
}
} else {
fasta_for_indexing = Channel
.fromPath("${params.fasta}", checkIfExists: true)
.into{ ch_fasta_for_bwaindex; ch_fasta_for_bt2index; ch_fasta_for_faidx; ch_fasta_for_seqdict; ch_fasta_for_circulargenerator; ch_fasta_for_circularmapper; ch_fasta_for_damageprofiler; ch_fasta_for_qualimap; ch_fasta_for_pmdtools; ch_fasta_for_genotyping_ug; ch_fasta__for_genotyping_hc; ch_fasta_for_genotyping_hc; ch_fasta_for_genotyping_freebayes; ch_fasta_for_genotyping_pileupcaller; ch_fasta_for_vcf2genome; ch_fasta_for_multivcfanalyzer;ch_fasta_for_genotyping_angsd;ch_fasta_for_damagerescaling }
}
// Check that fasta index file path ends in '.fai'
if (params.fasta_index && !params.fasta_index.endsWith(".fai")) {
exit 1, "The specified fasta index file (${params.fasta_index}) is not valid. Fasta index files should end in '.fai'."
}
// Check if genome exists in the config file. params.genomes is from igenomes.conf, params.genome specified by user
if ( params.genome && !params.genomes.containsKey(params.genome)) {
exit 1, "[nf-core/eager] error: the provided genome '${params.genome}' is not available in the iGenomes file. Currently the available genomes are ${params.genomes.keySet().join(", ")}."
}
// Mapper validation
if (params.mapper != 'bwaaln' && !params.mapper == 'circularmapper' && !params.mapper == 'bwamem' && !params.mapper == "bowtie2"){
exit 1, "[nf-core/eager] error: invalid mapper option. Options are: 'bwaaln', 'bwamem', 'circularmapper', 'bowtie2'. Default: 'bwaaln'. Found parameter: --mapper '${params.mapper}'."
}
if (params.mapper == 'bowtie2' && params.bt2_alignmode != 'local' && params.bt2_alignmode != 'end-to-end' ) {
exit 1, "[nf-core/eager] error: invalid bowtie2 alignment mode. Options: 'local', 'end-to-end'. Found parameter: --bt2_alignmode '${params.bt2_alignmode}'"
}
if (params.mapper == 'bowtie2' && params.bt2_sensitivity != 'no-preset' && params.bt2_sensitivity != 'very-fast' && params.bt2_sensitivity != 'fast' && params.bt2_sensitivity != 'sensitive' && params.bt2_sensitivity != 'very-sensitive' ) {
exit 1, "[nf-core/eager] error: invalid bowtie2 sensitivity mode. Options: 'no-preset', 'very-fast', 'fast', 'sensitive', 'very-sensitive'. Options are for both alignmodes Found parameter: --bt2_sensitivity '${params.bt2_sensitivity}'."
}
if (params.bt2n != 0 && params.bt2n != 1) {
exit 1, "[nf-core/eager] error: invalid bowtie2 --bt2n (-N) parameter. Options: 0, 1. Found parameter: --bt2n ${params.bt2n}."
}
// Index files provided? Then check whether they are correct and complete
if( params.bwa_index != '' && (params.mapper == 'bwaaln' | params.mapper == 'bwamem' | params.mapper == 'circularmapper')){
Channel
.fromPath(params.bwa_index, checkIfExists: true)
.ifEmpty { exit 1, "[nf-core/eager] error: bwa indices not found in: ${index_base}." }
.into {bwa_index; bwa_index_bwamem}
bt2_index = Channel.empty()
}
if( params.bt2_index != '' && params.mapper == 'bowtie2' ){
lastPath = params.bt2_index.lastIndexOf(File.separator)
bt2_dir = params.bt2_index.substring(0,lastPath+1)
bt2_base = params.bt2_index.substring(lastPath+1)
Channel
.fromPath(params.bt2_index, checkIfExists: true)
.ifEmpty { exit 1, "[nf-core/eager] error: bowtie2 indices not found in: ${bt2_dir}." }
.into {bt2_index; bt2_index_bwamem}
bwa_index = Channel.empty()
bwa_index_bwamem = Channel.empty()
}
// Validate BAM input isn't set to paired_end
if ( params.bam && !params.single_end ) {
exit 1, "[nf-core/eager] error: bams can only be specified with --single_end. Please check input command."
}
// Validate that skip_collapse is only set to True for paired_end reads!
if (!has_extension(params.input, "tsv") && params.skip_collapse && params.single_end){
exit 1, "[nf-core/eager] error: --skip_collapse can only be set for paired_end samples."
}
// Host removal mode validation
if (params.hostremoval_input_fastq){
if (!(['remove','replace'].contains(params.hostremoval_mode))) {
exit 1, "[nf-core/eager] error: --hostremoval_mode can only be set to 'remove' or 'replace'."
}
}
if (params.bam_unmapped_type == '') {
exit 1, "[nf-core/eager] error: please specify valid unmapped read output format. Options: 'discard', 'keep', 'bam', 'fastq', 'both'. Found parameter: --bam_unmapped_type '${params.bam_unmapped_type}'."
}
// Bedtools validation
if(params.run_bedtools_coverage && params.anno_file == ''){
exit 1, "[nf-core/eager] error: you have turned on bedtools coverage, but not specified a BED or GFF file with --anno_file. Please validate your parameters."
}
// Set up channels for annotation file
if (!params.run_bedtools_coverage){
ch_anno_for_bedtools = Channel.empty()
} else {
Channel
ch_anno_for_bedtools = Channel.fromPath(params.anno_file, checkIfExists: true)
.ifEmpty { exit 1, "[nf-core/eager] error: bedtools annotation file not found. Supplied parameter: --anno_file ${params.anno_file}."}
}
// BAM filtering validation
if (!params.run_bam_filtering && params.bam_mapping_quality_threshold != 0) {
exit 1, "[nf-core/eager] error: please turn on BAM filtering if you want to perform mapping quality filtering! Provide: --run_bam_filtering."
}
if (params.run_bam_filtering && params.bam_unmapped_type != 'discard' && params.bam_unmapped_type != 'keep' && params.bam_unmapped_type != 'bam' && params.bam_unmapped_type != 'fastq' && params.bam_unmapped_type != 'both' ) {
exit 1, "[nf-core/eager] error: please specify how to deal with unmapped reads. Options: 'discard', 'keep', 'bam', 'fastq', 'both'."
}
// Deduplication validation
if (params.dedupper != 'dedup' && params.dedupper != 'markduplicates') {
exit 1, "[nf-core/eager] error: Selected deduplication tool is not recognised. Options: 'dedup' or 'markduplicates'. Found parameter: --dedupper '${params.dedupper}'."
}
if (params.dedupper == 'dedup' && !params.mergedonly) {
log.warn "[nf-core/eager] Warning: you are using DeDup but without specifying --mergedonly for AdapterRemoval, dedup will likely fail! See documentation for more information."
}
// SexDetermination channel set up and bedfile validation
if (params.sexdeterrmine_bedfile == '') {
ch_bed_for_sexdeterrmine = Channel.fromPath("$projectDir/assets/nf-core_eager_dummy.txt")
} else {
ch_bed_for_sexdeterrmine = Channel.fromPath(params.sexdeterrmine_bedfile, checkIfExists: true)
}
// Genotyping validation
if (params.run_genotyping){
if (params.genotyping_source != 'raw' && params.genotyping_source != 'pmd' && params.genotyping_source != 'trimmed' && params.genotyping_source != 'rescaled' ) {
exit 1, "[nf-core/eager] error: please specify a valid genotyping source. Options: 'raw', 'pmd', 'trimmed', 'rescaled'. Found parameter: --genotyping_source '${params.genotyping_source}'."
}
if (params.genotyping_tool != 'ug' && params.genotyping_tool != 'hc' && params.genotyping_tool != 'freebayes' && params.genotyping_tool != 'pileupcaller' && params.genotyping_tool != 'angsd' ) {
exit 1, "[nf-core/eager] error: please specify a valid genotyper. Options: 'ug', 'hc', 'freebayes', 'pileupcaller'. Found parameter: --genotyping_tool '${params.genotyping_tool}'."
}
if (params.gatk_ug_out_mode != 'EMIT_VARIANTS_ONLY' && params.gatk_ug_out_mode != 'EMIT_ALL_CONFIDENT_SITES' && params.gatk_ug_out_mode != 'EMIT_ALL_SITES') {
exit 1, "[nf-core/eager] error: please check your GATK output mode. Options are: 'EMIT_VARIANTS_ONLY', 'EMIT_ALL_CONFIDENT_SITES', 'EMIT_ALL_SITES'. Found parameter: --gatk_ug_out_mode '${params.gatk_out_mode}'."
}
if (params.gatk_hc_out_mode != 'EMIT_VARIANTS_ONLY' && params.gatk_hc_out_mode != 'EMIT_ALL_CONFIDENT_SITES' && params.gatk_hc_out_mode != 'EMIT_ALL_ACTIVE_SITES') {
exit 1, "[nf-core/eager] error: please check your GATK output mode. Options are: 'EMIT_VARIANTS_ONLY', 'EMIT_ALL_CONFIDENT_SITES', 'EMIT_ALL_SITES'. Found parameter: --gatk_out_mode '${params.gatk_out_mode}'."
}
if (params.genotyping_tool == 'ug' && (params.gatk_ug_genotype_model != 'SNP' && params.gatk_ug_genotype_model != 'INDEL' && params.gatk_ug_genotype_model != 'BOTH' && params.gatk_ug_genotype_model != 'GENERALPLOIDYSNP' && params.gatk_ug_genotype_model != 'GENERALPLOIDYINDEL')) {
exit 1, "[nf-core/eager] error: please check your UnifiedGenotyper genotype model. Options: 'SNP', 'INDEL', 'BOTH', 'GENERALPLOIDYSNP', 'GENERALPLOIDYINDEL'. Found parameter: --gatk_ug_genotype_model '${params.gatk_ug_genotype_model}'."
}
if (params.genotyping_tool == 'hc' && (params.gatk_hc_emitrefconf != 'NONE' && params.gatk_hc_emitrefconf != 'GVCF' && params.gatk_hc_emitrefconf != 'BP_RESOLUTION')) {
exit 1, "[nf-core/eager] error: please check your HaplotyperCaller reference confidence parameter. Options: 'NONE', 'GVCF', 'BP_RESOLUTION'. Found parameter: --gatk_hc_emitrefconf '${params.gatk_hc_emitrefconf}'."
}
if (params.genotyping_tool == 'pileupcaller' && ! ( params.pileupcaller_method == 'randomHaploid' || params.pileupcaller_method == 'randomDiploid' || params.pileupcaller_method == 'majorityCall' ) ) {
exit 1, "[nf-core/eager] error: please check your pileupCaller method parameter. Options: 'randomHaploid', 'randomDiploid', 'majorityCall'. Found parameter: --pileupcaller_method '${params.pileupcaller_method}'."
}
if (params.genotyping_tool == 'pileupcaller' && ( params.pileupcaller_bedfile == '' || params.pileupcaller_snpfile == '' ) ) {
exit 1, "[nf-core/eager] error: please check your pileupCaller bed file and snp file parameters. You must supply a bed file and a snp file."
}
if (params.genotyping_tool == 'angsd' && ! ( params.angsd_glmodel == 'samtools' || params.angsd_glmodel == 'gatk' || params.angsd_glmodel == 'soapsnp' || params.angsd_glmodel == 'syk' ) ) {
exit 1, "[nf-core/eager] error: please check your ANGSD genotyping model! Options: 'samtools', 'gatk', 'soapsnp', 'syk'. Found parameter: --angsd_glmodel' ${params.angsd_glmodel}'."
}
if (params.genotyping_tool == 'angsd' && ! ( params.angsd_glformat == 'text' || params.angsd_glformat == 'binary' || params.angsd_glformat == 'binary_three' || params.angsd_glformat == 'beagle' ) ) {
exit 1, "[nf-core/eager] error: please check your ANGSD genotyping model! Options: 'text', 'binary', 'binary_three', 'beagle'. Found parameter: --angsd_glmodel '${params.angsd_glmodel}'."
}
if ( !params.angsd_createfasta && params.angsd_fastamethod != 'random' ) {
exit 1, "[nf-core/eager] error: to output a ANGSD FASTA file, please turn on FASTA creation with --angsd_createfasta."
}
if ( params.angsd_createfasta && !( params.angsd_fastamethod == 'random' || params.angsd_fastamethod == 'common' ) ) {
exit 1, "[nf-core/eager] error: please check your ANGSD FASTA file creation method. Options: 'random', 'common'. Found parameter: --angsd_fastamethod '${params.angsd_fastamethod}'."
}
if (params.genotyping_tool == 'pileupcaller' && ! ( params.pileupcaller_transitions_mode == 'AllSites' || params.pileupcaller_transitions_mode == 'TransitionsMissing' || params.pileupcaller_transitions_mode == 'SkipTransitions') ) {
exit 1, "[nf-core/eager] error: please check your pileupCaller transitions mode parameter. Options: 'AllSites', 'TransitionsMissing', 'SkipTransitions'. Found parameter: --pileupcaller_transitions_mode '${params.pileupcaller_transitions_mode}'"
}
}
// pileupCaller channel generation and input checks for 'random sampling' genotyping
if (params.pileupcaller_bedfile.isEmpty()) {
ch_bed_for_pileupcaller = Channel.fromPath("$projectDir/assets/nf-core_eager_dummy.txt")
} else {
ch_bed_for_pileupcaller = Channel.fromPath(params.pileupcaller_bedfile, checkIfExists: true)
}
if (params.pileupcaller_snpfile.isEmpty ()) {
ch_snp_for_pileupcaller = Channel.fromPath("$projectDir/assets/nf-core_eager_dummy2.txt")
} else {
ch_snp_for_pileupcaller = Channel.fromPath(params.pileupcaller_snpfile, checkIfExists: true)
}
// Consensus sequence generation validation
if (params.run_vcf2genome) {
if (!params.run_genotyping) {
exit 1, "[nf-core/eager] error: consensus sequence generation requires genotyping via UnifiedGenotyper on be turned on with the parameter --run_genotyping and --genotyping_tool 'ug'. Please check your genotyping parameters."
}
if (params.genotyping_tool != 'ug') {
exit 1, "[nf-core/eager] error: consensus sequence generation requires genotyping via UnifiedGenotyper on be turned on with the parameter --run_genotyping and --genotyping_tool 'ug'. Found parameter: --genotyping_tool '${params.genotyping_tool}'."
}
}
// MultiVCFAnalyzer validation
if (params.run_multivcfanalyzer) {
if (!params.run_genotyping) {
exit 1, "[nf-core/eager] error: MultiVCFAnalyzer requires genotyping to be turned on with the parameter --run_genotyping. Please check your genotyping parameters."
}
if (params.genotyping_tool != "ug") {
exit 1, "[nf-core/eager] error: MultiVCFAnalyzer only accepts VCF files from GATK UnifiedGenotyper. Found parameter: --genotyping_tool '${params.genotyping_tool}'."
}
if (params.gatk_ploidy != 2) {
exit 1, "[nf-core/eager] error: MultiVCFAnalyzer only accepts VCF files generated with a GATK ploidy set to 2. Found parameter: --gatk_ploidy ${params.gatk_ploidy}."
}
if (params.additional_vcf_files != '') {
ch_extravcfs_for_multivcfanalyzer = Channel.fromPath(params.additional_vcf_files, checkIfExists: true)
}
}
// Metagenomic validation
if (params.run_metagenomic_screening) {
if ( params.bam_unmapped_type == "discard" ) {
exit 1, "[nf-core/eager] error: metagenomic classification can only run on unmapped reads. Please supply --bam_unmapped_type 'fastq'. Supplied: --bam_unmapped_type '${params.bam_unmapped_type}'."
}
if (params.bam_unmapped_type != 'fastq' ) {
exit 1, "[nf-core/eager] error: metagenomic classification can only run on unmapped reads in FASTQ format. Please supply --bam_unmapped_type 'fastq'. Found parameter: --bam_unmapped_type '${params.bam_unmapped_type}'."
}
if (params.metagenomic_tool != 'malt' && params.metagenomic_tool != 'kraken') {
exit 1, "[nf-core/eager] error: metagenomic classification can currently only be run with 'malt' or 'kraken' (kraken2). Please check your classifier. Found parameter: --metagenomic_tool '${params.metagenomic_tool}'."
}
if (params.database == '' ) {
exit 1, "[nf-core/eager] error: metagenomic classification requires a path to a database directory. Please specify one with --database '/path/to/database/'."
}
if (params.metagenomic_tool == 'malt' && params.malt_mode != 'BlastN' && params.malt_mode != 'BlastP' && params.malt_mode != 'BlastX') {
exit 1, "[nf-core/eager] error: unknown MALT mode specified. Options: 'BlastN', 'BlastP', 'BlastX'. Found parameter: --malt_mode '${params.malt_mode}'."
}
if (params.metagenomic_tool == 'malt' && params.malt_alignment_mode != 'Local' && params.malt_alignment_mode != 'SemiGlobal') {
exit 1, "[nf-core/eager] error: unknown MALT alignment mode specified. Options: 'Local', 'SemiGlobal'. Found parameter: --malt_alignment_mode '${params.malt_alignment_mode}'."
}
if (params.metagenomic_tool == 'malt' && params.malt_min_support_mode == 'percent' && params.metagenomic_min_support_reads != 1) {
exit 1, "[nf-core/eager] error: incompatible MALT min support configuration. Percent can only be used with --malt_min_support_percent. You modified: --metagenomic_min_support_reads."
}
if (params.metagenomic_tool == 'malt' && params.malt_min_support_mode == 'reads' && params.malt_min_support_percent != 0.01) {
exit 1, "[nf-core/eager] error: incompatible MALT min support configuration. Reads can only be used with --malt_min_supportreads. You modified: --malt_min_support_percent."
}
if (params.metagenomic_tool == 'malt' && params.malt_memory_mode != 'load' && params.malt_memory_mode != 'page' && params.malt_memory_mode != 'map') {
exit 1, "[nf-core/eager] error: unknown MALT memory mode specified. Options: 'load', 'page', 'map'. Found parameter: --malt_memory_mode '${params.malt_memory_mode}'."
}
if (!params.metagenomic_min_support_reads.toString().isInteger()){
exit 1, "[nf-core/eager] error: incompatible min_support_reads configuration. min_support_reads can only be used with integers. --metagenomic_min_support_reads Found parameter: ${params.metagenomic_min_support_reads}."
}
}
// Create input channel for MALT database directory, checking directory exists
if ( params.database == '') {
ch_db_for_malt = Channel.empty()
} else {
ch_db_for_malt = Channel.fromPath(params.database, checkIfExists: true)
}
// MaltExtract validation
if (params.run_maltextract) {
if (params.run_metagenomic_screening && params.metagenomic_tool != 'malt') {
exit 1, "[nf-core/eager] error: MaltExtract can only accept MALT output. Please supply --metagenomic_tool 'malt'. Found parameter: --metagenomic_tool '${params.metagenomic_tool}'"
}
if (params.run_metagenomic_screening && params.metagenomic_tool != 'malt') {
exit 1, "[nf-core/eager] error: MaltExtract can only accept MALT output. Please supply --metagenomic_tool 'malt'. Found parameter: --metagenomic_tool '${params.metagenomic_tool}'"
}
if (params.maltextract_taxon_list == '') {
exit 1, "[nf-core/eager] error: MaltExtract requires a taxon list specifying the target taxa of interest. Specify the file with --params.maltextract_taxon_list."
}
if (params.maltextract_filter != 'def_anc' && params.maltextract_filter != 'default' && params.maltextract_filter != 'ancient' && params.maltextract_filter != 'scan' && params.maltextract_filter != 'crawl' && params.maltextract_filter != 'srna') {
exit 1, "[nf-core/eager] error: unknown MaltExtract filter specified. Options are: 'def_anc', 'default', 'ancient', 'scan', 'crawl', 'srna'. Found parameter: --maltextract_filter '${params.maltextract_filter}'."
}
}
// Create input channel for MaltExtract taxon list, to allow downloading of taxon list, checking file exists.
if ( params.maltextract_taxon_list== '' ) {
ch_taxonlist_for_maltextract = Channel.empty()
} else {
ch_taxonlist_for_maltextract = Channel.fromPath(params.maltextract_taxon_list, checkIfExists: true)
}
// Create input channel for MaltExtract NCBI files, checking files exists.
if ( params.maltextract_ncbifiles == '' ) {
ch_ncbifiles_for_maltextract = Channel.empty()
} else {
ch_ncbifiles_for_maltextract = Channel.fromPath(params.maltextract_ncbifiles, checkIfExists: true)
}
// Has the run name been specified by the user?
// this has the bonus effect of catching both -name and --name
custom_runName = params.name
if (!(workflow.runName ==~ /[a-z]+_[a-z]+/)) {
custom_runName = workflow.runName
}
// Check AWS batch settings
if (workflow.profile.contains('awsbatch')) {
// AWSBatch sanity checking
if (!params.awsqueue || !params.awsregion) exit 1, "Specify correct --awsqueue and --awsregion parameters on AWSBatch!"
// Check outdir paths to be S3 buckets if running on AWSBatch
// related: https://github.com/nextflow-io/nextflow/issues/813
if (!params.outdir.startsWith('s3:')) exit 1, "Outdir not on S3 - specify S3 Bucket to run on AWSBatch!"
// Prevent trace files to be stored on S3 since S3 does not support rolling files.
if (params.tracedir.startsWith('s3:')) exit 1, "Specify a local tracedir or run without trace! S3 cannot be used for tracefiles."
}
////////////////////////////////////////////////////
/* -- CONFIG FILES -- */
////////////////////////////////////////////////////
ch_multiqc_config = file("$projectDir/assets/multiqc_config.yaml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.empty()
ch_eager_logo = file("$projectDir/docs/images/nf-core_eager_logo.png")
ch_output_docs = file("$projectDir/docs/output.md", checkIfExists: true)
ch_output_docs_images = file("$projectDir/docs/images/", checkIfExists: true)
where_are_my_files = file("$projectDir/assets/where_are_my_files.txt")
///////////////////////////////////////////////////
/* -- INPUT FILE LOADING AND VALIDATING -- */
///////////////////////////////////////////////////
// check if we have valid --reads or --input
if (params.input == null) {
exit 1, "[nf-core/eager] error: --input was not supplied! Please check '--help' or documentation under 'running the pipeline' for details"
}
// Read in files properly from TSV file
tsv_path = null
if (params.input && (has_extension(params.input, "tsv"))) tsv_path = params.input
ch_input_sample = Channel.empty()
if (tsv_path) {
tsv_file = file(tsv_path)
if (tsv_file instanceof List) exit 1, "[nf-core/eager] error: can only accept one TSV file per run."
if (!tsv_file.exists()) exit 1, "[nf-core/eager] error: input TSV file could not be found. Does the file exist and is it in the right place? You gave the path: ${params.input}"
ch_input_sample = extract_data(tsv_path)
} else if (params.input && !has_extension(params.input, "tsv")) {
log.info ""
log.info "No TSV file provided - creating TSV from supplied directory."
log.info "Reading path(s): ${params.input}\n"
inputSample = retrieve_input_paths(params.input, params.colour_chemistry, params.single_end, params.single_stranded, params.udg_type, params.bam)
ch_input_sample = inputSample
} else exit 1, "[nf-core/eager] error: --input file(s) not correctly not supplied or improperly defined, see '--help' flag and documentation under 'running the pipeline' for details."
ch_input_sample
.into { ch_input_sample_downstream; ch_input_sample_check }
///////////////////////////////////////////////////
/* -- INPUT CHANNEL CREATION -- */
///////////////////////////////////////////////////
// Check we don't have any duplicate file names
ch_input_sample_check
.map {
it ->
def r1 = file(it[8]).getName()
def r2 = file(it[9]).getName()
def bam = file(it[10]).getName()
[r1, r2, bam]
}
.collect()
.map{
file ->
filenames = file
filenames -= 'NA'
if( filenames.size() != filenames.unique().size() )
exit 1, "[nf-core/eager] error: You have duplicate input FASTQ and/or BAM file names! All files must have unique names, different directories are not sufficent. Please check your input."
}
// Drop samples with R1/R2 to fastQ channel, BAM samples to other channel
ch_branched_input = ch_input_sample_downstream.branch{
fastq: it[8] != 'NA' //These are all fastqs
bam: it[10] != 'NA' //These are all BAMs
}
//Removing BAM/BAI in case of a FASTQ input
ch_fastq_channel = ch_branched_input.fastq.map {
samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, r1, r2, bam ->
[samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, r1, r2]
}
//Removing R1/R2 in case of BAM input
ch_bam_channel = ch_branched_input.bam.map {
samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, r1, r2, bam ->
[samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, bam]
}
// Prepare starting channels, here we go
ch_input_for_convertbam = Channel.empty()
ch_bam_channel
.into { ch_input_for_convertbam; ch_input_for_indexbam; }
// Also need to send raw files for lane merging, if we want to host removed fastq
ch_fastq_channel
.into { ch_input_for_skipconvertbam; ch_input_for_lanemerge_hostremovalfastq }
///////////////////////////////////////////////////
/* -- HEADER LOG INFO -- */
///////////////////////////////////////////////////
log.info nfcoreHeader()
def summary = [:]
summary['Pipeline Name'] = 'nf-core/eager'
summary['Pipeline Version'] = workflow.manifest.version
if (workflow.revision) summary['Pipeline Release'] = workflow.revision
summary['Run Name'] = custom_runName ?: workflow.runName
summary['Input'] = params.input
summary['Convert input BAM?'] = params.run_convertinputbam ? 'Yes' : 'No'
summary['Fasta Ref'] = params.fasta
summary['BAM Index Type'] = (params.large_ref == "") ? 'BAI' : 'CSI'
if(params.bwa_index || params.bt2_index ) summary['BWA Index'] = "Yes"
summary['Skipping FASTQC?'] = params.skip_fastqc ? 'Yes' : 'No'
summary['Skipping AdapterRemoval?'] = params.skip_adapterremoval ? 'Yes' : 'No'
if (!params.skip_adapterremoval) {
summary['Skip Read Merging'] = params.skip_collapse ? 'Yes' : 'No'
summary['Skip Adapter Trimming'] = params.skip_trim ? 'Yes' : 'No'
}
summary['Running BAM filtering'] = params.run_bam_filtering ? 'Yes' : 'No'
if (params.run_bam_filtering) {
summary['Skip Read Merging'] = params.bam_unmapped_type
}
summary['Run Fastq Host Removal'] = params.hostremoval_input_fastq ? 'Yes' : 'No'
if (params.hostremoval_input_fastq){
summary['Host removal mode'] = params.hostremoval_mode
}
summary['Skipping Preseq?'] = params.skip_preseq ? 'Yes' : 'No'
summary['Skipping Deduplication?'] = params.skip_deduplication ? 'Yes' : 'No'
summary['Skipping DamageProfiler?'] = params.skip_damage_calculation ? 'Yes' : 'No'
summary['Skipping Qualimap?'] = params.skip_qualimap ? 'Yes' : 'No'
summary['Run BAM Trimming?'] = params.run_trim_bam ? 'Yes' : 'No'
summary['Run PMDtools?'] = params.run_pmdtools ? 'Yes' : 'No'
summary['Run Genotyping?'] = params.run_genotyping ? 'Yes' : 'No'
if (params.run_genotyping){
summary['Genotyping Tool?'] = params.genotyping_tool
summary['Genotyping BAM Input?'] = params.genotyping_source
}
summary['Run MultiVCFAnalyzer'] = params.run_multivcfanalyzer ? 'Yes' : 'No'
summary['Run VCF2Genome'] = params.run_vcf2genome ? 'Yes' : 'No'
summary['Run SexDetErrMine'] = params.run_sexdeterrmine ? 'Yes' : 'No'
summary['Run Nuclear Contamination Estimation'] = params.run_nuclear_contamination ? 'Yes' : 'No'
summary['Run Bedtools Coverage'] = params.run_bedtools_coverage ? 'Yes' : 'No'
summary['Run Metagenomic Binning'] = params.run_metagenomic_screening ? 'Yes' : 'No'
if (params.run_metagenomic_screening) {
summary['Metagenomic Tool'] = params.metagenomic_tool
summary['Run MaltExtract'] = params.run_maltextract ? 'Yes' : 'No'
}
summary['Max Resources'] = "$params.max_memory memory, $params.max_cpus cpus, $params.max_time time per job"
summary['Output Dir'] = params.outdir
summary['Working Dir'] = workflow.workDir
summary['Container Engine'] = workflow.containerEngine
if(workflow.containerEngine) summary['Container'] = workflow.container
summary['Current Home'] = workflow.homeDir
summary['Current User'] = workflow.userName
summary['Working Dir'] = workflow.workDir
summary['Output Dir'] = params.outdir
summary['Script Dir'] = workflow.projectDir
summary['Config Profile'] = workflow.profile
summary['User'] = workflow.userName
if (workflow.profile.contains('awsbatch')) {
summary['AWS Region'] = params.awsregion
summary['AWS Queue'] = params.awsqueue
summary['AWS CLI'] = params.awscli
}
if(params.email) summary['E-mail Address'] = params.email
summary['Config Profile'] = workflow.profile
if (params.config_profile_description) summary['Config Description'] = params.config_profile_description
if (params.config_profile_contact) summary['Config Contact'] = params.config_profile_contact
if (params.config_profile_url) summary['Config URL'] = params.config_profile_url
if (params.email || params.email_on_fail) {
summary['E-mail Address'] = params.email
summary['E-mail on failure'] = params.email_on_fail
summary['MultiQC maxsize'] = params.max_multiqc_email_size
}
log.info summary.collect { k,v -> "${k.padRight(18)}: $v" }.join("\n")
log.info "-\033[2m--------------------------------------------------\033[0m-"
// Check the hostnames against configured profiles
checkHostname()
Channel.from(summary.collect{ [it.key, it.value] })
.map { k,v -> "<dt>$k</dt><dd><samp>${v ?: '<span style=\"color:#999999;\">N/A</a>'}</samp></dd>" }
.reduce { a, b -> return [a, b].join("\n ") }
.map { x -> """
id: 'nf-core-eager-summary'
description: " - this information is collected when the pipeline is started."
section_name: 'nf-core/eager Workflow Summary'
section_href: 'https://github.com/nf-core/eager'
plot_type: 'html'
data: |
<dl class=\"dl-horizontal\">
$x
</dl>
""".stripIndent() }
.set { ch_workflow_summary }
log.info "Schaffa, Schaffa, Genome Baua!"
///////////////////////////////////////////////////
/* -- REFERENCE FASTA INDEXING -- */
///////////////////////////////////////////////////
// BWA Index
if( params.bwa_index == '' && !params.fasta.isEmpty() && (params.mapper == 'bwaaln' || params.mapper == 'bwamem' || params.mapper == 'circularmapper')){
process makeBWAIndex {
label 'sc_medium'
tag "${fasta}"
publishDir path: "${params.outdir}/reference_genome/bwa_index", mode: params.publish_dir_mode, saveAs: { filename ->
if (params.save_reference) filename
else if(!params.save_reference && filename == "where_are_my_files.txt") filename
else null
}
input:
path fasta from ch_fasta_for_bwaindex
path where_are_my_files
output:
path "BWAIndex" into (bwa_index, bwa_index_bwamem)
path "where_are_my_files.txt"
script:
"""
bwa index $fasta
mkdir BWAIndex && mv ${fasta}* BWAIndex
"""
}
bt2_index = Channel.empty()
}
// bowtie2 Index
if(params.bt2_index == '' && !params.fasta.isEmpty() && params.mapper == "bowtie2"){
process makeBT2Index {
label 'sc_medium'
tag "${fasta}"
publishDir path: "${params.outdir}/reference_genome/bt2_index", mode: params.publish_dir_mode, saveAs: { filename ->
if (params.save_reference) filename
else if(!params.save_reference && filename == "where_are_my_files.txt") filename
else null
}
input:
path fasta from ch_fasta_for_bt2index
path where_are_my_files
output:
path "BT2Index" into (bt2_index)
path "where_are_my_files.txt"
script:
"""
bowtie2-build $fasta $fasta
mkdir BT2Index && mv ${fasta}* BT2Index
"""
}
bwa_index = Channel.empty()
bwa_index_bwamem = Channel.empty()
}
// FASTA Index (FAI)
if (params.fasta_index != '') {
Channel
.fromPath( params.fasta_index )
.set { ch_fai_for_skipfastaindexing }
} else {
Channel
.empty()
.set { ch_fai_for_skipfastaindexing }
}
process makeFastaIndex {
label 'sc_small'
tag "${fasta}"
publishDir path: "${params.outdir}/reference_genome/fasta_index", mode: params.publish_dir_mode, saveAs: { filename ->
if (params.save_reference) filename
else if(!params.save_reference && filename == "where_are_my_files.txt") filename
else null
}
when: params.fasta_index == '' && !params.fasta.isEmpty() && ( params.mapper == 'bwaaln' || params.mapper == 'bwamem' || params.mapper == 'circularmapper')
input:
path fasta from ch_fasta_for_faidx
path where_are_my_files
output:
path "*.fai" into ch_fasta_faidx_index
path "where_are_my_files.txt"
script:
"""
samtools faidx $fasta
"""
}
ch_fai_for_skipfastaindexing.mix(ch_fasta_faidx_index)
.into { ch_fai_for_ug; ch_fai_for_hc; ch_fai_for_freebayes; ch_fai_for_pileupcaller; ch_fai_for_angsd }
// Stage dict index file if supplied, else load it into the channel
if (params.seq_dict != '') {
Channel
.fromPath( params.seq_dict )
.set { ch_dict_for_skipdict }
} else {
Channel
.empty()
.set { ch_dict_for_skipdict }
}
process makeSeqDict {
label 'sc_medium'
tag "${fasta}"
publishDir path: "${params.outdir}/reference_genome/seq_dict", mode: params.publish_dir_mode, saveAs: { filename ->
if (params.save_reference) filename
else if(!params.save_reference && filename == "where_are_my_files.txt") filename
else null
}
when: params.seq_dict == '' && !params.fasta.isEmpty()
input:
path fasta from ch_fasta_for_seqdict
path where_are_my_files
output:
path "*.dict" into ch_seq_dict
path "where_are_my_files.txt"
script:
"""
picard -Xmx${task.memory.toMega()}M -Xms${task.memory.toMega()}M CreateSequenceDictionary R=$fasta O="${fasta.baseName}.dict"
"""
}
ch_dict_for_skipdict.mix(ch_seq_dict)
.into { ch_dict_for_ug; ch_dict_for_hc; ch_dict_for_freebayes; ch_dict_for_pileupcaller; ch_dict_for_angsd }
//////////////////////////////////////////////////
/* -- BAM INPUT PREPROCESSING -- */
//////////////////////////////////////////////////
// Convert to FASTQ if re-mapping is requested
process convertBam {
label 'mc_small'
tag "$libraryid"
when:
params.run_convertinputbam
input:
tuple samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, path(bam) from ch_input_for_convertbam
output:
tuple samplename, libraryid, lane, colour, seqtype, organism, strandedness, udg, path("*fastq.gz"), val('NA') into ch_output_from_convertbam
script:
base = "${bam.baseName}"
"""
samtools fastq -tn ${bam} | pigz -p ${task.cpus} > ${base}.converted.fastq.gz
"""
}
// If not converted to FASTQ generate pipeline compatible BAM index file (i.e. with correct samtools version)
process indexinputbam {
label 'sc_small'
tag "$libraryid"
when:
bam != 'NA' && !params.run_convertinputbam
input: