Skip to content
This repository was archived by the owner on Jan 27, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 63 additions & 7 deletions annotate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,19 @@ if (params.verbose) vcfReport = vcfReport.view {
process RunSnpeff {
tag {vcf}

publishDir params.outDir , saveAs: { it == "${vcf.baseName}.snpEff.csv" ? "${directoryMap.snpeffReports}/${it}" : "${directoryMap.snpeff}/${it}" }, mode: 'link'
publishDir params.outDir, mode: 'link', saveAs: {
if (it == "${vcf.baseName}.snpEff.csv") "${directoryMap.snpeffReports}/${it}"
else if (it == "${vcf.baseName}.snpEff.ann.vcf") null
else "${directoryMap.snpeff}/${it}"
}

input:
set variantCaller, file(vcf) from vcfForSnpeff
val snpeffDb from Channel.value(params.genomes[params.genome].snpeffDb)

output:
set file("${vcf.baseName}.snpEff.ann.vcf"), file("${vcf.baseName}.snpEff.genes.txt"), file("${vcf.baseName}.snpEff.csv"), file("${vcf.baseName}.snpEff.summary.html") into snpeffReport
set variantCaller,file("${vcf.baseName}.snpEff.ann.vcf") into snpEffOutputVCFs
set file("${vcf.baseName}.snpEff.genes.txt"), file("${vcf.baseName}.snpEff.csv"), file("${vcf.baseName}.snpEff.summary.html") into snpeffOutput
set variantCaller,file("${vcf.baseName}.snpEff.ann.vcf") into snpeffVCF

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

Expand All @@ -177,28 +181,56 @@ process RunSnpeff {
"""
}

if (params.verbose) snpeffReport = snpeffReport.view {
if (params.verbose) snpeffOutput = snpeffOutput.view {
"snpEff report:\n\
File : ${it.fileName}"
}

// When we are running in the 'merge' mode (first snpEff, then VEP)
// we have to exchange the channels

process CompressSnpeffVCF {
tag {vcf}

publishDir directoryMap.snpeff, mode: 'link'

input:
set variantCaller, file(vcf) from snpeffVCF

output:
set variantCaller, file("*.vcf.gz") into snpeffVCFcompressed
file("*.vcf.gz.tbi")

script:
"""
cat ${vcf} | bgzip > ${vcf}.gz
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bgzip < ${vcf} > ${vcf}.gz instead to avoid winning the “Useless Use of Cat Award” 😺

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️
Thanks !!!

tabix ${vcf}.gz
"""
}

if (params.verbose) snpeffVCFcompressed = snpeffVCFcompressed.view {
"snpEff VCF:\n\
File : ${it[1].fileName}"
}

if('merge' in tools) {
vcfForVep = snpEffOutputVCFs
vcfForVep = snpeffVCFcompressed
}

process RunVEP {
tag {vcf}

publishDir directoryMap.vep, mode: 'link'
publishDir params.outDir, mode: 'link', saveAs: {
if (it == "${vcf.baseName}.vep.summary.html") "${directoryMap.vep}/${it}"
else null
}

input:
set variantCaller, file(vcf) from vcfForVep

output:
set file("${vcf.baseName}.vep.ann.vcf"), file("${vcf.baseName}.vep.summary.html") into vepReport
file("${vcf.baseName}.vep.ann.vcf") into vepVCF
file("${vcf.baseName}.vep.summary.html") into vepReport

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

Expand Down Expand Up @@ -226,6 +258,30 @@ if (params.verbose) vepReport = vepReport.view {
Files : ${it.fileName}"
}

process CompressVEPvcf {
tag {vcf}

publishDir directoryMap.vep, mode: 'link'

input:
file(vcf) from vepVCF

output:
file("*.vcf.gz") into vepVCFcompressed
file("*.vcf.gz.tbi")

script:
"""
cat ${vcf} | bgzip > ${vcf}.gz
tabix ${vcf}.gz
"""
}

if (params.verbose) vepVCFcompressed = vepVCFcompressed.view {
"VEP VCF:\n\
File : ${it.fileName}"
}

process GetVersionBCFtools {
publishDir directoryMap.version, mode: 'link'
output: file("v_*.txt")
Expand Down
2 changes: 2 additions & 0 deletions configuration/containers.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ process {
$BuildPicardIndex.container = "${params.repository}/picard:${params.tag}"
$BuildSAMToolsIndex.container = "${params.repository}/sarek:${params.tag}"
$BuildVCFIndex.container = "${params.repository}/igvtools:${params.tag}"
$CompressSnpeffVCF.container = "${params.repository}/sarek:${params.tag}"
$CompressVEPvcf.container = "${params.repository}/sarek:${params.tag}"
$ConcatVCF.container = "${params.repository}/sarek:${params.tag}"
$CreateRecalibrationTable.container = "${params.repository}/gatk:${params.tag}"
$GetVersionAll.container = "${params.repository}/qctools:${params.tag}"
Expand Down
2 changes: 2 additions & 0 deletions configuration/singularity-path.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ process {
$BuildPicardIndex.container = "${params.containerPath}/picard-${params.tag}.img"
$BuildSAMToolsIndex.container = "${params.containerPath}/sarek-${params.tag}.img"
$BuildVCFIndex.container = "${params.containerPath}/igvtools-${params.tag}.img"
$CompressSnpeffVCF.container = "${params.containerPath}/sarek-${params.tag}.img"
$CompressVEPvcf.container = "${params.containerPath}/sarek-${params.tag}.img"
$ConcatVCF.container = "${params.containerPath}/sarek-${params.tag}.img"
$CreateRecalibrationTable.container = "${params.containerPath}/gatk-${params.tag}.img"
$GetVersionAll.container = "${params.containerPath}/qctools-${params.tag}.img"
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ then
ANNOTATOR=VEP
elif [[ ALL,ANNOTATEALL =~ $TEST ]]
then
ANNOTATOR=snpEFF,VEP
ANNOTATOR=merge,snpEFF,VEP
fi
if [[ $PROFILE == docker ]] && [[ $TRAVIS == true ]]
then
Expand Down