fix: fail with a GTF-specific error when no genes can be extracted - #132
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
fix: fail with a GTF-specific error when no genes can be extracted#132BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
A malformed or truncated GTF that yields zero genes used to log a WARN and carry on, so the run died later in count_reads with a "Chromosome name mismatch" error, an empty "GTF chromosomes (first 5):" list and a chromosome_mapping suggestion with nothing in it. The real cause (bad annotation file) was buried in an easy-to-miss warning above. parse_gtf now tracks why nothing was extracted and returns a fatal, actionable error naming the most likely cause: no annotation lines, lines with fewer than the 9 mandatory columns, no exon features (listing the feature types actually present, which flags GFF3 input), or exon features without gene_id attributes. count_reads keeps a guard for library callers: an empty annotation index now reports an empty-annotation error instead of the chromosome-mismatch diagnosis, which cannot apply when there is nothing to match against. Closes seqeralabs#126 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #126.
Problem
When a GTF yields zero genes,
parse_gtfonly logged aWARNand returned an empty map. The run then died much later incount_readswith the chromosome-mismatch diagnosis, which cannot apply — there is nothing on the GTF side to mismatch against:The suggested fix (
chromosome_mapping) is empty and cannot help, and the actual cause is aWARNline that is easy to miss.Fix
parse_gtfnow records why nothing was extracted while scanning, and returns a fatal error naming the most likely cause:the file contains no annotation lines (it is empty, or every line is a comment)all N annotation lines have fewer than the 9 mandatory tab-separated GTF columns (truncated file, or space- instead of tab-separated)exonfeaturesno 'exon' features were found; feature types present: gene, mRNA. GFF3 files ... are not supported — convert to GTFgene_idN feature lines were found but none carried a 'gene_id' attributecount_readskeeps a guard for library callers: an empty annotation index now produces an empty-annotation error rather than the chromosome-mismatch text.Behaviour change
An empty annotation is now a hard error at parse time instead of a warning. This is the same outcome as before (the run always failed a few seconds later), just reported at the point where the cause is known.
Verification
Reproducing the issue's steps with
cut -f1-5 tests/data/test.gtf:Four new unit tests cover the truncated, GFF3, missing-
gene_idand empty-file cases.cargo test— 204 lib + 18 integration tests passcargo fmt --check,cargo clippy -- -D warningsclean🤖 Generated with Claude Code