Error optional input for process

I have a process for launching program in 2 potential types: single input channel(only tumor bam) or two input channel (tumor and normal bam). How i can figure out this problem?

Code? for understanding problem

workflow {
    ch_raw_reads = channel.fromFilePairs(params.Tumor_raw_reads)

    ch_raw_reads_var2= channel.fromFilePairs(params.Normal_raw_reads )

    TEST(ch_raw_reads) // get error below

    TEST(ch_raw_reads)
    TEST(ch_raw_reads, ch_raw_reads_var2)
}



process TEST{
    input:
    tuple val(sample_id), path(reads)             //always
    tuple val(sample_id_var_2), path(reads_var_2) // sometimes
    
    script:
    def extra_param = sample_id_var_2 ? "--input2 $reads_var_2" : "" 
    
    """
    some_program \
        --input1 $reads \
        $extra_param

    """
}

I find solution Optional input path , but when i use them, i get next error:

ERROR ~ Path string cannot be empty

– Check ‘.nextflow.log’ file for details
ERROR ~ Path string cannot be empty

– Check ‘.nextflow.log’ file for details

How i can fix process when it can import both one and two input channel?

I would combine the two channels into a single channel of 3-tuples, where the normal reads can be missing. Should be possible with the join operator with remainder: true.

You’ll also need to replace each null value with an empty list, as it’s the only way to pass an “optional” file input to a process.

The new typed process syntax in 25.10 allows you to declare optional file inputs explicitly, but it is still in preview.

1 Like