Skip to content

Commit

Permalink
Update learnmsa module to work with compressed files. (#5276)
Browse files Browse the repository at this point in the history
* add compression handling to learnmsa

* add compression simulation to stub

* fix typo

* commit tests

* remove duplicate snapshot names & regenerate

* Update modules/nf-core/learnmsa/align/meta.yml

Co-authored-by: Luisa Santus <[email protected]>

---------

Co-authored-by: Leon Rauschning <[email protected]>
Co-authored-by: Luisa Santus <[email protected]>
  • Loading branch information
3 people authored Mar 22, 2024
1 parent db87ca5 commit 6200770
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 19 deletions.
3 changes: 2 additions & 1 deletion modules/nf-core/learnmsa/align/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ channels:
- bioconda
- defaults
dependencies:
- bioconda::learnmsa=1.3.2
- bioconda::learnmsa=2.0.1
- conda-forge::pigz=2.8
20 changes: 12 additions & 8 deletions modules/nf-core/learnmsa/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,47 @@ process LEARNMSA_ALIGN {

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

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

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

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

script:
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"
"""
learnMSA \\
$args \\
-i $fasta \\
-o ${prefix}.aln
-i <(unpigz -cdf $fasta) \\
-o $write_output
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
touch ${prefix}.aln${compress ? '.gz' : ''}
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
"""
}
11 changes: 7 additions & 4 deletions modules/nf-core/learnmsa/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ input:
e.g. `[ id:'test']`
- fasta:
type: file
description: Input sequences in FASTA format
pattern: "*.{fa,fasta}"
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.
output:
- meta:
type: map
Expand All @@ -30,8 +33,8 @@ output:
e.g. `[ id:'test']`
- alignment:
type: file
description: Alignment file.
pattern: "*.{aln}"
description: Alignment file, in FASTA format. May be gzipped or uncompressed.
pattern: "*.aln{.gz,}"
- versions:
type: file
description: File containing software versions
Expand Down
30 changes: 27 additions & 3 deletions modules/nf-core/learnmsa/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ nextflow_process {
tag "learnmsa"
tag "learnmsa/align"

test("sarscov2 - fasta") {
test("sarscov2 - fasta - uncompressed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true)
]
input[1] = false
"""
}
}
Expand All @@ -26,10 +27,33 @@ nextflow_process {
assertAll(
{ assert process.success },
{ assert path(process.out.alignment.get(0).get(1)).getText().contains(">sample1") },
{ assert snapshot(process.out.versions).match("versions_structure") }
{ 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
"""
}
}

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

}

}
22 changes: 19 additions & 3 deletions modules/nf-core/learnmsa/align/tests/main.nf.test.snap

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

0 comments on commit 6200770

Please sign in to comment.