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

sourmash/compare stub, nf-test, snapshot #4665

Merged
merged 11 commits into from
Jul 2, 2024
23 changes: 18 additions & 5 deletions modules/nf-core/sourmash/compare/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ process SOURMASH_COMPARE {
val save_csv

output:
tuple val(meta), path("*comp.npy.labels.txt"), path("*comp.npy"), optional:true, emit: matrix
path "*comp.csv" , optional:true, emit: csv
path "versions.yml" , emit: versions
tuple val(meta), path("*comp.npy") , emit: matrix, optional:true
tuple val(meta), path("*comp.npy.labels.txt") , emit: labels, optional:true
tuple val(meta), path("*comp.csv") , emit: csv , optional:true
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 prefix = task.ext.prefix ?: "${meta.id}"
def comp = save_numpy_matrix ? "--output comp.npy" : ''
def csv = save_csv ? "--csv comp.csv" : ''
if ( !save_numpy_matrix && !save_csv ) error "Supply either save_numpy_matrix, save_csv, or both or no output will be created"
def ffile = file_list ? "--from-file ${file_list}" : ''
def sigs = signatures ? "${signatures.join(' ')}" : ''
def sigs = signatures ? "${signatures.sort{it.toString()}.join(' ')}" : ''
if ( !file_list && !signatures ) error "Supply either signatures, file_list, or both"
"""
sourmash compare \\
Expand All @@ -44,4 +45,16 @@ process SOURMASH_COMPARE {
sourmash: \$(echo \$(sourmash --version 2>&1) | sed 's/^sourmash //' )
END_VERSIONS
"""

stub:
"""
touch comp.npy.labels.txt
touch comp.npy
touch comp.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
sourmash: \$(echo \$(sourmash --version 2>&1) | sed 's/^sourmash //' )
END_VERSIONS
"""
}
4 changes: 2 additions & 2 deletions modules/nf-core/sourmash/compare/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tools:
documentation: "https://sourmash.readthedocs.io/"
tool_dev_url: "https://github.com/sourmash-bio/sourmash"
doi: "10.21105/joss.00027"
licence: "['BSD-3-clause']"
licence: ["BSD-3-clause"]
input:
- meta:
type: map
Expand Down Expand Up @@ -50,7 +50,7 @@ output:
type: file
description: File containing software versions
pattern: "versions.yml"
- numpy_matrix:
- matrix:
type: file
description: An optional (dis)similarity matrix numpy binary format
pattern: "*.comp"
Expand Down
81 changes: 81 additions & 0 deletions modules/nf-core/sourmash/compare/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "sourmash"
tag "sourmash/compare"
tag "sourmash/sketch"

setup {
run("SOURMASH_SKETCH") {
script "../../sketch/main.nf"
process {
"""
input[0] = Channel.fromList([
[
[ id: 'test1' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
],
[
[ id: 'test2' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
]
)
"""
}
}
}

test("sarscov2 genome [fasta]") {

when {
process {
"""
input[0] = SOURMASH_SKETCH.out.signatures.collect{ it[1] }.map { it -> [ [id: "group1" ], it ] }
input[1] = []
input[2] = true // save_numpy_matrix
input[3] = true // save_csv
"""
}
}

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

}

test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = SOURMASH_SKETCH.out.signatures.collect{ it[1] }.map { it -> [ [id: "group1" ], it ] }
input[1] = []
input[2] = true // save_numpy_matrix
input[3] = true // save_csv
"""
}
}

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

}

}
132 changes: 132 additions & 0 deletions modules/nf-core/sourmash/compare/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"sarscov2 - bam - stub": {
"content": [
{
"0": [
[
{
"id": "group1"
},
"comp.npy:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "group1"
},
"comp.npy.labels.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
[
{
"id": "group1"
},
"comp.csv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
"versions.yml:md5,6c61aed52902d1e343640d606122f411"
],
"csv": [
[
{
"id": "group1"
},
"comp.csv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"labels": [
[
{
"id": "group1"
},
"comp.npy.labels.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"matrix": [
[
{
"id": "group1"
},
"comp.npy:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,6c61aed52902d1e343640d606122f411"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-02T14:45:34.007399207"
},
"sarscov2 genome [fasta]": {
"content": [
{
"0": [
[
{
"id": "group1"
},
"comp.npy:md5,8a8683e1201544f28e2c2e21d2b89e4f"
]
],
"1": [
[
{
"id": "group1"
},
"comp.npy.labels.txt:md5,5bdd30886cf6f00a7286ac6e7322a46e"
]
],
"2": [
[
{
"id": "group1"
},
"comp.csv:md5,79bb8895742bfa32d4a39d2fbc2be941"
]
],
"3": [
"versions.yml:md5,6c61aed52902d1e343640d606122f411"
],
"csv": [
[
{
"id": "group1"
},
"comp.csv:md5,79bb8895742bfa32d4a39d2fbc2be941"
]
],
"labels": [
[
{
"id": "group1"
},
"comp.npy.labels.txt:md5,5bdd30886cf6f00a7286ac6e7322a46e"
]
],
"matrix": [
[
{
"id": "group1"
},
"comp.npy:md5,8a8683e1201544f28e2c2e21d2b89e4f"
]
],
"versions": [
"versions.yml:md5,6c61aed52902d1e343640d606122f411"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-02T14:45:19.227025783"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/sourmash/compare/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName:SOURMASH_COMPARE {
ext.args = "--ksize 31"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/sourmash/compare/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sourmash/compare:
- "modules/nf-core/sourmash/compare/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1566,9 +1566,6 @@ snpsift/split:
somalier/ancestry:
- modules/nf-core/somalier/ancestry/**
- tests/modules/nf-core/somalier/ancestry/**
sourmash/compare:
- modules/nf-core/sourmash/compare/**
- tests/modules/nf-core/sourmash/compare/**
sourmash/gather:
- modules/nf-core/sourmash/gather/**
- tests/modules/nf-core/sourmash/gather/**
Expand Down
35 changes: 0 additions & 35 deletions tests/modules/nf-core/sourmash/compare/main.nf

This file was deleted.

8 changes: 0 additions & 8 deletions tests/modules/nf-core/sourmash/compare/nextflow.config

This file was deleted.

15 changes: 0 additions & 15 deletions tests/modules/nf-core/sourmash/compare/test.yml

This file was deleted.

Loading