From e438d026bdbbef05acee18ea8fabe96a4d71268e Mon Sep 17 00:00:00 2001 From: drpatelh Date: Thu, 10 Sep 2020 16:45:11 +0100 Subject: [PATCH] Unify syntax --- software/SOFTWARE/TOOL/main.nf | 4 +- software/bwa/index/main.nf | 4 +- software/bwa/mem/main.nf | 84 ++++---- software/deeptools/computematrix/main.nf | 82 ++++---- software/deeptools/plotfingerprint/main.nf | 86 ++++----- software/deeptools/plotheatmap/main.nf | 76 ++++---- software/deeptools/plotprofile/main.nf | 76 ++++---- software/fastqc/main.nf | 6 +- software/hisat2/align/main.nf | 180 +++++++++--------- software/hisat2/extractsplicesites/main.nf | 62 +++--- software/homer/annotatepeaks/main.nf | 86 ++++----- software/macs2/callpeak/main.nf | 95 ++++----- software/phantompeakqualtools/main.nf | 74 +++---- .../picard/collectmultiplemetrics/main.nf | 94 ++++----- software/picard/markduplicates/main.nf | 92 ++++----- software/picard/mergesamfiles/main.nf | 102 +++++----- software/preseq/lcextrap/main.nf | 84 ++++---- software/qualimap/rnaseq/main.nf | 108 +++++------ software/salmon/quant/main.nf | 100 +++++----- software/samtools/flagstat/main.nf | 4 +- software/samtools/idxstats/main.nf | 4 +- software/samtools/index/main.nf | 4 +- software/samtools/sort/main.nf | 4 +- software/samtools/stats/main.nf | 4 +- software/star/genomegenerate/main.nf | 86 ++++----- software/subread/featurecounts/main.nf | 98 +++++----- software/trimgalore/main.nf | 159 ++++++++-------- software/ucsc/bedgraphtobigwig/main.nf | 70 +++---- 28 files changed, 965 insertions(+), 963 deletions(-) diff --git a/software/SOFTWARE/TOOL/main.nf b/software/SOFTWARE/TOOL/main.nf index 336d33c6..94abc58f 100644 --- a/software/SOFTWARE/TOOL/main.nf +++ b/software/SOFTWARE/TOOL/main.nf @@ -53,14 +53,14 @@ process SOFTWARE_TOOL { // e.g. "*.fastq.gz" and NOT "*.fastq", "*.bam" and NOT "*.sam" etc. tuple val(meta), path(reads) // TODO nf-core: List additional required input channels/values here - val options + val options output: // TODO nf-core: Named file extensions MUST be emitted for ALL output channels // TODO nf-core: If meta is provided in "input:" section then it MUST be added to ALL output channels (except version) tuple val(meta), path("*.bam"), emit: bam // TODO nf-core: List additional required output channels/values here - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/bwa/index/main.nf b/software/bwa/index/main.nf index 38b86c1f..537e096a 100644 --- a/software/bwa/index/main.nf +++ b/software/bwa/index/main.nf @@ -15,10 +15,10 @@ process BWA_INDEX { input: path fasta - val options + val options output: - path "${fasta}.*", emit: index + path "${fasta}.*" , emit: index path "*.version.txt", emit: version script: diff --git a/software/bwa/mem/main.nf b/software/bwa/mem/main.nf index 127bc700..73eadaf8 100644 --- a/software/bwa/mem/main.nf +++ b/software/bwa/mem/main.nf @@ -1,42 +1,42 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process BWA_MEM { - tag "$meta.id" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:eabfac3657eda5818bae4090db989e3d41b01542-0" - //container "https://depot.galaxyproject.org/singularity/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:eabfac3657eda5818bae4090db989e3d41b01542-0" - - conda (params.conda ? "bioconda::bwa=0.7.17 bioconda::samtools=1.10" : null) - - input: - tuple val(meta), path(reads) - path index - path fasta - val options - - output: - tuple val(meta), path("*.bam"), emit: bam - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def rg = meta.read_group ? "-R ${meta.read_group}" : "" - """ - bwa mem \\ - $ioptions.args \\ - $rg \\ - -t $task.cpus \\ - $fasta \\ - $reads \\ - | samtools view $ioptions.args2 -@ $task.cpus -bS -o ${prefix}.bam - - - echo \$(bwa 2>&1) | sed 's/^.*Version: //; s/Contact:.*\$//' > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process BWA_MEM { + tag "$meta.id" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:eabfac3657eda5818bae4090db989e3d41b01542-0" + //container "https://depot.galaxyproject.org/singularity/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:eabfac3657eda5818bae4090db989e3d41b01542-0" + + conda (params.conda ? "bioconda::bwa=0.7.17 bioconda::samtools=1.10" : null) + + input: + tuple val(meta), path(reads) + path index + path fasta + val options + + output: + tuple val(meta), path("*.bam"), emit: bam + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def read_group = meta.read_group ? "-R ${meta.read_group}" : "" + """ + bwa mem \\ + $ioptions.args \\ + $read_group \\ + -t $task.cpus \\ + $fasta \\ + $reads \\ + | samtools view $ioptions.args2 -@ $task.cpus -bS -o ${prefix}.bam - + + echo \$(bwa 2>&1) | sed 's/^.*Version: //; s/Contact:.*\$//' > ${software}.version.txt + """ +} diff --git a/software/deeptools/computematrix/main.nf b/software/deeptools/computematrix/main.nf index f53662e3..27e3b042 100644 --- a/software/deeptools/computematrix/main.nf +++ b/software/deeptools/computematrix/main.nf @@ -1,41 +1,41 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process DEEPTOOLS_COMPUTEMATRIX { - tag "$meta.id" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/deeptools:3.4.3--py_0" - //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" - - conda (params.conda ? "bioconda::deeptools=3.4.3" : null) - - input: - tuple val(meta), path(bigwig) - path bed - val options - - output: - tuple val(meta), path("*.mat.gz"), emit: matrix - tuple val(meta), path("*.mat.tab"), emit: table - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - computeMatrix \\ - $ioptions.args \\ - --regionsFileName $bed \\ - --scoreFileName $bigwig \\ - --outFileName ${prefix}.computeMatrix.mat.gz \\ - --outFileNameMatrix ${prefix}.computeMatrix.vals.mat.tab \\ - --numberOfProcessors $task.cpus - - computeMatrix --version | sed -e "s/computeMatrix //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process DEEPTOOLS_COMPUTEMATRIX { + tag "$meta.id" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/deeptools:3.4.3--py_0" + //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" + + conda (params.conda ? "bioconda::deeptools=3.4.3" : null) + + input: + tuple val(meta), path(bigwig) + path bed + val options + + output: + tuple val(meta), path("*.mat.gz") , emit: matrix + tuple val(meta), path("*.mat.tab"), emit: table + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + computeMatrix \\ + $ioptions.args \\ + --regionsFileName $bed \\ + --scoreFileName $bigwig \\ + --outFileName ${prefix}.computeMatrix.mat.gz \\ + --outFileNameMatrix ${prefix}.computeMatrix.vals.mat.tab \\ + --numberOfProcessors $task.cpus + + computeMatrix --version | sed -e "s/computeMatrix //g" > ${software}.version.txt + """ +} diff --git a/software/deeptools/plotfingerprint/main.nf b/software/deeptools/plotfingerprint/main.nf index ede8a041..57b56a06 100644 --- a/software/deeptools/plotfingerprint/main.nf +++ b/software/deeptools/plotfingerprint/main.nf @@ -1,43 +1,43 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process DEEPTOOLS_PLOTFINGERPRINT { - tag "$meta.id" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/deeptools:3.4.3--py_0" - //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" - - conda (params.conda ? "bioconda::deeptools=3.4.3" : null) - - input: - tuple val(meta), path(bams), path(bais) - val options - - output: - tuple val(meta), path("*.pdf"), emit: pdf - tuple val(meta), path("*.raw.txt"), emit: matrix - tuple val(meta), path("*.qcmetrics.txt"), emit: metrics - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def extend = (meta.single_end && params.fragment_size > 0) ? "--extendReads ${params.fragment_size}" : '' - """ - plotFingerprint \\ - $ioptions.args \\ - $extend \\ - --bamfiles ${bams.join(' ')} \\ - --plotFile ${prefix}.plotFingerprint.pdf \\ - --outRawCounts ${prefix}.plotFingerprint.raw.txt \\ - --outQualityMetrics ${prefix}.plotFingerprint.qcmetrics.txt \\ - --numberOfProcessors $task.cpus - - plotFingerprint --version | sed -e "s/plotFingerprint //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process DEEPTOOLS_PLOTFINGERPRINT { + tag "$meta.id" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/deeptools:3.4.3--py_0" + //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" + + conda (params.conda ? "bioconda::deeptools=3.4.3" : null) + + input: + tuple val(meta), path(bams), path(bais) + val options + + output: + tuple val(meta), path("*.pdf") , emit: pdf + tuple val(meta), path("*.raw.txt") , emit: matrix + tuple val(meta), path("*.qcmetrics.txt"), emit: metrics + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def extend = (meta.single_end && params.fragment_size > 0) ? "--extendReads ${params.fragment_size}" : '' + """ + plotFingerprint \\ + $ioptions.args \\ + $extend \\ + --bamfiles ${bams.join(' ')} \\ + --plotFile ${prefix}.plotFingerprint.pdf \\ + --outRawCounts ${prefix}.plotFingerprint.raw.txt \\ + --outQualityMetrics ${prefix}.plotFingerprint.qcmetrics.txt \\ + --numberOfProcessors $task.cpus + + plotFingerprint --version | sed -e "s/plotFingerprint //g" > ${software}.version.txt + """ +} diff --git a/software/deeptools/plotheatmap/main.nf b/software/deeptools/plotheatmap/main.nf index 9cc740e2..ca8bf08f 100644 --- a/software/deeptools/plotheatmap/main.nf +++ b/software/deeptools/plotheatmap/main.nf @@ -1,38 +1,38 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process DEEPTOOLS_PLOTHEATMAP { - tag "$meta.id" - label 'process_low' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/deeptools:3.4.3--py_0" - //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" - - conda (params.conda ? "bioconda::deeptools=3.4.3" : null) - - input: - tuple val(meta), path(matrix) - val options - - output: - tuple val(meta), path("*.pdf"), emit: pdf - tuple val(meta), path("*.tab"), emit: table - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - plotHeatmap \\ - $ioptions.args \\ - --matrixFile $matrix \\ - --outFileName ${prefix}.plotHeatmap.pdf \\ - --outFileNameMatrix ${prefix}.plotHeatmap.mat.tab - - plotHeatmap --version | sed -e "s/plotHeatmap //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process DEEPTOOLS_PLOTHEATMAP { + tag "$meta.id" + label 'process_low' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/deeptools:3.4.3--py_0" + //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" + + conda (params.conda ? "bioconda::deeptools=3.4.3" : null) + + input: + tuple val(meta), path(matrix) + val options + + output: + tuple val(meta), path("*.pdf"), emit: pdf + tuple val(meta), path("*.tab"), emit: table + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + plotHeatmap \\ + $ioptions.args \\ + --matrixFile $matrix \\ + --outFileName ${prefix}.plotHeatmap.pdf \\ + --outFileNameMatrix ${prefix}.plotHeatmap.mat.tab + + plotHeatmap --version | sed -e "s/plotHeatmap //g" > ${software}.version.txt + """ +} diff --git a/software/deeptools/plotprofile/main.nf b/software/deeptools/plotprofile/main.nf index a822066b..6a976f7f 100644 --- a/software/deeptools/plotprofile/main.nf +++ b/software/deeptools/plotprofile/main.nf @@ -1,38 +1,38 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process DEEPTOOLS_PLOTPROFILE { - tag "$meta.id" - label 'process_low' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/deeptools:3.4.3--py_0" - //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" - - conda (params.conda ? "bioconda::deeptools=3.4.3" : null) - - input: - tuple val(meta), path(matrix) - val options - - output: - tuple val(meta), path("*.pdf"), emit: pdf - tuple val(meta), path("*.tab"), emit: table - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - plotProfile \\ - $ioptions.args \\ - --matrixFile $matrix \\ - --outFileName ${prefix}.plotProfile.pdf \\ - --outFileNameData ${prefix}.plotProfile.tab - - plotProfile --version | sed -e "s/plotProfile //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process DEEPTOOLS_PLOTPROFILE { + tag "$meta.id" + label 'process_low' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/deeptools:3.4.3--py_0" + //container "https://depot.galaxyproject.org/singularity/deeptools:3.4.3--py_0" + + conda (params.conda ? "bioconda::deeptools=3.4.3" : null) + + input: + tuple val(meta), path(matrix) + val options + + output: + tuple val(meta), path("*.pdf"), emit: pdf + tuple val(meta), path("*.tab"), emit: table + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + plotProfile \\ + $ioptions.args \\ + --matrixFile $matrix \\ + --outFileName ${prefix}.plotProfile.pdf \\ + --outFileNameData ${prefix}.plotProfile.tab + + plotProfile --version | sed -e "s/plotProfile //g" > ${software}.version.txt + """ +} diff --git a/software/fastqc/main.nf b/software/fastqc/main.nf index 7f882525..ed5cc561 100644 --- a/software/fastqc/main.nf +++ b/software/fastqc/main.nf @@ -15,12 +15,12 @@ process FASTQC { input: tuple val(meta), path(reads) - val options + val options output: tuple val(meta), path("*.html"), emit: html - tuple val(meta), path("*.zip"), emit: zip - path "*.version.txt", emit: version + tuple val(meta), path("*.zip") , emit: zip + path "*.version.txt" , emit: version script: // Add soft-links to original FastQs for consistent naming in pipeline diff --git a/software/hisat2/align/main.nf b/software/hisat2/align/main.nf index b6108e55..a57b5349 100644 --- a/software/hisat2/align/main.nf +++ b/software/hisat2/align/main.nf @@ -1,90 +1,90 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -def VERSION = '2.2.0' - -process HISAT2_ALIGN { - tag "$meta.id" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:2880dd9d8ad0a7b221d4eacda9a818e92983128d-0" - //container "https://depot.galaxyproject.org/singularity/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:2880dd9d8ad0a7b221d4eacda9a818e92983128d-0" - - conda (params.conda ? "bioconda::hisat2=2.2.0 bioconda::samtools=1.10" : null) - - input: - tuple val(meta), path(reads) - path index - path splicesites - val options - - output: - tuple val(meta), path("*.bam"), emit: bam - tuple val(meta), path("*.log"), emit: summary - path "*.version.txt" , emit: version - - tuple val(meta), path("*fastq.gz"), optional:true, emit: fastq - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - - def strandedness = '' - if (meta.strandedness == 'forward') { - strandedness = meta.single_end ? '--rna-strandness F' : '--rna-strandness FR' - } else if (meta.strandedness == 'reverse') { - strandedness = meta.single_end ? '--rna-strandness R' : '--rna-strandness RF' - } - def seq_center = params.seq_center ? "--rg-id ${prefix} --rg CN:${params.seq_center.replaceAll('\\s','_')} SM:$prefix" : "--rg-id ${prefix} --rg SM:$prefix" - if (meta.single_end) { - def unaligned = params.save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : '' - """ - INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'` - hisat2 \\ - -x \$INDEX \\ - -U $reads \\ - $strandedness \\ - --known-splicesite-infile $splicesites \\ - --summary-file ${prefix}.hisat2.summary.log \\ - --threads $task.cpus \\ - $seq_center \\ - $unaligned \\ - $ioptions.args \\ - | samtools view -bS -F 4 -F 256 - > ${prefix}.bam - - echo $VERSION > ${software}.version.txt - """ - } else { - def unaligned = params.save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : '' - """ - INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'` - hisat2 \\ - -x \$INDEX \\ - -1 ${reads[0]} \\ - -2 ${reads[1]} \\ - $strandedness \\ - --known-splicesite-infile $splicesites \\ - --summary-file ${prefix}.hisat2.summary.log \\ - --threads $task.cpus \\ - $seq_center \\ - $unaligned \\ - --no-mixed \\ - --no-discordant \\ - $ioptions.args \\ - | samtools view -bS -F 4 -F 8 -F 256 - > ${prefix}.bam - - if [ -f ${prefix}.unmapped.fastq.1.gz ]; then - mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz - fi - if [ -f ${prefix}.unmapped.fastq.2.gz ]; then - mv ${prefix}.unmapped.fastq.2.gz ${prefix}.unmapped_2.fastq.gz - fi - - echo $VERSION > ${software}.version.txt - """ - } -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +def VERSION = '2.2.0' + +process HISAT2_ALIGN { + tag "$meta.id" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:2880dd9d8ad0a7b221d4eacda9a818e92983128d-0" + //container "https://depot.galaxyproject.org/singularity/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:2880dd9d8ad0a7b221d4eacda9a818e92983128d-0" + + conda (params.conda ? "bioconda::hisat2=2.2.0 bioconda::samtools=1.10" : null) + + input: + tuple val(meta), path(reads) + path index + path splicesites + val options + + output: + tuple val(meta), path("*.bam"), emit: bam + tuple val(meta), path("*.log"), emit: summary + path "*.version.txt" , emit: version + + tuple val(meta), path("*fastq.gz"), optional:true, emit: fastq + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + + def strandedness = '' + if (meta.strandedness == 'forward') { + strandedness = meta.single_end ? '--rna-strandness F' : '--rna-strandness FR' + } else if (meta.strandedness == 'reverse') { + strandedness = meta.single_end ? '--rna-strandness R' : '--rna-strandness RF' + } + def seq_center = params.seq_center ? "--rg-id ${prefix} --rg CN:${params.seq_center.replaceAll('\\s','_')} SM:$prefix" : "--rg-id ${prefix} --rg SM:$prefix" + if (meta.single_end) { + def unaligned = params.save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : '' + """ + INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'` + hisat2 \\ + -x \$INDEX \\ + -U $reads \\ + $strandedness \\ + --known-splicesite-infile $splicesites \\ + --summary-file ${prefix}.hisat2.summary.log \\ + --threads $task.cpus \\ + $seq_center \\ + $unaligned \\ + $ioptions.args \\ + | samtools view -bS -F 4 -F 256 - > ${prefix}.bam + + echo $VERSION > ${software}.version.txt + """ + } else { + def unaligned = params.save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : '' + """ + INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'` + hisat2 \\ + -x \$INDEX \\ + -1 ${reads[0]} \\ + -2 ${reads[1]} \\ + $strandedness \\ + --known-splicesite-infile $splicesites \\ + --summary-file ${prefix}.hisat2.summary.log \\ + --threads $task.cpus \\ + $seq_center \\ + $unaligned \\ + --no-mixed \\ + --no-discordant \\ + $ioptions.args \\ + | samtools view -bS -F 4 -F 8 -F 256 - > ${prefix}.bam + + if [ -f ${prefix}.unmapped.fastq.1.gz ]; then + mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz + fi + if [ -f ${prefix}.unmapped.fastq.2.gz ]; then + mv ${prefix}.unmapped.fastq.2.gz ${prefix}.unmapped_2.fastq.gz + fi + + echo $VERSION > ${software}.version.txt + """ + } +} diff --git a/software/hisat2/extractsplicesites/main.nf b/software/hisat2/extractsplicesites/main.nf index aa17b93c..71aec5bc 100644 --- a/software/hisat2/extractsplicesites/main.nf +++ b/software/hisat2/extractsplicesites/main.nf @@ -1,31 +1,31 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -def VERSION = '2.2.0' - -process HISAT2_EXTRACTSPLICESITES { - tag "$gtf" - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:'') } - - container "quay.io/biocontainers/hisat2:2.2.0--py37hfa133b6_4" - //container "https://depot.galaxyproject.org/singularity/hisat2:2.2.0--py37hfa133b6_4" - - conda (params.conda ? "bioconda::hisat2=2.2.0" : null) - - input: - path gtf - val options - - output: - path "*.splice_sites.txt", emit: txt - path "*.version.txt" , emit: version - - script: - def software = getSoftwareName(task.process) - """ - hisat2_extract_splice_sites.py $gtf > ${gtf.baseName}.splice_sites.txt - echo $VERSION > ${software}.version.txt - """ -} +// Import generic module functions +include { saveFiles; getSoftwareName } from './functions' + +def VERSION = '2.2.0' + +process HISAT2_EXTRACTSPLICESITES { + tag "$gtf" + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:'') } + + container "quay.io/biocontainers/hisat2:2.2.0--py37hfa133b6_4" + //container "https://depot.galaxyproject.org/singularity/hisat2:2.2.0--py37hfa133b6_4" + + conda (params.conda ? "bioconda::hisat2=2.2.0" : null) + + input: + path gtf + val options + + output: + path "*.splice_sites.txt", emit: txt + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + """ + hisat2_extract_splice_sites.py $gtf > ${gtf.baseName}.splice_sites.txt + echo $VERSION > ${software}.version.txt + """ +} diff --git a/software/homer/annotatepeaks/main.nf b/software/homer/annotatepeaks/main.nf index 496f5cc4..98d234b0 100644 --- a/software/homer/annotatepeaks/main.nf +++ b/software/homer/annotatepeaks/main.nf @@ -1,43 +1,43 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -def VERSION = '4.11' - -process HOMER_ANNOTATEPEAKS { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/homer:4.11--pl526h9a982cc_2" - //container "https://depot.galaxyproject.org/singularity/homer:4.11--pl526h9a982cc_2" - - conda (params.conda ? "bioconda::homer=4.11" : null) - - input: - tuple val(meta), path(peak) - path fasta - path gtf - val options - - output: - tuple val(meta), path("*annotatePeaks.txt"), emit: txt - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - annotatePeaks.pl \\ - $peak \\ - $fasta \\ - $ioptions.args \\ - -gtf $gtf \\ - -cpu $task.cpus \\ - > ${prefix}.annotatePeaks.txt - - echo $VERSION > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +def VERSION = '4.11' + +process HOMER_ANNOTATEPEAKS { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/homer:4.11--pl526h9a982cc_2" + //container "https://depot.galaxyproject.org/singularity/homer:4.11--pl526h9a982cc_2" + + conda (params.conda ? "bioconda::homer=4.11" : null) + + input: + tuple val(meta), path(peak) + path fasta + path gtf + val options + + output: + tuple val(meta), path("*annotatePeaks.txt"), emit: txt + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + annotatePeaks.pl \\ + $peak \\ + $fasta \\ + $ioptions.args \\ + -gtf $gtf \\ + -cpu $task.cpus \\ + > ${prefix}.annotatePeaks.txt + + echo $VERSION > ${software}.version.txt + """ +} diff --git a/software/macs2/callpeak/main.nf b/software/macs2/callpeak/main.nf index 454f0fb6..e9a2a9c1 100644 --- a/software/macs2/callpeak/main.nf +++ b/software/macs2/callpeak/main.nf @@ -1,47 +1,48 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process MACS2_CALLPEAK { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/macs2:2.2.7.1--py37h516909a_0" - //container "https://depot.galaxyproject.org/singularity/macs2:2.2.7.1--py37h516909a_0" - - conda (params.conda ? "bioconda::macs2=2.2.7.1" : null) - - input: - tuple val(meta), path(ipbam), path(controlbam) - val macs2_gsize - val options - - output: - tuple val(meta), path("*.{narrowPeak,broadPeak}"), emit: peak - tuple val(meta), path("*.xls"), emit: xls - tuple val(meta), path("*.gappedPeak"), emit: gapped optional true - tuple val(meta), path("*.bed"), emit: bed optional true - tuple val(meta), path("*.bdg"), emit: bdg optional true - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def format = meta.single_end ? 'BAM' : 'BAMPE' - def control = controlbam ? "--control $controlbam" : '' - """ - macs2 \\ - callpeak \\ - $ioptions.args \\ - --gsize $macs2_gsize \\ - --format $format \\ - --name $prefix \\ - --treatment $ipbam \\ - $control - - macs2 --version | sed -e "s/macs2 //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process MACS2_CALLPEAK { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/macs2:2.2.7.1--py37h516909a_0" + //container "https://depot.galaxyproject.org/singularity/macs2:2.2.7.1--py37h516909a_0" + + conda (params.conda ? "bioconda::macs2=2.2.7.1" : null) + + input: + tuple val(meta), path(ipbam), path(controlbam) + val macs2_gsize + val options + + output: + tuple val(meta), path("*.{narrowPeak,broadPeak}"), emit: peak + tuple val(meta), path("*.xls") , emit: xls + path "*.version.txt" , emit: version + + tuple val(meta), path("*.gappedPeak"), optional:true, emit: gapped + tuple val(meta), path("*.bed") , optional:true, emit: bed + tuple val(meta), path("*.bdg") , optional:true, emit: bdg + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def format = meta.single_end ? 'BAM' : 'BAMPE' + def control = controlbam ? "--control $controlbam" : '' + """ + macs2 \\ + callpeak \\ + $ioptions.args \\ + --gsize $macs2_gsize \\ + --format $format \\ + --name $prefix \\ + --treatment $ipbam \\ + $control + + macs2 --version | sed -e "s/macs2 //g" > ${software}.version.txt + """ +} diff --git a/software/phantompeakqualtools/main.nf b/software/phantompeakqualtools/main.nf index 7777e132..f9471dc6 100644 --- a/software/phantompeakqualtools/main.nf +++ b/software/phantompeakqualtools/main.nf @@ -1,37 +1,37 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -def VERSION = '1.2.2' - -process PHANTOMPEAKQUALTOOLS { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/phantompeakqualtools:1.2.2--0" - //container "https://depot.galaxyproject.org/singularity/phantompeakqualtools:1.2.2--0" - - conda (params.conda ? "bioconda::phantompeakqualtools=1.2.2" : null) - - input: - tuple val(meta), path(bam) - val options - - output: - tuple val(meta), path("*.out"), emit: spp - tuple val(meta), path("*.pdf"), emit: pdf - tuple val(meta), path("*.Rdata"), emit: rdata - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - RUN_SPP=`which run_spp.R` - Rscript -e "library(caTools); source(\\"\$RUN_SPP\\")" -c="$bam" -savp="${prefix}.spp.pdf" -savd="${prefix}.spp.Rdata" -out="${prefix}.spp.out" -p=$task.cpus - echo $VERSION > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +def VERSION = '1.2.2' + +process PHANTOMPEAKQUALTOOLS { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/phantompeakqualtools:1.2.2--0" + //container "https://depot.galaxyproject.org/singularity/phantompeakqualtools:1.2.2--0" + + conda (params.conda ? "bioconda::phantompeakqualtools=1.2.2" : null) + + input: + tuple val(meta), path(bam) + val options + + output: + tuple val(meta), path("*.out") , emit: spp + tuple val(meta), path("*.pdf") , emit: pdf + tuple val(meta), path("*.Rdata"), emit: rdata + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + RUN_SPP=`which run_spp.R` + Rscript -e "library(caTools); source(\\"\$RUN_SPP\\")" -c="$bam" -savp="${prefix}.spp.pdf" -savd="${prefix}.spp.Rdata" -out="${prefix}.spp.out" -p=$task.cpus + echo $VERSION > ${software}.version.txt + """ +} diff --git a/software/picard/collectmultiplemetrics/main.nf b/software/picard/collectmultiplemetrics/main.nf index 8850d534..c59e0214 100644 --- a/software/picard/collectmultiplemetrics/main.nf +++ b/software/picard/collectmultiplemetrics/main.nf @@ -1,47 +1,47 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process PICARD_COLLECTMULTIPLEMETRICS { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/picard:2.23.2--0" - //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" - - conda (params.conda ? "bioconda::picard=2.23.2" : null) - - input: - tuple val(meta), path(bam) - path fasta - val options - - output: - tuple val(meta), path("*_metrics"), emit: metrics - tuple val(meta), path("*.pdf"), emit: pdf - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def avail_mem = 3 - if (!task.memory) { - log.info '[Picard CollectMultipleMetrics] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' - } else { - avail_mem = task.memory.giga - } - """ - picard \\ - -Xmx${avail_mem}g \\ - CollectMultipleMetrics \\ - $ioptions.args \\ - INPUT=$bam \\ - OUTPUT=${prefix}.CollectMultipleMetrics \\ - REFERENCE_SEQUENCE=$fasta - - echo \$(picard CollectMultipleMetrics --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process PICARD_COLLECTMULTIPLEMETRICS { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/picard:2.23.2--0" + //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" + + conda (params.conda ? "bioconda::picard=2.23.2" : null) + + input: + tuple val(meta), path(bam) + path fasta + val options + + output: + tuple val(meta), path("*_metrics"), emit: metrics + tuple val(meta), path("*.pdf") , emit: pdf + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def avail_mem = 3 + if (!task.memory) { + log.info '[Picard CollectMultipleMetrics] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = task.memory.giga + } + """ + picard \\ + -Xmx${avail_mem}g \\ + CollectMultipleMetrics \\ + $ioptions.args \\ + INPUT=$bam \\ + OUTPUT=${prefix}.CollectMultipleMetrics \\ + REFERENCE_SEQUENCE=$fasta + + echo \$(picard CollectMultipleMetrics --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt + """ +} diff --git a/software/picard/markduplicates/main.nf b/software/picard/markduplicates/main.nf index 8bfed256..93961e03 100644 --- a/software/picard/markduplicates/main.nf +++ b/software/picard/markduplicates/main.nf @@ -1,46 +1,46 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process PICARD_MARKDUPLICATES { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/picard:2.23.2--0" - //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" - - conda (params.conda ? "bioconda::picard=2.23.2" : null) - - input: - tuple val(meta), path(bam) - val options - - output: - tuple val(meta), path("*.bam"), emit: bam - tuple val(meta), path("*.metrics.txt"), emit: metrics - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def avail_mem = 3 - if (!task.memory) { - log.info '[Picard MarkDuplicates] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' - } else { - avail_mem = task.memory.giga - } - """ - picard \\ - -Xmx${avail_mem}g \\ - MarkDuplicates \\ - $ioptions.args \\ - INPUT=$bam \\ - OUTPUT=${prefix}.bam \\ - METRICS_FILE=${prefix}.MarkDuplicates.metrics.txt - - echo \$(picard MarkDuplicates --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process PICARD_MARKDUPLICATES { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/picard:2.23.2--0" + //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" + + conda (params.conda ? "bioconda::picard=2.23.2" : null) + + input: + tuple val(meta), path(bam) + val options + + output: + tuple val(meta), path("*.bam") , emit: bam + tuple val(meta), path("*.metrics.txt"), emit: metrics + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def avail_mem = 3 + if (!task.memory) { + log.info '[Picard MarkDuplicates] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = task.memory.giga + } + """ + picard \\ + -Xmx${avail_mem}g \\ + MarkDuplicates \\ + $ioptions.args \\ + INPUT=$bam \\ + OUTPUT=${prefix}.bam \\ + METRICS_FILE=${prefix}.MarkDuplicates.metrics.txt + + echo \$(picard MarkDuplicates --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt + """ +} diff --git a/software/picard/mergesamfiles/main.nf b/software/picard/mergesamfiles/main.nf index 062bbfc8..2a6b70de 100644 --- a/software/picard/mergesamfiles/main.nf +++ b/software/picard/mergesamfiles/main.nf @@ -1,51 +1,51 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process PICARD_MERGESAMFILES { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/picard:2.23.2--0" - //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" - - conda (params.conda ? "bioconda::picard=2.23.2" : null) - - input: - tuple val(meta), path(bams) - val options - - output: - tuple val(meta), path("*.bam"), emit: bam - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def bam_files = bams.sort() - def avail_mem = 3 - if (!task.memory) { - log.info '[Picard MergeSamFiles] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' - } else { - avail_mem = task.memory.giga - } - if (bam_files.size() > 1) { - """ - picard \\ - -Xmx${avail_mem}g \\ - MergeSamFiles \\ - $ioptions.args \\ - ${'INPUT='+bam_files.join(' INPUT=')} \\ - OUTPUT=${prefix}.bam - echo \$(picard MergeSamFiles --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt - """ - } else { - """ - ln -s ${bam_files[0]} ${prefix}.bam - echo \$(picard MergeSamFiles --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt - """ - } -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process PICARD_MERGESAMFILES { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/picard:2.23.2--0" + //container "https://depot.galaxyproject.org/singularity/picard:2.23.2--0" + + conda (params.conda ? "bioconda::picard=2.23.2" : null) + + input: + tuple val(meta), path(bams) + val options + + output: + tuple val(meta), path("*.bam"), emit: bam + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def bam_files = bams.sort() + def avail_mem = 3 + if (!task.memory) { + log.info '[Picard MergeSamFiles] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = task.memory.giga + } + if (bam_files.size() > 1) { + """ + picard \\ + -Xmx${avail_mem}g \\ + MergeSamFiles \\ + $ioptions.args \\ + ${'INPUT='+bam_files.join(' INPUT=')} \\ + OUTPUT=${prefix}.bam + echo \$(picard MergeSamFiles --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt + """ + } else { + """ + ln -s ${bam_files[0]} ${prefix}.bam + echo \$(picard MergeSamFiles --version 2>&1) | awk -F' ' '{print \$NF}' > ${software}.version.txt + """ + } +} diff --git a/software/preseq/lcextrap/main.nf b/software/preseq/lcextrap/main.nf index 26ed3829..7526ee4a 100644 --- a/software/preseq/lcextrap/main.nf +++ b/software/preseq/lcextrap/main.nf @@ -1,42 +1,42 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process PRESEQ_LCEXTRAP { - tag "$meta.id" - label 'process_medium' - label 'error_ignore' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/preseq:2.0.3--hf53bd2b_3" - //container "https://depot.galaxyproject.org/singularity/preseq:2.0.3--hf53bd2b_3" - - conda (params.conda ? "bioconda::preseq=2.0.3" : null) - - input: - tuple val(meta), path(bam) - val options - - output: - tuple val(meta), path("*.ccurve.txt"), emit: ccurve - tuple val(meta), path("*.log"), emit: log - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - def pe = meta.single_end ? '' : '-pe' - """ - preseq \\ - lc_extrap \\ - $ioptions.args \\ - $pe \\ - -output ${prefix}.ccurve.txt \\ - $bam - cp .command.err ${prefix}.command.log - - echo \$(preseq 2>&1) | sed 's/^.*Version: //; s/Usage:.*\$//' > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process PRESEQ_LCEXTRAP { + tag "$meta.id" + label 'process_medium' + label 'error_ignore' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/preseq:2.0.3--hf53bd2b_3" + //container "https://depot.galaxyproject.org/singularity/preseq:2.0.3--hf53bd2b_3" + + conda (params.conda ? "bioconda::preseq=2.0.3" : null) + + input: + tuple val(meta), path(bam) + val options + + output: + tuple val(meta), path("*.ccurve.txt"), emit: ccurve + tuple val(meta), path("*.log") , emit: log + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def paired_end = meta.single_end ? '' : '-pe' + """ + preseq \\ + lc_extrap \\ + $ioptions.args \\ + $paired_end \\ + -output ${prefix}.ccurve.txt \\ + $bam + cp .command.err ${prefix}.command.log + + echo \$(preseq 2>&1) | sed 's/^.*Version: //; s/Usage:.*\$//' > ${software}.version.txt + """ +} diff --git a/software/qualimap/rnaseq/main.nf b/software/qualimap/rnaseq/main.nf index 79aa1825..df0a7b87 100644 --- a/software/qualimap/rnaseq/main.nf +++ b/software/qualimap/rnaseq/main.nf @@ -1,54 +1,54 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process QUALIMAP_RNASEQ { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/qualimap:2.2.2d--1" - //container "https://depot.galaxyproject.org/singularity/qualimap:2.2.2d--1" - - conda (params.conda ? "bioconda::qualimap=2.2.2d" : null) - - input: - tuple val(meta), path(bam) - path gtf - val options - - output: - tuple val(meta), path("${prefix}"), emit: results - path "*.version.txt" , emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - - def strandedness = 'non-strand-specific' - if (meta.strandedness == 'forward') { - strandedness = 'strand-specific-forward' - } else if (meta.strandedness == 'reverse') { - strandedness = 'strand-specific-reverse' - } - def paired_end = meta.single_end ? '' : '-pe' - def memory = task.memory.toGiga() + "G" - """ - unset DISPLAY - mkdir tmp - export _JAVA_OPTIONS=-Djava.io.tmpdir=./tmp - qualimap \\ - --java-mem-size=$memory \\ - rnaseq \\ - $ioptions.args \\ - -bam $bam \\ - -gtf $gtf \\ - -p $strandedness \\ - $paired_end \\ - -outdir $prefix - - echo \$(qualimap 2>&1) | sed 's/^.*QualiMap v.//; s/Built.*\$//' > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process QUALIMAP_RNASEQ { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/qualimap:2.2.2d--1" + //container "https://depot.galaxyproject.org/singularity/qualimap:2.2.2d--1" + + conda (params.conda ? "bioconda::qualimap=2.2.2d" : null) + + input: + tuple val(meta), path(bam) + path gtf + val options + + output: + tuple val(meta), path("${prefix}"), emit: results + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def paired_end = meta.single_end ? '' : '-pe' + def memory = task.memory.toGiga() + "G" + + def strandedness = 'non-strand-specific' + if (meta.strandedness == 'forward') { + strandedness = 'strand-specific-forward' + } else if (meta.strandedness == 'reverse') { + strandedness = 'strand-specific-reverse' + } + """ + unset DISPLAY + mkdir tmp + export _JAVA_OPTIONS=-Djava.io.tmpdir=./tmp + qualimap \\ + --java-mem-size=$memory \\ + rnaseq \\ + $ioptions.args \\ + -bam $bam \\ + -gtf $gtf \\ + -p $strandedness \\ + $paired_end \\ + -outdir $prefix + + echo \$(qualimap 2>&1) | sed 's/^.*QualiMap v.//; s/Built.*\$//' > ${software}.version.txt + """ +} diff --git a/software/salmon/quant/main.nf b/software/salmon/quant/main.nf index 534574af..a333342b 100644 --- a/software/salmon/quant/main.nf +++ b/software/salmon/quant/main.nf @@ -1,50 +1,50 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process SALMON_QUANT { - tag "$meta.id" - label "process_medium" - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/salmon:1.3.0--hf69c8f4_0" - //container "https://depot.galaxyproject.org/singularity/salmon:1.3.0--hf69c8f4_0" - - conda (params.conda ? "bioconda::salmon=1.3.0" : null) - - input: - tuple val(meta), path(reads) - path index - path gtf - val options - - output: - tuple val(meta), path("${prefix}"), emit: results - path "*.version.txt" , emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - - def strandedness = meta.single_end ? 'U' : 'IU' - if (meta.strandedness == 'forward') { - strandedness = meta.single_end ? 'SF' : 'ISF' - } else if (meta.strandedness == 'reverse') { - strandedness = meta.single_end ? 'SR' : 'ISR' - } - def endedness = meta.single_end ? "-r $reads" : "-1 ${reads[0]} -2 ${reads[1]}" - """ - salmon quant \\ - --geneMap $gtf \\ - --threads $task.cpus \\ - --libType=$strandedness \\ - --index $index \\ - $endedness \\ - $ioptions.args \\ - -o $prefix - - salmon --version | sed -e "s/salmon //g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process SALMON_QUANT { + tag "$meta.id" + label "process_medium" + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/salmon:1.3.0--hf69c8f4_0" + //container "https://depot.galaxyproject.org/singularity/salmon:1.3.0--hf69c8f4_0" + + conda (params.conda ? "bioconda::salmon=1.3.0" : null) + + input: + tuple val(meta), path(reads) + path index + path gtf + val options + + output: + tuple val(meta), path("${prefix}"), emit: results + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def endedness = meta.single_end ? "-r $reads" : "-1 ${reads[0]} -2 ${reads[1]}" + + def strandedness = meta.single_end ? 'U' : 'IU' + if (meta.strandedness == 'forward') { + strandedness = meta.single_end ? 'SF' : 'ISF' + } else if (meta.strandedness == 'reverse') { + strandedness = meta.single_end ? 'SR' : 'ISR' + } + """ + salmon quant \\ + --geneMap $gtf \\ + --threads $task.cpus \\ + --libType=$strandedness \\ + --index $index \\ + $endedness \\ + $ioptions.args \\ + -o $prefix + + salmon --version | sed -e "s/salmon //g" > ${software}.version.txt + """ +} diff --git a/software/samtools/flagstat/main.nf b/software/samtools/flagstat/main.nf index 4c14a41a..a497c9ab 100644 --- a/software/samtools/flagstat/main.nf +++ b/software/samtools/flagstat/main.nf @@ -14,11 +14,11 @@ process SAMTOOLS_FLAGSTAT { input: tuple val(meta), path(bam), path(bai) - val options + val options output: tuple val(meta), path("*.flagstat"), emit: flagstat - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/samtools/idxstats/main.nf b/software/samtools/idxstats/main.nf index 9805bb14..baf3a9b8 100644 --- a/software/samtools/idxstats/main.nf +++ b/software/samtools/idxstats/main.nf @@ -14,11 +14,11 @@ process SAMTOOLS_IDXSTATS { input: tuple val(meta), path(bam), path(bai) - val options + val options output: tuple val(meta), path("*.idxstats"), emit: idxstats - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/samtools/index/main.nf b/software/samtools/index/main.nf index 456e2663..24dcaaee 100644 --- a/software/samtools/index/main.nf +++ b/software/samtools/index/main.nf @@ -14,11 +14,11 @@ process SAMTOOLS_INDEX { input: tuple val(meta), path(bam) - val options + val options output: tuple val(meta), path("*.bai"), emit: bai - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/samtools/sort/main.nf b/software/samtools/sort/main.nf index 9467e2ae..fc36d984 100644 --- a/software/samtools/sort/main.nf +++ b/software/samtools/sort/main.nf @@ -15,11 +15,11 @@ process SAMTOOLS_SORT { input: tuple val(meta), path(bam) - val options + val options output: tuple val(meta), path("*.bam"), emit: bam - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/samtools/stats/main.nf b/software/samtools/stats/main.nf index 52d5e2d7..23bfc96b 100644 --- a/software/samtools/stats/main.nf +++ b/software/samtools/stats/main.nf @@ -14,11 +14,11 @@ process SAMTOOLS_STATS { input: tuple val(meta), path(bam), path(bai) - val options + val options output: tuple val(meta), path("*.stats"), emit: stats - path "*.version.txt", emit: version + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) diff --git a/software/star/genomegenerate/main.nf b/software/star/genomegenerate/main.nf index b849dd89..1e179711 100644 --- a/software/star/genomegenerate/main.nf +++ b/software/star/genomegenerate/main.nf @@ -1,43 +1,43 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process STAR_GENOMEGENERATE { - tag "$fasta" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:'') } - - // Don't upgrade me - 2.7X indices incompatible with iGenomes. - container "quay.io/biocontainers/star:2.6.1d--0" - //container "https://depot.galaxyproject.org/singularity/star:2.6.1d--0" - - conda (params.conda ? "bioconda::star=2.6.1d" : null) - - input: - path fasta - path gtf - val options - - output: - path "star" , emit: index - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def avail_mem = task.memory ? "--limitGenomeGenerateRAM ${task.memory.toBytes() - 100000000}" : '' - """ - mkdir star - STAR \\ - --runMode genomeGenerate \\ - --genomeDir star/ \\ - --genomeFastaFiles $fasta \\ - --sjdbGTFfile $gtf \\ - --runThreadN $task.cpus \\ - $avail_mem \\ - $ioptions.args - - STAR --version | sed -e "s/STAR_//g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process STAR_GENOMEGENERATE { + tag "$fasta" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:'') } + + // Don't upgrade me - 2.7X indices incompatible with iGenomes. + container "quay.io/biocontainers/star:2.6.1d--0" + //container "https://depot.galaxyproject.org/singularity/star:2.6.1d--0" + + conda (params.conda ? "bioconda::star=2.6.1d" : null) + + input: + path fasta + path gtf + val options + + output: + path "star" , emit: index + path "*.version.txt", emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def memory = task.memory ? "--limitGenomeGenerateRAM ${task.memory.toBytes() - 100000000}" : '' + """ + mkdir star + STAR \\ + --runMode genomeGenerate \\ + --genomeDir star/ \\ + --genomeFastaFiles $fasta \\ + --sjdbGTFfile $gtf \\ + --runThreadN $task.cpus \\ + $memory \\ + $ioptions.args + + STAR --version | sed -e "s/STAR_//g" > ${software}.version.txt + """ +} diff --git a/software/subread/featurecounts/main.nf b/software/subread/featurecounts/main.nf index dcfbd898..f7285af8 100644 --- a/software/subread/featurecounts/main.nf +++ b/software/subread/featurecounts/main.nf @@ -1,49 +1,49 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process SUBREAD_FEATURECOUNTS { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/subread:2.0.1--hed695b0_0" - //container "https://depot.galaxyproject.org/singularity/subread:2.0.1--hed695b0_0" - - conda (params.conda ? "bioconda::subread=2.0.1" : null) - - input: - tuple val(meta), path(bams), path(annotation) - val options - - output: - tuple val(meta), path("*featureCounts.txt") , emit: counts - tuple val(meta), path("*featureCounts.txt.summary"), emit: summary - path "*.version.txt" , emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - - def strandedness = 0 - if (meta.strandedness == 'forward') { - strandedness = 1 - } else if (meta.strandedness == 'reverse') { - strandedness = 2 - } - def paired_end = meta.single_end ? '' : '-p' - """ - featureCounts \\ - $ioptions.args \\ - $paired_end \\ - -T $task.cpus \\ - -a $annotation \\ - -s $strandedness \\ - -o ${prefix}.featureCounts.txt \\ - ${bams.join(' ')} - - echo \$(featureCounts -v 2>&1) | sed -e "s/featureCounts v//g" > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process SUBREAD_FEATURECOUNTS { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/subread:2.0.1--hed695b0_0" + //container "https://depot.galaxyproject.org/singularity/subread:2.0.1--hed695b0_0" + + conda (params.conda ? "bioconda::subread=2.0.1" : null) + + input: + tuple val(meta), path(bams), path(annotation) + val options + + output: + tuple val(meta), path("*featureCounts.txt") , emit: counts + tuple val(meta), path("*featureCounts.txt.summary"), emit: summary + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + def paired_end = meta.single_end ? '' : '-p' + + def strandedness = 0 + if (meta.strandedness == 'forward') { + strandedness = 1 + } else if (meta.strandedness == 'reverse') { + strandedness = 2 + } + """ + featureCounts \\ + $ioptions.args \\ + $paired_end \\ + -T $task.cpus \\ + -a $annotation \\ + -s $strandedness \\ + -o ${prefix}.featureCounts.txt \\ + ${bams.join(' ')} + + echo \$(featureCounts -v 2>&1) | sed -e "s/featureCounts v//g" > ${software}.version.txt + """ +} diff --git a/software/trimgalore/main.nf b/software/trimgalore/main.nf index 219b3e65..e3201c20 100644 --- a/software/trimgalore/main.nf +++ b/software/trimgalore/main.nf @@ -1,79 +1,80 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -process TRIMGALORE { - tag "$meta.id" - label 'process_high' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/trim-galore:0.6.5--0" - //container "https://depot.galaxyproject.org/singularity/trim-galore:0.6.5--0" - - conda (params.conda ? "bioconda::trim-galore=0.6.5" : null) - - input: - tuple val(meta), path(reads) - val options - - output: - tuple val(meta), path("*.fq.gz"), emit: reads - tuple val(meta), path("*.html"), emit: html optional true - tuple val(meta), path("*.zip"), emit: zip optional true - tuple val(meta), path("*report.txt"), emit: log - path "*.version.txt", emit: version - - script: - // Calculate number of --cores for TrimGalore based on value of task.cpus - // See: https://github.com/FelixKrueger/TrimGalore/blob/master/Changelog.md#version-060-release-on-1-mar-2019 - // See: https://github.com/nf-core/atacseq/pull/65 - def cores = 1 - if (task.cpus) { - cores = (task.cpus as int) - 4 - if (meta.single_end) cores = (task.cpus as int) - 3 - if (cores < 1) cores = 1 - if (cores > 4) cores = 4 - } - - // Clipping presets have to be evaluated in the context of SE/PE - def c_r1 = params.clip_r1 > 0 ? "--clip_r1 ${params.clip_r1}" : '' - def c_r2 = params.clip_r2 > 0 ? "--clip_r2 ${params.clip_r2}" : '' - def tpc_r1 = params.three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${params.three_prime_clip_r1}" : '' - def tpc_r2 = params.three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${params.three_prime_clip_r2}" : '' - - // Added soft-links to original fastqs for consistent naming in MultiQC - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - if (meta.single_end) { - """ - [ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz - trim_galore \\ - $ioptions.args \\ - --cores $cores \\ - --gzip \\ - $c_r1 \\ - $tpc_r1 \\ - ${prefix}.fastq.gz - echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//' > ${software}.version.txt - """ - } else { - """ - [ ! -f ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz - [ ! -f ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz - trim_galore \\ - $ioptions.args \\ - --cores $cores \\ - --paired \\ - --gzip \\ - $c_r1 \\ - $c_r2 \\ - $tpc_r1 \\ - $tpc_r2 \\ - ${prefix}_1.fastq.gz \\ - ${prefix}_2.fastq.gz - echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//' > ${software}.version.txt - """ - } -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +process TRIMGALORE { + tag "$meta.id" + label 'process_high' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/trim-galore:0.6.5--0" + //container "https://depot.galaxyproject.org/singularity/trim-galore:0.6.5--0" + + conda (params.conda ? "bioconda::trim-galore=0.6.5" : null) + + input: + tuple val(meta), path(reads) + val options + + output: + tuple val(meta), path("*.fq.gz") , emit: reads + tuple val(meta), path("*report.txt"), emit: log + path "*.version.txt" , emit: version + + tuple val(meta), path("*.html"), emit: html optional true + tuple val(meta), path("*.zip") , emit: zip optional true + + script: + // Calculate number of --cores for TrimGalore based on value of task.cpus + // See: https://github.com/FelixKrueger/TrimGalore/blob/master/Changelog.md#version-060-release-on-1-mar-2019 + // See: https://github.com/nf-core/atacseq/pull/65 + def cores = 1 + if (task.cpus) { + cores = (task.cpus as int) - 4 + if (meta.single_end) cores = (task.cpus as int) - 3 + if (cores < 1) cores = 1 + if (cores > 4) cores = 4 + } + + // Clipping presets have to be evaluated in the context of SE/PE + def c_r1 = params.clip_r1 > 0 ? "--clip_r1 ${params.clip_r1}" : '' + def c_r2 = params.clip_r2 > 0 ? "--clip_r2 ${params.clip_r2}" : '' + def tpc_r1 = params.three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${params.three_prime_clip_r1}" : '' + def tpc_r2 = params.three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${params.three_prime_clip_r2}" : '' + + // Added soft-links to original fastqs for consistent naming in MultiQC + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + if (meta.single_end) { + """ + [ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz + trim_galore \\ + $ioptions.args \\ + --cores $cores \\ + --gzip \\ + $c_r1 \\ + $tpc_r1 \\ + ${prefix}.fastq.gz + echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//' > ${software}.version.txt + """ + } else { + """ + [ ! -f ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz + [ ! -f ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz + trim_galore \\ + $ioptions.args \\ + --cores $cores \\ + --paired \\ + --gzip \\ + $c_r1 \\ + $c_r2 \\ + $tpc_r1 \\ + $tpc_r2 \\ + ${prefix}_1.fastq.gz \\ + ${prefix}_2.fastq.gz + echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//' > ${software}.version.txt + """ + } +} diff --git a/software/ucsc/bedgraphtobigwig/main.nf b/software/ucsc/bedgraphtobigwig/main.nf index 4da63fe1..b21b5fe0 100644 --- a/software/ucsc/bedgraphtobigwig/main.nf +++ b/software/ucsc/bedgraphtobigwig/main.nf @@ -1,35 +1,35 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -def VERSION = '377' - -process UCSC_BEDRAPHTOBIGWIG { - tag "$meta.id" - label 'process_medium' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - container "quay.io/biocontainers/ucsc-bedgraphtobigwig:377--h446ed27_1" - //container "https://depot.galaxyproject.org/singularity/ucsc-bedgraphtobigwig:377--h446ed27_1" - - conda (params.conda ? "bioconda::ucsc-bedgraphtobigwig=377" : null) - - input: - tuple val(meta), path(bedgraph) - path sizes - val options - - output: - tuple val(meta), path("*.bigWig"), emit: bigwig - path "*.version.txt", emit: version - - script: - def software = getSoftwareName(task.process) - def ioptions = initOptions(options) - def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" - """ - bedGraphToBigWig $bedgraph $sizes ${prefix}.bigWig - echo $VERSION > ${software}.version.txt - """ -} +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +def VERSION = '377' + +process UCSC_BEDRAPHTOBIGWIG { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + container "quay.io/biocontainers/ucsc-bedgraphtobigwig:377--h446ed27_1" + //container "https://depot.galaxyproject.org/singularity/ucsc-bedgraphtobigwig:377--h446ed27_1" + + conda (params.conda ? "bioconda::ucsc-bedgraphtobigwig=377" : null) + + input: + tuple val(meta), path(bedgraph) + path sizes + val options + + output: + tuple val(meta), path("*.bigWig"), emit: bigwig + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def ioptions = initOptions(options) + def prefix = ioptions.suffix ? "${meta.id}${ioptions.suffix}" : "${meta.id}" + """ + bedGraphToBigWig $bedgraph $sizes ${prefix}.bigWig + echo $VERSION > ${software}.version.txt + """ +}