Skip to content

Commit bdc25ea

Browse files
committed
Support CRAM in the hifitrimmer module
1 parent 0e225fb commit bdc25ea

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

modules/nf-core/hifitrimmer/filterbam/main.nf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ process HIFITRIMMER_FILTERBAM {
2424
def args = task.ext.args ?: ''
2525
def args2 = task.ext.args2 ?: ''
2626
def suffix = args.contains('-f') ? "fastq.gz" : "fasta.gz"
27-
def input_convert = !input.name.endsWith('bam') ? "<(samtools import ${input} ${args2} -@ ${task.cpus})" : input
27+
def input_convert = input.name.endsWith('cram') ? "<(samtools view -u ${args2} -@ ${task.cpus} ${input}" :
28+
!input.name.endsWith('bam') ? "<(samtools import ${input} ${args2} -@ ${task.cpus})" : input
2829
"""
2930
hifi_trimmer filter_bam \\
3031
-t ${task.cpus} \\

modules/nf-core/hifitrimmer/filterbam/tests/main.nf.test

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,33 @@ nextflow_process {
9393
}
9494
}
9595

96+
test("hifi_trimmer filter_bam test - input cram") {
97+
98+
when {
99+
params {
100+
filter_bam_args = ""
101+
}
102+
process {
103+
"""
104+
input[0] = Channel.of(
105+
[
106+
[ id:'test_cram' ], // meta map
107+
file(params.modules_testdata_base_path + '/genomics/eukaryotes/Pipistrellus_nathusii/genome/test.cram', checkIfExists: true),
108+
file(params.modules_testdata_base_path + '/delete_me/hifitrimmer/test.bed.gz', checkIfExists: true)
109+
]
110+
)
111+
"""
112+
}
113+
}
114+
115+
then {
116+
assertAll(
117+
{ assert process.success },
118+
{ assert snapshot(process.out).match() }
119+
)
120+
}
121+
}
122+
96123
test("hifi_trimmer test - stub") {
97124

98125
options "-stub"

modules/nf-core/hifitrimmer/filterbam/tests/main.nf.test.snap

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,61 @@
164164
},
165165
"timestamp": "2026-02-24T13:47:30.864859989"
166166
},
167+
"hifi_trimmer filter_bam test - input cram": {
168+
"content": [
169+
{
170+
"0": [
171+
[
172+
{
173+
"id": "test_cram"
174+
},
175+
"test_cram.fastq.gz:md5,0915fb7cf10a2de8b07a9e0ae81f6316"
176+
]
177+
],
178+
"1": [
179+
[
180+
"HIFITRIMMER_FILTERBAM",
181+
"hifi_trimmer",
182+
"2.2.0"
183+
]
184+
],
185+
"2": [
186+
[
187+
"HIFITRIMMER_FILTERBAM",
188+
"samtools",
189+
"1.23"
190+
]
191+
],
192+
"filtered": [
193+
[
194+
{
195+
"id": "test_bam"
196+
},
197+
"test_cram.fastq.gz:md5,0915fb7cf10a2de8b07a9e0ae81f6316"
198+
]
199+
],
200+
"versions_hifitrimmer": [
201+
[
202+
"HIFITRIMMER_FILTERBAM",
203+
"hifi_trimmer",
204+
"2.2.0"
205+
]
206+
],
207+
"versions_samtools": [
208+
[
209+
"HIFITRIMMER_FILTERBAM",
210+
"samtools",
211+
"1.23"
212+
]
213+
]
214+
}
215+
],
216+
"meta": {
217+
"nf-test": "0.9.3",
218+
"nextflow": "25.10.0"
219+
},
220+
"timestamp": "2026-02-24T13:46:26.986596372"
221+
},
167222
"hifi_trimmer filter_bam test - input bam": {
168223
"content": [
169224
{
@@ -219,4 +274,4 @@
219274
},
220275
"timestamp": "2026-02-24T13:46:26.986596372"
221276
}
222-
}
277+
}

0 commit comments

Comments
 (0)