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 module to work with compressed files. #5276

Merged
merged 9 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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: 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. Maybe gzipped or uncompressed.
lrauschning marked this conversation as resolved.
Show resolved Hide resolved
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") }
Copy link
Contributor

Choose a reason for hiding this comment

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

why does have the 1 in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To get the output file from the meta + file-output channel, if you mean the .get(1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nvm, for the snapshot name of the versions snapshot it's because since v 0.8.4 nf-test throws an error when overwriting a snapshot with the same name – compare [0].
This was causing the CI to fail despite the test passing locally (where I have nf-test v 0.8.3 installed).

[0] askimed/nf-test@d2508b2#diff-fd31905853152ac935c5509db52bb497033040fa8cb2523810950c3595ba450aR31-R37

)
}

}

}
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.

Loading