@@ -325,25 +325,23 @@ def generate_alleles_and_xx_codes_and_who(db_connection: sqlite3.Connection, img
325325 shortnulls = dict ()
326326 for who in who_group :
327327 # e.g. DRB4*01:03
328- expression_alleles = []
329- expression_chars_found = set ()
328+ expression_alleles = dict ()
330329 if who [- 1 ] not in expression_chars and who [- 1 ] not in ['G' , 'P' ] and ":" in who :
331330 for an_allele in who_group [who ]:
332331 # if an allele in a who_group has an expression character but the group allele doesnt,
333332 # add it to shortnulls
334333 last_char = an_allele [- 1 ]
335334 if last_char in expression_chars :
336335 # e.g. DRB4*01:03:01:02N
337- expression_chars_found .add (last_char )
338- # add this allele to the set that this short null exapands to
339- expression_alleles .append (an_allele )
336+ a_shortnull = who + last_char
337+ if a_shortnull not in expression_alleles :
338+ expression_alleles [a_shortnull ] = []
339+ expression_alleles [a_shortnull ].append (an_allele )
340340 # only create a shortnull if there is one expression character in this who_group
341341 # there is nothing to be done for who_groups that have both Q and L for example
342- if expression_alleles :
343- if len (expression_chars_found ) == 1 :
344- # e.g. DRB4*01:03N
345- a_shortnull = who + list (expression_chars_found )[0 ]
346- shortnulls [a_shortnull ] = "/" .join (expression_alleles )
342+ for a_shortnull in expression_alleles :
343+ # e.g. DRB4*01:03N
344+ shortnulls [a_shortnull ] = "/" .join (expression_alleles [a_shortnull ])
347345
348346 db .save_dict (db_connection , 'shortnulls' , shortnulls , ('shortnull' , 'allele_list' ))
349347 shortnulls = {k : v .split ('/' ) for k , v in shortnulls .items ()}
0 commit comments