Laurenz Holcik
11/28/2025, 8:25 AMJames Fellows Yates
11/28/2025, 8:38 AM--use-daemon functionality, whihc I had not heard of as it sound svery nice - is this similar to KrakenUniq's 'preloaded' option?
To my knowledge (and a quick code search now), the nf-core pipelines do not touch anything to do with tmp/ directories by default.
Do you by any chance have your 'simple' pipeline available so we can compare?
As a general rule you can control the location of /tmp using the scratch directoive: https://nextflow.io/docs/latest/reference/process.html#scratch
When you say hardcoded, do you mean literally the string /tmp/classify.pid, or that it takes $TMPDIR?Laurenz Holcik
11/28/2025, 9:13 AM--preload function, loading the entire database into memory kraken2 does by default. Instead, when you're running kraken2 several times, it loads the database into memory (which takes long), then classifies reads of a sample and then would do the same all over again for the next sample.
With the --use-daemon option, the database is kept loaded in memory in the background so when kraken2 is run again on the next sample it can skip the step of loading it into memory. The issue is then how to tell the next kraken2 process how to find the daemon and how the k2 developers solved this is apparently that they just create a file /tmp/classify.pid with the process ID - and yes this is really hardcoded in the C++ code of kraken2 (I opened a request on their gh to make this path a parameter).
This is how I have adapted the KRAKEN2_KRAKEN2 process of the taxprofiler pipeline:
https://github.com/Laurenz0908/taxprofiler/blob/master/modules/nf-core/kraken2/kraken2/main.nf
And this is how my test script looks like:
process write_file {
script:
"""
k2 classify \\
--db /data/x1hbrnas4/big_db/kraken2_gtdb_226 \\
--use-daemon \\
/dev/null > /dev/null
"""
}
workflow {
write_file()
}
The test script works, the taxprofiler doesn't.
I think implementing this as a general feature for the pipeline will be rather difficult because of the shared use of the daemon, this would go against the process isolation principles of nextflow and hard to implement on a HPC cluster. But I would think that at least on a local executor without containers there should be a way...
EDIT: As you can see in the KRAKEN2_KRAKEN2 process I also added
touch /tmp/test_nf_core.txt to see wether the process can write to /tmp and this file is also not created. But maybe this is some issue with my server, I will also try it on my laptop now.James Fellows Yates
11/28/2025, 9:25 AMI think implementing this as a general feature for the pipeline will be rather difficult because of the shared use of the daemon, this would go against the process isolation principles of nextflow and hard to implement on a HPC cluster.Not necessarily, I think this should be a useful functionality we could actually implement - as you said database loading is annoying! We just gather multiple FASTQ files into a single process, and loop through them within the process using the same Kraken2 command that has
--use-daemonJames Fellows Yates
11/28/2025, 9:27 AMJames Fellows Yates
11/28/2025, 9:27 AM.command.run file in the work dir of the failing process, and see if that mentions tmp anwyerehLaurenz Holcik
11/28/2025, 9:31 AM--use-daemon flag. Kraken2 will then do this automatically to load it once for all samples, maybe this is the easier way to go.
For my taxprofiler, I don't get an error at all. Kraken2 looks for the /tmp/classify.pid file with a loop and this just goes on indefinitely. So no error, process just never finishes (I guess nextflow timeout at some point).
And yeah thank I did check .command.run and I saw that it creates a tmp directory for the process withing my /tmp/ directory, however this does not affect kraken2 because it doesn't take any environment variables and really just hardcoded the path.James Fellows Yates
11/28/2025, 9:35 AMscratch = varible to /tmp anyway... I don't see how a Nextflow process can isolate that location necessarily š¤Laurenz Holcik
11/28/2025, 9:39 AMJames Fellows Yates
11/28/2025, 9:44 AMJames Fellows Yates
11/28/2025, 9:44 AMJames Fellows Yates
11/28/2025, 9:44 AM/tmp/ but a nf-core pipeline cannotJames Fellows Yates
11/28/2025, 9:45 AM/tmp thing is that I wonder if that will work in containers or not...Laurenz Holcik
11/28/2025, 9:56 AMJames Fellows Yates
11/28/2025, 9:56 AMLaurenz Holcik
02/26/2026, 3:00 PMJames Fellows Yates
02/27/2026, 7:03 AMLaurenz Holcik
02/27/2026, 7:39 AMJames Fellows Yates
02/27/2026, 8:10 AMChris Fields
08/24/2026, 6:51 PM--use-daemon separately for a bit. Iād be happy to help if @Laurenz Holcik is okay with this.James Fellows Yates
08/24/2026, 7:09 PM