Skip to content

Commit 2af8f46

Browse files
authored
Merge pull request #8 from CaroAMN/dev
new module and subworkflow test
2 parents 971a211 + 6e93cc7 commit 2af8f46

File tree

10 files changed

+384
-9
lines changed

10 files changed

+384
-9
lines changed

conf/test.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ process {
2121
params {
2222
config_profile_name = 'Test profile'
2323
config_profile_description = 'Minimal test dataset to check pipeline function'
24-
25-
// Input data
26-
// TODO nf-core: Specify the paths to your test data on nf-core/test-datasets
27-
// TODO nf-core: Give any required params for the test so that command line flags are not needed
24+
// Define the input data
2825
input = 'https://raw.githubusercontent.com/CaroAMN/test-datasets/lsmquant/test_data/samplesheets/sample_sheet.csv'
2926
stage = 'full'
3027
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
3+
channels:
4+
- conda-forge
5+
- bioconda
6+
dependencies:
7+
- "YOUR-TOOL-HERE"

modules/local/mat2json/main.nf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
process MAT2JSON {
3+
tag "$meta.id"
4+
label 'process_single'
5+
6+
container 'carolinschwitalla/mat2json:latest'
7+
8+
input:
9+
tuple val(meta), path(matfile)
10+
11+
output:
12+
tuple val(meta), path("*.*"), emit: converted_file
13+
path "versions.yml" , emit: versions
14+
15+
when:
16+
task.ext.when == null || task.ext.when
17+
18+
script:
19+
def args = task.ext.args ?: ''
20+
def prefix = task.ext.prefix ?: "${meta.id}"
21+
22+
"""
23+
/usr/bin/mlrtapp/mat2json $matfile
24+
25+
cat <<-END_VERSIONS > versions.yml
26+
"${task.process}":
27+
mat2json: 1.0
28+
END_VERSIONS
29+
"""
30+
31+
stub:
32+
def args = task.ext.args ?: ''
33+
def prefix = task.ext.prefix ?: "${meta.id}"
34+
35+
"""
36+
touch ${prefix}.json
37+
38+
cat <<-END_VERSIONS > versions.yml
39+
"${task.process}":
40+
mat2json: 1.0
41+
END_VERSIONS
42+
"""
43+
}

modules/local/mat2json/meta.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
name: "mat2json"
3+
description: converst matlab .mat files into json or csv files.
4+
keywords:
5+
- file conversion
6+
- matlab
7+
- json
8+
- csv
9+
tools:
10+
- "mat2json":
11+
description: "converst matlab .mat files into json or csv files."
12+
homepage: ""
13+
documentation: ""
14+
tool_dev_url: ""
15+
doi: ""
16+
licence:
17+
identifier:
18+
19+
input:
20+
# Only when we have meta
21+
- - meta:
22+
type: map
23+
description: |
24+
Groovy Map containing sample information
25+
e.g. `[ id:'sample1']`
26+
27+
- mat_file:
28+
type: file
29+
description: matlab file
30+
pattern: "*.{mat}"
31+
32+
output:
33+
- converted_file:
34+
#Only when we have meta
35+
- meta:
36+
type: map
37+
description: |
38+
Groovy Map containing sample information
39+
e.g. `[ id:'sample1', single_end:false ]`
40+
41+
- "*_conv.*":
42+
type: file
43+
description: JSON or CSV file containing the the data from the input .mat file
44+
pattern: "*.{json,csv}"
45+
46+
- versions:
47+
- "versions.yml":
48+
type: file
49+
description: File containing software versions
50+
pattern: "versions.yml"
51+
52+
authors:
53+
- "@CaroAMN"
54+
maintainers:
55+
- "@CaroAMN"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
nextflow_process {
2+
3+
name "Test Process MAT2JSON"
4+
script "../main.nf"
5+
process "MAT2JSON"
6+
7+
tag "modules"
8+
tag "modules_"
9+
tag "mat2json"
10+
11+
test("matlab file conversion to json") {
12+
13+
when {
14+
process {
15+
"""
16+
input[0] = [
17+
[ id:'test'], // meta map
18+
file('/mnt/ssd/numorph_testdata_s/module_testrun/output_nextflow/intensity/results/variables/thresholds.mat', checkIfExists: true),
19+
]
20+
"""
21+
}
22+
}
23+
24+
then {
25+
assertAll(
26+
{ assert process.success },
27+
{ assert snapshot(process.out).match() }
28+
29+
)
30+
}
31+
32+
}
33+
34+
test("matlab file conversion to json - stub") {
35+
36+
options "-stub"
37+
38+
when {
39+
process {
40+
"""
41+
input[0] = [
42+
[ id:'test'], // meta map
43+
file('/mnt/ssd/numorph_testdata_s/module_testrun/output_nextflow/intensity/results/variables/thresholds.mat', checkIfExists: true),
44+
]
45+
"""
46+
}
47+
}
48+
49+
then {
50+
assertAll(
51+
{ assert process.success },
52+
{ assert snapshot(process.out).match() }
53+
)
54+
}
55+
56+
}
57+
58+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"matlab file conversion to json": {
3+
"content": [
4+
{
5+
"0": [
6+
[
7+
{
8+
"id": "test"
9+
},
10+
[
11+
"thresholds.json:md5,88adeb36bb657798c80085b6a58ac58b",
12+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
13+
]
14+
]
15+
],
16+
"1": [
17+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
18+
],
19+
"converted_file": [
20+
[
21+
{
22+
"id": "test"
23+
},
24+
[
25+
"thresholds.json:md5,88adeb36bb657798c80085b6a58ac58b",
26+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
27+
]
28+
]
29+
],
30+
"versions": [
31+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
32+
]
33+
}
34+
],
35+
"meta": {
36+
"nf-test": "0.9.2",
37+
"nextflow": "24.10.4"
38+
},
39+
"timestamp": "2025-02-21T15:36:22.030027548"
40+
},
41+
"matlab file conversion to json - stub": {
42+
"content": [
43+
{
44+
"0": [
45+
[
46+
{
47+
"id": "test"
48+
},
49+
[
50+
"test.json:md5,d41d8cd98f00b204e9800998ecf8427e",
51+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
52+
]
53+
]
54+
],
55+
"1": [
56+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
57+
],
58+
"converted_file": [
59+
[
60+
{
61+
"id": "test"
62+
},
63+
[
64+
"test.json:md5,d41d8cd98f00b204e9800998ecf8427e",
65+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
66+
]
67+
]
68+
],
69+
"versions": [
70+
"versions.yml:md5,d8fdb19b7f6440f3644b923cf0bf7eee"
71+
]
72+
}
73+
],
74+
"meta": {
75+
"nf-test": "0.9.2",
76+
"nextflow": "24.10.4"
77+
},
78+
"timestamp": "2025-02-21T15:36:26.450520824"
79+
}
80+
}

subworkflows/local/numorph_preprocessing.nf renamed to subworkflows/local/numorph_preprocessing/main.nf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

2-
3-
4-
include { NUMORPHINTENSITY } from '../../modules/local/numorphintensity/'
5-
include { NUMORPHALIGN } from '../../modules/local/numorphalign/'
6-
include { NUMORPHSTITCH } from '../../modules/local/numorphstitch/'
2+
include { NUMORPHINTENSITY } from '../../../modules/local/numorphintensity/'
3+
include { NUMORPHALIGN } from '../../../modules/local/numorphalign/'
4+
include { NUMORPHSTITCH } from '../../../modules/local/numorphstitch/'
75

86
workflow NUMORPH_PREPROCESSING {
97

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
2+
name: "numorph_preprocessing"
3+
## TODO nf-core: Add a description of the subworkflow and list keywords
4+
description: Sort SAM/BAM/CRAM file
5+
keywords:
6+
- sort
7+
- bam
8+
- sam
9+
- cram
10+
## TODO nf-core: Add a list of the modules and/or subworkflows used in the subworkflow
11+
components:
12+
- samtools/sort
13+
- samtools/index
14+
## TODO nf-core: List all of the channels used as input with a description and their structure
15+
input:
16+
- ch_bam:
17+
type: file
18+
description: |
19+
The input channel containing the BAM/CRAM/SAM files
20+
Structure: [ val(meta), path(bam) ]
21+
pattern: "*.{bam/cram/sam}"
22+
## TODO nf-core: List all of the channels used as output with a descriptions and their structure
23+
output:
24+
- bam:
25+
type: file
26+
description: |
27+
Channel containing BAM files
28+
Structure: [ val(meta), path(bam) ]
29+
pattern: "*.bam"
30+
- bai:
31+
type: file
32+
description: |
33+
Channel containing indexed BAM (BAI) files
34+
Structure: [ val(meta), path(bai) ]
35+
pattern: "*.bai"
36+
- csi:
37+
type: file
38+
description: |
39+
Channel containing CSI files
40+
Structure: [ val(meta), path(csi) ]
41+
pattern: "*.csi"
42+
- versions:
43+
type: file
44+
description: |
45+
File containing software versions
46+
Structure: [ path(versions.yml) ]
47+
pattern: "versions.yml"
48+
authors:
49+
- "@CaroAMN"
50+
maintainers:
51+
- "@CaroAMN"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
nextflow_workflow {
2+
3+
name "Test Subworkflow NUMORPH_PREPROCESSING"
4+
script "../main.nf"
5+
workflow "NUMORPH_PREPROCESSING"
6+
7+
tag "subworkflows"
8+
tag "subworkflows_"
9+
tag "subworkflows/numorph_preprocessing"
10+
tag "numorph"
11+
tag "numorph preprocessing"
12+
tag "numorph intensity"
13+
tag "numorph align"
14+
tag "numorph stitch"
15+
16+
17+
test("Numorph Preprocessing") {
18+
options "-stub"
19+
20+
when {
21+
workflow {
22+
"""
23+
input[0] = Channel.fromList([
24+
tuple([ id:'TEST1'],
25+
file('/home/schwitalla/Documents/test-datasets/test_data/images'),
26+
file('test-datasets/test_data/parameterfiles/params_TEST1_lsmquant.csv'))
27+
])
28+
"""
29+
}
30+
}
31+
32+
then {
33+
assertAll(
34+
{ assert workflow.success},
35+
{ assert snapshot(workflow.out).match()}
36+
)
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)