Skip to content

Commit 305ab4a

Browse files
committed
Simplify operator logic with static-typed maps
Signed-off-by: Ben Sherman <[email protected]>
1 parent 24f4c36 commit 305ab4a

File tree

12 files changed

+129
-121
lines changed

12 files changed

+129
-121
lines changed

main.nf

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_fetc
2222
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_fetchngs_pipeline'
2323
include { SOFTWARE_VERSIONS } from './subworkflows/nf-core/utils_nfcore_pipeline'
2424
include { DownloadMethod } from './workflows/sra'
25-
include { SraParams } from './workflows/sra'
2625
include { Sample } from './workflows/sra'
2726

2827
/*
@@ -45,7 +44,7 @@ params {
4544
download_method: DownloadMethod = 'ftp'
4645

4746
// Only download metadata for public data database ids and don't download the FastQ files.
48-
skip_fastq_download: boolean = false
47+
skip_fastq_download: Boolean = false
4948

5049
// dbGaP repository key.
5150
dbgap_key: Path? = null
@@ -78,12 +77,12 @@ workflow {
7877
//
7978
sra = SRA (
8079
Channel.fromList(params.input),
81-
SraParams(
82-
params.ena_metadata_fields,
83-
params.download_method,
84-
params.skip_fastq_download,
85-
params.dbgap_key
86-
)
80+
[
81+
ena_metadata_fields: params.ena_metadata_fields,
82+
download_method: params.download_method,
83+
skip_fastq_download: params.skip_fastq_download,
84+
dbgap_key: params.dbgap_key
85+
]
8786
)
8887

8988
//
@@ -128,7 +127,7 @@ output {
128127
}
129128
}
130129

131-
metadata {
130+
metadata: Channel<Path> {
132131
path 'metadata'
133132
}
134133

modules/local/aspera_cli/main.nf

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
process ASPERA_CLI {
2-
tag "$meta.id"
2+
tag "$id"
33
label 'process_medium'
44

55
conda "${moduleDir}/environment.yml"
@@ -8,34 +8,39 @@ process ASPERA_CLI {
88
'biocontainers/aspera-cli:4.14.0--hdfd78af_1' }"
99

1010
input:
11-
meta : Map<String,String>
12-
user : String
11+
id : String
12+
single_end : Boolean
13+
fastq_aspera : String
14+
md5_1 : String
15+
md5_2 : String?
16+
user : String
1317

1418
output:
19+
id : String = id
1520
fastq_1 : Path = file('*_1.fastq.gz')
1621
fastq_2 : Path? = file('*_2.fastq.gz')
1722
md5_1 : Path = file('*_1.fastq.gz.md5')
1823
md5_2 : Path? = file('*_2.fastq.gz.md5')
1924

2025
topic:
21-
( task.process, 'aspera_cli', eval('ascli --version') ) >> 'versions'
26+
[process: task.process, name: 'aspera_cli', version: eval('ascli --version')] >> 'versions'
2227

2328
script:
2429
def args = task.ext.args ?: ''
2530
def conda_prefix = ['singularity', 'apptainer'].contains(workflow.containerEngine) ? "export CONDA_PREFIX=/usr/local" : ""
26-
def fastq = meta.fastq_aspera.tokenize(';')
27-
if (meta.single_end.toBoolean()) {
31+
def fastq = fastq_aspera.tokenize(';')
32+
if (single_end) {
2833
"""
2934
$conda_prefix
3035
3136
ascp \\
3237
$args \\
3338
-i \$CONDA_PREFIX/etc/aspera/aspera_bypass_dsa.pem \\
3439
${user}@${fastq[0]} \\
35-
${meta.id}.fastq.gz
40+
${id}.fastq.gz
3641
37-
echo "${meta.md5_1} ${meta.id}.fastq.gz" > ${meta.id}.fastq.gz.md5
38-
md5sum -c ${meta.id}.fastq.gz.md5
42+
echo "${md5_1} ${id}.fastq.gz" > ${id}.fastq.gz.md5
43+
md5sum -c ${id}.fastq.gz.md5
3944
"""
4045
} else {
4146
"""
@@ -45,19 +50,19 @@ process ASPERA_CLI {
4550
$args \\
4651
-i \$CONDA_PREFIX/etc/aspera/aspera_bypass_dsa.pem \\
4752
${user}@${fastq[0]} \\
48-
${meta.id}_1.fastq.gz
53+
${id}_1.fastq.gz
4954
50-
echo "${meta.md5_1} ${meta.id}_1.fastq.gz" > ${meta.id}_1.fastq.gz.md5
51-
md5sum -c ${meta.id}_1.fastq.gz.md5
55+
echo "${md5_1} ${id}_1.fastq.gz" > ${id}_1.fastq.gz.md5
56+
md5sum -c ${id}_1.fastq.gz.md5
5257
5358
ascp \\
5459
$args \\
5560
-i \$CONDA_PREFIX/etc/aspera/aspera_bypass_dsa.pem \\
5661
${user}@${fastq[1]} \\
57-
${meta.id}_2.fastq.gz
62+
${id}_2.fastq.gz
5863
59-
echo "${meta.md5_2} ${meta.id}_2.fastq.gz" > ${meta.id}_2.fastq.gz.md5
60-
md5sum -c ${meta.id}_2.fastq.gz.md5
64+
echo "${md5_2} ${id}_2.fastq.gz" > ${id}_2.fastq.gz.md5
65+
md5sum -c ${id}_2.fastq.gz.md5
6166
"""
6267
}
6368
}
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
process SRA_FASTQ_FTP {
3-
tag "$meta.id"
3+
tag "$id"
44
label 'process_low'
55
label 'error_retry'
66

@@ -10,46 +10,52 @@ process SRA_FASTQ_FTP {
1010
'biocontainers/wget:1.20.1' }"
1111

1212
input:
13-
meta : Map<String,String>
13+
id : String
14+
single_end : Boolean
15+
fastq_1 : String
16+
fastq_2 : String?
17+
md5_1 : String
18+
md5_2 : String?
1419

1520
output:
21+
id : String = id
1622
fastq_1 : Path = file('*_1.fastq.gz')
1723
fastq_2 : Path? = file('*_2.fastq.gz')
1824
md5_1 : Path = file('*_1.fastq.gz.md5')
1925
md5_2 : Path? = file('*_2.fastq.gz.md5')
2026

2127
topic:
22-
( task.process, 'wget', eval("echo \$(wget --version | head -n 1 | sed 's/^GNU Wget //; s/ .*\$//')") ) >> 'versions'
28+
[process: task.process, name: 'wget', version: eval("echo \$(wget --version | head -n 1 | sed 's/^GNU Wget //; s/ .*\$//')")] >> 'versions'
2329

2430
script:
2531
def args = task.ext.args ?: ''
26-
if (meta.single_end.toBoolean()) {
32+
if (single_end) {
2733
"""
2834
wget \\
2935
$args \\
30-
-O ${meta.id}.fastq.gz \\
31-
${meta.fastq_1}
36+
-O ${id}.fastq.gz \\
37+
${fastq_1}
3238
33-
echo "${meta.md5_1} ${meta.id}.fastq.gz" > ${meta.id}.fastq.gz.md5
34-
md5sum -c ${meta.id}.fastq.gz.md5
39+
echo "${md5_1} ${id}.fastq.gz" > ${id}.fastq.gz.md5
40+
md5sum -c ${id}.fastq.gz.md5
3541
"""
3642
} else {
3743
"""
3844
wget \\
3945
$args \\
40-
-O ${meta.id}_1.fastq.gz \\
41-
${meta.fastq_1}
46+
-O ${id}_1.fastq.gz \\
47+
${fastq_1}
4248
43-
echo "${meta.md5_1} ${meta.id}_1.fastq.gz" > ${meta.id}_1.fastq.gz.md5
44-
md5sum -c ${meta.id}_1.fastq.gz.md5
49+
echo "${md5_1} ${id}_1.fastq.gz" > ${id}_1.fastq.gz.md5
50+
md5sum -c ${id}_1.fastq.gz.md5
4551
4652
wget \\
4753
$args \\
48-
-O ${meta.id}_2.fastq.gz \\
49-
${meta.fastq_2}
54+
-O ${id}_2.fastq.gz \\
55+
${fastq_2}
5056
51-
echo "${meta.md5_2} ${meta.id}_2.fastq.gz" > ${meta.id}_2.fastq.gz.md5
52-
md5sum -c ${meta.id}_2.fastq.gz.md5
57+
echo "${md5_2} ${id}_2.fastq.gz" > ${id}_2.fastq.gz.md5
58+
md5sum -c ${id}_2.fastq.gz.md5
5359
"""
5460
}
5561
}

modules/local/sra_ids_to_runinfo/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ process SRA_IDS_TO_RUNINFO {
1616
file('*.runinfo.tsv')
1717

1818
topic:
19-
( task.process, 'python', eval("python --version | sed 's/Python //g'") ) >> 'versions'
19+
[process: task.process, name: 'python', version: eval("python --version | sed 's/Python //g'")] >> 'versions'
2020

2121
script:
2222
def metadata_fields = fields ? "--ena_metadata_fields ${fields}" : ''

modules/local/sra_runinfo_to_ftp/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ process SRA_RUNINFO_TO_FTP {
1313
file('*.runinfo_ftp.tsv')
1414

1515
topic:
16-
( task.process, 'python', eval("python --version | sed 's/Python //g'") ) >> 'versions'
16+
[process: task.process, name: 'python', version: eval("python --version | sed 's/Python //g'")] >> 'versions'
1717

1818
script:
1919
"""

modules/nf-core/custom/sratoolsncbisettings/main.nf

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/nf-core/sratools/fasterqdump/main.nf

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/nf-core/sratools/prefetch/main.nf

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

subworkflows/nf-core/fastq_download_prefetch_fasterqdump_sratools/main.nf

Lines changed: 18 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

subworkflows/nf-core/utils_nextflow_pipeline/main.nf

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)