Skip to content

Commit

Permalink
Merge pull request #7 from CaroAMN/dev
Browse files Browse the repository at this point in the history
nf-tests for modules
  • Loading branch information
CaroAMN authored Feb 20, 2025
2 parents 5b5954b + a09868e commit 971a211
Show file tree
Hide file tree
Showing 24 changed files with 623 additions and 168 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ testing/
testing*
*.pyc
null/
.nf-test
4 changes: 2 additions & 2 deletions conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ params {
// Input data
// TODO nf-core: Specify the paths to your test data on nf-core/test-datasets
// TODO nf-core: Give any required params for the test so that command line flags are not needed
input = params.pipelines_testdata_base_path + 'viralrecon/samplesheet/samplesheet_test_illumina_amplicon.csv'// Genome references
genome = 'R64-1-1'
input = 'https://raw.githubusercontent.com/CaroAMN/test-datasets/lsmquant/test_data/samplesheets/sample_sheet.csv'
stage = 'full'
}
21 changes: 3 additions & 18 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
IMPORT FUNCTIONS / MODULES / SUBWORKFLOWS / WORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

//include { NUMORPH_PREPROCESSING } from './subworkflows/local/numorph_preprocessing'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_lsmquant_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_lsmquant_pipeline'
include { LSMQUANT } from './workflows/lsmquant'
Expand All @@ -31,24 +29,11 @@ include { LSMQUANT } from './workflows/lsmquant'
//
workflow NFCORE_LSMQUANT {
take:
ch_input // the sample sheet
samplesheet // channel: samplesheet read in from --input

main:
Channel
.fromPath(ch_input)
.splitCsv(header: true)
.map { row ->
def meta = [id: row.sample_id]
tuple(meta, file(row.img_directory), file(row.parameter_file))
}
.set { sample_data }

LSMQUANT(sample_data)





LSMQUANT(samplesheet)

}
/*
Expand Down Expand Up @@ -76,7 +61,7 @@ workflow {
// WORKFLOW: Run main workflow
//
NFCORE_LSMQUANT (
params.input
PIPELINE_INITIALISATION.out.samplesheet
)
//
// SUBWORKFLOW: Run completion tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,28 @@ process NUMORPHALIGN {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numorph: 1.0
numorphalign: 1.0
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
// TODO nf-core: A stub section should mimic the execution of the original module as best as possible
// Have a look at the following examples:
// Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63
// Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54

"""
touch ${prefix}.bam
mkdir -p results/samples/alignment
mkdir -p results/variables
touch results/variables/path_table.mat
touch results/variables/alignment_table.mat
touch results/variables/z_displacement_align.mat
touch results/NM_variables.mat
touch results/samples/alignment/${meta.id}_full.tif
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numorphalign: \$(samtools --version |& sed '1!d ; s/samtools //')
numorphalign: 1.0
END_VERSIONS
"""
}
48 changes: 48 additions & 0 deletions modules/local/numorphalign/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
nextflow_process {
name "Test Process Numorphalign"
script "../main.nf"
process "NUMORPHALIGN"

test("Numorphalign stub test") {
options '-stub'
setup {
run ("NUMORPHINTENSITY") {
script "../../numorphintensity/main.nf"
options '-stub'
process {
"""
input[0] = Channel.fromList([
tuple([ id:'TEST1'],
file('/home/schwitalla/Documents/test-datasets/test_data/images'),
file('test-datasets/test_data/parameterfiles/params_TEST1_lsmquant.csv'))
])
"""
}
}


}

when {
process {
"""
input[0] = Channel.fromList([
tuple([ id:'TEST1'],
file('/home/schwitalla/Documents/test-datasets/test_data/images'),
file('test-datasets/test_data/parameterfiles/params_TEST1_lsmquant.csv'))
])
input[1] = NUMORPHINTENSITY.out.adj_params_mat
input[2] = NUMORPHINTENSITY.out.path_table_mat
input[3] = NUMORPHINTENSITY.out.thresholds_mat
input[4] = NUMORPHINTENSITY.out.NM_variables
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
49 changes: 49 additions & 0 deletions modules/local/numorphalign/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"Numorphalign stub test": {
"content": [
{
"0": [
"TEST1_full.tif:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"path_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"2": [
"alignment_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"3": [
"z_displacement_align.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"4": [
"NM_variables.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"5": [
"versions.yml:md5,c413276640fb035336c7c5bc450abde3"
],
"NM_variables": [
"NM_variables.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"alignment_table_mat": [
"alignment_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"path_table_mat": [
"path_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"samples": [
"TEST1_full.tif:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,c413276640fb035336c7c5bc450abde3"
],
"z_displacement_align_mat": [
"z_displacement_align.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-19T13:04:16.238937653"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ process NUMORPHINTENSITY {


input:
// TODO nf-core: Where applicable all sample-specific information e.g. "id", "single_end", "read_group"
// MUST be provided as an input via a Groovy Map called "meta".
// This information may not be required in some instances e.g. indexing reference genome files:
// https://github.com/nf-core/modules/blob/master/modules/nf-core/bwa/index/main.nf

tuple val(meta), path(img_directory), path(parameter_file)


output:
path "results/samples/intensity_adjustment/*" , emit: samples
path "results/variables/adj_params.mat" , emit: adj_params_mat
Expand All @@ -23,8 +17,6 @@ process NUMORPHINTENSITY {
path "results/NM_variables.mat" , emit: NM_variables
path "versions.yml" , emit: versions



when:
task.ext.when == null || task.ext.when

Expand All @@ -43,24 +35,28 @@ process NUMORPHINTENSITY {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numorph: 1.0
numorphintensity : 1.0
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
// TODO nf-core: A stub section should mimic the execution of the original module as best as possible
// Have a look at the following examples:
// Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63
// Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54

"""
touch ${prefix}.bam
mkdir -p results/samples/intensity_adjustment
mkdir -p results/variables
touch results/variables/adj_params.mat
touch results/variables/path_table.mat
touch results/variables/thresholds.mat
touch results/NM_variables.mat
touch results/samples/intensity_adjustment/${meta.id}.png
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numorph: 1.0
numorphintensity : 1.0
END_VERSIONS
"""
}
33 changes: 33 additions & 0 deletions modules/local/numorphintensity/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
nextflow_process {

name "Test Process Numorphintensity"
script "../main.nf"
process "NUMORPHINTENSITY"

tag "lsmquant"
tag "stub"

test("Numorphintensity stub test") {

options '-stub'

when {
process {
"""
input[0] = Channel.fromList([
tuple([ id:'TEST1'],
file('/home/schwitalla/Documents/test-datasets/test_data/images'),
file('test-datasets/test_data/parameterfiles/params_TEST1_lsmquant.csv'))
])
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }

)
}
}
}
49 changes: 49 additions & 0 deletions modules/local/numorphintensity/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"Numorphintensity stub test": {
"content": [
{
"0": [
"TEST1.png:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"adj_params.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"2": [
"path_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"3": [
"thresholds.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"4": [
"NM_variables.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"5": [
"versions.yml:md5,885c43b8dff8c26d121a817887a07702"
],
"NM_variables": [
"NM_variables.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"adj_params_mat": [
"adj_params.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"path_table_mat": [
"path_table.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"samples": [
"TEST1.png:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"thresholds_mat": [
"thresholds.mat:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,885c43b8dff8c26d121a817887a07702"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-20T14:54:29.642551731"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ process NUMORPHREGISTER {
container "carolinschwitalla/numorph_analyze:latest"

input:
// TODO nf-core: Where applicable all sample-specific information e.g. "id", "single_end", "read_group"
// MUST be provided as an input via a Groovy Map called "meta".
// This information may not be required in some instances e.g. indexing reference genome files:
// https://github.com/nf-core/modules/blob/master/modules/nf-core/bwa/index/main.nf
tuple val(meta), path(resampled_directory), path(parameter_file)
path NM_variables

Expand All @@ -21,10 +17,6 @@ process NUMORPHREGISTER {
path "versions.yml" , emit: versions



//errorStrategy { task.exitStatus == 249 ? 'ignore' : 'terminate' }


when:
task.ext.when == null || task.ext.when

Expand All @@ -46,23 +38,26 @@ process NUMORPHREGISTER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numorph: 1.0
numoprhregister: 1.0
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
// TODO nf-core: A stub section should mimic the execution of the original module as best as possible
// Have a look at the following examples:
// Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63
// Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54

"""
touch ${prefix}.bam
mkdir -p results/registered
mkdir -p results/variables
touch results/variables/reg_params.mat
touch results/variables/${meta.id}_mask.mat
touch results/NM_variables.mat
touch results/registered/${meta.id}_registered.tif
cat <<-END_VERSIONS > versions.yml
"${task.process}":
numoprhregister: \$(samtools --version |& sed '1!d ; s/samtools //')
numoprhregister: 1.0
END_VERSIONS
"""
}
Loading

0 comments on commit 971a211

Please sign in to comment.