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

Update learnmsa #7413

Merged
merged 10 commits into from
Jan 31, 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
3 changes: 1 addition & 2 deletions modules/nf-core/learnmsa/align/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ channels:
- conda-forge
- bioconda
dependencies:
- bioconda::learnmsa=2.0.1
- conda-forge::pigz=2.8
- conda-forge::coreutils=9.5
27 changes: 11 additions & 16 deletions modules/nf-core/learnmsa/align/main.nf
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
process LEARNMSA_ALIGN {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-741e0da5cf2d6d964f559672e2908c2111cbb46b:4930edd009376542543bfd2e20008bb1ae58f841-0' :
'biocontainers/mulled-v2-741e0da5cf2d6d964f559672e2908c2111cbb46b:4930edd009376542543bfd2e20008bb1ae58f841-0' }"
container "registry.hub.docker.com/felbecker/learnmsa:2.0.9"

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

output:
tuple val(meta), path("*.aln{.gz,}"), emit: alignment
tuple val(meta), path("*.aln") , emit: alignment
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def write_output = compress ? ">(pigz -cp ${task.cpus} > ${prefix}.aln.gz)" : "${prefix}.aln"
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error("LearnMSA align module does not support Conda. Please use Docker / Singularity / Podman instead.")
}
"""
learnMSA \\
$args \\
-i <(unpigz -cdf $fasta) \\
-o $write_output
-i $fasta \\
-o "${prefix}.aln" \\
$args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
learnmsa: \$(learnMSA -h | grep 'version' | awk -F 'version ' '{print \$2}' | awk '{print \$1}' | sed 's/)//g')
pigz: \$(echo \$(pigz --version 2>&1) | sed 's/^.*pigz\\w*//' ))
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.aln${compress ? '.gz' : ''}
touch ${prefix}.aln

cat <<-END_VERSIONS > versions.yml
"${task.process}":
learnmsa: \$(learnMSA -h | grep 'version' | awk -F 'version ' '{print \$2}' | awk '{print \$1}' | sed 's/)//g')
pigz: \$(echo \$(pigz --version 2>&1) | sed 's/^.*pigz\\w*//' ))
learnmsa: \$(if command -v learnMSA &>/dev/null; then learnMSA -h | grep 'version' | awk -F 'version ' '{print \$2}' | awk '{print \$1}' | sed 's/)//g'; else echo "STUB_TEST_HARDCODED_VERSION"; fi)
END_VERSIONS
"""
}
15 changes: 5 additions & 10 deletions modules/nf-core/learnmsa/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,19 @@ input:
e.g. `[ id:'test']`
- fasta:
type: file
description: Input sequences in FASTA format. May be gz-compressed or uncompressed.
pattern: "*.{fa,fasta}{.gz,}"
- - compress:
type: boolean
description: Flag representing whether the output MSA should be compressed.
Set to true to enable/false to disable compression. Compression is done using
pigz, and is multithreaded.
description: Input sequences in FASTA format.
pattern: "*.{fa,fasta}"
output:
- alignment:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test']`
- "*.aln{.gz,}":
- "*.aln":
type: file
description: Alignment file, in FASTA format. May be gzipped or uncompressed.
pattern: "*.aln{.gz,}"
description: Alignment file, in FASTA format.
pattern: "*.aln"
- versions:
- versions.yml:
type: file
Expand Down
34 changes: 6 additions & 28 deletions modules/nf-core/learnmsa/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
nextflow_process {

name "Test Process LEARNMSA_ALIGN"
config "./nextflow.config"
script "../main.nf"
process "LEARNMSA_ALIGN"

Expand All @@ -10,47 +11,24 @@ nextflow_process {
tag "learnmsa"
tag "learnmsa/align"

test("sarscov2 - fasta - uncompressed") {
test("seatoxin - stub") {
options "-stub"

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true)
input[0] = [ [ id:'test' ],
file(params.modules_testdata_base_path + "../../multiplesequencealign/testdata/setoxin-ref.fa", checkIfExists: true)
]
input[1] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.alignment.get(0).get(1)).getText().contains(">sample1") },
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("sarscov2 - fasta - compressed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true)
]
input[1] = true
"""
}
}
{ assert snapshot ( process.out ).match() }

then {
assertAll(
{ assert process.success },
{ assert path(process.out.alignment.get(0).get(1)).getTextGzip().contains(">sample1") },
{ assert snapshot(process.out.versions).match("versions1") }
)
}

Expand Down
47 changes: 28 additions & 19 deletions modules/nf-core/learnmsa/align/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
{
"versions": {
"seatoxin - stub": {
"content": [
[
"versions.yml:md5,85322b0f038aa768f202fd0d748d6c7c"
]
{
"0": [
[
{
"id": "test"
},
"test.aln:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,c3886d32309d141ad22aba3a8a119d62"
],
"alignment": [
[
{
"id": "test"
},
"test.aln:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,c3886d32309d141ad22aba3a8a119d62"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2024-03-20T16:06:48.867020809"
},
"versions1": {
"content": [
[
"versions.yml:md5,85322b0f038aa768f202fd0d748d6c7c"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-20T16:12:13.921813607"
"timestamp": "2025-01-31T13:29:53.669503397"
}
}
7 changes: 7 additions & 0 deletions modules/nf-core/learnmsa/align/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
process {

withName: LEARNMSA_ALIGN{
container = "nf-core/ubuntu:22.04"
}

}
Loading