Skip to content

Commit

Permalink
Merge pull request #8 from CaroAMN/dev
Browse files Browse the repository at this point in the history
new module and subworkflow test
  • Loading branch information
CaroAMN authored Feb 21, 2025
2 parents 971a211 + 6e93cc7 commit 2af8f46
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 9 deletions.
5 changes: 1 addition & 4 deletions conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ process {
params {
config_profile_name = 'Test profile'
config_profile_description = 'Minimal test dataset to check pipeline function'

// 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
// Define the input data
input = 'https://raw.githubusercontent.com/CaroAMN/test-datasets/lsmquant/test_data/samplesheets/sample_sheet.csv'
stage = 'full'
}
7 changes: 7 additions & 0 deletions modules/local/mat2json/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- "YOUR-TOOL-HERE"
43 changes: 43 additions & 0 deletions modules/local/mat2json/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

process MAT2JSON {
tag "$meta.id"
label 'process_single'

container 'carolinschwitalla/mat2json:latest'

input:
tuple val(meta), path(matfile)

output:
tuple val(meta), path("*.*"), emit: converted_file
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
/usr/bin/mlrtapp/mat2json $matfile
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mat2json: 1.0
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
touch ${prefix}.json
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mat2json: 1.0
END_VERSIONS
"""
}
55 changes: 55 additions & 0 deletions modules/local/mat2json/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: "mat2json"
description: converst matlab .mat files into json or csv files.
keywords:
- file conversion
- matlab
- json
- csv
tools:
- "mat2json":
description: "converst matlab .mat files into json or csv files."
homepage: ""
documentation: ""
tool_dev_url: ""
doi: ""
licence:
identifier:

input:
# Only when we have meta
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1']`
- mat_file:
type: file
description: matlab file
pattern: "*.{mat}"

output:
- converted_file:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*_conv.*":
type: file
description: JSON or CSV file containing the the data from the input .mat file
pattern: "*.{json,csv}"

- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@CaroAMN"
maintainers:
- "@CaroAMN"
58 changes: 58 additions & 0 deletions modules/local/mat2json/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
nextflow_process {

name "Test Process MAT2JSON"
script "../main.nf"
process "MAT2JSON"

tag "modules"
tag "modules_"
tag "mat2json"

test("matlab file conversion to json") {

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file('/mnt/ssd/numorph_testdata_s/module_testrun/output_nextflow/intensity/results/variables/thresholds.mat', checkIfExists: true),
]
"""
}
}

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

)
}

}

test("matlab file conversion to json - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file('/mnt/ssd/numorph_testdata_s/module_testrun/output_nextflow/intensity/results/variables/thresholds.mat', checkIfExists: true),
]
"""
}
}

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

}

}
80 changes: 80 additions & 0 deletions modules/local/mat2json/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"matlab file conversion to json": {
"content": [
{
"0": [
[
{
"id": "test"
},
[
"thresholds.json:md5,88adeb36bb657798c80085b6a58ac58b",
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
]
],
"1": [
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
],
"converted_file": [
[
{
"id": "test"
},
[
"thresholds.json:md5,88adeb36bb657798c80085b6a58ac58b",
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
]
],
"versions": [
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-21T15:36:22.030027548"
},
"matlab file conversion to json - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
[
"test.json:md5,d41d8cd98f00b204e9800998ecf8427e",
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
]
],
"1": [
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
],
"converted_file": [
[
{
"id": "test"
},
[
"test.json:md5,d41d8cd98f00b204e9800998ecf8427e",
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
]
],
"versions": [
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-21T15:36:26.450520824"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@



include { NUMORPHINTENSITY } from '../../modules/local/numorphintensity/'
include { NUMORPHALIGN } from '../../modules/local/numorphalign/'
include { NUMORPHSTITCH } from '../../modules/local/numorphstitch/'
include { NUMORPHINTENSITY } from '../../../modules/local/numorphintensity/'
include { NUMORPHALIGN } from '../../../modules/local/numorphalign/'
include { NUMORPHSTITCH } from '../../../modules/local/numorphstitch/'

workflow NUMORPH_PREPROCESSING {

Expand Down
51 changes: 51 additions & 0 deletions subworkflows/local/numorph_preprocessing/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "numorph_preprocessing"
## TODO nf-core: Add a description of the subworkflow and list keywords
description: Sort SAM/BAM/CRAM file
keywords:
- sort
- bam
- sam
- cram
## TODO nf-core: Add a list of the modules and/or subworkflows used in the subworkflow
components:
- samtools/sort
- samtools/index
## TODO nf-core: List all of the channels used as input with a description and their structure
input:
- ch_bam:
type: file
description: |
The input channel containing the BAM/CRAM/SAM files
Structure: [ val(meta), path(bam) ]
pattern: "*.{bam/cram/sam}"
## TODO nf-core: List all of the channels used as output with a descriptions and their structure
output:
- bam:
type: file
description: |
Channel containing BAM files
Structure: [ val(meta), path(bam) ]
pattern: "*.bam"
- bai:
type: file
description: |
Channel containing indexed BAM (BAI) files
Structure: [ val(meta), path(bai) ]
pattern: "*.bai"
- csi:
type: file
description: |
Channel containing CSI files
Structure: [ val(meta), path(csi) ]
pattern: "*.csi"
- versions:
type: file
description: |
File containing software versions
Structure: [ path(versions.yml) ]
pattern: "versions.yml"
authors:
- "@CaroAMN"
maintainers:
- "@CaroAMN"
39 changes: 39 additions & 0 deletions subworkflows/local/numorph_preprocessing/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
nextflow_workflow {

name "Test Subworkflow NUMORPH_PREPROCESSING"
script "../main.nf"
workflow "NUMORPH_PREPROCESSING"

tag "subworkflows"
tag "subworkflows_"
tag "subworkflows/numorph_preprocessing"
tag "numorph"
tag "numorph preprocessing"
tag "numorph intensity"
tag "numorph align"
tag "numorph stitch"


test("Numorph Preprocessing") {
options "-stub"

when {
workflow {
"""
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 workflow.success},
{ assert snapshot(workflow.out).match()}
)
}
}
}
Loading

0 comments on commit 2af8f46

Please sign in to comment.