From 238be074580d82944e50c7125f626dd4fc612651 Mon Sep 17 00:00:00 2001 From: Yann Vanrobaeys Date: Fri, 4 Sep 2026 11:50:41 -0400 Subject: [PATCH] Fix Clair3 model download staging when explicit override bypasses auto-detection PREPARE_REFERENCE_FILES computed the WGET/UNTAR staging directory name (meta_new.id) independently from the actual download URL (model): the URL correctly fell back to the samplesheet's explicit clair3_model override when basecall_model_meta didn't match clair3_modelMap, but the staging id did not -- it was only ever clair3_modelMap.get(basecall_model_meta), which resolves to null on any unmapped model. UNTAR then failed with "mkdir: missing operand" because its output directory name came out empty, even though the model itself downloaded successfully under the correct override. This isn't specific to any one basecall model -- it triggers for any sample whose auto-detected basecall_model_meta isn't in clair3_modelMap (currently only dna_r10.4.1_e8.2_*_sup@v4.x/v5.x and hifi_revio are mapped), whether that's because the model genuinely isn't supported yet, or because BAM header metadata is missing/malformed. Hit this validating the SAVANA PR against both public and internal real-world ONT data. Fix: derive meta_new.id from the same resolved `model` value used for the download URL, so an explicit clair3_model override always works regardless of whether the auto-detected model has a modelMap entry. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01DhE7yZ2qRjaG86P7JgZbA4 --- subworkflows/local/prepare_reference_files.nf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/subworkflows/local/prepare_reference_files.nf b/subworkflows/local/prepare_reference_files.nf index efc867d9..8e047fae 100644 --- a/subworkflows/local/prepare_reference_files.nf +++ b/subworkflows/local/prepare_reference_files.nf @@ -49,9 +49,15 @@ workflow PREPARE_REFERENCE_FILES { // Priority: explicit meta.clair3_model param > auto-detected from BAM header via modelMap // PacBio models from HKU mirror; ONT models from Oxford Nanopore CDN basecall_meta.map { meta, basecall_model_meta, _kinetics_meta -> - def id_new = basecall_model_meta ? clair3_modelMap.get(basecall_model_meta) : basecall_model_meta - def meta_new = [id: id_new] + // model resolves to the samplesheet's explicit override first, falling back to the + // modelMap lookup from the auto-detected basecall model. meta_new.id reuses this same + // value (rather than recomputing it from basecall_model_meta alone) so the WGET/UNTAR + // staging directory name never diverges from the model actually being downloaded -- + // previously it could resolve to null (and UNTAR would fail with "mkdir: missing + // operand") whenever basecall_model_meta didn't match the modelMap, even if an + // explicit clair3_model override was given. def model = (!meta.clair3_model || meta.clair3_model.toString().trim() in ['', '[]']) ? clair3_modelMap.get(basecall_model_meta) : meta.clair3_model + def meta_new = [id: model] def download_prefix = ( basecall_model_meta == 'hifi_revio' ? "https://www.bio8.cs.hku.hk/clair3/clair3_models/" : "https://cdn.oxfordnanoportal.com/software/analysis/models/clair3" ) def url = "${download_prefix}/${model}.tar.gz" return [ meta_new, url ]