Handle empty inputs in parsing and mapping#61
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the robustness of data parsing and mapping functions by ensuring they gracefully handle empty and header-only input files while preserving expected column structures. The changes prevent downstream failures when processing empty datasets by using DataFrame.reindex() to guarantee consistent schemas even when all inputs are empty.
Key Changes
- Added empty-case handling in
parse_sylph()andparse_mash_winning_sorted_tab()to return DataFrames with complete column definitions after filtering operations - Updated all mapping functions to use
DataFrame.reindex()instead of direct column selection, ensuring required columns exist even with empty inputs - Added comprehensive regression tests covering empty inputs for both parsers and mapping helpers
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/test_parse.py | Added tests for header-only TSV files and empty sylph files to verify column structure preservation |
| scripts/test_map.py | Added comprehensive test verifying all mapping functions handle empty parsed outputs correctly |
| scripts/parse.py | Enhanced parse_mash_winning_sorted_tab() and parse_sylph() to return DataFrames with expected columns when inputs become empty after filtering |
| scripts/map.py | Replaced direct column selection with DataFrame.reindex() in all mapping functions to guarantee column presence regardless of input emptiness |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Testing
Codex Task