Skip to content

Commit 629bd27

Browse files
committed
enhance annotation
1 parent b26f1a3 commit 629bd27

3 files changed

Lines changed: 43 additions & 37 deletions

File tree

annotate.nf

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ kate: syntax groovy; space-indent on; indent-width 2;
1818
Marcel Martin <marcel.martin@scilifelab.se> [@marcelm]
1919
Björn Nystedt <bjorn.nystedt@scilifelab.se> [@bjornnystedt]
2020
Pall Olason <pall.olason@scilifelab.se> [@pallolason]
21-
Pelin Sahlén <pelin.akan@scilifelab.se> [@pelinakan]
2221
--------------------------------------------------------------------------------
2322
@Homepage
2423
http://opensource.scilifelab.se/projects/sarek/
@@ -76,17 +75,17 @@ vcfNotToAnnotate = Channel.create()
7675
if (annotateVCF == []) {
7776
Channel.empty().mix(
7877
Channel.fromPath("${directoryMap.haplotypecaller}/*.vcf.gz")
79-
.flatten().map{vcf -> ['none', 'haplotypecaller', vcf, null]},
78+
.flatten().map{vcf -> ['haplotypecaller', vcf]},
8079
Channel.fromPath("${directoryMap.manta}/*SV.vcf.gz")
81-
.flatten().map{vcf -> ['none', 'manta', vcf, null]},
80+
.flatten().map{vcf -> ['manta', vcf]},
8281
Channel.fromPath("${directoryMap.mutect1}/*.vcf.gz")
83-
.flatten().map{vcf -> ['none', 'mutect1', vcf, null]},
82+
.flatten().map{vcf -> ['mutect1', vcf]},
8483
Channel.fromPath("${directoryMap.mutect2}/*.vcf.gz")
85-
.flatten().map{vcf -> ['none', 'mutect2', vcf, null]},
84+
.flatten().map{vcf -> ['mutect2', vcf]},
8685
Channel.fromPath("${directoryMap.strelka}/*{somatic,variants}*.vcf.gz")
87-
.flatten().map{vcf -> ['none', 'strelka', vcf, null]},
86+
.flatten().map{vcf -> ['strelka', vcf]},
8887
Channel.fromPath("${directoryMap.strelkabp}/*{somatic,variants}*.vcf.gz")
89-
.flatten().map{vcf -> ['none', 'strelkabp', vcf, null]}
88+
.flatten().map{vcf -> ['strelkabp', vcf]}
9089
).choice(vcfToAnnotate, vcfNotToAnnotate) {
9190
annotateTools == [] || (annotateTools != [] && it[0] in annotateTools) ? 0 : 1
9291
}
@@ -95,25 +94,30 @@ if (annotateVCF == []) {
9594
annotateVCF.each{ list += ",${it}" }
9695
list = list.substring(1)
9796
if (StringUtils.countMatches("${list}", ",") == 0) vcfToAnnotate = Channel.fromPath("${list}")
98-
.map{vcf -> ['none', 'userspecified', vcf, null]}
97+
.map{vcf -> ['userspecified', vcf]}
9998
else vcfToAnnotate = Channel.fromPath("{$list}")
100-
.map{vcf -> ['none', 'userspecified', vcf, null]}
99+
.map{vcf -> ['userspecified', vcf]}
101100
} else exit 1, "specify only tools or files to annotate, not both"
102101

103102
vcfNotToAnnotate.close()
104103

105104
(vcfForBCFtools, vcfForVCFtools, vcfForSnpeff, vcfForVep) = vcfToAnnotate.into(4)
106105

106+
vcfForVep = vcfForVep.map {
107+
variantCaller, vcf ->
108+
["vep", variantCaller, vcf, null]
109+
}
110+
107111
process RunBcftoolsStats {
108112
tag {vcf}
109113

110114
publishDir directoryMap.bcftoolsStats, mode: 'link'
111115

112116
input:
113-
set annotator, variantCaller, file(vcf), file(idx) from vcfForBCFtools
117+
set variantCaller, file(vcf) from vcfForBCFtools
114118

115119
output:
116-
file ("${vcf.baseName}.bcf.tools.stats.out") into bcfReport
120+
file ("*.bcf.tools.stats.out") into bcfReport
117121

118122
when: !params.noReports
119123

@@ -131,10 +135,10 @@ process RunVcftools {
131135
publishDir directoryMap.vcftools, mode: 'link'
132136

133137
input:
134-
set annotator, variantCaller, file(vcf), file(idx) from vcfForVCFtools
138+
set variantCaller, file(vcf) from vcfForVCFtools
135139

136140
output:
137-
file ("${vcf.baseName}.*") into vcfReport
141+
file ("${vcf.simpleName}.*") into vcfReport
138142

139143
when: !params.noReports
140144

@@ -147,21 +151,21 @@ if (params.verbose) vcfReport = vcfReport.view {
147151
}
148152

149153
process RunSnpeff {
150-
tag {vcf}
154+
tag {"${variantCaller} - ${vcf}"}
151155

152156
publishDir params.outDir, mode: 'link', saveAs: {
153-
if (it == "${vcf.baseName}.snpEff.csv") "${directoryMap.snpeffReports}/${it}"
154-
else if (it == "${vcf.baseName}.snpEff.ann.vcf") null
157+
if (it == "${vcf.simpleName}_snpEff.csv") "${directoryMap.snpeffReports}/${it}"
158+
else if (it == "${vcf.simpleName}_snpEff.ann.vcf") null
155159
else "${directoryMap.snpeff}/${it}"
156160
}
157161

158162
input:
159-
set annotator, variantCaller, file(vcf), file(idx) from vcfForSnpeff
163+
set variantCaller, file(vcf) from vcfForSnpeff
160164
val snpeffDb from Channel.value(params.genomes[params.genome].snpeffDb)
161165

162166
output:
163-
set file("${vcf.baseName}.snpEff.genes.txt"), file("${vcf.baseName}.snpEff.csv"), file("${vcf.baseName}.snpEff.summary.html") into snpeffOutput
164-
set val("snpeff"), variantCaller, file("${vcf.baseName}.snpEff.ann.vcf") into snpeffVCF
167+
set file("${vcf.simpleName}_snpEff.genes.txt"), file("${vcf.simpleName}_snpEff.csv"), file("${vcf.simpleName}_snpEff.summary.html") into snpeffOutput
168+
set val("snpeff"), variantCaller, file("${vcf.simpleName}_snpEff.ann.vcf") into snpeffVCF
165169

166170
when: 'snpeff' in tools || 'merge' in tools
167171

@@ -170,14 +174,14 @@ process RunSnpeff {
170174
java -Xmx${task.memory.toGiga()}g \
171175
-jar \$SNPEFF_HOME/snpEff.jar \
172176
${snpeffDb} \
173-
-csvStats ${vcf.baseName}.snpEff.csv \
177+
-csvStats ${vcf.simpleName}_snpEff.csv \
174178
-nodownload \
175179
-canon \
176180
-v \
177181
${vcf} \
178-
> ${vcf.baseName}.snpEff.ann.vcf
182+
> ${vcf.simpleName}_snpEff.ann.vcf
179183
180-
mv snpEff_summary.html ${vcf.baseName}.snpEff.summary.html
184+
mv snpEff_summary.html ${vcf.simpleName}_snpEff.summary.html
181185
"""
182186
}
183187

@@ -195,41 +199,44 @@ if('merge' in tools) {
195199
vcfCompressed = Channel.create()
196200

197201
vcfForVep = Channel.empty().mix(
198-
vcfCompressed.until({it[0]!="snpeff"})
202+
vcfCompressed.until({ it[0]=="merge" })
199203
)
200204
}
201205

202206
process RunVEP {
203-
tag {vcf}
207+
tag {"${variantCaller} - ${vcf}"}
204208

205209
publishDir params.outDir, mode: 'link', saveAs: {
206-
if (it == "${vcf.baseName}.vep.summary.html") "${directoryMap.vep}/${it}"
210+
if (it == "${vcf.simpleName}_VEP.summary.html") "${directoryMap.vep}/${it}"
207211
else null
208212
}
209213

210214
input:
211215
set annotator, variantCaller, file(vcf), file(idx) from vcfForVep
212216

213217
output:
214-
set val("vep"), variantCaller, file("${vcf.baseName}.vep.ann.vcf") into vepVCF
215-
file("${vcf.baseName}.vep.summary.html") into vepReport
218+
set finalannotator, variantCaller, file("${vcf.simpleName}_VEP.ann.vcf") into vepVCF
219+
file("${vcf.simpleName}_VEP.summary.html") into vepReport
216220

217221
when: 'vep' in tools || 'merge' in tools
218222

219223
script:
224+
finalannotator = annotator == "snpeff" ? 'merge' : 'vep'
220225
genome = params.genome == 'smallGRCh37' ? 'GRCh37' : params.genome
221226
"""
222227
vep \
223228
-i ${vcf} \
224-
-o ${vcf.baseName}.vep.ann.vcf \
225-
--stats_file ${vcf.baseName}.vep.summary.html \
229+
-o ${vcf.simpleName}_VEP.ann.vcf \
230+
--assembly ${genome} \
226231
--cache \
232+
--database \
227233
--everything \
228234
--filter_common \
235+
--fork ${task.cpus} \
229236
--format vcf \
230237
--offline \
231238
--per_gene \
232-
--fork ${task.cpus} \
239+
--stats_file ${vcf.simpleName}_VEP.summary.html \
233240
--total_length \
234241
--vcf
235242
"""
@@ -245,7 +252,7 @@ vcfToCompress = snpeffVCF.mix(vepVCF)
245252
process CompressVCF {
246253
tag {"${annotator} - ${vcf}"}
247254

248-
publishDir "${directoryMap."$annotator"}", mode: 'link'
255+
publishDir "${directoryMap."$finalannotator"}", mode: 'link'
249256

250257
input:
251258
set annotator, variantCaller, file(vcf) from vcfToCompress
@@ -254,6 +261,7 @@ process CompressVCF {
254261
set annotator, variantCaller, file("*.vcf.gz"), file("*.vcf.gz.tbi") into (vcfCompressed, vcfCompressedoutput)
255262

256263
script:
264+
finalannotator = annotator == "merge" ? "vep" : annotator
257265
"""
258266
bgzip < ${vcf} > ${vcf}.gz
259267
tabix ${vcf}.gz

germlineVC.nf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ kate: syntax groovy; space-indent on; indent-width 2;
1818
Marcel Martin <marcel.martin@scilifelab.se> [@marcelm]
1919
Björn Nystedt <bjorn.nystedt@scilifelab.se> [@bjornnystedt]
2020
Pall Olason <pall.olason@scilifelab.se> [@pallolason]
21-
Pelin Sahlén <pelin.akan@scilifelab.se> [@pelinakan]
2221
--------------------------------------------------------------------------------
2322
@Homepage
2423
http://opensource.scilifelab.se/projects/sarek/
@@ -561,7 +560,7 @@ process RunBcftoolsStats {
561560
set variantCaller, file(vcf) from vcfForBCFtools
562561

563562
output:
564-
file ("${vcf.baseName}.bcf.tools.stats.out") into bcfReport
563+
file ("${vcf.simpleName}.bcf.tools.stats.out") into bcfReport
565564

566565
when: !params.noReports
567566

@@ -584,7 +583,7 @@ process RunVcftools {
584583
set variantCaller, file(vcf) from vcfForVCFtools
585584

586585
output:
587-
file ("${vcf.baseName}.*") into vcfReport
586+
file ("${vcf.simpleName}.*") into vcfReport
588587

589588
when: !params.noReports
590589

somaticVC.nf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ kate: syntax groovy; space-indent on; indent-width 2;
1818
Marcel Martin <marcel.martin@scilifelab.se> [@marcelm]
1919
Björn Nystedt <bjorn.nystedt@scilifelab.se> [@bjornnystedt]
2020
Pall Olason <pall.olason@scilifelab.se> [@pallolason]
21-
Pelin Sahlén <pelin.akan@scilifelab.se> [@pelinakan]
2221
--------------------------------------------------------------------------------
2322
@Homepage
2423
http://opensource.scilifelab.se/projects/sarek/
@@ -812,7 +811,7 @@ process RunBcftoolsStats {
812811
set variantCaller, file(vcf) from vcfForBCFtools
813812

814813
output:
815-
file ("${vcf.baseName}.bcf.tools.stats.out") into bcfReport
814+
file ("${vcf.simpleName}.bcf.tools.stats.out") into bcfReport
816815

817816
when: !params.noReports
818817

@@ -835,7 +834,7 @@ process RunVcftools {
835834
set variantCaller, file(vcf) from vcfForVCFtools
836835

837836
output:
838-
file ("${vcf.baseName}.*") into vcfReport
837+
file ("${vcf.simpleName}.*") into vcfReport
839838

840839
when: !params.noReports
841840

0 commit comments

Comments
 (0)