Skip to content

Commit

Permalink
Apply nf-test suggestions in ska/distance
Browse files Browse the repository at this point in the history
  • Loading branch information
itrujnara committed Feb 6, 2025
1 parent f3b6aa3 commit ca4c914
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 60 deletions.
4 changes: 2 additions & 2 deletions modules/nf-core/ska/distance/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ process SKA_DISTANCE {
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" : ""
def output_dot = task.ext.args =~ "-S" || sketch_files.size() > 1 ? "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}}
for i in {1..${sketch_files.size()}}
do
touch ${prefix}.cluster\${i}.txt
done
Expand Down
45 changes: 32 additions & 13 deletions modules/nf-core/ska/distance/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
process.out.versions,
path(process.out.distances[0][1]).csv(sep:"\t").sort(),
path(process.out.cluster_list[0][1]).csv(sep:"\t").sort(),
process.out.dot
).match() }
)
}

Expand Down Expand Up @@ -62,30 +67,44 @@ 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
"""
run("WGET", alias: "WGET1") {
script "modules/nf-core/ska/distance/wget.nf"
process {
"""
input[0] = params.modules_testdata_base_path + 'genomics/sarscov2/genome/ska/sarscov2_reduced.skf'
input[1] = "sarscov2_reduced.skf"
"""
}
}

run("WGET", alias: "WGET2") {
script "modules/nf-core/ska/distance/wget.nf"
process {
"""
input[0] = params.modules_testdata_base_path + 'genomics/eukaryotes/plasmodium_falciparum/ska/plasmodium_reduced.skf'
input[1] = "plasmodium_reduced.skf"
"""
}
}
}

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
[],
[file("sketch_list.txt", checkIfExists: true)]
]
input[0] = WGET1.out.outfile.mix(WGET2.out.outfile).map {it -> it.toString()}.collectFile(name: 'samples.txt', newLine: true).map { it -> [['id': 'test'], [], it] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
process.out.versions,
path(process.out.distances[0][1]).csv(sep:"\t").sort(),
path(process.out.cluster_list[0][1]).csv(sep:"\t").sort(),
process.out.dot
).match() }
)
}

Expand Down
Loading

0 comments on commit ca4c914

Please sign in to comment.