-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
165 lines (135 loc) · 5.48 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
#!/usr/bin/env nextflow
// mads 2024-02-16
// Use newest nextflow dsl
nextflow.enable.dsl = 2
log.info """\
===================================
D o B S e q - W F
===================================
"""
.stripIndent()
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT MODULES AND SUBWORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { MAPPING } from './subworkflows/mapping'
include { MAPPING_UMI } from './subworkflows/mapping_umi'
include { CALLING } from './subworkflows/calling'
include { CALL_TRUTH } from './subworkflows/call_wgs_truthset'
include { ANNOTATION } from './subworkflows/annotation'
// Cram conversion
include { BAM } from './modules/bam'
include { INDEX } from './modules/index'
// Pinpoint methods
include { PILOT_PINPOINT } from './modules/pilot_pinpoint'
include { PINPOINT } from './subworkflows/pinpoint'
// Test
include { TEST } from './modules/test'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INPUT CHANNELS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
pooltable_ch = Channel
.fromPath(params.pooltable)
.splitCsv(sep: '\t')
.map { row -> tuple(row[0], [file(row[1]), file(row[2])]) }
if (params.step == 'calling') {
cramtable_ch = Channel
.fromPath(params.cramtable)
.splitCsv(sep: '\t')
.map { row -> tuple(row[0], file(row[1])) }
}
if (params.step == 'pinpoint') {
vcftable_ch = Channel
.fromPath(params.vcftable)
.splitCsv(sep: '\t')
.map { row -> tuple(row[0], file(row[1]), row[2]) }
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REFERENCE FILE CHANNELS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
reference_genome_ch = Channel.fromPath(params.reference_genome + "*", checkIfExists: true).collect()
bedfile_ch = Channel.fromPath(params.bedfile, checkIfExists: true).collect()
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow {
if (params.step == 'mapping' || params.step == 'all' || params.step == '') {
if (params.umi) {
bam_file_w_index_ch = MAPPING_UMI(pooltable_ch, reference_genome_ch, bedfile_ch)
} else {
bam_file_w_index_ch = MAPPING(pooltable_ch, reference_genome_ch, bedfile_ch)
}
} else if (params.step == 'calling') {
BAM(cramtable_ch, reference_genome_ch)
bam_file_w_index_ch = INDEX(BAM.out.bam_file)
}
if (params.step == 'calling' || params.step == 'all' || params.step == '') {
CALLING(bam_file_w_index_ch, reference_genome_ch, bedfile_ch)
lofreq_ch = CALLING.out.vcf_lofreq
gatk_ch = CALLING.out.vcf_hc
} else if (params.step == 'pinpoint') {
vcftable_ch
.branch { sample, vcf_file, caller ->
GATK: caller == 'GATK'
lofreq: caller == 'lofreq'
other: true
}
.set { vcftable_ch }
gatk_ch = vcftable_ch.GATK
.map { sample, vcf_file, caller -> tuple(sample, vcf_file) }
lofreq_ch = vcftable_ch.lofreq
.map { sample, vcf_file, caller -> tuple(sample, vcf_file) }
}
if (params.step == 'pinpoint' || params.step == 'all' || params.step == '') {
if (params.pinpoint_method == 'pilot') {
vcf_ch = gatk_ch
.mix(lofreq_ch)
.map { pool_id, vcf_file -> vcf_file }
PILOT_PINPOINT(vcf_ch.collect(), file(params.pooltable), file(params.decodetable))
pin_ch = PILOT_PINPOINT.out.pinned_variants
} else if (params.pinpoint_method == 'new') {
PINPOINT(gatk_ch, file(params.decodetable), reference_genome_ch)
pin_ch = PINPOINT.out.pinned_variants
}
}
if (params.testing && params.step != 'mapping' && params.step != 'calling' && params.step != 'pinpoint') {
TEST(pin_ch, file(params.snv_list), params.pinpoint_method)
}
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTERNATIVE WORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
// Call variants in WGS data from CRAM files
// Requires a tsv with CRAM files
workflow truthset {
CALL_TRUTH(reference_genome_ch, bedfile_ch)
}
workflow annotate {
Channel
.fromPath(params.vcftable)
.splitCsv(sep: '\t')
.map { row -> tuple(row[0], file(row[1]), row[2]) }
.branch { sample, vcf_file, caller ->
GATK: caller == 'GATK'
lofreq: caller == 'lofreq'
other: true
}
.set { vcftable_ch }
gatk_ch = vcftable_ch.GATK
.map { sample, vcf_file, caller -> tuple(sample, vcf_file) }
lofreq_ch = vcftable_ch.lofreq
.map { sample, vcf_file, caller -> tuple(sample, vcf_file) }
ANNOTATION(gatk_ch)
}
workflow.onComplete {
log.info ( workflow.success ? "\nDoBSeq-WF is done!\n" : "Oops .. something went wrong" )
}