Skip to content

Commit 0102cae

Browse files
edmundmillerchaochaowong
authored andcommitted
fix: Improve samtools flagstat stub to generate realistic output (nf-core#9064)
* fix: Improve samtools flagstat stub to generate realistic output - Replace empty touch command with proper flagstat format in stub - Include realistic read counts and mapping statistics - Ensure stub output matches expected flagstat format for parsing - Critical for pipelines that parse flagstat files for scale factors - Enables proper testing of downstream processes in stub workflows The previous stub created empty files that caused parsing failures when processes attempted to extract mapped read counts from flagstat output. This change provides realistic flagstat content that matches the format of actual samtools flagstat output. * test: Update samtools flagstat snapshots with current versions - Regenerate snapshots to match current samtools version (1.22.1) - Fix versions.yml checksum mismatch - Ensure tests pass with updated container versions * test: Update bam_stats_samtools snapshots for improved flagstat stub - Update subworkflow snapshots to match realistic flagstat content - Fix stub test failures caused by empty file → realistic content change - All flagstat checksums updated from d41d8cd98f00b204e9800998ecf8427e to 67394650dbae96d1a4fcc70484822159 - Ensures consistency between module and subworkflow test expectations * test: Fix samtools flagstat snapshots for CI environment - Update versions.yml checksums to match CI Docker environment - Use bdc0bfb2b0542580e7cd65e80d8570bc instead of 108a155f2d4a99f50bf3176904208d27 - Keep realistic flagstat content checksums (67394650dbae96d1a4fcc70484822159 for stub) - Ensures tests pass in both local and CI environments * test: Update bam_stats_samtools snapshots with Docker profile - Regenerate snapshots using Docker containers to match CI environment - All 6 subworkflow tests pass with updated version checksums - Ensures consistency between local and CI test environments
1 parent b808fa2 commit 0102cae

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

modules/nf-core/samtools/flagstat/main.nf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ process SAMTOOLS_FLAGSTAT {
3535
stub:
3636
def prefix = task.ext.prefix ?: "${meta.id}"
3737
"""
38-
touch ${prefix}.flagstat
38+
cat <<-END_FLAGSTAT > ${prefix}.flagstat
39+
1000000 + 0 in total (QC-passed reads + QC-failed reads)
40+
0 + 0 secondary
41+
0 + 0 supplementary
42+
0 + 0 duplicates
43+
900000 + 0 mapped (90.00% : N/A)
44+
1000000 + 0 paired in sequencing
45+
500000 + 0 read1
46+
500000 + 0 read2
47+
800000 + 0 properly paired (80.00% : N/A)
48+
850000 + 0 with mate mapped to a different chr
49+
50000 + 0 with mate mapped to a different chr (mapQ>=5)
50+
END_FLAGSTAT
3951
4052
cat <<-END_VERSIONS > versions.yml
4153
"${task.process}":

modules/nf-core/samtools/flagstat/tests/main.nf.test.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": "test",
99
"single_end": false
1010
},
11-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
11+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
1212
]
1313
],
1414
"1": [
@@ -20,7 +20,7 @@
2020
"id": "test",
2121
"single_end": false
2222
},
23-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
23+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
2424
]
2525
],
2626
"versions": [
@@ -32,7 +32,7 @@
3232
"nf-test": "0.9.2",
3333
"nextflow": "25.04.6"
3434
},
35-
"timestamp": "2025-09-10T13:31:17.098789"
35+
"timestamp": "2025-09-15T15:02:00.813612"
3636
},
3737
"BAM": {
3838
"content": [
@@ -67,6 +67,6 @@
6767
"nf-test": "0.9.2",
6868
"nextflow": "25.04.6"
6969
},
70-
"timestamp": "2025-09-10T13:31:12.661288"
70+
"timestamp": "2025-09-15T15:01:55.232954"
7171
}
7272
}

subworkflows/nf-core/bam_stats_samtools/tests/main.nf.test.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"id": "test",
1818
"single_end": true
1919
},
20-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
20+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
2121
]
2222
],
2323
"2": [
@@ -40,7 +40,7 @@
4040
"id": "test",
4141
"single_end": true
4242
},
43-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
43+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
4444
]
4545
],
4646
"idxstats": [
@@ -72,7 +72,7 @@
7272
"nf-test": "0.9.2",
7373
"nextflow": "25.04.6"
7474
},
75-
"timestamp": "2025-09-10T13:37:48.492968"
75+
"timestamp": "2025-09-15T15:20:35.417926"
7676
},
7777
"test_bam_stats_samtools_single_end - stub": {
7878
"content": [
@@ -92,7 +92,7 @@
9292
"id": "test",
9393
"single_end": true
9494
},
95-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
95+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
9696
]
9797
],
9898
"2": [
@@ -115,7 +115,7 @@
115115
"id": "test",
116116
"single_end": true
117117
},
118-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
118+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
119119
]
120120
],
121121
"idxstats": [
@@ -147,7 +147,7 @@
147147
"nf-test": "0.9.2",
148148
"nextflow": "25.04.6"
149149
},
150-
"timestamp": "2025-09-10T13:37:43.4053"
150+
"timestamp": "2025-09-15T15:20:25.439222"
151151
},
152152
"test_bam_stats_samtools_paired_end_cram - stub": {
153153
"content": [
@@ -167,7 +167,7 @@
167167
"id": "test",
168168
"single_end": false
169169
},
170-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
170+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
171171
]
172172
],
173173
"2": [
@@ -190,7 +190,7 @@
190190
"id": "test",
191191
"single_end": false
192192
},
193-
"test.flagstat:md5,d41d8cd98f00b204e9800998ecf8427e"
193+
"test.flagstat:md5,67394650dbae96d1a4fcc70484822159"
194194
]
195195
],
196196
"idxstats": [
@@ -222,7 +222,7 @@
222222
"nf-test": "0.9.2",
223223
"nextflow": "25.04.6"
224224
},
225-
"timestamp": "2025-09-10T13:37:53.52248"
225+
"timestamp": "2025-09-15T15:20:46.02738"
226226
},
227227
"test_bam_stats_samtools_single_end": {
228228
"content": [
@@ -263,7 +263,7 @@
263263
"nf-test": "0.9.2",
264264
"nextflow": "25.04.6"
265265
},
266-
"timestamp": "2025-09-10T13:37:27.672053"
266+
"timestamp": "2025-09-15T15:20:00.064679"
267267
},
268268
"test_bam_stats_samtools_paired_end": {
269269
"content": [
@@ -304,7 +304,7 @@
304304
"nf-test": "0.9.2",
305305
"nextflow": "25.04.6"
306306
},
307-
"timestamp": "2025-09-10T13:37:32.985079"
307+
"timestamp": "2025-09-15T15:20:08.141202"
308308
},
309309
"test_bam_stats_samtools_paired_end_cram": {
310310
"content": [
@@ -345,6 +345,6 @@
345345
"nf-test": "0.9.2",
346346
"nextflow": "25.04.6"
347347
},
348-
"timestamp": "2025-09-10T13:37:38.347584"
348+
"timestamp": "2025-09-15T15:20:16.06318"
349349
}
350350
}

0 commit comments

Comments
 (0)