Fix add_sample_from_csv crash on unmatched transcript/gene ids (2.0.7) - #44
Merged
Conversation
…e id The gene_id/chr column construction used a list comprehension inside try/except KeyError -- if even one transcript_id or gene_id from the coverage csv wasn't found in the transcripts file, the whole comprehension raised and the column silently never got created for *any* row, crashing later with a confusing AttributeError far from the real cause (e.g. 'Series' object has no attribute 'chr'). Switch to per-row .get() lookups with explicit filtering, so one unmatched id only drops that row. Also make the warning actionable: point at infer_genes=True when gene info can't be resolved, which is the actual fix for files with no gene lines (e.g. PacBio isoseq-collapse/Pigeon output). Closes #25.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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
Closes #25:
add_sample_from_csvcrashed with a confusingAttributeErrorwhen importing PacBio isoseq-collapse/Pigeon-style files that have nogenelines.TypeErroroninfer_genesis already fixed on master (side effect of Trouble while working with .csi indexes #28's fix in 2.0.3).AttributeErrorwas deeper than it looked:gene_id/chrcolumn construction used a list comprehension insidetry/except KeyError-- one unmatched id silently broke the column for every row, not just that one, crashing far downstream with an unrelated-looking error.Fix: per-row
.get()lookups with explicit filtering, so an unmatched id only drops that row. The warning is now also actionable, pointing atinfer_genes=Truewhen gene info can't be resolved -- confirmed as the actual fix against the reporter's scenario.Bumps version to 2.0.7.
Test plan
pytestsuite passes (19 passed), including the new regression testflake8/blackcleanpython -m build+twine check dist/*pass at 2.0.7