nf-core_modules/modules/trimmomatic/main.nf
alyssa-ab c1eb9cce44
Trimmomatic (#1757)
* Trimmomatic main only first draft

* Add test files

* SE PE Adjustment

* Remove extra reads input

* chore: Remove TODOs

* Apply suggestions from code review

Co-authored-by: Edmund Miller <edmund.a.miller@gmail.com>

* fix(trimmomatic): Handle SE output correctly

Since there's never going to be unpaired reads for SE reads we can get
away with it for SE

* fix(trimmomatic): Use correct elvis operator to handle logic

* fix(trimmomatic): Add hack to work with SE and PE reads

* Update test.yml

* use the PE and SE trimming correctly

* Made user set adaptors

* Add documentation

* test(trimmomatic): Add files to pytest_modules

* test(trimmomatic): Update name of failing test

Co-authored-by: Edmund Miller <edmund.a.miller@protonmail.com>
Co-authored-by: Edmund Miller <edmund.a.miller@gmail.com>
2022-06-17 13:18:15 +00:00

46 lines
1.6 KiB
Text

process TRIMMOMATIC {
tag "$meta.id"
label 'process_medium'
conda (params.enable_conda ? "bioconda::trimmomatic=0.39" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/trimmomatic:0.39--hdfd78af_2':
'quay.io/biocontainers/trimmomatic:0.39--hdfd78af_2' }"
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("*.paired.trim*.fastq.gz") , emit: trimmed_reads
tuple val(meta), path("*.unpaired.trim_*.fastq.gz"), optional:true, emit: unpaired_reads
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 trimmed = meta.single_end ? "SE" : "PE"
def output = meta.single_end ?
"${prefix}.SE.paired.trim.fastq.gz" // HACK to avoid unpaired and paired in the trimmed_reads output
: "${prefix}.paired.trim_1.fastq.gz ${prefix}.unpaired.trim_1.fastq.gz ${prefix}.paired.trim_2.fastq.gz ${prefix}.unpaired.trim_2.fastq.gz"
// TODO Give better error output
def qual_trim = task.ext.args2 ?: ''
"""
trimmomatic \\
$trimmed \\
-threads $task.cpus \\
-trimlog ${prefix}.log \\
$reads \\
$output \\
$qual_trim \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
trimmomatic: \$(trimmomatic -version)
END_VERSIONS
"""
}