Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fellen31 committed Feb 14, 2025
1 parent c148d20 commit 161a736
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 89 deletions.
6 changes: 3 additions & 3 deletions modules/nf-core/samtools/view/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ process SAMTOOLS_VIEW {
args.contains("--output-fmt cram") ? "cram" :
input.getExtension()

output_file = index_format ? "${prefix}.${file_type}##idx##${prefix}.${file_type}.${index_format}" : "${prefix}.${file_type}"
output_file = index_format ? "${prefix}.${file_type}##idx##${prefix}.${file_type}.${index_format} --write-index" : "${prefix}.${file_type}"
// Can't choose index type of unselected file
readnames = qname ? "--qname-file ${qname} --output-unselected ${prefix}.unselected.${file_type}": ""

Expand Down Expand Up @@ -76,10 +76,10 @@ process SAMTOOLS_VIEW {
default_index_format =
file_type == "bam" ? "csi" :
file_type == "cram" ? "crai" : ""
index = args.contains("--write-index") && index_format ? "touch ${prefix}.${file_type}.${index_format}" : args.contains("--write-index") ? "touch ${prefix}.${file_type}.${default_index_format}" : ""
index = index_format ? "touch ${prefix}.${file_type}.${index_format}" : args.contains("--write-index") ? "touch ${prefix}.${file_type}.${default_index_format}" : ""
unselected = qname ? "touch ${prefix}.unselected.${file_type}" : ""
// Can't choose index type of unselected file
unselected_index = qname && args.contains("--write-index") ? "touch ${prefix}.unselected.${file_type}.${default_index_format}" : ""
unselected_index = qname && (args.contains("--write-index") || index_format) ? "touch ${prefix}.unselected.${file_type}.${default_index_format}" : ""

if ("$input" == "${prefix}.${file_type}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
if (index_format) {
Expand Down
14 changes: 14 additions & 0 deletions subworkflows/nf-core/bam_split_by_region/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// IMPORTANT: Add this configuration to your modules.config

process {
withName: ".*BAM_SPLIT_BY_REGION:SAMTOOLS_VIEW" {
ext.args2 = {
[
"${meta.genomic_region}", // Specifies the chromosome name used for splitting the input bam file.
].join(' ').trim()
}

ext.prefix = { "${meta.id}_${meta.genomic_region}" }
}

}
31 changes: 28 additions & 3 deletions subworkflows/nf-core/bam_split_by_region/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,37 @@ nextflow_workflow {
assertAll(
{ assert workflow.success },
{ assert snapshot(
workflow.out.bam_bai.findAll { file(it.get(1)).name }.toSorted(),
workflow.out.bam_bai.findAll { bam(it.get(1)).getReadsMD5() }.toSorted(),
workflow.out.bam_bai.findAll { file(it.get(2)).name }.toSorted(),
workflow.out.bam_bai.toSorted { a, b -> file(a.get(1)).name <=> file(b.get(1)).name }.collect { file(it.get(1)).name },
workflow.out.bam_bai.toSorted { a, b -> file(a.get(1)).name <=> file(b.get(1)).name }.collect { bam(it.get(1)).getReadsMD5() },
workflow.out.bam_bai.toSorted { a, b -> file(a.get(1)).name <=> file(b.get(1)).name }.collect { file(it.get(2)).name },
workflow.out.versions
).match() }
)
}
}

test("homo_sapiens - test_paired_end_markduplicates_sorted_bam - stub") {

options "-stub"

when {
workflow {
"""
input[0] = Channel.of([
[ id: 'test', single_end: false ],
file(params.modules_testdata_base_path +'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path +'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path +'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true),
])
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
)
}
}
}
169 changes: 87 additions & 82 deletions subworkflows/nf-core/bam_split_by_region/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,19 @@
"homo_sapiens - test_paired_end_markduplicates_sorted_bam": {
"content": [
[
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:24132499-24910998"
},
"test_chr21:24132499-24910998.bam:md5,649908006f4333ef13e42313e0885d96",
"test_chr21:24132499-24910998.bam.bai:md5,0d76977b2e36046cc176112776c5fa4e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:25689497-46709983"
},
"test_chr21:25689497-46709983.bam:md5,c4bc65ad94bde9cc901d33e964a977c6",
"test_chr21:25689497-46709983.bam.bai:md5,834238b87a13404627fecaa1ed7ae4f4"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:1-23354000"
},
"test_chr21:1-23354000.bam:md5,e17b22b80b4ba098232f12a3cb612c73",
"test_chr21:1-23354000.bam.bai:md5,adbf2a0b95a947c055c219f0d950add0"
]
"test_chr21:1-23354000.bam",
"test_chr21:24132499-24910998.bam",
"test_chr21:25689497-46709983.bam"
],
[
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:24132499-24910998"
},
"test_chr21:24132499-24910998.bam:md5,649908006f4333ef13e42313e0885d96",
"test_chr21:24132499-24910998.bam.bai:md5,0d76977b2e36046cc176112776c5fa4e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:25689497-46709983"
},
"test_chr21:25689497-46709983.bam:md5,c4bc65ad94bde9cc901d33e964a977c6",
"test_chr21:25689497-46709983.bam.bai:md5,834238b87a13404627fecaa1ed7ae4f4"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:1-23354000"
},
"test_chr21:1-23354000.bam:md5,e17b22b80b4ba098232f12a3cb612c73",
"test_chr21:1-23354000.bam.bai:md5,adbf2a0b95a947c055c219f0d950add0"
]
"a2288aed3c12eb43e20164dc85787fad",
"d41d8cd98f00b204e9800998ecf8427e",
"831a9c955bc0fbfe24da0b16ffee4365"
],
[
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:24132499-24910998"
},
"test_chr21:24132499-24910998.bam:md5,649908006f4333ef13e42313e0885d96",
"test_chr21:24132499-24910998.bam.bai:md5,0d76977b2e36046cc176112776c5fa4e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:25689497-46709983"
},
"test_chr21:25689497-46709983.bam:md5,c4bc65ad94bde9cc901d33e964a977c6",
"test_chr21:25689497-46709983.bam.bai:md5,834238b87a13404627fecaa1ed7ae4f4"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:1-23354000"
},
"test_chr21:1-23354000.bam:md5,e17b22b80b4ba098232f12a3cb612c73",
"test_chr21:1-23354000.bam.bai:md5,adbf2a0b95a947c055c219f0d950add0"
]
"test_chr21:1-23354000.bam.bai",
"test_chr21:24132499-24910998.bam.bai",
"test_chr21:25689497-46709983.bam.bai"
],
[
"versions.yml:md5,022ce36c7637b4c28f9e7a3b6d788543",
Expand All @@ -97,6 +25,83 @@
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-14T08:59:50.32521715"
"timestamp": "2025-02-14T09:29:31.729957588"
},
"homo_sapiens - test_paired_end_markduplicates_sorted_bam - stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:1-23354000"
},
"test_chr21:1-23354000.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:1-23354000.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:24132499-24910998"
},
"test_chr21:24132499-24910998.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:24132499-24910998.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:25689497-46709983"
},
"test_chr21:25689497-46709983.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:25689497-46709983.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,022ce36c7637b4c28f9e7a3b6d788543",
"versions.yml:md5,1430b8967dea6b0eb5a65313c8d81e81"
],
"bam_bai": [
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:1-23354000"
},
"test_chr21:1-23354000.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:1-23354000.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:24132499-24910998"
},
"test_chr21:24132499-24910998.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:24132499-24910998.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "test",
"single_end": false,
"genomic_region": "chr21:25689497-46709983"
},
"test_chr21:25689497-46709983.bam:md5,d41d8cd98f00b204e9800998ecf8427e",
"test_chr21:25689497-46709983.bam.bai:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,022ce36c7637b4c28f9e7a3b6d788543",
"versions.yml:md5,1430b8967dea6b0eb5a65313c8d81e81"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-02-14T09:01:38.813440955"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ workflow FASTQ_CREATE_UMI_CONSENSUS_FGBIO {
// using the above created groups, a consensus across reads in the same group
// can be called
// this will emit a consensus BAM file
CALLUMICONSENSUS ( GROUPREADSBYUMI.out.bam )
CALLUMICONSENSUS ( GROUPREADSBYUMI.out.bam, [], [])
ch_versions = ch_versions.mix(CALLUMICONSENSUS.out.versions)
consensus_bam = CALLUMICONSENSUS.out.bam
}
Expand Down

0 comments on commit 161a736

Please sign in to comment.