Skip to content

fix: reject FASTA headers without sequences - #280

Draft
aelde wants to merge 2 commits into
scverse:devfrom
aelde:fix/fasta-trailing-header
Draft

aelde wants to merge 2 commits into
scverse:devfrom
aelde:fix/fasta-trailing-header

Conversation

@aelde

@aelde aelde commented Nov 1, 2026

Copy link
Copy Markdown

A FASTA file ending in a header without a sequence can silently reuse the preceding record's sequence. For example, >first\nACGT\n>missing\n returns (['first', 'missing'], ['ACGT', 'ACGT']), potentially mislabelling sequence input to gget mutate.

Reject the unfinished record with ValueError, consistent with the existing rejection of consecutive headers. Ignore blank lines so they cannot hide a missing sequence. Complete records retain their output, including multiline sequences and files without a final newline. Zero-byte file handling is unchanged.

Adds 16 synthetic regression cases and a changelog entry.

Validation (Python 3.12.3, normal package imports):

python -m pytest -q -p no:cacheprovider tests/test_read_fasta.py tests/test_utils.py::TestUtils::test_read_fasta
  • Base bc7b353ea2215cba00697591c33887b1094c660b: 9 failed, 8 passed.
  • With this fix: 17 passed, including the existing FASTA fixture.
  • git diff --check passed. The full live-service test suite and lint/type-check matrix were not run locally.

AI assistance: OpenAI Codex assisted with investigation, implementation, tests, changelog, and this description. The human contributor reviewed and approved the missing-sequence error behavior and main validation conditions before this commit. The tests above were executed by Codex; this disclosure does not claim a human independently ran them.

@codecov-commenter

codecov-commenter commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.02%. Comparing base (63f592f) to head (f99e145).
⚠️ Report is 4 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #280      +/-   ##
==========================================
+ Coverage   55.87%   57.02%   +1.14%     
==========================================
  Files          29       29              
  Lines        9392     9421      +29     
==========================================
+ Hits         5248     5372     +124     
+ Misses       4144     4049      -95     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants