File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 2828
2929expr_regex = re .compile ("[PNQLSGg]" )
3030glstring_chars = re .compile ("[/|+^~]" )
31+ serology_splitter = re .compile (r"(\D+)(\d+)" )
3132
3233
3334@functools .lru_cache (maxsize = constants .DEFAULT_CACHE_SIZE )
@@ -63,7 +64,11 @@ def smart_sort_comparator(a1, a2):
6364
6465 # Handle serology
6566 if ":" not in a1 :
66- return 1 if a1 > a2 else - 1
67+ serology1_match = serology_splitter .match (a1 )
68+ serology1_num = int (serology1_match .group (2 ))
69+ serology2_match = serology_splitter .match (a2 )
70+ serology2_num = int (serology2_match .group (2 ))
71+ return 1 if serology1_num > serology2_num else - 1
6772
6873 # Extract and Compare 1st fields first
6974 a1_f1 = int (a1 [a1 .find ("*" ) + 1 : a1 .find (":" )])
Original file line number Diff line number Diff line change @@ -104,6 +104,11 @@ def test_fourth_field_comparator_ge(self):
104104 allele2 = "HLA-A*01:01:01:09"
105105 self .assertEqual (smart_sort_comparator (allele1 , allele2 ), 1 )
106106
107+ def test_serology_le (self ):
108+ serology1 = "Cw10"
109+ serology2 = "Cw3"
110+ self .assertEqual (smart_sort_comparator (serology1 , serology2 ), 1 )
111+
107112
108113if __name__ == "__main__" :
109114 unittest .main ()
You can’t perform that action at this time.
0 commit comments