Skip to content

Commit

Permalink
Fix sort order of Imported Allele Infos
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMadBug committed Aug 15, 2023
1 parent e8ad556 commit 4084b6a
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions classification/models/classification_variant_info_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,6 @@ def get_absolute_url(self):
def __str__(self):
return f"{self.imported_genome_build_patch_version} {self.imported_c_hgvs or self.imported_g_hgvs}"

def __lt__(self, other: 'ImportedAlleleInfo'):
def sort_key(obj: ImportedAlleleInfo):
return obj.imported_genome_build_patch_version, obj.imported_c_hgvs
return sort_key(self) < sort_key(other)

@property
def variant_coordinates_imported_and_resolved(self) -> Tuple[VariantCoordinate, VariantCoordinate]:
imported_vc: Optional[VariantCoordinate] = self.variant_coordinate_obj
Expand Down Expand Up @@ -502,15 +497,10 @@ def apply_validation(self, force_update: bool = False):
latest_validation.save()
self.latest_validation = latest_validation

def __lt__(self, other):
if self.grch38:
if other.grch38:
return self.grch38 < other.grch38
else:
return False
elif other.grch38:
return True
return self.imported_c_hgvs < other.imported_c_hgvs
def __lt__(self, other: 'ImportedAlleleInfo'):
def sort_key(obj: ImportedAlleleInfo):
return obj.imported_genome_build_patch_version, obj.imported_c_hgvs
return sort_key(self) < sort_key(other)

@property
def imported_c_hgvs_obj(self) -> Optional[CHGVS]:
Expand Down

0 comments on commit 4084b6a

Please sign in to comment.