Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new module: PERBASE #7457

Merged
merged 9 commits into from
Feb 18, 2025
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
7 changes: 7 additions & 0 deletions modules/nf-core/perbase/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::perbase=0.10.2
52 changes: 52 additions & 0 deletions modules/nf-core/perbase/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
process PERBASE {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/perbase:0.10.2--h15397dd_0':
'biocontainers/perbase:0.10.2--h15397dd_0' }"

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

output:
tuple val(meta), path("*.tsv.gz"), emit: tsv
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Harshil alignment here would be great

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be applied in the module template upstream?
https://github.com/nf-core/tools/blob/main/nf_core/module-template/main.nf

def prefix = task.ext.prefix ?: "${meta.id}"
def reference = fasta ? "--ref-fasta ${fasta}" : ""
"""
perbase \\
base-depth \\
$bam \\
$args \\
$reference \\
--threads $task.cpus \\
--bgzip \\
--output ${prefix}.tsv.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
perbase: \$(perbase --version |& sed '1!d ; s/perbase //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be applied in the module template upstream?
https://github.com/nf-core/tools/blob/main/nf_core/module-template/main.nf

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly, I need to discuss this with core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I can look at opening a PR if needed.

"""
echo "" | gzip > ${prefix}.tsv.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
perbase: \$(perbase --version |& sed '1!d ; s/perbase //')
END_VERSIONS
"""
}
77 changes: 77 additions & 0 deletions modules/nf-core/perbase/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "perbase"
description: Per-base metrics on BAM/CRAM files.
keywords:
- bam
- cram
- depth
tools:
- "perbase":
description: "Per-base metrics on BAM/CRAM files."
homepage: "https://github.com/sstadick/perbase/blob/v0.10.2/README.md"
documentation: "https://github.com/sstadick/perbase/blob/v0.10.2/README.md"
tool_dev_url: "https://github.com/sstadick/perbase"
licence: ["MIT"]
identifier: biotools:perbase

input:
# Only when we have meta
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please confirm that single_end is relevant here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is from the nf-core module template, but I believe it's still relevant here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, thanks

- bam:
type: file
description: Sorted BAM/CRAM file
pattern: "*.{bam,cram}"
ontologies:
- edam: "http://edamontology.org/format_25722"
- edam: "http://edamontology.org/format_3462"

- index:
type: file
description: BAI/CRAI file
pattern: "*.{bai,crai}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there no suitable index format on EDAM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is for BAI: https://edamontology.github.io/edam-browser/#format_3327
CRAI is still to be added: edamontology/edamontology#835
It looks like there are more general index entries too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add the best fit for each entry? It will make life easier for some people

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the ontology for BAI.

The parent Data index format sounded the most appropriate, but has the notRecommendedForAnnotation attribute as it is a placeholder concept, rather than a specific file format.

ontologies:
- edam: "http://edamontology.org/format_3327"
- - meta2:
type: map
description: |
Groovy Map containing reference information
e.g. [ id:'genome' ]
- fasta:
type: file
description: Reference fasta (optional)
pattern: "*.{fasta,fa}"
ontologies:
- edam: "http://edamontology.org/format_1929"
- fai:
type: file
description: FAI file (optional)
pattern: "*.{fai}"
output:
- tsv:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.tsv.gz":
type: file
description: TSV file
pattern: "*.{tsv.gz}"
ontologies:
- edam: "http://edamontology.org/format_3475"

- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@camlloyd"
maintainers:
- "@camlloyd"
126 changes: 126 additions & 0 deletions modules/nf-core/perbase/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
nextflow_process {

name "Test Process PERBASE"
script "../main.nf"
process "PERBASE"

tag "modules"
tag "modules_nfcore"
tag "perbase"

test("homo_sapiens - illumina - cram") {


when {
process {
"""

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.recalibrated.sorted.cram', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.recalibrated.sorted.cram.crai', checkIfExists: true),
]
input[1] = [
[ id:'genome' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true)

]
"""
}
}

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

}

test("homo_sapiens - illumina - cram - stub") {

options "-stub"

when {
process {
"""

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.recalibrated.sorted.cram', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.recalibrated.sorted.cram.crai', checkIfExists: true)
]
input[1] = [
[ id:'genome' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true)
]
"""
}
}

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

}

test("homo_sapiens - illumina - bam") {


when {
process {
"""

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true)
]
input[1] = [[],[],[]]
"""
}
}

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

}

test("homo_sapiens - illumina - bam - stub") {

options "-stub"

when {
process {
"""

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true)
]
input[1] = [[],[],[]]
"""
}
}

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

}

}
Loading
Loading