Skip to content

Commit

Permalink
added optional input - hope it is being parsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
afombravo committed Jan 19, 2025
2 parents 96dd572 + 48a87b5 commit d9982e3
Show file tree
Hide file tree
Showing 158 changed files with 2,501 additions and 1,578 deletions.
2 changes: 2 additions & 0 deletions .github/skip_nf_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
"docker_self_hosted": ["modules/nf-core/parabricks"],
"singularity": [
"modules/nf-core/bases2fastq",
"modules/nf-core/deepvariant/rundeepvariant",
"modules/nf-core/deepvariant/vcfstatsreport",
"modules/nf-core/deepsomatic",
"modules/nf-core/parabricks",
"modules/nf-core/universc"
Expand Down
21 changes: 17 additions & 4 deletions modules/nf-core/custom/matrixfilter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ process CUSTOM_MATRIXFILTER {
tag "$meta"
label 'process_single'
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/r-base:4.2.1' :
'biocontainers/r-base:4.2.1' }"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/48/483e9d9b3b07e5658792d579e230ad40ed18daf7b9ebfb4323c08570f92fd1d5/data'
: 'community.wave.seqera.io/library/r-base:4.2.1--b0b5476e2e7a0872'}"

input:
tuple val(meta), path(abundance)
Expand All @@ -13,7 +13,7 @@ process CUSTOM_MATRIXFILTER {
output:
tuple val(meta), path("*.filtered.tsv") , emit: filtered
tuple val(meta), path("*.tests.tsv") , emit: tests
tuple val(meta), path("R_sessionInfo.log") , emit: session_info
tuple val(meta), path("*R_sessionInfo.log") , emit: session_info
path "versions.yml" , emit: versions

when:
Expand All @@ -27,4 +27,17 @@ process CUSTOM_MATRIXFILTER {
// (new variables defined here don't seem to be available in templates, so
// we have to access $task directly)
template 'matrixfilter.R'

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.filtered.tsv
touch ${prefix}.tests.tsv
touch ${prefix}.R_sessionInfo.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/nf-core/custom/matrixfilter/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ output:
description: |
Groovy Map containing information on experiment.
e.g. [ id:'test' ]
- R_sessionInfo.log:
- "*R_sessionInfo.log":
type: file
description: Log file containing R session information
pattern: "*.log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ keep <- apply(boolean_matrix, 1, all)
# Write out the matrix retaining the specified rows and re-prepending the
# column with the feature identifiers

prefix = ifelse('$task.ext.prefix' == 'null', '', '$task.ext.prefix')
prefix = ifelse('$task.ext.prefix' == 'null', '$meta.id', '$task.ext.prefix')

write.table(
data.frame(rownames(abundance_matrix)[keep], abundance_matrix[keep,,drop = FALSE]),
Expand Down
100 changes: 100 additions & 0 deletions modules/nf-core/custom/matrixfilter/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
nextflow_process {

name "Test Process CUSTOM_MATRIXFILTER"
script "../main.nf"
process "CUSTOM_MATRIXFILTER"
config "./nextflow.config"
tag "modules"
tag "modules_nfcore"
tag "custom_matrixfilter"
tag "custom"
tag "custom/matrixfilter"

test("test_custom_matrixfilter") {

when {
params {
observations_id_col = 'sample'
filtering_min_samples = 1.0
filtering_min_abundance = 10
filtering_min_proportion = null
filtering_grouping_var = null
filtering_min_proportion_not_na = 0.5
filtering_min_samples_not_na = null

module_args = [
"--sample_id_col \"${params.observations_id_col}\"",
"--minimum_samples ${params.filtering_min_samples}",
"--minimum_abundance ${params.filtering_min_abundance}",
(params.filtering_min_proportion ? "--minimum_proportion ${params.filtering_min_proportion}" : ''),
(params.filtering_grouping_var ? "--grouping_variable \"${params.filtering_grouping_var}\"" : ''),
(params.filtering_min_proportion_not_na ? "--minimum_proportion_not_na \"${params.filtering_min_proportion_not_na}\"" : ''),
(params.filtering_min_samples_not_na ? "--minimum_samples_not_na \"${params.filtering_min_samples_not_na}\"" : '')
].join(' ').trim()
}
process {
"""
input[0] = [ [id:"test"],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.salmon.merged.gene_counts.top1000cov.assay.tsv",checkIfExists: true)
]
input[1] = [ [id:"test"],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.samplesheet.sample_metadata.tsv",checkIfExists: true)
]
"""

}
}

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

test("test_custom_matrixfilter - stub") {

options "-stub"

when {
params {
observations_id_col = 'sample'
filtering_min_samples = 1.0
filtering_min_abundance = 10
filtering_min_proportion = null
filtering_grouping_var = null
filtering_min_proportion_not_na = 0.5
filtering_min_samples_not_na = null
module_args = [
"--sample_id_col \"${params.observations_id_col}\"",
"--minimum_samples ${params.filtering_min_samples}",
"--minimum_abundance ${params.filtering_min_abundance}",
(params.filtering_min_proportion ? "--minimum_proportion ${params.filtering_min_proportion}" : ''),
(params.filtering_grouping_var ? "--grouping_variable \"${params.filtering_grouping_var}\"" : ''),
(params.filtering_min_proportion_not_na ? "--minimum_proportion_not_na \"${params.filtering_min_proportion_not_na}\"" : ''),
(params.filtering_min_samples_not_na ? "--minimum_samples_not_na \"${params.filtering_min_samples_not_na}\"" : '')
].join(' ').trim()
}
process {
"""
input[0] = [ [id:"test"],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.salmon.merged.gene_counts.top1000cov.assay.tsv",checkIfExists: true)
]
input[1] = [ [id:"test"],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.samplesheet.sample_metadata.tsv",checkIfExists: true)
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
95 changes: 95 additions & 0 deletions modules/nf-core/custom/matrixfilter/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"test_custom_matrixfilter": {
"content": [
[
[
{
"id": "test"
},
"test.filtered.tsv:md5,ecc3ca4c6538f9248dce844108474a66"
]
],
[
[
{
"id": "test"
},
"test.tests.tsv:md5,9a0f14988df8c1b8975039eed91b85e2"
]
],
[
"versions.yml:md5,275e382be9ca5bdd30ff5d6fc4340616"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-13T21:21:11.862199262"
},
"test_custom_matrixfilter - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.filtered.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "test"
},
"test.tests.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
[
{
"id": "test"
},
"test.R_sessionInfo.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
"versions.yml:md5,275e382be9ca5bdd30ff5d6fc4340616"
],
"filtered": [
[
{
"id": "test"
},
"test.filtered.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"session_info": [
[
{
"id": "test"
},
"test.R_sessionInfo.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"tests": [
[
{
"id": "test"
},
"test.tests.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,275e382be9ca5bdd30ff5d6fc4340616"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-13T21:22:31.144793503"
}
}
3 changes: 3 additions & 0 deletions modules/nf-core/custom/matrixfilter/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
process {
ext.args = params.module_args
}
13 changes: 12 additions & 1 deletion modules/nf-core/custom/tabulartogseacls/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ process CUSTOM_TABULARTOGSEACLS {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bash: \$(echo \$(bash --version | grep -Eo 'version [[:alnum:].]+' | sed 's/version //'))
awk: \$(mawk -W version | head -n 1 | awk '{print \$2}')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.cls
cat <<-END_VERSIONS > versions.yml
"${task.process}":
awk: \$(mawk -W version | head -n 1 | awk '{print \$2}')
END_VERSIONS
"""

}
63 changes: 63 additions & 0 deletions modules/nf-core/custom/tabulartogseacls/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
nextflow_process {

name "Test Process CUSTOM_TABULARTOGSEACLS"
script "../main.nf"
process "CUSTOM_TABULARTOGSEACLS"
config "./nextflow.config"
tag "modules"
tag "modules_nfcore"
tag "custom_tabulartogseacls"
tag "custom"
tag "custom/tabulartogseacls"

test("test_custom_tabulartogseacls") {

when {
params {
module_args = [ "separator": "\t", "variable": "treatment" ]
}
process {
"""
input[0] = [
[id:'treatment_mCherry_hND6_sample_number', variable:'treatment', reference:'mCherry', target:'hND6', blocking:'sample_number'],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.samplesheet.sample_metadata.tsv", checkIfExists: true)
]
"""

}
}

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

test("test_custom_tabulartogseacls - stub") {

options "-stub"

when {
params {
module_args = { [ "separator": "\t", "variable": "treatment" ] }
}
process {
"""
input[0] = [
[id:'treatment_mCherry_hND6_sample_number', variable:'treatment', reference:'mCherry', target:'hND6', blocking:'sample_number'],
file(params.modules_testdata_base_path + "genomics/mus_musculus/rnaseq_expression/SRP254919.samplesheet.sample_metadata.tsv", checkIfExists: true)
]
"""
}
}

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

0 comments on commit d9982e3

Please sign in to comment.