Skip to content

Adding a check in the less than method for the VariantCall class to ensure that in cases where there is a mix of arrays and scalar values that the comparison still works. #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gcp_variant_transforms/beam_io/vcf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ def __lt__(self, other):
if self.sample_id != other.sample_id:
return self.sample_id < other.sample_id
elif self.genotype != other.genotype:
if(type(self.genotype) is list and type(other.genotype) is not list):
return False
if(type(other.genotype) is list and type(self.genotype) is not list):
return True
return self.genotype < other.genotype
elif self.phaseset != other.phaseset:
return self.phaseset < other.phaseset
Expand Down
8 changes: 8 additions & 0 deletions gcp_variant_transforms/beam_io/vcf_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def test_variant_call_order(self):
variant_call_2.phaseset = 1
self.assertGreater(variant_call_2, variant_call_1)

def test_genotype_compare(self):
variant_call_1 = self._default_variant_call()
variant_call_2 = vcfio.VariantCall(
sample_id=hash_name('Sample1'), name='Sample1', genotype=-1,
phaseset=vcfio.DEFAULT_PHASESET_VALUE, info={'GQ': 48})

self.assertLess(variant_call_2, variant_call_1)


if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
Expand Down