Repository navigation
fix(pysam): retain variant summaries with non-finite QUAL values - #316
Open
ketpatil77 wants to merge 1 commit into
Open
ketpatil77 wants to merge 1 commit into
ketpatil77 wants to merge 1 commit into
Conversation
rahul05ranjan
left a comment
There was a problem hiding this comment.
Verified the crash path and the fix mechanics locally (my host doesn't have pysam, so I couldn't run tests/pysam itself — details below).
- Confirmed the script serializes with
allow_nan=False(variant_summary.py line 340), so on main ananQUAL falls into theelsebranch and poisons the mean:json.dumps({"mean_quality": nan}, allow_nan=False)raisesValueError: Out of range float values are not JSON compliant. That matches the reported exit 2, andinf/-infwould hit the same wall. - Replicated the new branch logic (lines 246–254) with a stdlib snippet:
[nan, 50.0]→nonfinite_quality=1,mean_quality=50.0, serializes clean;[inf, -inf, 50.0]→nonfinite_quality=2, mean still 50.0. The all-non-finite edge is also safe:mean_qualityis already guarded byif quality_count(line 308) and becomesNone, which passes strict JSON. - One observation: since
record_countsis aCounter,nonfinite_qualityonly appears in the report when non-finite QUALs exist — butmissing_qualitybehaves the same way, so it's consistent with the existing shape.
Nice minimal fix, and the docs paragraph plus the metadata bump cover the behavior change. LGTM.
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.
A local VCF containing a
nanQUAL value causedvariant_summary.pyto exit 2 when strict JSON serialization encountered a non-finite mean. HTSlib also accepts positive and negative infinity.Exclude non-finite qualities from the mean and count them separately as
record_counts.nonfinite_quality, while preserving all variants in other counts. Document that behavior and bump the pysam skill metadata version.Validation: reproduced the CLI failure before the fix; all three non-finite regressions failed before the change.
python -m pytest tests/pysam -q: 63 passed, 33 subtests passed. Repository meta checks: 18 passed, 4,224 subtests passed. No remote genomic data was accessed.