Skip to content
Open
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/ensembl/features/red/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
channels:
- conda-forge
- bioconda

dependencies:
- red=2018.09.10
67 changes: 67 additions & 0 deletions modules/ensembl/features/red/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// See the NOTICE file distributed with this work for additional information
// regarding copyright ownership.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

process FEATURES_RED {
tag "${meta.id}"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "quay.io/biocontainers/red:2018.09.10--h9948957_3"

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

output:
tuple val(meta), path("rpt/*.bed"), emit: bed
tuple val("${task.process}"), val('red'), eval("conda list red --json | python -c 'import sys,json; print(json.load(sys.stdin)[0][\"version\"])' || echo 2.0"), emit: versions_red, topic: versions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tuple val("${task.process}"), val('red'), eval("conda list red --json | python -c 'import sys,json; print(json.load(sys.stdin)[0][\"version\"])' || echo 2.0"), emit: versions_red, topic: versions
tuple val("${task.process}"), val('red'), eval("conda list red --json | jq -r '.version' || echo 2.0"), emit: versions_red, topic: versions

Not sure if this will work, but sounds less overkilling than loading Python to just extract the version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having looked into this, we could maybe use jq -r '.[0].version' but I think I'm inclined to stick with Python unless you strongly feel otherwise. From what I can gather, many nf-core modules use small Python one-liners to parse JSON since it is considered part of the expected runtime environment, whereas jq is not. Therefore, this seems like the more portable option.


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

script:
def args = task.ext.args ?: ''

def reserved = ['-gnm', '-rpt', '-msk', '-frm', '-cor']
def supplied = args.tokenize()

supplied.each { opt ->
if (opt in reserved) {
error "FEATURES_RED: ${opt} is managed by the module and must not be supplied via task.ext.args."
}
}

"""
mkdir -p genome rpt

# Red only processes .fa files in the genome directory
ln -snf \$(realpath "${fasta}") genome/${meta.id}.fa

Red \
-gnm genome \
-rpt rpt \
-cor ${task.cpus} \
-frm 2 \
${args}
"""

stub:
"""
mkdir -p rpt

cat > rpt/${meta.id}.bed <<EOF
${meta.id}\t1\t100
EOF
"""
}
67 changes: 67 additions & 0 deletions modules/ensembl/features/red/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: "features_red"
description: Detect repeats de novo in genome FASTA sequences with Red.
keywords:
- fasta
- features
- repeats
- de novo repeats
- red
- genomio
tools:
- "red":
description: "Red detects repeats de novo on the genomic scale."
homepage: "http://toolsmith.ens.utulsa.edu"
documentation: "http://toolsmith.ens.utulsa.edu"
tool_dev_url: "http://toolsmith.ens.utulsa.edu"
doi: "10.1186/s12859-015-0654-5"
licence: ["custom"]
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- fasta:
type: file
description: FASTA file containing genome sequence(s).
pattern: "*.{fa,fasta,fna}"
ontologies:
- edam: "http://edamontology.org/format_1929" # FASTA
output:
rpt:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "rpt/*.bed":
type: file
description: Red repeat report file.
pattern: "*.bed"
versions_red:
- - ${task.process}:
type: string
description: The process the versions were collected from
- red:
type: string
description: The tool name
- conda list red --json | python -c 'import sys,json; print(json.load(sys.stdin)[0]["version"])' || echo 2.0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above if it works.

type: eval
description: The expression to obtain the Red version
topics:
versions:
- - ${task.process}:
type: string
description: The process the versions were collected from
- red:
type: string
description: The tool name
- conda list red --json | python -c 'import sys,json; print(json.load(sys.stdin)[0]["version"])' || echo 2.0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above if it works.

type: eval
description: The expression to obtain the Red version
authors:
- "ensembl-dev@ebi.ac.uk"
maintainers:
- "ensembl-dev@ebi.ac.uk"
52 changes: 52 additions & 0 deletions modules/ensembl/features/red/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// See the NOTICE file distributed with this work for additional information
// regarding copyright ownership.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

nextflow_process {

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

tag "modules"
tag "modules_local"
tag "features"
tag "features/red"

test("Stub creates Red repeat report") {

when {
options "-stub"

process {
"""
def fasta = file("test.fa")
fasta.text = ">test\\nACGT\\n"

input[0] = [[ id:'test' ], fasta]
"""
}
}

then {
assert process.success
assert snapshot(process.out).match()
assert process.out.bed.size() == 1
assert process.out.bed[0][0] == [ id: 'test' ]
assert file(process.out.bed[0][1]).name == "test.bed"
assert file(process.out.bed[0][1]).size() > 0
assert process.out.versions_red.size() == 1
}
}
}
43 changes: 43 additions & 0 deletions modules/ensembl/features/red/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"Stub creates Red repeat report": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.bed:md5,aa604b48150afc506072a1f9656b6bb7"
]
],
"1": [
[
"FEATURES_RED",
"red",
"2.0"
]
],
"bed": [
[
{
"id": "test"
},
"test.bed:md5,aa604b48150afc506072a1f9656b6bb7"
]
],
"versions_red": [
[
"FEATURES_RED",
"red",
"2.0"
]
]
}
],
"timestamp": "2026-07-14T16:03:16.866216",
"meta": {
"nf-test": "0.9.5",
"nextflow": "26.04.3"
}
}
}
Loading