Andrea Bagnacani
10/27/2025, 8:48 AMMERGE_BAM_FILES that, among other things, uses nf-core/samtools/merge to merge n BAM input files into one.
Nextflow runs the subworkflow as intended when I provide it 1 or many input BAM files. However, the merging process fails to run under nf-test.
nextflow run:
...
[1e/73a6d8] process > NFCORE_MY_WF:MY_WF:MY_SUBWF:MERGE_BAM_FILES (Biosample-15lines) [100%] 1 of 1 ✔
...
nf-test run:
Nextflow stdout:
ERROR ~ Error executing process > 'NFCORE_MY_WF:MY_WF:MY_SUBWF:MERGE_BAM_FILES (Biosample-15lines)'
Caused by:
Process `NFCORE_MY_WF:MY_WF:MY_SUBWF:MERGE_BAM_FILES (Biosample-15lines)` terminated with an error exit status (1)
Command executed:
# Note: --threads value represents *additional* CPUs to allocate (total CPUs = 1 + --threads).
samtools \
merge \
--threads 1 \
\
\
Biosample-15lines.bam \
1/Biosample-15lines.bam
cat <<-END_VERSIONS > versions.yml
"NFCORE_MY_WF:MY_WF:MY_SUBWF:MERGE_BAM_FILES":
samtools: $(echo $(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*$//')
END_VERSIONS
Command exit status:
1
Command output:
(empty)
Command error:
[E::hts_open_format] Failed to open file "1/Biosample-15lines.bam" : No such file or directory
samtools merge: fail to open "1/Biosample-15lines.bam": No such file or directory
Work dir:
/home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/work/89/53bf46d5477fb39398c9e3423740f6
If I look at the offending path, I see a broken symlink:
$ tree /home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/work/89/53bf46d5477fb39398c9e3423740f6
/home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/work/89/53bf46d5477fb39398c9e3423740f6
└── 1
└── Biosample-15lines.bam -> /home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/tests/inputs/mini/Biosample-15lines.bam
$ ls /home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/tests/inputs/mini/Biosample-15lines.bam
ls: cannot access '/home/user1/src/my_wf/.nf-test/tests/eb83213b17e329329c7a66fe535eecef/tests/inputs/mini/Biosample-15lines.bam': No such file or directory
The meta fields of the tuple that SAMTOOLS_MERGE receives as input look like this:
[[id:Biosample-15lines], [/home/user1/src/my_wf/tests/inputs/mini/Biosample-15lines.bam]]
So it looks like nf-test is not copying the input file /home/user1/src/my_wf/tests/inputs/mini/Biosample-15lines.bam to its .nf-test directory.
I see that the SAMTOOLS_MERGE module stages files as follows:
input:
tuple val(meta), path(input_files, stageAs: "?/*")
Does this have anything to do with the failing nf-test? How can I fix this?
(I use Nextflow 24.04.2 and nf-test 0.9.3)Sateesh_Peri
10/27/2025, 8:50 AMAndrea Bagnacani
10/27/2025, 10:19 AMnextflow_pipeline {
name "Test main.nf workflow"
script "main.nf"
test("Should run the main workflow tests against a minimal set of input data.") {
config "${projectDir}/tests/configs/mini/nextflow.config"
when {
params {
bedfile_scatter_size = 2
}
}
then {
// The workflow runs as expected.
assert workflow.success
}
}
}
The config file that is imported defines the following parameters:
params {
fai = "${projectDir}/path_to_ref_genome/ref_genome.fa.fai"
fasta = "${projectDir}/path_to_ref_genome/ref_genome.fa"
input = "${projectDir}/tests/inputs/mini/samplesheet.csv"
input_dir = "${projectDir}/tests/inputs/mini"
outdir = "${projectDir}/results/mini"
}
The pipeline uses the parameter input = ${projectDir}/tests/inputs/mini/samplesheet.csv to resolve a second file (via substring substitution samplesheet -> samplesheet.sampleName_key). The resolved file ( ${projectDir}/tests/inputs/mini/samplesheet.sampleName_key.csv.) contains the lines:
sampleName,key
Biosample-15lines,tests/inputs/mini/Biosample-15lines.bam
The key column contains the path to the input data tests/inputs/mini/Biosample-15lines.bam, which exists locally.Sateesh_Peri
10/27/2025, 12:47 PMSateesh_Peri
10/27/2025, 12:51 PM.nf-test for the params evaluated