Skip to content

Commit

Permalink
EGGNOGMAPPER: Handled optional inputs (#5477)
Browse files Browse the repository at this point in the history
* EGGNOGMAPPER: Handled optional inputs

* Included versions in snapshot

* Added test for empty-params

* Now using a single common setup
  • Loading branch information
GallVp authored Apr 15, 2024
1 parent 9c0d4eb commit c070729
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 25 deletions.
22 changes: 12 additions & 10 deletions modules/nf-core/eggnogmapper/main.nf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
process EGGNOGMAPPER {
tag "$meta.id"
label 'process_long'
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
Expand All @@ -23,11 +23,13 @@ process EGGNOGMAPPER {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def is_compressed = fasta.name.endsWith(".gz")
def fasta_name = fasta.name.replace(".gz", "")
def dbmem = task.memory.toMega() > 40000 ? '--dbmem' : ''
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def is_compressed = fasta.extension == '.gz' ? true : false
def fasta_name = is_compressed ? fasta.baseName : "$fasta"
def dbmem = task.memory.toMega() > 40000 ? '--dbmem' : ''
def database_arg = eggnog_db ? "--database $eggnog_db" : ''
def dmnd_db_arg = eggnog_diamond_db ? "--dmnd_db $eggnog_diamond_db" : ''
"""
if [ "$is_compressed" == "true" ]; then
gzip -c -d $fasta > $fasta_name
Expand All @@ -38,8 +40,8 @@ process EGGNOGMAPPER {
-i ${fasta_name} \\
--data_dir ${eggnog_data_dir} \\
-m diamond \\
--dmnd_db ${eggnog_diamond_db} \\
--database ${eggnog_db} \\
$dmnd_db_arg \\
$database_arg \\
--output ${prefix} \\
${dbmem} \\
$args
Expand All @@ -51,8 +53,8 @@ process EGGNOGMAPPER {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.emapper.annotations
touch ${prefix}.emapper.seed_orthologs
Expand Down
3 changes: 3 additions & 0 deletions modules/nf-core/eggnogmapper/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ output:
pattern: "versions.yml"
authors:
- "@vagkaratzas"
maintainers:
- "@vagkaratzas"
- "@gallvp"
67 changes: 53 additions & 14 deletions modules/nf-core/eggnogmapper/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ nextflow_process {
tag "eggnogmapper"
tag "diamond/makedb"

test("Should search for protein annotations against the eggnogmapper db") {

setup {
run("DIAMOND_MAKEDB") {
script "../../diamond/makedb/main.nf"
process {
"""
input[0] = [ [id:'test2'], file(params.test_data['sarscov2']['genome']['proteome_fasta'], checkIfExists: true) ]
input[1] = []
input[2] = []
input[3] = []
"""
}
setup {
run("DIAMOND_MAKEDB") {
script "../../diamond/makedb/main.nf"
process {
"""
input[0] = [ [id:'test2'], file(params.test_data['sarscov2']['genome']['proteome_fasta'], checkIfExists: true) ]
input[1] = []
input[2] = []
input[3] = []
"""
}
}
}

test("Should search for protein annotations against the eggnogmapper db") {

when {
params {
Expand All @@ -47,7 +47,46 @@ nextflow_process {
{ assert path(process.out.annotations.get(0).get(1)).readLines().contains("ENSSASP00005000002.1\tENSSASP00005000002.1\t0.0\t14179.0\tCOG0498@1|root,COG0498@2|Bacteria,1MUWQ@1224|Proteobacteria,2VHR6@28216|Betaproteobacteria,2KUMA@206389|Rhodocyclales\t1224|Proteobacteria\tE\tthreonine synthase\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-") },
{ assert path(process.out.orthologs.get(0).get(1)).readLines().contains("ENSSASP00005000002.1\tENSSASP00005000002.1\t0.0\t14179.0\t1\t7096\t1\t7096\t100.0\t100.0\t100.0") },
{ assert snapshot(process.out.hits).match("hits") },
{ assert process.out.versions }
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("Should search for protein annotations against the eggnogmapper db -- empty-params") {

when {
params {
outdir = "$outputDir"
}
process {
"""
eggnog_db = file("https://github.com/nf-core/test-datasets/raw/eddf5b0e3336e0f93c81d4b4843b07257f9efaec/data/delete_me/eggnogmapper/eggnog.db", checkIfExists: true)
eggnog_db.copyTo("${workDir}/tmp/eggnog.db")
ch_synced_inputs = DIAMOND_MAKEDB.out.db.map { meta, dmnd ->
dmnd.copyTo("${workDir}/tmp/eggnog_proteins.dmnd")
return true
}
| combine ( Channel.fromPath( "${workDir}/tmp/" ) )
eggnog_data_dir = ch_synced_inputs.map { sync_status, data_dir -> data_dir }
input[0] = [ [id:'test'], file(params.test_data['sarscov2']['genome']['proteome_fasta'], checkIfExists: true) ]
input[1] = []
input[2] = eggnog_data_dir
input[3] = [[], []]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.annotations.get(0).get(1)).readLines().contains("ENSSASP00005000002.1\tENSSASP00005000002.1\t0.0\t14179.0\tCOG0498@1|root,COG0498@2|Bacteria,1MUWQ@1224|Proteobacteria,2VHR6@28216|Betaproteobacteria,2KUMA@206389|Rhodocyclales\t1224|Proteobacteria\tE\tthreonine synthase\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-\t-") },
{ assert path(process.out.orthologs.get(0).get(1)).readLines().contains("ENSSASP00005000002.1\tENSSASP00005000002.1\t0.0\t14179.0\t1\t7096\t1\t7096\t100.0\t100.0\t100.0") },
{ assert snapshot(process.out.hits).match("hits--empty-params") },
{ assert snapshot(process.out.versions).match("versions--empty-params") }
)
}

Expand Down
47 changes: 46 additions & 1 deletion modules/nf-core/eggnogmapper/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,51 @@
]
]
],
"timestamp": "2023-11-08T20:43:50.173213923"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-12T13:43:01.751295"
},
"versions--empty-params": {
"content": [
[
"versions.yml:md5,d3e4efad28b5a924585ea3dfcf72c32c"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-15T11:42:23.737523"
},
"versions": {
"content": [
[
"versions.yml:md5,d3e4efad28b5a924585ea3dfcf72c32c"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-12T13:45:26.555465"
},
"hits--empty-params": {
"content": [
[
[
{
"id": "test"
},
"test.emapper.hits:md5,864b7a1f902893d8aee6621baeab7be8"
]
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-15T11:42:23.690105"
}
}

0 comments on commit c070729

Please sign in to comment.