I’m trying to pass in a “when” block inside a process with a condition of the form: ‘{sample_id}-{taxid}’ in taxid_dict_v2[taxid]. I expect the process to execute for some samples, however the process never executes. When trying to:
println(“Checking if {sample_id}-{taxid} is in ${taxid_dict_v2[taxid]}”)
everything looks correct.
A brief reproducible example:
An example when “when” handles a condition correctly:
def taxid_dict_v2 = [
‘3050337’: [‘k10_bird_S5-3050337-megahit-3050337’],
‘694014’: [‘k18_bird_S13-694014-megahit-694014’, ‘k16_bird_S11-694014-megahit-694014’, ‘k24_bird_S19-694014-megahit-694014’],
]
params.taxid_dict_v2 = taxid_dict_v2
params.taxid = [‘3050337’, ‘694014’]
process EXTRACT_KRAKEN_READS_FASTA {
input:
tuple val(sample_id), val(reads)
val(taxid_dict_v2)
each taxid
when:
sample_id in taxid_dict_v2[taxid]
output:
val sample_id
script:
"""
echo ${sample_id}
"""
}
workflow {
taxid_dict_v2 = params.taxid_dict_v2
taxid = params.taxid
samples = Channel.of( [‘k10_bird_S5-3050337-megahit-3050337’, ‘1’], [‘k18_bird_S13-694014-megahit-694014’, ‘2’], [‘k24_bird_S19-694014-megahit-694014’, ‘3’] )
EXTRACT_KRAKEN_READS_FASTA(samples , taxid_dict_v2, taxid).view()
}
An example when “when” handles a condition incorrectly
process EXTRACT_KRAKEN_READS_FASTA {
input:
tuple val(sample_id), val(reads)
val(taxid_dict_v2)
each taxid
when:
"${sample_id}-${taxid}" in taxid_dict_v2[taxid]
output:
val sample_id
script:
"""
echo ${sample_id}
"""
}
workflow {
taxid_dict_v2 = params.taxid_dict_v2
taxid = params.taxid
samples = Channel.of( [‘k10_bird_S5-3050337-megahit’, ‘1’], [‘k18_bird_S13-694014-megahit’, ‘2’], [‘k24_bird_S19-694014-megahit’, ‘3’] )
EXTRACT_KRAKEN_READS_FASTA(samples, taxid_dict_v2, taxid).view()
}
Matvei Agletdinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.