From fa28176af60ff15e1bb0edf9e8a5a4b77113ec36 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Mon, 16 Dec 2024 13:28:31 +1300 Subject: [PATCH] Fixed post-liftoff merge --- CHANGELOG.md | 1 + subworkflows/local/fasta_liftoff/main.nf | 21 ++++++++++++++++++++- tests/stub/main.nf.test.snap | 22 ++-------------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9937888..a274d90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 2. Switched branch name from `master` to `main` in the GHA CIs 3. Fixed an issue in `genepal_report.Rmd` which caused the pangene matrix plot to fail when the number of clusters exceeded 65536 [#124](https://github.com/Plant-Food-Research-Open/genepal/issues/124) 4. Fixed an issue where `GENEPALREPORT` process failed due to OOM kill signal from SLURM [#123](https://github.com/Plant-Food-Research-Open/genepal/issues/123) +5. Fixed an issue where Gff merge after liftoff failed when one of the Gff files did not contain any genes ### `Dependencies` diff --git a/subworkflows/local/fasta_liftoff/main.nf b/subworkflows/local/fasta_liftoff/main.nf index d1d818f..559c0b2 100644 --- a/subworkflows/local/fasta_liftoff/main.nf +++ b/subworkflows/local/fasta_liftoff/main.nf @@ -88,7 +88,26 @@ workflow FASTA_LIFTOFF { ) ch_liftoff_gff3 = LIFTOFF.out.polished_gff3 - | map { meta, gff -> [ [ id: meta.target_assembly ], gff ] } + | map { meta, gff -> + + def gene_count = gff.readLines() + .findAll { it -> + if ( it.startsWith('#') ) { return false } + + def cols = it.split('\t') + def feat = cols[2] + + if ( feat != 'gene' ) { return false } + + return true + }.size() + + // To avoid failure in AGAT_SPMERGEANNOTATIONS + // when one of the GFF files is empty + if ( gene_count < 1 ) { return null } + + [ [ id: meta.target_assembly ], gff ] + } | groupTuple ch_versions = ch_versions.mix(LIFTOFF.out.versions.first()) diff --git a/tests/stub/main.nf.test.snap b/tests/stub/main.nf.test.snap index 7ed6f6e..d96bf68 100644 --- a/tests/stub/main.nf.test.snap +++ b/tests/stub/main.nf.test.snap @@ -2,7 +2,7 @@ "full - stub": { "content": [ { - "successful tasks": 166, + "successful tasks": 126, "versions": { "AGAT_CONVERTSPGFF2GTF": { "agat": "v1.4.0" @@ -16,15 +16,6 @@ "AGAT_SPEXTRACTSEQUENCES": { "agat": "v1.4.0" }, - "AGAT_SPFILTERFEATUREFROMKILLLIST": { - "agat": "v1.4.0" - }, - "AGAT_SPFLAGSHORTINTRONS": { - "agat": "v1.4.1" - }, - "AGAT_SPMERGEANNOTATIONS": { - "agat": "v1.4.0" - }, "BENCHMARK": { "gffcompare": "0.12.6" }, @@ -46,9 +37,6 @@ "CAT_PROTEIN_FASTAS": { "pigz": "2.3.4" }, - "COMPARE_BRAKER_TO_LIFTOFF": { - "gffcompare": "0.12.6" - }, "CUSTOM_SRATOOLSNCBISETTINGS": { "sratools": "3.0.8" }, @@ -79,9 +67,6 @@ "GFF2FASTA_FOR_EGGNOGMAPPER": { "gffread": "0.12.7" }, - "GFFREAD_AFTER_LIFTOFF": { - "gffread": "0.12.7" - }, "GFFREAD_BEFORE_LIFTOFF": { "gffread": "0.12.7" }, @@ -106,9 +91,6 @@ "LIFTOFF": { "liftoff": "v1.6.3" }, - "MERGE_LIFTOFF_ANNOTATIONS": { - "agat": "v1.4.0" - }, "ORTHOFINDER": { "orthofinder": "2.5.5" }, @@ -208,6 +190,6 @@ "nf-test": "0.9.2", "nextflow": "24.04.4" }, - "timestamp": "2024-12-11T21:51:12.841395" + "timestamp": "2024-12-16T13:24:49.69503" } } \ No newline at end of file