Skip to content

Commit

Permalink
Added gt/stat (#5577)
Browse files Browse the repository at this point in the history
* Added gt/stat

* Fixed typo in pattern
  • Loading branch information
GallVp committed May 11, 2024
1 parent 28adf00 commit 8798f3d
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/gt/stat/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "gt_stat"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::genometools-genometools=1.6.5"
46 changes: 46 additions & 0 deletions modules/nf-core/gt/stat/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
process GT_STAT {
tag "$meta.id"
label 'process_single'

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

input:
tuple val(meta), path(gff3)

output:
tuple val(meta), path("${prefix}.yml") , emit: stats
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
gt \\
stat \\
$args \\
$gff3 \\
> ${prefix}.yml
cat <<-END_VERSIONS > versions.yml
"${task.process}":
genometools: \$(gt --version | head -1 | sed 's/gt (GenomeTools) //')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.yml
cat <<-END_VERSIONS > versions.yml
"${task.process}":
genometools: \$(gt --version | head -1 | sed 's/gt (GenomeTools) //')
END_VERSIONS
"""
}
46 changes: 46 additions & 0 deletions modules/nf-core/gt/stat/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "gt_stat"
description: "GenomeTools gt-stat utility to show statistics about features contained in GFF3 files"
keywords:
- genome
- gff3
- annotation
- statistics
- stats
tools:
- "gt":
description: "The GenomeTools genome analysis system"
homepage: "https://genometools.org/index.html"
documentation: "https://genometools.org/documentation.html"
tool_dev_url: "https://github.com/genometools/genometools"
doi: "10.1109/TCBB.2013.68"
licence: ["ISC"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test' ]`
- gff3:
type: file
description: Input gff3 file
pattern: "*.{gff,gff3}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test' ]`
- stats:
type: file
description: Stats file in yaml format
pattern: "*.yml"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@GallVp"
maintainers:
- "@GallVp"
62 changes: 62 additions & 0 deletions modules/nf-core/gt/stat/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "gt"
tag "gt/stat"

test("sarscov2-gff3") {

when {
process {
"""
input[0] = Channel.of(
"##gff-version 3" +
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true).text.toLowerCase()
)
.collectFile(name: 'sample.gff3', newLine: true)
.map { file -> [ [ id:'test' ], file ] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert path(process.out.stats[0][1]).text.contains("cdss: 12") }
)
}

}

test("sarscov2-gff3-stub") {

options '-stub'

when {
process {
"""
input[0] = [
[ id: 'test' ],
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.stats != null }, // md5sum for empty files not allowed by nf-core/tools 2.14.0
{ assert snapshot(process.out.versions).match("stub_versions") }
)
}

}

}
47 changes: 47 additions & 0 deletions modules/nf-core/gt/stat/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"sarscov2-gff3": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.yml:md5,ebba7831ddbf916b8bbea675ba8693b5"
]
],
"1": [
"versions.yml:md5,a184b50afb2ad6dd2d3d37b0a211dd71"
],
"stats": [
[
{
"id": "test"
},
"test.yml:md5,ebba7831ddbf916b8bbea675ba8693b5"
]
],
"versions": [
"versions.yml:md5,a184b50afb2ad6dd2d3d37b0a211dd71"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-05-09T19:29:08.925383"
},
"stub_versions": {
"content": [
[
"versions.yml:md5,a184b50afb2ad6dd2d3d37b0a211dd71"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-05-09T19:29:12.808817"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/gt/stat/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gt/stat:
- "modules/nf-core/gt/stat/**"

0 comments on commit 8798f3d

Please sign in to comment.