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: fastme #4920

Merged
merged 12 commits into from
Feb 15, 2024
9 changes: 9 additions & 0 deletions modules/nf-core/fastme/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: "fastme"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::fastme=2.1.6.1"
63 changes: 63 additions & 0 deletions modules/nf-core/fastme/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
process FASTME {
tag "$infile"
label 'process_medium'

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

input:
path infile
path initial_tree

output:
path "*.nwk" , emit: nwk
path "*_stat.txt" , emit: stats
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to add optional output channels at least for the more commonly used optional outputs, in particular the bootstrap supports.

path "versions.yml" , emit: versions
path "*.matrix.phy" , emit: matrix , optional: true
path "*.bootstrap" , emit: bootstrap , optional: true

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: infile
def initarg = initial_tree ? "-u $initial_tree" : ''
def matarg = task.ext.args =~ "-O" ? "-O ${prefix}.matrix.phy" : ''
def bootarg = task.ext.args =~ "-B" ? "-B ${prefix}.bootstrap" : ''
"""
fastme \\
$args \\
-i $infile \\
$initarg \\
-o ${prefix}.nwk \\
$matarg \\
$bootarg \\
-T $task.cpus


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

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: infile
def mat = task.ext.args =~ "-O" ? "touch ${prefix}.matrix.phy" : ''
def boot = task.ext.args =~ "-B" ? "touch ${prefix}.bootstrap" : ''
"""
touch ${prefix}.nwk
touch ${prefix}_stat.txt
$mat
$boot

cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastme: \$(fastme --version |& sed '1!d ; s/FastME //')
END_VERSIONS
"""
}
56 changes: 56 additions & 0 deletions modules/nf-core/fastme/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "fastme"
description: "Distance-based phylogeny with FastME"
keywords:
- phylogenetics
- newick
- minimum_evolution
- distance-based
tools:
- "fastme":
description: "A comprehensive, accurate and fast distance-based phylogeny inference program."
homepage: "http://www.atgc-montpellier.fr/fastme"
documentation: "http://www.atgc-montpellier.fr/fastme/usersguide.php"
tool_dev_url: "https://gite.lirmm.fr/atgc/FastME/"
doi: "10.1093/molbev/msv150"
licence: ["GPL v3"]
args_id: "$args"

input:
- infile:
type: file
description: MSA or distance matrix in Phylip format
pattern: "*"
# note: I have omitted any specific extension as it is not standardized for those file types
- topo:
type: file
description: Initial tree topology in Newick format
pattern: "*.{nwk,dnd}"

output:
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- nwk:
type: file
description: Final phylogeny in Newick format
pattern: "*.nwk"
- stats:
type: file
description: A text file with the statistics of the phylogeny
pattern: "*_stat.txt"
- matrix:
type: file
description: Optional; the distance matrix in Phylip matrix format; it is generated if the -O option is passed in ext.args, although the provided file name will be overwritten
pattern: "*.matrix.phy"
- bootstrap:
type: file
description: A file containing all bootstrap trees in Newick format; it is generated if the -B option is passed in ext.args (and bootstrap is used), although the provided file name will be overwritten
pattern: "*.bootstrap"
Comment on lines +44 to +51
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!


authors:
- "@itrujnara"
maintainers:
- "@itrujnara"
8 changes: 8 additions & 0 deletions modules/nf-core/fastme/tests/main.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
process {
withName: "TCOFFEE_SEQREFORMAT" {
ext.args = { "-output phylip_aln" }
}
withName: "FASTME" {
ext.args = { "-p LG -q" }
}
}
128 changes: 128 additions & 0 deletions modules/nf-core/fastme/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "fastme"
tag "tcoffee/seqreformat"
tag "famsa/guidetree"

test("setoxin - phylip - basic") {

config "./main.config"

setup {
run("TCOFFEE_SEQREFORMAT") {
script "../../tcoffee/seqreformat/main.nf"
process {
"""
input[0] = [ [ id: "test" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/multiplesequencealign/testdata/setoxin.ref", checkIfExists: true)
]
"""
}
}
}

when {
process {
"""
input[0] = TCOFFEE_SEQREFORMAT.out.formatted_file.collect{ meta, aln -> aln }
input[1] = []
"""
}
}

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

test("setoxin - phylip - with_tree") {

config "./main.config"

setup {
run("TCOFFEE_SEQREFORMAT") {
script "../../tcoffee/seqreformat/main.nf"
process {
"""
input[0] = [ [ id: "test" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/multiplesequencealign/testdata/setoxin.ref", checkIfExists: true)
]
"""
}
}
run("FAMSA_GUIDETREE") {
script "../../famsa/guidetree/main.nf"
process {
"""
input[0] = [ [ id: "test" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/multiplesequencealign/testdata/setoxin.ref", checkIfExists: true)
]

"""
}
}
}

when {
process {
"""
input[0] = TCOFFEE_SEQREFORMAT.out.formatted_file.collect{ meta, aln -> aln }
input[1] = FAMSA_GUIDETREE.out.tree.collect{ meta, tree -> tree }
"""
}
}

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

}

test("setoxin - phylip - bootstrap") {

config "./optionals.config"

setup {
run("TCOFFEE_SEQREFORMAT") {
script "../../tcoffee/seqreformat/main.nf"
process {
"""
input[0] = [ [ id: "test" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/multiplesequencealign/testdata/setoxin.ref", checkIfExists: true)
]
"""
}
}
}

when {
process {
"""
input[0] = TCOFFEE_SEQREFORMAT.out.formatted_file.collect{ meta, aln -> aln }
input[1] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.nwk },
{ assert process.out.matrix },
{ assert process.out.bootstrap }
)
}
}
}
84 changes: 84 additions & 0 deletions modules/nf-core/fastme/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions modules/nf-core/fastme/tests/optionals.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
process {
withName: "TCOFFEE_SEQREFORMAT" {
ext.args = { "-output phylip_aln" }
}
withName: "FASTME" {
ext.args = { "-p LG -q -b 10 -O -B" }
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/fastme/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fastme:
- "modules/nf-core/fastme/**"
Loading