Alec Wysoker
04/02/2026, 8:31 PMprocess foo {
input:
path inputBams
val inputExtension
val outputExtension
output:
path "${output_file}", emit: taggedAndTrimmedBams
script:
print("inputBams in foo: ${inputBams}")
output_file = inputBams.replaceLast(inputExtension, outputExtension)
inputBams is not a channel and it is not a single file. It appears to be a BlankSeparatedList.
inputBams in foo: SMRI_V11_rxn1.0.unmapped.bam SMRI_V11_rxn1.1.unmapped.bam
Execution cancelled -- Finishing pending tasks before exit
-[mccarroll/nextflow] Pipeline completed with errors-
ERROR ~ Error executing process > 'NEXTFLOW:align_locus_function_workflow:foo'
Caused by:
No signature of method: nextflow.util.BlankSeparatedList.replaceLast() is applicable for argument types: (String, String) values: [unmapped.bam, unmapped_tagged_trimmed_filtered.bam]
All I want is for each input file <stuff>.unmapped.bam, produce an output file <stuff>.unmapped_tagged_trimmed_filtered.bam
What am I doing wrong?Thomas Danhorn
04/03/2026, 2:49 AMprocess is not (only) determined by the input parameters (although they are important and need to be compatible with how you use it), but how the process is invoked, because that's how you specify the channels that feed it. Are your extensions the same for each file? Because if they are, you don't necessarily need a separate channel for each, but could define those via params. (Using params in modules is frowned up, though, because it limits reuse of the module to pipelines with exactly that parameter. But it may still be helpful for testing.)pontus
04/03/2026, 7:02 AMinputBams is a list rather than a string, you'd need to call replace (I don't know what interfaces provide a replaceLast) on the toString() of each item separately, e.g.
output_file = inputBams.collect( { it.toString().replace(inputExtension, outputExtension) })
but I don't know if a path output will be happy to receive a list. For most cases, it seems it should be possible to rather just do
output_file = "*.${outputExtension}"
or just doing that directly in the output section.
Assuming you really need to deal with different extensions at all.Alec Wysoker
04/03/2026, 1:47 PMoutput:
path "${libraryName}.[0-9]*.unmapped.bam", emit: splitBams
I'm guessing that there is something different about an output channel being produced this way.
Tangentially, the reason I don't create the output file name in the output: section is that I want to refer to that value in the script itself. If I use a glob in the output section, I still need to create the filename somewhere.pontus
04/03/2026, 1:58 PMAlec Wysoker
04/03/2026, 2:25 PM