Skip to content

fix: use is not None for region boundary checks in _subset_genome_sequence_region#1082

Open
Carbon14-48 wants to merge 1 commit intomalariagen:masterfrom
Carbon14-48:fix/plasmodium-region-start-truthiness
Open

fix: use is not None for region boundary checks in _subset_genome_sequence_region#1082
Carbon14-48 wants to merge 1 commit intomalariagen:masterfrom
Carbon14-48:fix/plasmodium-region-start-truthiness

Conversation

@Carbon14-48
Copy link

What

Fixed region boundary checks in _subset_genome_sequence_region() in plasmodium.py,
and fixed a typo in the docstring ("Sebset" → "Subset").

Why

The current code uses if region.start: and if region.end: to check whether
region boundaries are set. In Python, 0 is falsy, so when a user queries a
region starting at position 0, the slicing is silently skipped and the full
contig is returned instead.

This is the same class of bug as described in #940 for the Anopheles side
(snp_data.py / hap_data.py), but this instance in the Plasmodium code
was not covered there.

Fix

Replaced if region.start: with if region.start is not None: (and same
for region.end) to correctly distinguish between "no boundary specified"
(None) and "boundary is zero" (0).

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.

1 participant