Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Syntax for Compatibility with Nextflow 23.04.4 #131

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion conf/illumina.config
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ params {
// iVar frequency threshold to call variant (ivar variants: -t )
ivarMinFreqThreshold = 0.25

// iVar minimum mapQ to call variant (ivar variants: -q)
// iVar minimum baseQ to call variant (ivar variants: -q)
ivarMinVariantQuality = 20

// Typing frequency threshold to call aa consequences of variant. Set to ivarFreqThreshold for consistency with consensus
Expand Down
20 changes: 11 additions & 9 deletions environments/illumina/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ channels:
- bioconda
- defaults
dependencies:
- python=3
- python
- biopython=1.74
- libxcb
- matplotlib=3.3.3
- pandas=0.23.0=py36_1
- bwa=0.7.17=pl5.22.0_2
- samtools=1.10
- bcftools=1.10
- trim-galore=0.6.5
- ivar=1.3
- matplotlib=3
- pandas=2
- bwa=0.7.17
- samtools=1.18
- bcftools=1.18
- trim-galore=0.6.10
- ivar=1.4.2
- pyvcf=0.6.8
- pyyaml=5.3.1
- pyyaml=6.0.1
- freyja=1.4.7
- pangolin=4.3
18 changes: 18 additions & 0 deletions environments/illumina/environment.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: artic-ncov2019-illumina
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- python=3
- biopython=1.74
- libxcb
- matplotlib=3.3.3
- pandas=0.23.0=py36_1
- bwa=0.7.17=pl5.22.0_2
- samtools=1.10
- bcftools=1.10
- trim-galore=0.6.5
- ivar=1.3
- pyvcf=0.6.8
- pyyaml=5.3.1
2 changes: 1 addition & 1 deletion main.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nextflow

// enable dsl2
nextflow.preview.dsl = 2
nextflow.enable.dsl = 2

// include modules
include {printHelp} from './modules/help.nf'
Expand Down
87 changes: 73 additions & 14 deletions modules/illumina.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ process readTrimming {
cpus 2

input:
tuple(sampleName, path(forward), path(reverse))
tuple(val(sampleName), path(forward), path(reverse))

output:
tuple(sampleName, path("*_val_1.fq.gz"), path("*_val_2.fq.gz")) optional true
tuple(val(sampleName), path("*_val_1.fq.gz"), path("*_val_2.fq.gz")) optional true

script:
"""
Expand All @@ -38,7 +38,7 @@ process indexReference {
path(ref)

output:
tuple path('ref.fa'), path('ref.fa.*')
tuple(path('ref.fa'), path('ref.fa.*'))

script:
"""
Expand All @@ -62,10 +62,10 @@ process readMapping {
publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.sorted.bam", mode: 'copy'

input:
tuple sampleName, path(forward), path(reverse), path(ref), path("*")
tuple(val(sampleName), path(forward), path(reverse), path(ref), path("*"))

output:
tuple(sampleName, path("${sampleName}.sorted.bam"))
tuple(val(sampleName), path("${sampleName}.sorted.bam"))

script:
"""
Expand All @@ -82,11 +82,11 @@ process trimPrimerSequences {
publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.mapped.primertrimmed.sorted.bam", mode: 'copy'

input:
tuple sampleName, path(bam), path(bedfile)
tuple(val(sampleName), path(bam), path(bedfile))

output:
tuple sampleName, path("${sampleName}.mapped.bam"), emit: mapped
tuple sampleName, path("${sampleName}.mapped.primertrimmed.sorted.bam" ), emit: ptrim
tuple(val(sampleName), path("${sampleName}.mapped.bam"), emit: mapped)
tuple(val(sampleName), path("${sampleName}.mapped.primertrimmed.sorted.bam" ), emit: ptrim)

script:
if (params.allowNoprimer){
Expand Down Expand Up @@ -121,17 +121,36 @@ process trimPrimerSequences {
"""
}

process getDepths {
tag { sampleName }

publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.depths.tsv", mode: 'copy'

input:
tuple(val(sampleName), path(bam), path(ref))

output:
tuple(val(sampleName), path("${sampleName}.depths.tsv"), emit: depths)

script:
"""
samtools mpileup -aa -A -d 0 -Q 0 -q ${params.ivarMinVariantQuality} -B -f ${ref} ${bam} | cut -f1-4 > "${sampleName}.depths.tsv"
"""
}
process callVariants {

tag { sampleName }

publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.variants.tsv", mode: 'copy'

errorStrategy { sleep(Math.pow(2, task.attempt) * 1 as long); return 'retry' }
maxRetries 9999999999

input:
tuple(sampleName, path(bam), path(ref))
tuple(val(sampleName), path(bam), path(ref))

output:
tuple sampleName, path("${sampleName}.variants.tsv"), emit: variants
tuple(val(sampleName), path("${sampleName}.variants.tsv"), emit: variants)

script:
"""
Expand All @@ -147,10 +166,10 @@ process makeConsensus {
publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.primertrimmed.consensus.fa", mode: 'copy'

input:
tuple(sampleName, path(bam))
tuple(val(sampleName), path(bam))

output:
tuple(sampleName, path("${sampleName}.primertrimmed.consensus.fa"))
tuple(val(sampleName), path("${sampleName}.primertrimmed.consensus.fa"), emit: consensus)

script:
"""
Expand All @@ -160,6 +179,46 @@ process makeConsensus {
"""
}

process callLineage {

tag { sampleName }

publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.pangolin.csv", mode: 'copy'

errorStrategy { sleep(Math.pow(2, task.attempt) * 1 as long); return 'retry' }
maxRetries -1

input:
tuple(val(sampleName), path(consensus))

output:
tuple(val(sampleName), path("${sampleName}.pangolin.csv"))

script:
"""
pangolin ${consensus} -t 1 --outfile ${sampleName}.pangolin.csv --verbose
"""
}

process freyjaDemix {
tag { sampleName }

publishDir "${params.outdir}/${task.process.replaceAll(":","_")}", pattern: "${sampleName}.freyja.demix.tsv", mode: 'copy'

errorStrategy 'ignore'

input:
tuple(val(sampleName), path(variants), path(depths))

output:
tuple(val(sampleName), path("${sampleName}.freyja.demix.tsv"))

script:
"""
freyja demix ${variants} ${depths} --output ${sampleName}.freyja.demix.tsv
"""
}

process cramToFastq {
/**
* Converts CRAM to fastq (http://bio-bwa.sourceforge.net/)
Expand All @@ -169,10 +228,10 @@ process cramToFastq {
*/

input:
tuple sampleName, file(cram)
tuple(val(sampleName), file(cram))

output:
tuple sampleName, path("${sampleName}_1.fastq.gz"), path("${sampleName}_2.fastq.gz")
tuple(val(sampleName), path("${sampleName}_1.fastq.gz"), path("${sampleName}_2.fastq.gz"))

script:
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/qc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process makeQCCSV {
publishDir "${params.outdir}/qc_plots", pattern: "${sampleName}.depth.png", mode: 'copy'

input:
tuple sampleName, path(bam), path(fasta), path(ref)
tuple(val(sampleName), path(bam), path(fasta), path(ref))

output:
path "${params.prefix}.${sampleName}.qc.csv", emit: csv
Expand Down
2 changes: 1 addition & 1 deletion modules/upload.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process collateSamples {
publishDir "${params.outdir}/qc_pass_climb_upload/${params.prefix}", pattern: "${sampleName}", mode: 'copy'

input:
tuple(sampleName, path(bam), path(fasta))
tuple(val(sampleName), path(bam), path(fasta))

output:
path("${sampleName}")
Expand Down
11 changes: 10 additions & 1 deletion workflows/illuminaNcov.nf
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env nextflow

// enable dsl2
nextflow.preview.dsl = 2
nextflow.enable.dsl = 2

// import modules
include {articDownloadScheme } from '../modules/artic.nf'
include {readTrimming} from '../modules/illumina.nf'
include {indexReference} from '../modules/illumina.nf'
include {readMapping} from '../modules/illumina.nf'
include {trimPrimerSequences} from '../modules/illumina.nf'
include {getDepths} from '../modules/illumina.nf'
include {callVariants} from '../modules/illumina.nf'
include {freyjaDemix} from '../modules/illumina.nf'
include {makeConsensus} from '../modules/illumina.nf'
include {callLineage} from '../modules/illumina.nf'
include {cramToFastq} from '../modules/illumina.nf'

include {makeQCCSV} from '../modules/qc.nf'
Expand Down Expand Up @@ -95,8 +98,14 @@ workflow sequenceAnalysis {

callVariants(trimPrimerSequences.out.ptrim.combine(ch_preparedRef.map{ it[0] }))

getDepths(trimPrimerSequences.out.ptrim.combine(ch_preparedRef.map{ it[0] }))

freyjaDemix(callVariants.out.variants.join(getDepths.out.depths))

makeConsensus(trimPrimerSequences.out.ptrim)

callLineage(makeConsensus.out.consensus)

makeQCCSV(trimPrimerSequences.out.ptrim.join(makeConsensus.out, by: 0)
.combine(ch_preparedRef.map{ it[0] }))

Expand Down