From b8b1f3f9156fa6f2b3b1e0f1158a0b7fb8dd31c1 Mon Sep 17 00:00:00 2001 From: BenjaminWehnert1008 Date: Wed, 28 Oct 2026 16:44:09 +0100 Subject: [PATCH] Resolve the BWA index prefix without find(1) MERGE_ALIGN failed with exit 127 and ".command.sh: line 2: find: command not found" on both real-data shards of -profile singularity, the first time that leg has ever run (conda and singularity are excluded from the matrix unless a PR targets master, so #54 is the first PR to exercise them). Seqera Containers builds the two variants of the same conda spec on different userlands: the Docker image of bwa_samtools_vsearch is Ubuntu 24.04 based and carries /usr/bin/find, while the Singularity image is built from mambaorg/micromamba:2-amazon2023, whose base ships no findutils. Wave's own build script already patches around the same gap for `which`. Of everything this module calls, only find is affected - sed, awk, cat, mv and head are all present in that base, which is also why BWA_INDEX (mkdir) succeeded. Globbing with bash parameter expansion needs no external binary, and this was the only find(1) call site in the repository. The leading ./ is kept deliberately: find printed ./bwa/.amb, so $INDEX was ./bwa/, and bwa records that string in the BAM's @PG header. Dropping it would change every sorted BAM's md5 and move the nf-test snapshot for no reason. Verified against the old command: both yield ./bwa/GID1A. An empty index directory now fails with a clear message instead of passing a literal glob to bwa mem. --- modules/local/bamprocessing/merge_align/main.nf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/local/bamprocessing/merge_align/main.nf b/modules/local/bamprocessing/merge_align/main.nf index cc2170f..8a17a38 100644 --- a/modules/local/bamprocessing/merge_align/main.nf +++ b/modules/local/bamprocessing/merge_align/main.nf @@ -27,7 +27,20 @@ process MERGE_ALIGN { def args2 = task.ext.args2 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" """ - INDEX=`find -L ./ -name "*.amb" | sed 's/\\.amb\$//'` + # The BWA index prefix, resolved with a glob and bash parameter expansion instead of `find`. + # Seqera Containers builds the Docker image of a conda spec on an Ubuntu base but the + # Singularity image on an Amazon Linux 2023 one, and that base ships no findutils, so the usual + # `find -L ./ -name "*.amb"` fails with exit 127 under -profile singularity. Globbing needs no + # external binary. The leading ./ is kept so the prefix, which bwa records in the BAM's @PG + # header, stays exactly what find returned. + INDEX='' + for amb in ./${index}/*.amb; do + if [ -e "\$amb" ]; then INDEX="\${amb%.amb}"; fi + done + if [ -z "\$INDEX" ]; then + echo "No BWA index (*.amb) found in './${index}'" >&2 + exit 1 + fi # Merge the overlapping mates of each raw read pair into one consensus read, so the overlap is # counted once and its bases carry a recalculated quality. Merging comes first, before any