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
32 changes: 20 additions & 12 deletions modules/nf-core/coverm/contig/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,51 @@ process COVERM_CONTIG {
label "process_medium"

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/coverm:0.7.0--hcb7b614_4' :
'biocontainers/coverm:0.7.0--hcb7b614_4' }"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/c4/c4402aed2ff8bd062a013369c9049e68bdd159e849b271a227a8ce2727e941e1/data'
: 'community.wave.seqera.io/library/coverm:0.7.0--c57cbb9db4d660fb'}"

input:
tuple val(meta), path(input)
tuple val(meta2), path(reference)
val bam_input
val interleaved
val enable_bam_output
Comment on lines 11 to +15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put all these inputs into one tuple? That will make sure you're sure that EVERY time everything comes together in the right combination.

Copy link
Copy Markdown
Member Author

@dialvarezs dialvarezs Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this?

tuple val(meta), path(input), path(reference), val(bam_input), val(interleaved), val(enable_bam_output)

I'm not so sure about that. In my opinion that would introduce extra complexity in the workflows, because you will have to build the channel by joining/combinig all together.
And other similar modules use this pattern too: minimap2, bwa, bowtie. All of them separates the reads, the reference and additional flags as separate inputs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that, we just try to converge more on that because the combine statements make sure that the channels do not get mixed up, but its more of a goal and not something I would enforce here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a bad idea to put most of these as a single input, as they're sample-dependent vals - but presumably enable_bam_output is something you'd want to configure once as a single input?


output:
tuple val(meta), path("*.depth.txt"), emit: coverage
tuple val(meta), path('*.depth.tsv'), emit: coverage
tuple val(meta), path('*.bam') , emit: bam, optional: true
tuple val("${task.process}"), val('coverm'), eval('coverm --version | sed "s/coverm //"'), emit: versions_coverm, topic: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def fastq_input = meta.single_end ? "--single" : interleaved ? "--interleaved" : "--coupled"
def input_type = bam_input ? "--bam-files" : "${fastq_input}"
def reference_str = bam_input ? "" : "--reference ${reference}"
def args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def fastq_input = meta.single_end ? "--single" : interleaved ? "--interleaved" : "--coupled"
def input_type = bam_input ? "--bam-files" : "${fastq_input}"

def reference_str = bam_input ? "" : "--reference ${reference}"
def bam_output_str = enable_bam_output ? "--bam-file-cache-directory _bam_cache/" : ""
"""
TMPDIR=.

coverm contig \\
--threads ${task.cpus} \\
${input_type} ${input} \\
${reference_str} \\
${bam_output_str} \\
${args} \\
--output-file ${prefix}.depth.txt
--output-file ${prefix}.depth.tsv

mv _bam_cache/*.bam . || true
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def prefix = task.ext.prefix ?: "${meta.id}"
Comment thread
dialvarezs marked this conversation as resolved.
"""
touch ${prefix}.depth.txt
touch ${prefix}.depth.tsv
touch ${prefix}.bam
"""
}
36 changes: 28 additions & 8 deletions modules/nf-core/coverm/contig/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ input:
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`

- input:
type: file
description: |
Expand All @@ -32,6 +31,8 @@ input:
pattern: "*.{fa,fq,fa.gz,fq.gz,bam}"
ontologies:
- edam: http://edamontology.org/format_1930 # FASTQ
- edam: http://edamontology.org/format_2572 # BAM

- - meta2:
type: map
description: |
Expand All @@ -40,11 +41,13 @@ input:

- reference:
type: file
description: Reference FASTA file to map reads to, or minimap2/strobealign index.
description: |
Reference FASTA file to map reads to, or minimap2/strobealign index.
Not required if using BAM input.
pattern: "*.{fasta,fasta.gz,mmi,sti}"
ontologies:
- edam: http://edamontology.org/format_1929 # FASTA

ontologies: []
- bam_input:
type: boolean
description: True if input is bam files
Expand All @@ -53,20 +56,37 @@ input:
type: boolean
description: True if input is interleaved fastq file

- enable_bam_output:
type: boolean
description: True to enable BAM output of aligned reads

output:
coverage:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
pattern: "*.depths.{txt}"
- "*.depth.txt":
e.g. `[ id:'sample1' ]`
- "*.depth.tsv":
type: file
description: Tab-delimited file containing coverage information for each contig and sample.
pattern: "*.depth.tsv"
ontologies:
- edam: http://edamontology.org/format_3475 # TSV

bam:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
pattern: "*.depths.{txt}"
e.g. `[ id:'sample1' ]`
- "*.bam":
type: file
description: BAM file containing aligned reads.
pattern: "*.bam"
ontologies:
- edam: http://edamontology.org/format_2572 # BAM

versions_coverm:
- - ${task.process}:
type: string
Expand Down
39 changes: 31 additions & 8 deletions modules/nf-core/coverm/contig/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nextflow_process {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_2.fastq.gz', checkIfExists: true),
Expand All @@ -29,14 +29,24 @@ nextflow_process {
]
input[2] = false
input[3] = false
input[4] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
process.out.coverage,
process.out.bam.collect { meta, bam_files ->
[
meta,
bam_files.collect { file -> bam(file).getReadsMD5() }
]
},
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
}

Expand All @@ -48,24 +58,36 @@ nextflow_process {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/bam/test1.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/bam/test2.sorted.bam', checkIfExists: true)
[ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/bam/test1.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/bam/test2.sorted.bam', checkIfExists: true)
]
]
input[1] = [
[],
[]
]
input[2] = true
input[3] = false
input[4] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
process.out.coverage,
process.out.bam.collect { meta, bam_files ->
[
meta,
bam_files.collect { file -> bam(file).getReadsMD5() }
]
},
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
}

Expand All @@ -79,7 +101,7 @@ nextflow_process {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_2.fastq.gz', checkIfExists: true),
Expand All @@ -91,14 +113,15 @@ nextflow_process {
]
input[2] = false
input[3] = false
input[4] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}

Expand Down
Loading
Loading