Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow 'publish:' feature and optional processes #5313

Open
maressyl opened this issue Sep 19, 2024 · 1 comment
Open

Workflow 'publish:' feature and optional processes #5313

maressyl opened this issue Sep 19, 2024 · 1 comment

Comments

@maressyl
Copy link

maressyl commented Sep 19, 2024

Hi,

I'm experimenting with this very promising feature of defining files to publish directly in the workflow, however I can't figure out how to deal with my optional processes (processes which run only if a specific params boolean is set). Here is a simplified example of my current pipeline :

workflow {

	... many processes ...

	if(params.varcall) {
		
		... many processes ...

		mutect2(...)
	}
	
	publish:
	bam_sort.out.BAM >> 'BAM'
	edgeR.out.TSV >> 'expression'
	multiqc.out.HTML >> 'QC'
	mutect2.out.VCF >> 'variants'
}

output {
	directory { params.output }
	
	'variants' {
		enable false
		ignoreErrors true
	}
}

The documentation suggests numerous ways of disabling publication (enable false, ch_foo >> (params.save_foo ? 'foo' : null)...) or ignoring errors during publications, but whatever I use I still get the following error, which seems to be triggered before all these mechanisms fire :

N E X T F L O W  ~  version 24.04.4
WARN: It appears you have never run this project before -- Option `-resume` is ignored
Launching `/srv/scratch/DEPOT/pipelines/SAMI-V2/main.nf` [awesome_leakey] DSL2 - revision: 31b9236abf
WARN: WORKFLOW OUTPUT DSL IS A PREVIEW FEATURE - SYNTAX AND FUNCTIONALITY CAN CHANGE IN FUTURE RELEASES
Access to 'mutect2.out' is undefined since the process 'mutect2' has not been invoked before accessing the output attribute

 -- Check script '/srv/scratch/DEPOT/pipelines/SAMI-V2/main.nf' at line: 477 or see '.nextflow.log' file for more details

Did I miss something ?

Best regards,
Sylvain

@bentsherman
Copy link
Member

For conditional processes, you can't rely on the .out property in the publish section because that property won't exist when the process isn't invoked. You have to do something like this:

workflow {

	if (params.varcall) {
		mutect2(...)
                vcf = mutect2.out.VCF
	}
        else {
                vcf = Channel.empty()
        }
	
	publish:
	vcf >> 'variants'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@maressyl @bentsherman and others