Skip to content

Commit

Permalink
Updates to gnu sort module to include nf-test (nf-core#4950)
Browse files Browse the repository at this point in the history
* Updates to gnu sort module to include nf-test

* Linting

* Linting

* Fix output
  • Loading branch information
DLBPointon authored Feb 23, 2024
1 parent f2fdc5e commit ca199cf
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 73 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/gnu/sort/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GNU_SORT
name: gnu_sort
channels:
- conda-forge
- bioconda
Expand Down
3 changes: 1 addition & 2 deletions modules/nf-core/gnu/sort/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ process GNU_SORT {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
suffix = task.ext.suffix ?: "${input.extension}"
output_file = "${prefix}.${suffix}"
def VERSION = "9.1"

if ("$input" == "$output_file") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
"""
sort ${args} ${input} > ${output_file}
touch ${output_file}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/gnu/sort/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "GNU_SORT"
name: "gnu_sort"
description: |
Writes a sorted concatenation of file/s
keywords:
Expand Down
120 changes: 120 additions & 0 deletions modules/nf-core/gnu/sort/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
nextflow_process {

name "Test Process GNU_SORT"
script "modules/nf-core/gnu/sort/main.nf"
process "GNU_SORT"

tag "modules"
tag "modules_nfcore"
tag "gnu"
tag "gnu/sort"

test("unsorted_genome_sort") {
config "./sort_simple_bed.config"

when {
process {
"""
input[0] = [
[id:'genome_test'],
file(params.test_data['generic']['unsorted_data']['unsorted_text']['genome_file'],
checkIfExists: true)
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert snapshot(
file(process.out.sorted[0][1]).name
).match("genome_sort")
}
)
}

}

test("unsorted_intervals_sort") {
config "./sort_simple_bed.config"
when {
process {
"""
input[0] = [
[id:'test'],
file(params.test_data['generic']['unsorted_data']['unsorted_text']['intervals'],
checkIfExists: true)
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert snapshot(
file(process.out.sorted[0][1]).name
).match("interval_sort")
}
)
}

}

test("unsorted_csv_sort") {
config "./sort_complex.config"

when {
process {
"""
input[0] = [
[id:'test'],
file(params.test_data['generic']['unsorted_data']['unsorted_text']['numbers_csv'],
checkIfExists: true)
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert snapshot(
file(process.out.sorted[0][1]).name
).match("csv_sort")
}
)
}

}

test("unsorted_csv_sort_stub") {
config "./sort_complex.config"
options "-stub"

when {
process {
"""
input[0] = [
[id:'test'],
file(params.test_data['generic']['unsorted_data']['unsorted_text']['numbers_csv'],
checkIfExists: true)
]
"""
}
}

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

}

}
136 changes: 136 additions & 0 deletions modules/nf-core/gnu/sort/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions modules/nf-core/gnu/sort/tests/sort_complex.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: GNU_SORT {
ext.args = { "-t ';' -g -k 1,1 -k 2,2" }
ext.suffix = { "csv.sorted" }
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/gnu/sort/tests/sort_simple_bed.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: GNU_SORT {
ext.args = { "-k1,1 -k2,2n" }
ext.suffix = { "bed.sorted" }
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/gnu/sort/tests/sort_simple_genome.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: GNU_SORT {
ext.args = { "-k1,1 -k2,2n" }
ext.suffix = { "genome.sorted" }
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/gnu/sort/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gnu/sort:
- "modules/nf-core/gnu/sort/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,6 @@ glimpse2/splitreference:
glnexus:
- modules/nf-core/glnexus/**
- tests/modules/nf-core/glnexus/**
gnu/sort:
- modules/nf-core/gnu/sort/**
- tests/modules/nf-core/gnu/sort/**
goat/taxonsearch:
- modules/nf-core/goat/taxonsearch/**
- tests/modules/nf-core/goat/taxonsearch/**
Expand Down
34 changes: 0 additions & 34 deletions tests/modules/nf-core/gnu/sort/main.nf

This file was deleted.

19 changes: 0 additions & 19 deletions tests/modules/nf-core/gnu/sort/nextflow.config

This file was deleted.

13 changes: 0 additions & 13 deletions tests/modules/nf-core/gnu/sort/test.yml

This file was deleted.

0 comments on commit ca199cf

Please sign in to comment.