Adapterremoval glob fix (#1391)

* fix: remove left-over unnecessary code

* Partial fix for AR module output declarations

* Remove `def` for prefix so useable in output block

* Fix tests

* Add adapterlist support

* Fix tests after addition of adapter list
This commit is contained in:
James A. Fellows Yates 2022-03-14 07:32:21 +01:00 committed by GitHub
parent 79a9d5e1ea
commit 625098a408
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 41 deletions

View file

@ -9,48 +9,34 @@ process ADAPTERREMOVAL {
input:
tuple val(meta), path(reads)
path(adapterlist)
output:
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
tuple val(meta), path("${prefix}.truncated.gz") , optional: true, emit: singles_truncated
tuple val(meta), path("${prefix}.discarded.gz") , optional: true, emit: discarded
tuple val(meta), path("${prefix}.pair1.truncated.gz") , optional: true, emit: pair1_truncated
tuple val(meta), path("${prefix}.pair2.truncated.gz") , optional: true, emit: pair2_truncated
tuple val(meta), path("${prefix}.collapsed.gz") , optional: true, emit: collapsed
tuple val(meta), path("${prefix}.collapsed.truncated.gz") , optional: true, emit: collapsed_truncated
tuple val(meta), path("${prefix}.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
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def list = adapterlist ? "--adapter-list ${adapterlist}" : ""
prefix = task.ext.prefix ?: "${meta.id}"
if (meta.single_end) {
"""
AdapterRemoval \\
--file1 $reads \\
$args \\
--basename $prefix \\
--threads ${task.cpus} \\
--settings ${prefix}.log \\
--seed 42 \\
--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 ) {
"""
AdapterRemoval \\
--file1 ${reads[0]} \\
--file2 ${reads[1]} \\
$args \\
--basename $prefix \\
$adapterlist \\
--basename ${prefix} \\
--threads ${task.cpus} \\
--settings ${prefix}.log \\
--seed 42 \\
@ -67,13 +53,13 @@ process ADAPTERREMOVAL {
--file1 ${reads[0]} \\
--file2 ${reads[1]} \\
$args \\
--basename $prefix \\
$adapterlist \\
--basename ${prefix} \\
--threads $task.cpus \\
--settings ${prefix}.log \\
--seed 42 \\
--gzip
cat *.collapsed.gz *.collapsed.truncated.gz > ${prefix}.merged.fastq.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")

View file

@ -24,6 +24,13 @@ input:
List of input FastQ files of size 1 and 2 for single-end and paired-end data,
respectively.
pattern: "*.{fq,fastq,fq.gz,fastq.gz}"
- adapterlist:
type: file
description:
Optional text file containing list of adapters to look for for removal
with one adapter per line. Otherwise will look for default adapters (see
AdapterRemoval man page), or can be modified to remove user-specified
adapters via ext.args.
output:
- meta:

View file

@ -2,14 +2,16 @@
nextflow.enable.dsl = 2
include { ADAPTERREMOVAL } from '../../../modules/adapterremoval/main.nf'
include { ADAPTERREMOVAL } from '../../../modules/adapterremoval/main.nf'
include { ADAPTERREMOVAL as ADAPTERREMOVAL_COLLAPSE } from '../../../modules/adapterremoval/main.nf'
workflow test_adapterremoval_single_end {
input = [ [ id:'test', single_end:true, collapse:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
]
ADAPTERREMOVAL ( input )
ADAPTERREMOVAL ( input, [] )
}
workflow test_adapterremoval_paired_end {
@ -18,15 +20,15 @@ workflow test_adapterremoval_paired_end {
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
]
ADAPTERREMOVAL ( input )
ADAPTERREMOVAL ( input, [] )
}
workflow test_adapterremoval_paired_end_collapse {
input = [ [ id:'test', single_end:false, collapse:true ], // meta map
input = [ [ id:'test', single_end:false ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
]
ADAPTERREMOVAL ( input )
ADAPTERREMOVAL_COLLAPSE ( input, [] )
}

View file

@ -2,4 +2,8 @@ process {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
withName: ADAPTERREMOVAL_COLLAPSE {
ext.args = "--collapse"
}
}

View file

@ -23,7 +23,6 @@
md5sum: 294a6277f0139bd597e57c6fa31f39c7
- path: output/adapterremoval/test.pair2.truncated.gz
md5sum: de7b38e2c881bced8671acb1ab452d78
- path: output/adapterremoval/test.singleton.truncated.gz
- path: output/adapterremoval/versions.yml
md5sum: fa621c887897da5a379c719399c17db7
@ -32,13 +31,15 @@
tags:
- adapterremoval
files:
- path: output/adapterremoval/test.collapsed.gz
md5sum: ff956de3532599a56c3efe5369f0953f
- path: output/adapterremoval/test.collapsed.truncated.gz
- path: output/adapterremoval/test.discarded.gz
- path: output/adapterremoval/test.log
md5sum: b8a451d3981b327f3fdb44f40ba2d6d1
md5sum: 7f0b2328152226e46101a535cce718b3
- path: output/adapterremoval/test.pair1.truncated.gz
md5sum: 294a6277f0139bd597e57c6fa31f39c7
md5sum: 683be19bc1c83008944b6b719bfa34e1
- path: output/adapterremoval/test.pair2.truncated.gz
md5sum: de7b38e2c881bced8671acb1ab452d78
- path: output/adapterremoval/test.singleton.truncated.gz
md5sum: e6548fe061f3ef86368b26da930174d0
- path: output/adapterremoval/versions.yml
md5sum: fd428f92a8446e0b34c5ae1c447215b8
md5sum: 78f589bb313c8da0147ca8ce77d7f3bf