Skip to content

Commit 551d8a5

Browse files
committed
Perform W reductions and then exon reductions when not already in exon mapping, e.g. for 2 field alleles
Fixes #320
1 parent b619e5e commit 551d8a5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pyard/ard.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,15 @@ def _redux_allele(
258258

259259
return exon_group_allele
260260
else:
261-
# for 'exon' return allele with only first 3 fields
262-
return ":".join(allele.split(":")[0:3])
261+
# Expand to W level and then reduce to exon
262+
w_redux = self.redux(allele, "W")
263+
# If the W redux produces 2 field allele or the same allele,
264+
# don't recurse
265+
if w_redux == allele or len(w_redux.split(":")) == 2:
266+
return allele
267+
else:
268+
# recurse with the W fields
269+
return self.redux(w_redux, "exon")
263270
elif redux_type == "U2":
264271
allele_fields = allele.split(":")
265272
# If resolved out to second field leave alone

tests/features/who.feature

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ Feature: WHO expansion and Exon reduction
2222

2323
Scenario Outline: Exon reduction
2424

25+
Exon reductions will expand 2 field alleles to W level before generating
26+
exon level reductions.
27+
2528
Given the typing is <Allele>
2629
When expanding at the <Level> level
2730
Then the expanded allele is found to be <Expanded Alleles>
2831
Examples:
29-
| Allele | Level | Expanded Alleles |
30-
| DRB1*11:01 | exon | DRB1*11:01 |
31-
| A*01:01:01:03 | exon | A*01:01:01 |
32+
| Allele | Level | Expanded Alleles |
33+
| A*01:01:01:03 | exon | A*01:01:01 |
34+
| DRB1*11:01 | exon | DRB1*11:01:01/DRB1*11:01:02/DRB1*11:01:03/DRB1*11:01:04/DRB1*11:01:05/DRB1*11:01:06/DRB1*11:01:07/DRB1*11:01:08/DRB1*11:01:09/DRB1*11:01:10/DRB1*11:01:11/DRB1*11:01:12/DRB1*11:01:13/DRB1*11:01:14/DRB1*11:01:15/DRB1*11:01:16/DRB1*11:01:17/DRB1*11:01:18/DRB1*11:01:19/DRB1*11:01:20/DRB1*11:01:21/DRB1*11:01:22/DRB1*11:01:23/DRB1*11:01:24/DRB1*11:01:25/DRB1*11:01:26/DRB1*11:01:27/DRB1*11:01:28/DRB1*11:01:29/DRB1*11:01:30/DRB1*11:01:31/DRB1*11:01:32/DRB1*11:01:33/DRB1*11:01:34/DRB1*11:01:35/DRB1*11:01:36/DRB1*11:01:37/DRB1*11:01:38/DRB1*11:01:39/DRB1*11:01:40/DRB1*11:01:41/DRB1*11:01:42/DRB1*11:01:43 |

0 commit comments

Comments
 (0)