Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pigz to trimgalore #7169

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/nf-core/trimgalore/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- conda-forge
- bioconda

dependencies:
- bioconda::cutadapt=4.9
- bioconda::trim-galore=0.6.10
- conda-forge::pigz=2.8
49 changes: 30 additions & 19 deletions modules/nf-core/trimgalore/main.nf
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
process TRIMGALORE {
tag "$meta.id"
tag "${meta.id}"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/trim-galore%3A0.6.10--hdfd78af_1' :
'biocontainers/trim-galore:0.6.10--hdfd78af_1' }"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/9b/9becad054093ad4083a961d12733f2a742e11728fe9aa815d678b882b3ede520/data'
: 'community.wave.seqera.io/library/cutadapt_trim-galore_pigz:a98edd405b34582d'}"

input:
tuple val(meta), path(reads)

output:
tuple val(meta), path("*{3prime,5prime,trimmed,val}*.fq.gz"), emit: reads
tuple val(meta), path("*report.txt") , emit: log , optional: true
tuple val(meta), path("*unpaired*.fq.gz") , emit: unpaired, optional: true
tuple val(meta), path("*.html") , emit: html , optional: true
tuple val(meta), path("*.zip") , emit: zip , optional: true
path "versions.yml" , emit: versions
tuple val(meta), path("*report.txt"), emit: log, optional: true
tuple val(meta), path("*unpaired*.fq.gz"), emit: unpaired, optional: true
tuple val(meta), path("*.html"), emit: html, optional: true
tuple val(meta), path("*.zip"), emit: zip, optional: true
path "versions.yml", emit: versions
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
SPPearce marked this conversation as resolved.
Show resolved Hide resolved

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
// 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/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 > 8) cores = 8
if (meta.single_end) {
cores = (task.cpus as int) - 3
}
if (cores < 1) {
cores = 1
}
if (cores > 8) {
cores = 8
}
}

// Added soft-links to original fastqs for consistent naming in MultiQC
Expand All @@ -40,26 +46,28 @@ process TRIMGALORE {
def args_list = args.split("\\s(?=--)").toList()
args_list.removeAll { it.toLowerCase().contains('_r2 ') }
"""
[ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz
[ ! -f ${prefix}.fastq.gz ] && ln -s ${reads} ${prefix}.fastq.gz
trim_galore \\
${args_list.join(' ')} \\
--cores $cores \\
--cores ${cores} \\
--gzip \\
${prefix}.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
trimgalore: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
cutadapt: \$(cutadapt --version)
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
} else {
}
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 \\
$args \\
--cores $cores \\
${args} \\
--cores ${cores} \\
--paired \\
--gzip \\
${prefix}_1.fastq.gz \\
Expand All @@ -69,6 +77,7 @@ process TRIMGALORE {
"${task.process}":
trimgalore: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
cutadapt: \$(cutadapt --version)
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
}
Expand All @@ -78,7 +87,8 @@ process TRIMGALORE {
if (meta.single_end) {
output_command = "echo '' | gzip > ${prefix}_trimmed.fq.gz ;"
output_command += "touch ${prefix}.fastq.gz_trimming_report.txt"
} else {
}
else {
output_command = "echo '' | gzip > ${prefix}_1_trimmed.fq.gz ;"
output_command += "touch ${prefix}_1.fastq.gz_trimming_report.txt ;"
output_command += "echo '' | gzip > ${prefix}_2_trimmed.fq.gz ;"
Expand All @@ -91,6 +101,7 @@ process TRIMGALORE {
"${task.process}":
trimgalore: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
cutadapt: \$(cutadapt --version)
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
}
14 changes: 9 additions & 5 deletions modules/nf-core/trimgalore/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ nextflow_process {
{ assert path(process.out.log.get(0).get(1)).getText().contains(report1_line) }
}
},
{ assert snapshot(process.out.versions).match() }
{ assert snapshot(path(process.out.versions.get(0)).yaml).match() },
)
}
}
Expand All @@ -61,7 +61,10 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
process.out,
path(process.out.versions.get(0)).yaml
).match() },
)
}
}
Expand Down Expand Up @@ -118,7 +121,7 @@ nextflow_process {
{ assert path(process.out.log.get(0).get(1).get(1)).getText().contains(report2_line) }
}
},
{ assert snapshot(process.out.versions).match() }
{ assert snapshot(path(process.out.versions.get(0)).yaml).match() },
)
}
}
Expand All @@ -143,8 +146,9 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(process.out).match() },
{ assert snapshot(path(process.out.versions.get(0)).yaml).match("versions") },
)
}
}
}
}
75 changes: 53 additions & 22 deletions modules/nf-core/trimgalore/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"test_trimgalore_single_end": {
"content": [
[
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
]
{
"TRIMGALORE": {
"trimgalore": "0.6.10",
"cutadapt": 4.9,
"pigz": 2.8
}
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-10-22T19:23:17.969056957"
"timestamp": "2024-12-05T22:56:18.454197"
},
"test_trimgalore_single_end - stub": {
"content": [
Expand Down Expand Up @@ -42,7 +46,7 @@

],
"5": [
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
"versions.yml:md5,5928323d579768de37e83c56c821757f"
],
"html": [

Expand All @@ -69,18 +73,25 @@

],
"versions": [
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
"versions.yml:md5,5928323d579768de37e83c56c821757f"
],
"zip": [

]
},
{
"TRIMGALORE": {
"trimgalore": "0.6.10",
"cutadapt": 4.9,
"pigz": 2.8
}
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-10-22T19:23:28.617831159"
"timestamp": "2024-12-05T22:56:22.085472"
},
"test_trimgalore_paired_end - stub": {
"content": [
Expand Down Expand Up @@ -119,7 +130,7 @@

],
"5": [
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
"versions.yml:md5,5928323d579768de37e83c56c821757f"
],
"html": [

Expand Down Expand Up @@ -152,29 +163,49 @@

],
"versions": [
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
"versions.yml:md5,5928323d579768de37e83c56c821757f"
],
"zip": [

]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-05T22:44:33.751013"
},
"versions": {
"content": [
{
"TRIMGALORE": {
"trimgalore": "0.6.10",
"cutadapt": 4.9,
"pigz": 2.8
}
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-10-22T19:23:51.539787731"
"timestamp": "2024-12-05T22:57:28.77107"
},
"test_trimgalore_paired_end": {
"content": [
[
"versions.yml:md5,81a0b49f3a9e1315fe564f9946eb8c50"
]
{
"TRIMGALORE": {
"trimgalore": "0.6.10",
"cutadapt": 4.9,
"pigz": 2.8
}
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-10-22T19:23:41.16485915"
"timestamp": "2024-12-05T22:56:27.019872"
}
}
Loading
Loading