Skip to content

Commit

Permalink
Apply some code review comments for ska/distance
Browse files Browse the repository at this point in the history
  • Loading branch information
itrujnara committed Feb 6, 2025
1 parent 031eafc commit f3b6aa3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 109 deletions.
22 changes: 15 additions & 7 deletions modules/nf-core/ska/distance/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process SKA_DISTANCE {
'biocontainers/ska:1.0--h077b44d_6' }"

input:
tuple val(meta), path(sketch_files), path(sketch_list)
tuple val(meta), path(sketch_files, arity: '0..*'), path(sketch_list)

output:
tuple val(meta), path("*distances.tsv"), emit: distances , optional: true
Expand Down Expand Up @@ -39,13 +39,21 @@ process SKA_DISTANCE {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def output_dist = task.ext.args =~ "-d" ? "" : "touch ${prefix}.distances.tsv"
def output_clust = task.ext.args =~ "-c" ? "" : "touch ${prefix}.clusters.tsv"
// this is not a complete criterion for this output but it is good enough
def output_dot = task.ext.args =~ "-S" || sketch_files.size > 1 ? "touch ${prefix}.dot" : ""
"""
touch ${prefix}.distances.tsv
touch ${prefix}.clusters.tsv
touch ${prefix}.cluster.1.txt
touch ${prefix}.dot
$output_dist
$output_clust
# this is not how this works but it's the best we can do without knowing the input content
for i in {1..${sketch_files.size}}
do
touch ${prefix}.cluster\${i}.txt
done
$output_dot
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
32 changes: 32 additions & 0 deletions modules/nf-core/ska/distance/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,38 @@ nextflow_process {

}

test("sarscov2 - pfal - list") {

setup {
"""
echo "sarscov2_reduced.skf" > sketch_list.txt
echo "plasmodium_reduced.skf" >> sketch_list.txt
wget https://raw.githubusercontent.com/nf-core/test-datasets/modules/genomics/sarscov2/genome/ska/sarscov2_reduced.skf
wget https://raw.githubusercontent.com/nf-core/test-datasets/modules/genomics/eukaryotes/plasmodium_falciparum/ska/plasmodium_reduced.skf
"""
}

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
[],
[file("sketch_list.txt", checkIfExists: true)]
]
"""
}
}

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

}

test("sarscov2 - pfal - list - stub") {

options "-stub"
Expand Down
124 changes: 22 additions & 102 deletions modules/nf-core/ska/distance/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,163 +3,83 @@
"content": [
{
"0": [
[
{
"id": "test"
},
"test.distances.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"1": [
[
{
"id": "test"
},
"test.clusters.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"2": [
[
{
"id": "test"
},
"test.cluster.1.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"3": [
[
{
"id": "test"
},
"test.dot:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"4": [
"versions.yml:md5,914078627d4223f14da56bb9dd72a667"

],
"cluster_files": [
[
{
"id": "test"
},
"test.cluster.1.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"cluster_list": [
[
{
"id": "test"
},
"test.clusters.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"distances": [
[
{
"id": "test"
},
"test.distances.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"dot": [
[
{
"id": "test"
},
"test.dot:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"versions": [
"versions.yml:md5,914078627d4223f14da56bb9dd72a667"

]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-05T15:11:42.205396"
"timestamp": "2025-02-06T11:12:06.481928"
},
"sarscov2 - pfal - skf - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.distances.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"1": [
[
{
"id": "test"
},
"test.clusters.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"2": [
[
{
"id": "test"
},
"test.cluster.1.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"3": [
[
{
"id": "test"
},
"test.dot:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"4": [
"versions.yml:md5,914078627d4223f14da56bb9dd72a667"

],
"cluster_files": [
[
{
"id": "test"
},
"test.cluster.1.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"cluster_list": [
[
{
"id": "test"
},
"test.clusters.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"distances": [
[
{
"id": "test"
},
"test.distances.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"dot": [
[
{
"id": "test"
},
"test.dot:md5,d41d8cd98f00b204e9800998ecf8427e"
]

],
"versions": [
"versions.yml:md5,914078627d4223f14da56bb9dd72a667"

]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-05T15:10:16.276917"
"timestamp": "2025-02-06T11:12:02.343424"
},
"sarscov2 - pfal - skf": {
"content": [
Expand Down

0 comments on commit f3b6aa3

Please sign in to comment.