storeDir
Use explicit workflow logic instead.
The storeDir directive stores task outputs in a permanent store directory instead of the work directory.
On subsequent runs, each task is executed only if the declared output files do not exist in the store directory. When the files are present, the task is skipped and these files are used as the task outputs.
Usage
The following example shows how to use the storeDir directive to create a directory containing a BLAST database for each species specified by an input parameter:
process make_blast_db {
storeDir '/db/genomes'
input:
path species
output:
path "${dbName}.*"
script:
dbName = species.baseName
"""
makeblastdb -dbtype nucl -in ${species} -out ${dbName}
"""
}
Caveats:
-
The
env,eval, andstdoutoutput qualifiers cannot be used withstoreDirbecause they rely on helper files in the task directory. -
If a process uses
storeDirand all of its outputs are optional, the process is always skipped, even if the store directory is empty. -
The
storeDirdirective is not a replacement for publishing outputs. Use the publishDir directive or workflow outputs instead.
Alternative: Explicit workflow logic
Instead of storeDir, use explicit workflow logic to reuse an intermediate output if it is present and compute it otherwise:
params {
genome: Path
index: Path?
}
workflow {
index = params.index
? channel.value(params.index)
: build_index(params.genome)
align(reads, index)
}
This approach avoids the storeDir limitations described above and makes the caching behavior visible in the workflow logic.