I was thinking about giving a solution to re-use l...
# help
d
I was thinking about giving a solution to re-use local reference databases that are given as remote resource: If there is a directory for reference storage given, then check if there is already a local copy of a database, use that instead of re-downloading, otherwise download it and use. Here how I thought this could work conceptually (code not tested, might not work):
Copy code
params_ref_url = "url/to/reference/database/file"
params_ref_storage = "path/to/local_dir" // default: ""

file_in_ref_storage = "${params_ref_storage}/${file(params_ref_url).name.toString()}"
if ( !params_ref_storage ) {
	// no reference storage used
 	ch_ref = channel.fromPath( params_ref_url )
} else if ( file( file_in_ref_storage ).exists() ) {
	// if file already stored
 	ch_ref = channel.fromPath( file_in_ref_storage )
} else {
	// if file not yet stored
	file( params_ref_storage ).mkdir()
 	file( params_ref_url ).copyTo( params_ref_storage )
 	ch_ref = channel.fromPath( file_in_ref_storage )
}
Is somewhere already a solution to it? Might that mess with -resume?
m
Use
storeDir
Copy code
params.ref_url = "<https://url/to/reference/database/file.fa.gz>"
params.ref_storage = "/path/to/local_dir" // default: ""

process DOWNLOAD_REFERENCE {
    storeDir params.ref_storage ?: "${launchDir}/reference_store"
    
    input:
    val ref_url
    
    output:
    path "${local_filename}"
    
    script:
    local_filename = file(ref_url).name
    """
    wget -O "${local_filename}" "${ref_url}"
    # or use curl:
    # curl -L -o ${local_filename} ${ref_url}
    """
}
d
Hm that seems indeed better, will try that out!
Thanks!