2021-03-22 17:16:04 +00:00
|
|
|
process ADAPTERREMOVAL {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_medium'
|
|
|
|
|
|
|
|
conda (params.enable_conda ? "bioconda::adapterremoval=2.3.2" : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
|
|
|
'https://depot.galaxyproject.org/singularity/adapterremoval:2.3.2--hb7ba0dd_0' :
|
|
|
|
'quay.io/biocontainers/adapterremoval:2.3.2--hb7ba0dd_0' }"
|
2021-03-22 17:16:04 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path('*.fastq.gz'), emit: reads
|
|
|
|
tuple val(meta), path('*.log') , emit: log
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-03-22 17:16:04 +00:00
|
|
|
|
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-03-22 17:16:04 +00:00
|
|
|
|
|
|
|
if (meta.single_end) {
|
|
|
|
"""
|
|
|
|
AdapterRemoval \\
|
|
|
|
--file1 $reads \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-03-22 17:16:04 +00:00
|
|
|
--basename $prefix \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
--settings ${prefix}.log \\
|
|
|
|
--output1 ${prefix}.trimmed.fastq.gz \\
|
|
|
|
--seed 42 \\
|
|
|
|
--gzip \\
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-03-22 17:16:04 +00:00
|
|
|
"""
|
|
|
|
} else if (!meta.single_end && !meta.collapse) {
|
|
|
|
"""
|
|
|
|
AdapterRemoval \\
|
|
|
|
--file1 ${reads[0]} \\
|
2021-11-10 12:21:12 +00:00
|
|
|
--file2 ${reads[1]} \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-03-22 17:16:04 +00:00
|
|
|
--basename $prefix \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
--settings ${prefix}.log \\
|
|
|
|
--output1 ${prefix}.pair1.trimmed.fastq.gz \\
|
|
|
|
--output2 ${prefix}.pair2.trimmed.fastq.gz \\
|
|
|
|
--seed 42 \\
|
|
|
|
--gzip \\
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-03-22 17:16:04 +00:00
|
|
|
"""
|
|
|
|
} else {
|
|
|
|
"""
|
|
|
|
AdapterRemoval \\
|
|
|
|
--file1 ${reads[0]} \\
|
2021-11-10 12:21:12 +00:00
|
|
|
--file2 ${reads[1]} \\
|
2021-03-22 17:16:04 +00:00
|
|
|
--collapse \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-03-22 17:16:04 +00:00
|
|
|
--basename $prefix \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
--settings ${prefix}.log \\
|
|
|
|
--seed 42 \\
|
|
|
|
--gzip \\
|
|
|
|
|
|
|
|
cat *.collapsed.gz *.collapsed.truncated.gz > ${prefix}.merged.fastq.gz
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-03-22 17:16:04 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|