Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion modules/nf-core/rastair2/call/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process RASTAIR2_CALL {
: 'community.wave.seqera.io/library/htslib_rastair:4ffd26b40813e268'}"

input:
tuple val(meta), path(bam), path(index)
tuple val(meta), path(bam), path(index), path(mbias_cutoffs)
tuple val(meta2), path(fasta), path(fai)

output:
Expand All @@ -27,10 +27,17 @@ process RASTAIR2_CALL {
def prefix = task.ext.prefix ?: "${meta.id}"
// Single-end reads carry no pairing flags: strand comes from the alignment direction alone.
def unpaired = meta.single_end ? '--unpaired' : ''
// Bases to ignore at read ends, as suggested by rastair2/mbias: line 1 is --nOT, line 2 --nOB
def cutoffs_files = mbias_cutoffs instanceof List ? mbias_cutoffs : [mbias_cutoffs]
if (cutoffs_files.size() > 1) {
error("rastair2/call takes one M-bias cutoffs file per sample, got ${cutoffs_files.size()}: restrict rastair2/mbias to one contig with --region")
}
def trim = cutoffs_files ? "--nOT \$(sed -n 1p ${mbias_cutoffs}) --nOB \$(sed -n 2p ${mbias_cutoffs})" : ''
"""
rastair call \\
${args} \\
${unpaired} \\
${trim} \\
--threads ${task.cpus} \\
--fasta-file ${fasta} \\
--vcf ${prefix}.vcf.gz \\
Expand Down
9 changes: 9 additions & 0 deletions modules/nf-core/rastair2/call/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ input:
pattern: "*.{bai,csi,crai}"
ontologies:
- edam: "http://edamontology.org/format_3327"
- mbias_cutoffs:
type: file
description: |
Optional. One M-bias cutoffs file from rastair2/mbias (pass `[]` for none).
Line 1 is used as `--nOT` and line 2 as `--nOB`: bases to ignore at the
read ends, as `r1_start,r1_end,r2_start,r2_end`.
pattern: "*.cutoffs.txt"
ontologies:
- edam: "http://edamontology.org/format_3475"
- - meta2:
type: map
description: |
Expand Down
103 changes: 81 additions & 22 deletions modules/nf-core/rastair2/call/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ nextflow_process {
tag "modules_nfcore"
tag "rastair2"
tag "rastair2/call"
tag "rastair2/mbias"

// NOTE The VCF header records the command line (including --threads), so only the #CHROM line
// and records are snapshotted. They are hashed as text because rastair declares Number=M
Expand All @@ -18,12 +19,13 @@ nextflow_process {
when {
process {
"""
input[0] = Channel.of([
input[0] = channel.of([
[ id:'test', single_end:false ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true)
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true),
[]
])
input[1] = Channel.of([
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
Expand All @@ -33,11 +35,11 @@ nextflow_process {
}

then {
assert process.success
assertAll(
{ assert process.success },
{ assert path(process.out.vcf[0][1]).linesGzip.any { it.startsWith('##rastairVersion=') } },
{ assert path(process.out.vcf[0][1]).linesGzip.any { line -> line.startsWith('##rastairVersion=') } },
{ assert snapshot(
path(process.out.vcf[0][1]).linesGzip.findAll { !it.startsWith('##') }.join('\n').md5(),
path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('##') }.join('\n').md5(),
process.out.tbi.collect { meta, tbi -> file(tbi).name },
process.out.bed,
process.out.bed_tbi.collect { meta, tbi -> file(tbi).name },
Expand All @@ -52,12 +54,13 @@ nextflow_process {
when {
process {
"""
input[0] = Channel.of([
input[0] = channel.of([
[ id:'test', single_end:true ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.single_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.single_end.sorted.bam.bai', checkIfExists: true)
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.single_end.sorted.bam.bai', checkIfExists: true),
[]
])
input[1] = Channel.of([
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
Expand All @@ -67,11 +70,11 @@ nextflow_process {
}

then {
assert process.success
assertAll(
{ assert process.success },
{ assert path(process.out.vcf[0][1]).linesGzip.any { it.startsWith('##rastairCommand=') && it.contains('--unpaired') } },
{ assert path(process.out.vcf[0][1]).linesGzip.any { line -> line.startsWith('##rastairCommand=') && line.contains('--unpaired') } },
{ assert snapshot(
path(process.out.vcf[0][1]).linesGzip.findAll { !it.startsWith('##') }.join('\n').md5(),
path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('##') }.join('\n').md5(),
process.out.tbi.collect { meta, tbi -> file(tbi).name },
process.out.bed,
process.out.bed_tbi.collect { meta, tbi -> file(tbi).name },
Expand All @@ -86,12 +89,13 @@ nextflow_process {
when {
process {
"""
input[0] = Channel.of([
input[0] = channel.of([
[ id:'test', single_end:false ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai', checkIfExists: true)
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai', checkIfExists: true),
[]
])
input[1] = Channel.of([
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)
Expand All @@ -101,11 +105,65 @@ nextflow_process {
}

then {
assert process.success
assertAll(
{ assert process.success },
{ assert path(process.out.vcf[0][1]).linesGzip.any { !it.startsWith('#') } },
{ assert path(process.out.vcf[0][1]).linesGzip.any { line -> !line.startsWith('#') } },
{ assert snapshot(
path(process.out.vcf[0][1]).linesGzip.findAll { !it.startsWith('##') }.join('\n').md5(),
path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('##') }.join('\n').md5(),
process.out.tbi.collect { meta, tbi -> file(tbi).name },
process.out.bed,
process.out.bed_tbi.collect { meta, tbi -> file(tbi).name },
process.out.findAll { key, val -> key.startsWith("versions") }
).match() }
)
}
}

test("sarscov2 - paired-end methylated bam - mbias cutoffs") {

setup {
run("RASTAIR2_MBIAS") {
script "../../mbias/main.nf"
process {
"""
input[0] = channel.of([
[ id:'test', single_end:false ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true)
])
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
])
"""
}
}
}

when {
process {
"""
input[0] = channel.of([
[ id:'test', single_end:false ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true)
]).join(RASTAIR2_MBIAS.out.cutoffs)
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
])
"""
}
}

then {
assert process.success
assertAll(
{ assert path(process.out.vcf[0][1]).linesGzip.any { line -> line.startsWith('##rastairCommand=') && line.contains('--nOT') && line.contains('--nOB') } },
{ assert snapshot(
path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('##') }.join('\n').md5(),
process.out.tbi.collect { meta, tbi -> file(tbi).name },
process.out.bed,
process.out.bed_tbi.collect { meta, tbi -> file(tbi).name },
Expand All @@ -122,12 +180,13 @@ nextflow_process {
when {
process {
"""
input[0] = Channel.of([
input[0] = channel.of([
[ id:'test', single_end:false ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true)
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.methylated.sorted.bam.bai', checkIfExists: true),
[]
])
input[1] = Channel.of([
input[1] = channel.of([
[ id:'genome' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
Expand All @@ -137,8 +196,8 @@ nextflow_process {
}

then {
assert process.success
assertAll(
{ assert process.success },
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}
Expand Down
41 changes: 41 additions & 0 deletions modules/nf-core/rastair2/call/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,47 @@
"nextflow": "26.10.5"
}
},
"sarscov2 - paired-end methylated bam - mbias cutoffs": {
"content": [
"d1630262a4ab6255e9e441e6857e746f",
[
"test.vcf.gz.tbi"
],
[
[
{
"id": "test",
"single_end": false
},
"test.bed.gz:md5,ed8237adc7795a7485dab20c69146675"
]
],
[
"test.bed.gz.tbi"
],
{
"versions_rastair": [
[
"RASTAIR2_CALL",
"rastair",
"2.2.0"
]
],
"versions_tabix": [
[
"RASTAIR2_CALL",
"tabix",
"1.24"
]
]
}
],
"timestamp": "2026-11-10T10:58:57.116513",
"meta": {
"nf-test": "0.9.5",
"nextflow": "26.10.5"
}
},
"sarscov2 - single-end bam": {
"content": [
"1b3f2f0fde4de41a51853252c8ba063f",
Expand Down
Loading
Loading