File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -834,6 +834,7 @@ def expand_mac(self, mac_code: str):
834834
835835 raise InvalidMACError (f"{ mac_code } is an invalid MAC." )
836836
837+ @functools .lru_cache ()
837838 def lookup_mac (self , allelelist_gl : str ):
838839 """
839840 Finds a MAC code corresponding to
@@ -856,10 +857,18 @@ def lookup_mac(self, allelelist_gl: str):
856857 locus = allelelist_gl .split ("*" )[0 ]
857858 return f"{ locus } *{ antigen_groups [0 ]} :{ mac_code } "
858859
859- # Try the list of first_field:second_field combinations
860- mac_expansion = "/" .join (sorted ( allele_fields ) )
860+ # Try the given list order first with first_field:second_field combinations
861+ mac_expansion = "/" .join (allele_fields )
861862 mac_code = db .alleles_to_mac_code (self .db_connection , mac_expansion )
863+ if mac_code :
864+ locus = allelelist_gl .split ("*" )[0 ]
865+ return f"{ locus } *{ antigen_groups [0 ]} :{ mac_code } "
862866
867+ # Try the sorted list of first_field:second_field combinations
868+ mac_expansion = "/" .join (
869+ sorted (allele_fields , key = functools .cmp_to_key (self .smart_sort_comparator ))
870+ )
871+ mac_code = db .alleles_to_mac_code (self .db_connection , mac_expansion )
863872 if mac_code :
864873 locus = allelelist_gl .split ("*" )[0 ]
865874 return f"{ locus } *{ antigen_groups [0 ]} :{ mac_code } "
You can’t perform that action at this time.
0 commit comments