Hi <@U039DEJ1RJS> Looking at picard/fastqtosam nf...
# modules
a
Hi @Matthias De Smet Looking at picard/fastqtosam nf-core module, it appears that the only way I can set sample_name independently of file prefix is to set one of them in task.ext. But is there a way to do that dynamically? E.g. if I have a pairs of FASTQs per lane, and I'd like to produce files <library>.0.bam, <library>1.bam, etc, but have the same --SAMPLE_NAME and --LIBRARY_NAME value set in every BAM, how would I do that?
m
You can use a config file and set the values in
ext.args
for the the process dynamically using a closure
e.g.
Copy code
process {
    withName: '.*BOWTIE2_ALIGN' {
        cpus      = 16
        memory    = 32.GB
        ext.args  = {
            [
                "--local",
                "--fast-local",
                meta.readgroup ? "--rg-id ${meta.readgroup.ID}" : "",
                meta.readgroup ? "--rg " + meta.readgroup.findResults { rg -> rg.value?.trim() ? "${rg.key}:${rg.value}" : null }.join(" --rg ") : "",
            ].join(" ").trim()
        }
        ext.args2 = "--fast"
    }
}
a
Thanks, I was starting to figure this out. I have to say that the pattern of having to have some code in a separate file from the wf that invokes a process, that relies on the wf stuffing values into meta, is not great. I don't know enough about Nextflow yet to understand the feasibility, but it would be nice if the closure above could be passed as part of the process invocation.