@@ -106,7 +106,7 @@ def remove_locus_name(reduced_allele):
106106 return "/" .join (map (lambda a : a .split ("*" )[1 ], reduced_allele .split ("/" )))
107107
108108
109- def reduce (allele , locus , column_name ):
109+ def redux (allele , locus , column_name ):
110110 # Does the allele name have the locus in it ?
111111 if allele == "" :
112112 return allele
@@ -115,7 +115,13 @@ def reduce(allele, locus, column_name):
115115 elif ard_config .get ("locus_in_allele_name" ):
116116 locus_allele = allele
117117 else :
118- locus_allele = f"{ locus } *{ allele } "
118+ if allele .startswith (locus ):
119+ locus_allele = allele
120+ else :
121+ if ":" in allele :
122+ locus_allele = f"{ locus } *{ allele } "
123+ else :
124+ locus_allele = f"{ locus } { allele } " # serology
119125
120126 # Check the config if this allele should be reduced
121127 if should_be_reduced (allele , locus_allele ):
@@ -162,9 +168,9 @@ def clean_locus(allele: str, locus: str, column_name: str = "Unknown") -> str:
162168 allele = white_space_regex .sub ("" , allele )
163169 # If the allele comes in as an allele list, apply reduce to all alleles
164170 if "/" in allele :
165- return "/" .join (map ( reduce , allele .split ("/" ), locus , column_name ) )
171+ return "/" .join ([ redux ( a , locus , column_name ) for a in allele .split ("/" )] )
166172 else :
167- return reduce (allele , locus , column_name )
173+ return redux (allele , locus , column_name )
168174 return allele
169175
170176
@@ -189,7 +195,9 @@ def reduce_locus_columns(df, ard_config, locus_column_mapping, verbose):
189195 df .insert (
190196 new_column_index ,
191197 new_column_name ,
192- df [column ].apply (clean_locus , locus = locus , column_name = column ),
198+ df [column ].apply (
199+ clean_locus , locus = locus .upper (), column_name = column
200+ ),
193201 )
194202 locus_columns [locus_columns .index (column )] = new_column_name
195203 else :
0 commit comments