Skip to content

Commit

Permalink
try porting mmseqs/search to nf-test (#7231)
Browse files Browse the repository at this point in the history
* try porting to nf-test

* remove from pytest

* Apply suggestions from code review

Co-authored-by: Jim Downie <[email protected]>

* fix stub

* remove pytest

* Working except for linting

* Only check the names

* Fix meta for linting

---------

Co-authored-by: Jim Downie <[email protected]>
Co-authored-by: Simon Pearce <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent 89a5ca7 commit 0853f51
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 69 deletions.
5 changes: 1 addition & 4 deletions modules/nf-core/mmseqs/easysearch/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ process MMSEQS_EASYSEARCH {
"""

stub:
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: "*.dbtype"
def prefix = task.ext.prefix ?: "${meta.id}"
"""
${prefix}.tsv
touch ${prefix}.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
16 changes: 6 additions & 10 deletions modules/nf-core/mmseqs/search/main.nf
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

process MMSEQS_SEARCH {
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/mmseqs2:14.7e284--pl5321h6a68c12_2':
'biocontainers/mmseqs2:14.7e284--pl5321h6a68c12_2' }"
'https://depot.galaxyproject.org/singularity/mmseqs2:15.6f452--pl5321h6a68c12_0':
'biocontainers/mmseqs2:15.6f452--pl5321h6a68c12_0' }"

input:
tuple val(meta), path(db_query)
tuple val(meta2), path(db_target)

output:
tuple val(meta), path("${prefix}"), emit: db_search
tuple val(meta), path("${prefix}/"), emit: db_search
path "versions.yml" , emit: versions

when:
Expand All @@ -40,9 +39,7 @@ process MMSEQS_SEARCH {
${prefix}/${prefix} \\
tmp1 \\
$args \\
--threads ${task.cpus} \\
--compressed 1
--threads ${task.cpus}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -51,8 +48,7 @@ process MMSEQS_SEARCH {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
prefix = task.ext.prefix ?: "${meta.id}"
if ("$db_query" == "${prefix}" || "$db_target" == "${prefix}" ) error "Input and output names of databases are the same, set prefix in module configuration to disambiguate!"
"""
mkdir -p $prefix
Expand All @@ -62,7 +58,7 @@ process MMSEQS_SEARCH {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mmseqs: \$(mmseqs | grep 'Version' | sed 's/MMseqs2 Version: /')
mmseqs: \$(mmseqs | grep 'Version' | sed 's/MMseqs2 Version: //')
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/nf-core/mmseqs/search/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ output:
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- ${prefix}:
- ${prefix}/:
type: directory
description: an MMseqs2 database with search results
- versions:
Expand Down
95 changes: 95 additions & 0 deletions modules/nf-core/mmseqs/search/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
nextflow_process {

name "Test Process MMSEQS_SEARCH"
script "../main.nf"
process "MMSEQS_SEARCH"

tag "modules"
tag "modules_nfcore"
tag "mmseqs"
tag "mmseqs/search"
tag "mmseqs/createdb"

config "./nextflow.config"

setup {
run("MMSEQS_CREATEDB", alias: "MMSEQS_CREATEDB_QUERY") {
script "../../../mmseqs/createdb/main.nf"
process {
"""
input[0] = [ [ id:'test_query', single_end:true ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fasta/contigs.fasta', checkIfExists: true)
]
"""
}
}

run("MMSEQS_CREATEDB", alias: "MMSEQS_CREATEDB_TARGET") {
script "../../../mmseqs/createdb/main.nf"
process {
"""
input[0] = [ [ id:'test_target', single_end:true ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fasta/scaffolds.fasta', checkIfExists: true)
]
"""
}
}
}

test("sarscov2 - test-search") {

when {
params {
module_args = '--remove-tmp-files 1 --search-type 2'
module_prefix = 'test_output_search'
}
process {
"""
input[0] = MMSEQS_CREATEDB_QUERY.out.db
input[1] = MMSEQS_CREATEDB_TARGET.out.db
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.db_search.get(0).get(1)).list().sort(), //second file is empty so fails linting
path(process.out.versions[0]).yaml
).match() }
)
}

}

test("sarscov2 - test-search - stub") {

options "-stub"

when {
params {
module_args = '--remove-tmp-files 1 --search-type 2'
module_prefix = 'test_output_search'
}
process {
"""
input[0] = MMSEQS_CREATEDB_QUERY.out.db
input[1] = MMSEQS_CREATEDB_TARGET.out.db
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
path(process.out.versions[0]).yaml
).match() }
)
}

}

}
88 changes: 88 additions & 0 deletions modules/nf-core/mmseqs/search/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"sarscov2 - test-search": {
"content": [
[
"test_output_search.0",
"test_output_search.1",
"test_output_search.dbtype",
"test_output_search.index"
],
{
"MMSEQS_SEARCH": {
"mmseqs": "15.6f452"
}
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-15T09:38:30.159081322"
},
"sarscov2 - test-search - stub": {
"content": [
{
"0": [
[
{
"id": "test_query",
"single_end": true
},
[
"test_output_search.0:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.1:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.2:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.3:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.4:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.5:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.6:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.7:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.8:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.9:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.dbtype:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.index:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"1": [
"versions.yml:md5,2568126b1f8eb47999b31cd5f3b9c68e"
],
"db_search": [
[
{
"id": "test_query",
"single_end": true
},
[
"test_output_search.0:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.1:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.2:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.3:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.4:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.5:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.6:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.7:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.8:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.9:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.dbtype:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_output_search.index:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"versions": [
"versions.yml:md5,2568126b1f8eb47999b31cd5f3b9c68e"
]
},
{
"MMSEQS_SEARCH": {
"mmseqs": "15.6f452"
}
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-15T09:28:46.406630911"
}
}
8 changes: 8 additions & 0 deletions modules/nf-core/mmseqs/search/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
process {

withName: MMSEQS_SEARCH {
ext.prefix = params.module_prefix
ext.args = params.module_args
}

}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ mitohifi/mitohifi:
mmseqs/easysearch:
- modules/nf-core/mmseqs/easysearch/**
- tests/modules/nf-core/mmseqs/easysearch/**
mmseqs/search:
- modules/nf-core/mmseqs/search/**
- tests/modules/nf-core/mmseqs/search/**
mmseqs/tsv2exprofiledb:
- modules/nf-core/mmseqs/tsv2exprofiledb/**
- tests/modules/nf-core/mmseqs/tsv2exprofiledb/**
Expand Down
23 changes: 0 additions & 23 deletions tests/modules/nf-core/mmseqs/search/main.nf

This file was deleted.

17 changes: 0 additions & 17 deletions tests/modules/nf-core/mmseqs/search/nextflow.config

This file was deleted.

11 changes: 0 additions & 11 deletions tests/modules/nf-core/mmseqs/search/test.yml

This file was deleted.

0 comments on commit 0853f51

Please sign in to comment.