diff --git a/gcp_variant_transforms/beam_io/vcf_parser.py b/gcp_variant_transforms/beam_io/vcf_parser.py index 04afec0c..ed34339a 100644 --- a/gcp_variant_transforms/beam_io/vcf_parser.py +++ b/gcp_variant_transforms/beam_io/vcf_parser.py @@ -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 diff --git a/gcp_variant_transforms/beam_io/vcf_parser_test.py b/gcp_variant_transforms/beam_io/vcf_parser_test.py index 5ea06d3d..03f48aeb 100644 --- a/gcp_variant_transforms/beam_io/vcf_parser_test.py +++ b/gcp_variant_transforms/beam_io/vcf_parser_test.py @@ -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)