Pouya Ahmadvand
Pouya Ahmadvand

Reputation: 259

Nextflow - cannot get access to the variable at publishDir

I have a pipeline with two processes. I want to pass the results files of the first process used by the second process and save the output files in a separate directory for each of the files:

process one {
.
.

    output:
    file "split.*.json" into groups
.
.

}

process two {
.
.
    publishDir params.output_path + "/exec_logs/train/${split.baseName}", mode: 'copy'


    input:
    set split from groups.flatten()

    output:
    file ".command.out"
    file ".command.err"
.
.
    """
    echo $split
    """
}

When I try the run the pipeline I get the following error: No such variable: split in the publishDir ... line, but I have access to the split variable in the run section.

How can I get access to the split variable in the publishDir?

Thanks

Upvotes: 1

Views: 269

Answers (1)

Steve
Steve

Reputation: 54502

I think the problem is actually the string concatenation. Try supplying instead a single GString:

publishDir "${params.output_path}/exec_logs/train/${split.baseName}", mode: 'copy'

For the example above, ensure also that the 'split' variable is provided using the path qualifier:

input:
path split from groups.flatten()

Upvotes: 1

Related Questions