Skip to content

Commit a667748

Browse files
committed
Fix Single field MICA, MICB Alleles failing
1 parent d7f788e commit a667748

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

pyard/ard.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
VALID_REDUCTION_TYPES,
4444
expression_chars,
4545
DEFAULT_CACHE_SIZE,
46+
G_GROUP_LOCI,
4647
)
4748

4849
default_config = {
@@ -388,6 +389,10 @@ def redux(self, glstring: str, redux_type: VALID_REDUCTION_TYPES) -> str:
388389
loc_allele = glstring.split(":")
389390
loc_antigen, code = loc_allele[0], loc_allele[1]
390391
else:
392+
if "*" in glstring:
393+
locus, _ = glstring.split("*")
394+
if locus not in G_GROUP_LOCI:
395+
return glstring
391396
raise InvalidTypingError(
392397
f"{glstring} is not a valid V2 or Serology typing."
393398
)
@@ -535,6 +540,7 @@ def is_v2(self, allele: str) -> bool:
535540
self._config["reduce_v2"]
536541
and "*" in allele
537542
and ":" not in allele
543+
and allele.split("*")[0] not in ["MICA", "MICB"]
538544
and allele != self._map_v2_to_v3(allele)
539545
)
540546

pyard/constants.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,32 @@
2525

2626
HLA_regex = re.compile("^HLA-")
2727

28-
VALID_REDUCTION_TYPES = ["G", "P", "lg", "lgx", "W", "exon", "U2", "S"]
29-
expression_chars = ["N", "Q", "L", "S"]
28+
VALID_REDUCTION_TYPES = ("G", "P", "lg", "lgx", "W", "exon", "U2", "S")
29+
expression_chars = ("N", "Q", "L", "S")
3030
# List of P and G characters
3131
PandG_chars = ["P", "G"]
32+
33+
# Loci with G group data
34+
# Retrieved from lgx_group
35+
# sqlite> select distinct(substr(allele, 1, instr(allele, '*') - 1)) from lgx_group;
36+
G_GROUP_LOCI = (
37+
"A",
38+
"B",
39+
"C",
40+
"DMA",
41+
"DMB",
42+
"DOA",
43+
"DOB",
44+
"DPA1",
45+
"DPB1",
46+
"DQA1",
47+
"DQB1",
48+
"DRA",
49+
"DRB1",
50+
"DRB3",
51+
"DRB4",
52+
"DRB5",
53+
"E",
54+
"F",
55+
"G",
56+
)

tests/features/allele.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,18 @@ Feature: Alleles
7171
| Allele | Level | Redux Allele |
7272
| A*24:329 | lgx | A*24:329Q |
7373
| DQB1*03:276 | lgx | DQB1*03:01 |
74+
75+
76+
Scenario Outline: Single field MICA, MICB Alleles
77+
78+
For MICA, MICB alleles with single field, their reduced version is self.
79+
80+
Given the allele as <Allele>
81+
When reducing on the <Level> level
82+
Then the reduced allele is found to be <Redux Allele>
83+
84+
Examples:
85+
| Allele | Level | Redux Allele |
86+
| MICA*040 | lgx | MICA*040 |
87+
| MICB*006 | lgx | MICB*006 |
88+
| MICB*029 | lgx | MICB*029 |

0 commit comments

Comments
 (0)