-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.nf
137 lines (88 loc) · 3.89 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
/*
INSERT PIPELINE DESCRIPTION
*/
// ----------------Workflow---------------- //
include { TrimFastQ } from './modules/trimgalore.nf'
include { Kraken } from './modules/kraken.nf'
include { QuantTB } from './modules/quanttb.nf'
include { MapReads_BWA } from './modules/map_reads_bwa.nf'
include { MapReads_Bowtie } from './modules/map_reads_bowtie.nf'
include { MakeLowCoverageMask } from './modules/make_low_coverage_mask.nf'
include { RunAMR } from './modules/amr.nf'
include { TbProfiler } from './modules/tb_profiler.nf'
include { GATK } from './workflows/gatk_calling.nf'
include { LOFREQ } from './workflows/lofreq_calling.nf'
include { SummarizeRun } from './modules/make_run_summary.nf'
workflow {
// CREATING RAW-READS CHANNEL ----------- //
Channel
.fromPath("${params.resources_dir}/${params.reads_list}")
.splitCsv(header: true, sep: '\t')
.map{row -> tuple(row.sample, file(row.fastq_1), file(row.fastq_2), row.batch)}
.set{raw_reads}
// TRIMGALORE --------------------------- //
TrimFastQ(raw_reads)
// KRAKEN ------------------------------- //
// Channel for Kraken2 database
Channel.fromPath("${params.resources_dir}/${params.kraken_database_path}/*{kmer_distrib,k2d,txt,map}")
.collect()
.set{kraken_database}
// Running Kraken2
Kraken(kraken_database, TrimFastQ.out.trimmed_fastq_files)
// QUANTTB ------------------------------ //
//QuantTB(Kraken.out.kraken_filtered_files)
// MAPPING READS ------------------------ //
if (params.mapper == "bwa") {
// MAPPING READS WITH BWA --------------- //
// Channel for genome reference fasta
reference_fasta = Channel.fromPath("${params.resources_dir}/${params.reference_fasta_path}")
// Channel for BWA index
Channel.fromPath("${params.resources_dir}/${params.bwa_index_path}/*{amb,ann,bwt,pac,sa}")
.collect()
.set{bwa_index}
// Mapping and removing duplicates
MapReads_BWA(reference_fasta, bwa_index, Kraken.out.kraken_filtered_files)
bam_files = MapReads_BWA.out.bam_files
mapping_reports = MapReads_BWA.out.mapping_reports
coverage_stats = MapReads_BWA.out.coverage_stats
dup_metrics = MapReads_BWA.out.dup_metrics
}
else {
// MAPPING READS WITH BOWTIE2 ----------- //
// Channel for Bowtie2 index
Channel.fromPath("${params.resources_dir}/${params.bowtie_index_path}/*bt2")
.collect()
.set{bowtie_index}
// Mapping and removing duplicates
MapReads_Bowtie(reference_fasta, bowtie_index, Kraken.out.kraken_filtered_files)
bam_files = MapReads_Bowtie.out.bam_files
mapping_reports = MapReads_Bowtie.out.mapping_reports
coverage_stats = MapReads_Bowtie.out.coverage_stats
dup_metrics = MapReads_Bowtie.out.dup_metrics
}
// AMR ---------------------------------- //
RunAMR(bam_files)
// TB PROFILER -------------------------- //
TbProfiler(bam_files)
// VARIANT CALLING ---------------------- //
// Making a bed mask for low coverage regions
MakeLowCoverageMask(bam_files)
// GATK variant calling, consensus fasta generation, and cvs file annotation
GATK(bam_files, MakeLowCoverageMask.out.low_coverage_mask)
// Running LoFreq variant calling and cvs file annotation, if desired
if (params.run_lofreq == true) {
LOFREQ(bam_files)
}
// MAKING SUMMARY REPORT ---------------- //
// Creating channel for make_run_summary.py script
Channel
.fromPath("${projectDir}/scripts/make_run_summary.py")
.set{summary_script}
// Creating channel for reads_list file (needed to parse trimming_reports)
Channel
.fromPath("${params.resources_dir}/${params.reads_list}")
.set{reads_list_file}
SummarizeRun(summary_script, reads_list_file, TrimFastQ.out.trimming_reports.flatten().collect(), Kraken.out.kraken_reports.collect(), mapping_reports.collect(), coverage_stats.collect(), dup_metrics.collect(), TbProfiler.out.tbprofiler_reports.collect())
}