forked from nf-core/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added gt/gff3validator (nf-core#4718)
* Added gt/gff3validator * Make error handling a bit more intuitive * Fixed a problem with info echo and simplified test assertions --------- Co-authored-by: Leon Rauschning <99650940+lrauschning@users.noreply.github.com>
- Loading branch information
1 parent
8ce34a4
commit 5ed10bd
Showing
7 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_gff3validator" | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
- defaults | ||
dependencies: | ||
- "bioconda::genometools-genometools=1.6.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
process GT_GFF3VALIDATOR { | ||
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('*.success.log') , emit: success_log , optional: true | ||
tuple val(meta), path('*.error.log') , emit: error_log , optional: true | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
gt \\ | ||
gff3validator \\ | ||
"$gff3" \\ | ||
> "${prefix}.stdout" \\ | ||
2> >(tee "${prefix}.stderr" >&2) \\ | ||
|| echo "Errors from gt-gff3validator printed to ${prefix}.error.log" | ||
if grep -q "input is valid GFF3" "${prefix}.stdout"; then | ||
echo "Validation successful..." | ||
# emit stdout to the success output channel | ||
mv \\ | ||
"${prefix}.stdout" \\ | ||
"${prefix}.success.log" | ||
else | ||
echo "Validation failed..." | ||
# emit stderr to the error output channel | ||
mv \\ | ||
"${prefix}.stderr" \\ | ||
"${prefix}.error.log" | ||
fi | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
genometools: \$(gt --version | head -1 | sed 's/gt (GenomeTools) //') | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
touch "${prefix}.success.log" | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
genometools: \$(gt --version | head -1 | sed 's/gt (GenomeTools) //') | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json | ||
name: "gt_gff3validator" | ||
description: "GenomeTools gt-gff3validator utility to strictly validate a GFF3 file" | ||
keywords: | ||
- genome | ||
- gff3 | ||
- annotation | ||
- validation | ||
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' ]` | ||
- success_log: | ||
type: file | ||
description: Log file for successful validation | ||
pattern: "*.success.log" | ||
- error_log: | ||
type: file | ||
description: Log file for failed validation | ||
pattern: "*.error.log" | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
authors: | ||
- "@GallVp" | ||
maintainers: | ||
- "@GallVp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
nextflow_process { | ||
|
||
name "Test Process GT_GFF3VALIDATOR" | ||
script "../main.nf" | ||
process "GT_GFF3VALIDATOR" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "gt" | ||
tag "gt/gff3validator" | ||
tag "gt/gff3" | ||
|
||
test("sarscov2-gff3-valid") { | ||
|
||
config './nextflow.config' | ||
|
||
setup { | ||
run("GT_GFF3") { | ||
script "../../../../nf-core/gt/gff3" | ||
|
||
process { | ||
""" | ||
input[0] = [ | ||
[ id:'test' ], | ||
file(params.test_data['sarscov2']['genome']['genome_gff3'], checkIfExists: true) | ||
] | ||
""" | ||
} | ||
} | ||
} | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = GT_GFF3.out.gt_gff3 | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() }, | ||
{ assert path(process.out.success_log[0][1]).text.contains("input is valid GFF3") }, | ||
{ assert process.out.error_log == [] } | ||
) | ||
} | ||
|
||
} | ||
|
||
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 snapshot(process.out).match() } | ||
) | ||
} | ||
|
||
} | ||
|
||
test("sarscov2-gff3-invalid") { | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = [ | ||
[ id:'test' ], // meta map | ||
file(params.test_data['homo_sapiens']['genome']['genome_gff3'], checkIfExists: true) | ||
] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() }, | ||
{ assert process.out.success_log == [] }, | ||
{ assert path(process.out.error_log[0][1]).text.contains("gt gff3validator: error:") } | ||
) | ||
} | ||
|
||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
modules/nf-core/gt/gff3validator/tests/main.nf.test.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
process { | ||
withName: GT_GFF3 { | ||
ext.args = '-tidy -retainids' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gt/gff3validator: | ||
- "modules/nf-core/gt/gff3validator/**" |