Multi-channel output cannot be applied to operator combine

Hi everyone, I’m trying to develop a bespoke tool for extracting sequences using Nextflow. Currently, I have this workflow:

workflow {
    // Define the input channels
    assembly_ch = Channel.fromPath(params.assemblies)
                         .ifEmpty { error "Cannot find any assemblies matching: ${params.assemblies}" }

    query_ch = Channel.value(params.query)

    // Create BLAST database for each assembly
    blastdb_ch = assembly_ch | createBlastDB

    // Move BLAST databases to the final directory
    blastdb_ch | moveBlastDB

    // Combine BLAST databases and query for the search process
    blast_results_ch = blastdb_ch.combine(query_ch) | runBlastSearch

    // Split the tuple into unfiltered and filtered BLAST results
    blast_results_unfiltered_ch = blast_results_ch.map { it[0] }
    blast_results_filtered_ch = blast_results_ch.map { it[1] }

    // Move unfiltered BLAST results to "02_blastoutput"
    blast_results_unfiltered_ch | moveBlastOutput

    // Move filtered BLAST results to "03_blastoutput_filtered"
    blast_results_filtered_ch | moveFilteredBlastOutput

    // Extract sequences based on the filtered BLAST results
    blast_results_filtered_ch.map { filtered_out ->
        def base_name = filtered_out.baseName.replace("_vs_", "_blastdb_")
        def fasta_file = "blastdb/${base_name}/${base_name}.fasta"
        return tuple(filtered_out, fasta_file)
    } | extractSequences

But I always get an error that is: “Multi-channel output cannot be applied to operator combine for which argument is already provided”. I’ve tried many things to address this, but it seems that I’ve hit a well. Can anyone help?

You get this because your process createBlastDB likely defines more than one output channel.

Use the emit: keyword to label output channels and select specifically which you want to use.

workflow {
    task_ch = TASK().csv
    task_ch.combine(
        Channel.value(1)
    ).view()
}

process TASK {
    script:
    """
    touch sample.{csv,tsv}
    """

    output:
    path 'sample.csv', emit: csv
    path 'sample.tsv', emit: tsv
}

If the .csv is left off, you’ll get the error you’ve seen.

Since it seems your moveBlastDB also takes more than one channel as input too, another option is to change the blastdb_ch.combine(query_ch) to

blastdb_ch.<ch_name>.combine(query_ch) // If you use emit:

or

blastdb_ch[index].combine(query_ch) // where index is the index of the channel starting at 0

That’s great, thanks very much. When I incorporated your suggestions to the script, it’s now working.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.