Fix WP genotype condition always evaluating to False in vcf_func.py - #261
Merged
Conversation
The condition checked if the string "WP" was a member of a list of lists
([x.split('=') for x in ...]), which can never be True. The fix extracts
only the key portion of each INFO field pair ([x.split('=')[0] for x in ...])
so the membership test works as intended for legacy NEAT WP genotype records.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tests
Both WP code paths used 'for record in record[7].split(";")' which shadowed
the outer record list, causing a crash at the chrom/location assignments
that follow. Fixed by renaming the loop variable to info_item and, in the
has-format path, capturing record[9] before the loop begins.
Also adds tests/test_read_simulator/test_vcf_func.py with 14 tests covering:
- Path B (no FORMAT, WP in INFO): genotype matches WP value, slash/pipe
notation, WP among other fields, WP absent → random genotype
- Path A (FORMAT without GT, WP in INFO): genotype from WP
- Standard GT path: unaffected by WP fix
- General correctness: unknown chrom skipped, ref mismatch skipped,
missing QUAL defaulted
Co-Authored-By: Claude Sonnet 4.6 <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.
The condition checked if the string "WP" was a member of a list of lists ([x.split('=') for x in ...]), which can never be True. The fix extracts only the key portion of each INFO field pair ([x.split('=')[0] for x in ...]) so the membership test works as intended for legacy NEAT WP genotype records.