Skip to content

Commit e8070df

Browse files
authored
Merge pull request #542 from nf-core/strict-syntax-warnings
Fix remaining linting warnings
2 parents d3e9a95 + fbe6d72 commit e8070df

11 files changed

Lines changed: 53 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Chore
1717

18+
- Clear all `nextflow lint` warnings (use `channel` factory API, explicit closure parameters, unused-parameter prefixes). ([#542](https://github.com/nf-core/scrnaseq/pull/542))
1819
- Migrate local subworkflows to directory-based layout with `main.nf`, matching the new nf-core standard structure for modules and subworkflows ([#553](https://github.com/nf-core/scrnaseq/pull/553))
1920
- Template update for nf-core/tools v3.5.1 ([#509](https://github.com/nf-core/scrnaseq/pull/509))
2021
- Template update for nf-core/tools v4.0.2 ([#541](https://github.com/nf-core/scrnaseq/pull/541))

conf/modules.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ process {
159159
publishDir = [
160160
path: { "${params.outdir}/${params.aligner}/${meta.id}" },
161161
mode: params.publish_dir_mode,
162-
saveAs: { (!it.endsWith('.bam') || params.save_align_intermeds) ? it : null }
162+
saveAs: { filename -> (!filename.endsWith('.bam') || params.save_align_intermeds) ? filename : null }
163163
]
164164
}
165165

subworkflows/local/align_cellranger/main.nf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ workflow CELLRANGER_ALIGN {
4141
ch_matrices_raw =
4242
CELLRANGER_COUNT.out.outs.map { meta, mtx_files ->
4343
def desired_files = []
44-
mtx_files.each{
45-
if ( it.toString().contains("raw_feature_bc_matrix") ) { desired_files.add( it ) }
44+
mtx_files.each{ path ->
45+
if ( path.toString().contains("raw_feature_bc_matrix") ) { desired_files.add( path ) }
4646
}
4747
[ meta + [input_type: 'raw'], desired_files ]
4848
}
4949

5050
ch_matrices_filtered =
5151
CELLRANGER_COUNT.out.outs.map { meta, mtx_files ->
5252
def desired_files = []
53-
mtx_files.each{
54-
if ( it.toString().contains("filtered_feature_bc_matrix") ) { desired_files.add( it ) }
53+
mtx_files.each{ path ->
54+
if ( path.toString().contains("filtered_feature_bc_matrix") ) { desired_files.add( path ) }
5555
}
5656
[ meta + [input_type: 'filtered'], desired_files ]
5757
}

subworkflows/local/align_cellrangerarc/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def parse_demultiplexed_output_channels(in_ch, pattern) {
6767
meta_clone.input_type = pattern.contains('raw_') ? 'raw' : 'filtered'
6868
// Iterate over the matrix files and add the ones matching the pattern to the desired files list
6969
def desired_files = []
70-
mtx_files.each{ if ( it.toString().contains("${pattern}") ) { desired_files.add( it ) } }
70+
mtx_files.each{ path -> if ( path.toString().contains("${pattern}") ) { desired_files.add( path ) } }
7171
[ meta_clone, desired_files ]
7272
}
7373

subworkflows/local/align_cellrangermulti/main.nf

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ workflow CELLRANGER_MULTI_ALIGN {
2929
.flatten()
3030
.map{ meta ->
3131
def meta_clone = meta.clone()
32-
def data_dict = meta_clone.find{ it.key == "${meta_clone.feature_type}" }
32+
def data_dict = meta_clone.find{ entry -> entry.key == "${meta_clone.feature_type}" }
3333
def fastqs = data_dict?.value
3434
meta_clone.remove( data_dict?.key )
3535
[ meta_clone, fastqs ]
@@ -90,26 +90,26 @@ workflow CELLRANGER_MULTI_ALIGN {
9090

9191
// CMO
9292
ch_grouped_fastq.gex
93-
.map{ [it[0].id] }
94-
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.cmo.flatten().map { [ "${it.baseName}" - "_cmo", it ] } )
93+
.map{ pair -> [pair[0].id] }
94+
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.cmo.flatten().map { csv -> [ "${csv.baseName}" - "_cmo", csv ] } )
9595
.groupTuple()
96-
.map { if ( it.size() == 2 ) { it[1] } else { [] } } // a correct tuple from snippet will have: [ sample, cmo.csv ]
96+
.map { grp -> if ( grp.size() == 2 ) { grp[1] } else { [] } } // a correct tuple from snippet will have: [ sample, cmo.csv ]
9797
.set { ch_cmo_barcode_csv }
9898

9999
// OCM
100100
ch_grouped_fastq.gex
101-
.map{ [it[0].id] }
102-
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.ocm.flatten().map { [ "${it.baseName}" - "_ocm", it ] } )
101+
.map{ pair -> [pair[0].id] }
102+
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.ocm.flatten().map { csv -> [ "${csv.baseName}" - "_ocm", csv ] } )
103103
.groupTuple()
104-
.map { if ( it.size() == 2 ) { it[1] } else { [] } } // a correct tuple from snippet will have: [ sample, ocm.csv ]
104+
.map { grp -> if ( grp.size() == 2 ) { grp[1] } else { [] } } // a correct tuple from snippet will have: [ sample, ocm.csv ]
105105
.set { ch_ocm_barcode_csv }
106106

107107
// FRNA
108108
ch_grouped_fastq.gex
109-
.map{ [it[0].id] }
110-
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.frna.flatten().map { [ "${it.baseName}" - "_frna", it ] } )
109+
.map{ pair -> [pair[0].id] }
110+
.concat( PARSE_CELLRANGERMULTI_SAMPLESHEET.out.frna.flatten().map { csv -> [ "${csv.baseName}" - "_frna", csv ] } )
111111
.groupTuple()
112-
.map { if ( it.size() == 2 ) { it[1] } else { [] } } // a correct tuple from snippet will have: [ sample, frna.csv ]
112+
.map { grp -> if ( grp.size() == 2 ) { grp[1] } else { [] } } // a correct tuple from snippet will have: [ sample, frna.csv ]
113113
.set { ch_frna_sample_csv }
114114

115115
} else {
@@ -197,7 +197,7 @@ workflow CELLRANGER_MULTI_ALIGN {
197197
// MODULE: cellranger multi
198198
//
199199
CELLRANGER_MULTI(
200-
ch_grouped_fastq.gex.map{ it[0] },
200+
ch_grouped_fastq.gex.map{ pair -> pair[0] },
201201
ch_grouped_fastq.gex,
202202
ch_grouped_fastq.vdj,
203203
ch_grouped_fastq.ab,
@@ -244,7 +244,7 @@ def parse_demultiplexed_output_channels(in_ch, pattern) {
244244
def out_ch = in_ch
245245
.map { meta, mtx_files ->
246246
def desired_files = []
247-
mtx_files.each{ if ( it.toString().contains("${pattern}") ) { desired_files.add( it ) } }
247+
mtx_files.each{ path -> if ( path.toString().contains("${pattern}") ) { desired_files.add( path ) } }
248248
[ meta, desired_files ]
249249
} // separate only desired files
250250
.transpose() // transpose for handling one meta/file pair at a time
@@ -260,7 +260,7 @@ def parse_demultiplexed_output_channels(in_ch, pattern) {
260260
}
261261
[ meta_clone, mtx_files ]
262262
} // check if output is from demultiplexed sample, if yes, correct meta.id for proper conversion naming
263-
.filter{ it != null } // remove nulls from previous step
263+
.filter{ item -> item != null } // remove nulls from previous step
264264
.groupTuple( by: 0 ) // group it back as one file collection per sample
265265

266266
return out_ch

subworkflows/local/fastqc/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ workflow FASTQC_CHECK {
2626
.map { it -> [ it[1] ] }
2727
.set { fastqc_html_only }
2828

29-
fastqc_multiqc = Channel.empty()
29+
fastqc_multiqc = channel.empty()
3030
fastqc_multiqc = fastqc_multiqc.mix( fastqc_zip_only, fastqc_html_only )
3131

3232
emit:

subworkflows/local/kallisto_bustools/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ workflow KALLISTO_BUSTOOLS {
1717
ch_fastq
1818

1919
main:
20-
ch_versions = Channel.empty()
20+
ch_versions = channel.empty()
2121

2222
assert (txp2gene && kallisto_index) || (genome_fasta && gtf):
2323
"Must provide a genome fasta file ('--fasta') and a gtf file ('--gtf') if no index is given!"

subworkflows/local/simpleaf/main.nf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ workflow SIMPLEAF {
2020
map_dir
2121

2222
main:
23-
ch_versions = Channel.empty()
23+
ch_versions = channel.empty()
2424

2525
/*
2626
* Build simpleaf index if needed
@@ -60,20 +60,20 @@ workflow SIMPLEAF {
6060
if (!txp2gene) {
6161
txp2gene = SIMPLEAF_INDEX.out.t2g.collect().map { _meta, it -> it }
6262
} else {
63-
txp2gene = Channel.of( txp2gene )
63+
txp2gene = channel.of( txp2gene )
6464
}
6565
} else {
6666
// we have a map dir, so we do not need to build the index
67-
simpleaf_index = Channel.of( [ [:], [] ] )
67+
simpleaf_index = channel.of( [ [:], [] ] )
6868
}
6969
} else {
7070
// we have a simpleaf index, we use it directly
7171
// ensure simpleaf index and txp2gene are Channels
72-
simpleaf_index = Channel.of( [ [ id: simpleaf_index.getName() ], simpleaf_index ] )
72+
simpleaf_index = channel.of( [ [ id: simpleaf_index.getName() ], simpleaf_index ] )
7373

7474
// channel or null
7575
if (txp2gene) {
76-
txp2gene = Channel.of( txp2gene )
76+
txp2gene = channel.of( txp2gene )
7777
}
7878
}
7979

@@ -119,7 +119,7 @@ workflow SIMPLEAF {
119119
/*
120120
* Run qcatch QC (optional)
121121
*/
122-
ch_qcatch_report = Channel.empty()
122+
ch_qcatch_report = channel.empty()
123123
if ( !skip_qcatch ) {
124124
// Map quant channel to include chemistry for qcatch: tuple(meta, chemistry, quant_dir)
125125
ch_qcatch_input = ch_af_quant.map { meta, quant_dir -> [meta, qcatch_chemistry, quant_dir] }

subworkflows/local/starsolo/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ workflow STARSOLO {
6969
star_counts = STAR_ALIGN.out.counts
7070
raw_counts = raw_counts
7171
filtered_counts = filtered_counts
72-
for_multiqc = STAR_ALIGN.out.log_final.map{ meta, it -> it }
72+
for_multiqc = STAR_ALIGN.out.log_final.map{ _meta, logFinal -> logFinal }
7373
}

subworkflows/local/utils_nfcore_scrnaseq_pipeline/main.nf

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ workflow PIPELINE_INITIALISATION {
3131
monochrome_logs // boolean: Do not use coloured log outputs
3232
nextflow_cli_args // array: List of positional nextflow CLI args
3333
outdir // string: The output directory where the results will be saved
34-
input // string: Path to input samplesheet
34+
_input // string: Path to input samplesheet
3535
help // boolean: Display help message and exit
3636
help_full // boolean: Show the full help message
3737
show_hidden // boolean: Show hidden parameters in the help message
@@ -107,7 +107,7 @@ workflow PIPELINE_INITIALISATION {
107107
// Create channel from input file provided through params.input
108108
//
109109
if (params.aligner == 'cellrangermulti') { // the cellrangermulti sub-workflow logic needs that channels have reads separated by feature_type. Cannot merge all.
110-
Channel
110+
channel
111111
.fromList(samplesheetToList(params.input, "${projectDir}/assets/schema_input.json"))
112112
.map {
113113
meta, fastq_1, fastq_2 ->
@@ -118,17 +118,17 @@ workflow PIPELINE_INITIALISATION {
118118
}
119119
}
120120
.groupTuple( by: [0,1] )
121-
.map{ id, type, meta, reads -> [ id, meta, reads ] }
122-
.map {
123-
validateInputSamplesheet(it)
121+
.map{ id, _type, meta, reads -> [ id, meta, reads ] }
122+
.map { sheet_row ->
123+
validateInputSamplesheet(sheet_row)
124124
}
125125
.map {
126126
meta, fastqs ->
127127
return [ meta, fastqs.flatten() ]
128128
}
129129
.set { ch_samplesheet }
130130
} else if (params.aligner == 'cellrangerarc') { // the cellrangerarc sub-workflow logic needs that channels have a meta, type, subsample, fastqs structure.
131-
Channel
131+
channel
132132
.fromList(samplesheetToList(params.input, "${projectDir}/assets/schema_input.json"))
133133
.map { meta, fastq_1, fastq_2 ->
134134
if (!fastq_2 || (meta.sample_type == "atac" && !meta.fastq_barcode)) {
@@ -141,12 +141,12 @@ workflow PIPELINE_INITIALISATION {
141141
}
142142
}
143143
.groupTuple()
144-
.map {
145-
cellrangerarcStructure(it)
144+
.map { structure_input ->
145+
cellrangerarcStructure(structure_input)
146146
}
147147
.set { ch_samplesheet }
148148
} else {
149-
Channel
149+
channel
150150
.fromList(samplesheetToList(params.input, "${projectDir}/assets/schema_input.json"))
151151
.map {
152152
meta, fastq_1, fastq_2 ->
@@ -157,8 +157,8 @@ workflow PIPELINE_INITIALISATION {
157157
}
158158
}
159159
.groupTuple()
160-
.map {
161-
validateInputSamplesheet(it)
160+
.map { sheet_row ->
161+
validateInputSamplesheet(sheet_row)
162162
}
163163
.map {
164164
meta, fastqs ->
@@ -241,7 +241,7 @@ def validateCellrangerMultiBarcodes() {
241241
def cellranger_multi_barcodes = file(params.cellranger_multi_barcodes).splitCsv(header: true)
242242

243243
// Get unique samples from input samplesheet for cross-validation
244-
def inputSamples = file(params.input).splitCsv(header: true).collect { it.sample }.toSet()
244+
def inputSamples = file(params.input).splitCsv(header: true).collect { row -> row.sample }.toSet()
245245

246246
// Check that at least one barcode column is provided for each row
247247
// and that each sample uses only one type of barcode
@@ -268,14 +268,14 @@ def validateCellrangerMultiBarcodes() {
268268

269269
// Validate that at least one barcode identifier is populated in each row
270270
if (rowsWithoutBarcodes) {
271-
def errorDetails = rowsWithoutBarcodes.collect { "row ${it.row} (${it.multiplexed_sample_id})" }.join(', ')
271+
def errorDetails = rowsWithoutBarcodes.collect { missing -> "row ${missing.row} (${missing.multiplexed_sample_id})" }.join(', ')
272272
error("Please check cellranger_multi_barcodes samplesheet -> " +
273273
"The following rows have no barcode identifiers: ${errorDetails}. " +
274274
"Each row must have exactly one of: 'probe_barcode_ids', 'cmo_ids', or 'ocm_ids'.")
275275
}
276276

277277
// Validate that no more than one barcode identifier is populated in each row
278-
def samplesWithMixedBarcodes = sampleBarcodeTypes.findAll { multiplexed_sample_id, info -> info.types.size() > 1 }
278+
def samplesWithMixedBarcodes = sampleBarcodeTypes.findAll { _multiplexed_sample_id, info -> info.types.size() > 1 }
279279
if (samplesWithMixedBarcodes) {
280280
def errorMsg = samplesWithMixedBarcodes.collect { multiplexed_sample_id, info ->
281281
"'${multiplexed_sample_id}' (row ${info.row}) uses multiple barcode types: ${info.types.join(', ')}"
@@ -321,7 +321,7 @@ def cellrangerarcStructure(input) {
321321

322322
// Validate that the property "sample_type" is present and has valid values
323323
def valid_sample_types = ["gex", "atac"]
324-
def sample_type_ok = metas.collect { meta -> meta.sample_type }.unique().every { it in valid_sample_types }
324+
def sample_type_ok = metas.collect { meta -> meta.sample_type }.unique().every { st -> st in valid_sample_types }
325325
if (!sample_type_ok) {
326326
error("Please check input samplesheet -> The property 'sample_type' is required and can only be 'gex' or 'atac'.")
327327
}

0 commit comments

Comments
 (0)