Skip to content

Commit

Permalink
Update genomescope2 module and add nf-tests (#5399)
Browse files Browse the repository at this point in the history
* Add genomescope nf-test

* Add stub and fitted histogram lookup table

Co-authored-by: rodtheo <[email protected]>

* Add snapshot

* Update build version

* Fix output channel contents

* Update channel tests

* Update tests

* Lint licence

Co-authored-by: rodtheo <[email protected]>

* Fix linting and output file

* Fix snapshot for missing file

---------

Co-authored-by: rodtheo <[email protected]>
  • Loading branch information
mahesh-panchal and rodtheo authored Mar 26, 2024
1 parent faf85d1 commit 9bc4822
Show file tree
Hide file tree
Showing 10 changed files with 365 additions and 67 deletions.
42 changes: 33 additions & 9 deletions modules/nf-core/genomescope2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ process GENOMESCOPE2 {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/genomescope2:2.0--py310r41hdfd78af_5':
'biocontainers/genomescope2:2.0--py310r41hdfd78af_5' }"
'https://depot.galaxyproject.org/singularity/genomescope2:2.0--py311r42hdfd78af_6':
'biocontainers/genomescope2:2.0--py311r42hdfd78af_6' }"

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

output:
tuple val(meta), path("*_linear_plot.png") , emit: linear_plot_png
tuple val(meta), path("*_transformed_linear_plot.png"), emit: transformed_linear_plot_png
tuple val(meta), path("*_log_plot.png") , emit: log_plot_png
tuple val(meta), path("*_transformed_log_plot.png") , emit: transformed_log_plot_png
tuple val(meta), path("*_model.txt") , emit: model
tuple val(meta), path("*_summary.txt") , emit: summary
path "versions.yml" , emit: versions
tuple val(meta), path("${prefix}_linear_plot.png") , emit: linear_plot_png
tuple val(meta), path("${prefix}_transformed_linear_plot.png"), emit: transformed_linear_plot_png
tuple val(meta), path("${prefix}_log_plot.png") , emit: log_plot_png
tuple val(meta), path("${prefix}_transformed_log_plot.png") , emit: transformed_log_plot_png
tuple val(meta), path("${prefix}_model.txt") , emit: model
tuple val(meta), path("${prefix}_summary.txt") , emit: summary
tuple val(meta), path("${prefix}_lookup_table.txt") , emit: lookup_table, optional: true
tuple val(meta), path("${prefix}_fitted_hist.png") , emit: fitted_histogram_png, optional: true
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -32,6 +34,28 @@ process GENOMESCOPE2 {
--output . \\
--name_prefix $prefix
test -f "fitted_hist.png" && mv fitted_hist.png ${prefix}_fitted_hist.png
test -f "lookup_table.txt" && mv lookup_table.txt ${prefix}_lookup_table.txt
cat <<-END_VERSIONS > versions.yml
'${task.process}':
genomescope2: \$( genomescope2 -v | sed 's/GenomeScope //' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}_linear_plot.png
touch ${prefix}_transformed_linear_plot.png
touch ${prefix}_log_plot.png
touch ${prefix}_transformed_log_plot.png
touch ${prefix}_model.txt
touch ${prefix}_summary.txt
touch ${prefix}_fitted_hist.png
touch ${prefix}_lookup_table.txt
cat <<-END_VERSIONS > versions.yml
'${task.process}':
genomescope2: \$( genomescope2 -v | sed 's/GenomeScope //' )
Expand Down
10 changes: 9 additions & 1 deletion modules/nf-core/genomescope2/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tools:
documentation: "https://github.com/tbenavi1/genomescope2.0/blob/master/README.md"
tool_dev_url: "https://github.com/tbenavi1/genomescope2.0"
doi: "10.1038/s41467-020-14998-3"
licence: "['Apache License, Version 2.0 (Apache-2.0)']"
licence: ["Apache-2.0"]
input:
- meta:
type: map
Expand Down Expand Up @@ -60,6 +60,14 @@ output:
type: file
description: Genomescope2 histogram summary
pattern: "*_summary.txt"
- lookup_table:
type: file
description: Fitted histogram lookup table
pattern: "*_lookup_table.txt"
- fitted_histogram_png:
type: file
description: A genomescope2 fitted histogram plot in PNG format
pattern: "*_fitted_hist.png"
authors:
- "@mahesh-panchal"
maintainers:
Expand Down
84 changes: 84 additions & 0 deletions modules/nf-core/genomescope2/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
nextflow_process {

name "Test Process GENOMESCOPE2"
script "../main.nf"
config "./nextflow.config"
process "GENOMESCOPE2"

tag "modules"
tag "modules_nfcore"
tag "genomescope2"
tag "meryl/count"
tag "meryl/histogram"

setup {
run('MERYL_COUNT'){
script "../../../../modules/nf-core/meryl/count/main.nf"
process {
"""
input[0] = Channel.value([
[ id: 'test', single_end: true ], // meta map
file( params.modules_testdata_base_path + "/genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz", checkIfExists: true )
])
"""
}
}
run('MERYL_HISTOGRAM'){
script "../../../../modules/nf-core/meryl/histogram/main.nf"
process {
"""
input[0] = MERYL_COUNT.out.meryl_db
"""
}
}
}

test("bacteroides_fragilis - fastq") {

when {
process {
"""
input[0] = MERYL_HISTOGRAM.out.hist
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert file(process.out.linear_plot_png[0][1]).exists() }, // PNG md5sum mismatches using conda
{ assert file(process.out.transformed_linear_plot_png[0][1]).exists() }, // PNG md5sum mismatches using conda
{ assert file(process.out.log_plot_png[0][1]).exists() }, // PNG md5sum mismatches using conda
{ assert file(process.out.transformed_log_plot_png[0][1]).exists() }, // PNG md5sum mismatches using conda
{ assert snapshot(process.out.model).match("model") },
{ assert snapshot(process.out.summary).match("summary") },
{ assert snapshot(process.out.lookup_table).match("lookup_table") },
{ assert file(process.out.fitted_histogram_png[0][1]).exists() }, // PNG md5sum mismatches using conda
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("bacteroides_fragilis - fastq - stub") {

options "-stub"

when {
process {
"""
input[0] = MERYL_HISTOGRAM.out.hist
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading

0 comments on commit 9bc4822

Please sign in to comment.