diff --git a/modules/adapterremoval/main.nf b/modules/adapterremoval/main.nf index 55c5f17c..77838287 100644 --- a/modules/adapterremoval/main.nf +++ b/modules/adapterremoval/main.nf @@ -11,9 +11,15 @@ process ADAPTERREMOVAL { tuple val(meta), path(reads) output: - tuple val(meta), path('*.fastq.gz'), emit: reads - tuple val(meta), path('*.log') , emit: log - path "versions.yml" , emit: versions + tuple val(meta), path('*.truncated.gz') , optional: true, emit: singles_truncated + tuple val(meta), path('*.discarded.gz') , optional: true, emit: discarded + tuple val(meta), path('*.pair1.truncated.gz') , optional: true, emit: pair1_truncated + tuple val(meta), path('*.pair2.truncated.gz') , optional: true, emit: pair2_truncated + tuple val(meta), path('*.collapsed.gz') , optional: true, emit: collapsed + tuple val(meta), path('*.collapsed.truncated') , optional: true, emit: collapsed_truncated + tuple val(meta), path('*paired.gz') , optional: true, emit: paired_interleaved + tuple val(meta), path('*.log') , emit: log + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -28,30 +34,27 @@ process ADAPTERREMOVAL { --file1 $reads \\ $args \\ --basename $prefix \\ - --threads $task.cpus \\ + --threads ${task.cpus} \\ --settings ${prefix}.log \\ - --output1 ${prefix}.trimmed.fastq.gz \\ --seed 42 \\ - --gzip \\ + --gzip cat <<-END_VERSIONS > versions.yml "${task.process}": adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g") END_VERSIONS """ - } else if (!meta.single_end && !meta.collapse) { + } else if (!meta.single_end ) { """ AdapterRemoval \\ --file1 ${reads[0]} \\ --file2 ${reads[1]} \\ $args \\ --basename $prefix \\ - --threads $task.cpus \\ + --threads ${task.cpus} \\ --settings ${prefix}.log \\ - --output1 ${prefix}.pair1.trimmed.fastq.gz \\ - --output2 ${prefix}.pair2.trimmed.fastq.gz \\ --seed 42 \\ - --gzip \\ + --gzip cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -63,13 +66,12 @@ process ADAPTERREMOVAL { AdapterRemoval \\ --file1 ${reads[0]} \\ --file2 ${reads[1]} \\ - --collapse \\ $args \\ --basename $prefix \\ --threads $task.cpus \\ --settings ${prefix}.log \\ --seed 42 \\ - --gzip \\ + --gzip cat *.collapsed.gz *.collapsed.truncated.gz > ${prefix}.merged.fastq.gz cat <<-END_VERSIONS > versions.yml diff --git a/modules/adapterremoval/meta.yml b/modules/adapterremoval/meta.yml index 4923fa42..a9a071f5 100644 --- a/modules/adapterremoval/meta.yml +++ b/modules/adapterremoval/meta.yml @@ -17,13 +17,13 @@ input: type: map description: | Groovy Map containing sample information - e.g. [ id:'test', single_end:false, collapse:false ] + e.g. [ id:'test', single_end:false ] - reads: type: file description: | List of input FastQ files of size 1 and 2 for single-end and paired-end data, respectively. - pattern: "*.{fq,fastq,fg.gz,fastq.gz}" + pattern: "*.{fq,fastq,fq.gz,fastq.gz}" output: - meta: @@ -31,12 +31,45 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - reads: + - singles_truncated: type: file description: | - List of input adapter trimmed FastQ files of size 1 or 2 for - single-end or collapsed data and paired-end data, respectively. - pattern: "*.{fastq.gz}" + Adapter trimmed FastQ files of either single-end reads, or singleton + 'orphaned' reads from merging of paired-end data (i.e., one of the pair + was lost due to filtering thresholds). + pattern: "*.truncated.gz" + - discarded: + type: file + description: | + Adapter trimmed FastQ files of reads that did not pass filtering + thresholds. + pattern: "*.discarded.gz" + - pair1_truncated: + type: file + description: | + Adapter trimmed R1 FastQ files of paired-end reads that did not merge + with their respective R2 pair due to long templates. The respective pair + is stored in 'pair2_truncated'. + pattern: "*.pair1.truncated.gz" + - pair2_truncated: + type: file + description: | + Adapter trimmed R2 FastQ files of paired-end reads that did not merge + with their respective R1 pair due to long templates. The respective pair + is stored in 'pair1_truncated'. + pattern: "*.pair2.truncated.gz" + - collapsed: + type: file + description: | + Collapsed FastQ of paired-end reads that successfully merged with their + respective R1 pair but were not trimmed. + pattern: "*.collapsed.gz" + - collapsed_truncated: + type: file + description: | + Collapsed FastQ of paired-end reads that successfully merged with their + respective R1 pair and were trimmed of adapter due to sufficient overlap. + pattern: "*.collapsed.truncated.gz" - log: type: file description: AdapterRemoval log file @@ -48,3 +81,4 @@ output: authors: - "@maxibor" + - "@jfy133" diff --git a/tests/modules/adapterremoval/test.yml b/tests/modules/adapterremoval/test.yml index a6c4a6cf..805af9fc 100644 --- a/tests/modules/adapterremoval/test.yml +++ b/tests/modules/adapterremoval/test.yml @@ -1,31 +1,44 @@ - name: adapterremoval test_adapterremoval_single_end - command: nextflow run ./tests/modules/adapterremoval -entry test_adapterremoval_single_end -c ./tests/config/nextflow.config -c ./tests/modules/adapterremoval/nextflow.config + command: nextflow run tests/modules/adapterremoval -entry test_adapterremoval_single_end -c tests/config/nextflow.config tags: - adapterremoval files: + - path: output/adapterremoval/test.discarded.gz - path: output/adapterremoval/test.log md5sum: 2fd3d5d703b63ba33a83021fccf25f77 - - path: output/adapterremoval/test.trimmed.fastq.gz + - path: output/adapterremoval/test.truncated.gz md5sum: 62139afee94defad5b83bdd0b8475a1f + - path: output/adapterremoval/versions.yml + md5sum: ac5b46719719b7ee62739530b80869fc - name: adapterremoval test_adapterremoval_paired_end - command: nextflow run ./tests/modules/adapterremoval -entry test_adapterremoval_paired_end -c ./tests/config/nextflow.config -c ./tests/modules/adapterremoval/nextflow.config + command: nextflow run tests/modules/adapterremoval -entry test_adapterremoval_paired_end -c tests/config/nextflow.config tags: - adapterremoval files: + - path: output/adapterremoval/test.discarded.gz - path: output/adapterremoval/test.log md5sum: b8a451d3981b327f3fdb44f40ba2d6d1 - - path: output/adapterremoval/test.pair1.trimmed.fastq.gz + - path: output/adapterremoval/test.pair1.truncated.gz md5sum: 294a6277f0139bd597e57c6fa31f39c7 - - path: output/adapterremoval/test.pair2.trimmed.fastq.gz + - path: output/adapterremoval/test.pair2.truncated.gz md5sum: de7b38e2c881bced8671acb1ab452d78 + - path: output/adapterremoval/test.singleton.truncated.gz + - path: output/adapterremoval/versions.yml + md5sum: fa621c887897da5a379c719399c17db7 - name: adapterremoval test_adapterremoval_paired_end_collapse - command: nextflow run ./tests/modules/adapterremoval -entry test_adapterremoval_paired_end_collapse -c ./tests/config/nextflow.config -c ./tests/modules/adapterremoval/nextflow.config + command: nextflow run tests/modules/adapterremoval -entry test_adapterremoval_paired_end_collapse -c tests/config/nextflow.config tags: - adapterremoval files: + - path: output/adapterremoval/test.discarded.gz - path: output/adapterremoval/test.log - md5sum: 7f0b2328152226e46101a535cce718b3 - - path: output/adapterremoval/test.merged.fastq.gz - md5sum: 07a8f725bfd3ecbeabdc41b32d898dee + md5sum: b8a451d3981b327f3fdb44f40ba2d6d1 + - path: output/adapterremoval/test.pair1.truncated.gz + md5sum: 294a6277f0139bd597e57c6fa31f39c7 + - path: output/adapterremoval/test.pair2.truncated.gz + md5sum: de7b38e2c881bced8671acb1ab452d78 + - path: output/adapterremoval/test.singleton.truncated.gz + - path: output/adapterremoval/versions.yml + md5sum: fd428f92a8446e0b34c5ae1c447215b8