Skip to content

Commit e9c88f7

Browse files
authored
Merge pull request #240 from pbashyal-nmdp/support_ARS_as_g_suffix
Allow ARS suffix instead of g
2 parents 85b7c11 + f519820 commit e9c88f7

File tree

4 files changed

+61
-28
lines changed

4 files changed

+61
-28
lines changed

pyard/ard.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"ping": False,
5555
"map_drb345_to_drbx": True,
5656
"verbose_log": True,
57+
"ARS_as_lg": False,
5758
}
5859

5960

@@ -64,7 +65,7 @@ class ARD(object):
6465
"""
6566
ARD reduction for HLA
6667
Allows reducing alleles, allele code(MAC), Serology to
67-
G, lg, lgx, W, exon and U2 levels.
68+
G, lg, lgx, W, exon, S and U2 levels.
6869
"""
6970

7071
def __init__(
@@ -214,6 +215,9 @@ def _redux_allele(
214215
# return allele with only first 2 field
215216
redux_allele = ":".join(allele.split(":")[0:2])
216217
if redux_type == "lg":
218+
# ARS suffix maybe used instead of g
219+
if self._config["ARS_as_lg"]:
220+
return redux_allele + "ARS"
217221
# lg mode has g appended with lgx reduction
218222
return redux_allele + "g"
219223
return redux_allele

tests/environment.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ def before_all(context):
2626
context.ard = pyard.init("3440", data_dir="/tmp/py-ard")
2727

2828
# an ard with ping set to True
29-
my_config = {
29+
ping_config = {
3030
"ping": True,
3131
}
32-
context.ard_ping = pyard.init("3440", data_dir="/tmp/py-ard", config=my_config)
32+
context.ard_ping = pyard.init("3440", data_dir="/tmp/py-ard", config=ping_config)
33+
34+
# an ard with ARS suffix for lg
35+
lg_ars_config = {
36+
"ARS_as_lg": True,
37+
}
38+
context.ard_ars = pyard.init("3440", data_dir="/tmp/py-ard", config=lg_ars_config)

tests/features/allele.feature

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Feature: Alleles
77
Then the reduced allele is found to be <Redux Allele>
88

99
Examples:
10-
| Allele | Level | Redux Allele |
11-
| C*02:02 | lg | C*02:02g |
12-
| C*02:02 | lgx | C*02:02 |
13-
| C*02:10 | lg | C*02:02g |
14-
| C*02:10 | lgx | C*02:02 |
15-
| C*06:17 | lgx | C*06:02 |
10+
| Allele | Level | Redux Allele |
11+
| C*02:02 | lg | C*02:02g |
12+
| C*02:02 | lgx | C*02:02 |
13+
| C*02:10 | lg | C*02:02g |
14+
| C*02:10 | lgx | C*02:02 |
15+
| C*06:17 | lgx | C*06:02 |
1616

1717
Scenario Outline: allele reduction
1818

@@ -21,22 +21,39 @@ Feature: Alleles
2121
Then the reduced allele is found to be <Redux Allele>
2222

2323
Examples:
24-
| Allele | Level | Redux Allele |
25-
| A*01:01:01 | G | A*01:01:01G |
26-
| A*01:01:01 | lg | A*01:01g |
27-
| A*01:01:01 | lgx | A*01:01 |
28-
29-
| HLA-A*01:01:01 | G | HLA-A*01:01:01G |
30-
| HLA-A*01:01:01 | lg | HLA-A*01:01g |
31-
| HLA-A*01:01:01 | lgx | HLA-A*01:01 |
32-
33-
| DRB1*14:05:01 | lgx | DRB1*14:05 |
34-
| DRB1*14:05:01 | lg | DRB1*14:05g |
35-
36-
| DRB1*14:06:01 | lgx | DRB1*14:06 |
37-
| DRB1*14:06:01 | lg | DRB1*14:06g |
38-
| C*02:02 | lg | C*02:02g |
39-
| C*02:02 | lgx | C*02:02 |
40-
| C*02:10 | lg | C*02:02g |
41-
| C*02:10 | lgx | C*02:02 |
42-
| C*06:17 | lgx | C*06:17 |
24+
| Allele | Level | Redux Allele |
25+
| A*01:01:01 | G | A*01:01:01G |
26+
| A*01:01:01 | lg | A*01:01g |
27+
| A*01:01:01 | lgx | A*01:01 |
28+
29+
| HLA-A*01:01:01 | G | HLA-A*01:01:01G |
30+
| HLA-A*01:01:01 | lg | HLA-A*01:01g |
31+
| HLA-A*01:01:01 | lgx | HLA-A*01:01 |
32+
33+
| DRB1*14:05:01 | lgx | DRB1*14:05 |
34+
| DRB1*14:05:01 | lg | DRB1*14:05g |
35+
36+
| DRB1*14:06:01 | lgx | DRB1*14:06 |
37+
| DRB1*14:06:01 | lg | DRB1*14:06g |
38+
| C*02:02 | lg | C*02:02g |
39+
| C*02:02 | lgx | C*02:02 |
40+
| C*02:10 | lg | C*02:02g |
41+
| C*02:10 | lgx | C*02:02 |
42+
| C*06:17 | lgx | C*06:17 |
43+
44+
45+
Scenario Outline: allele reduction with ARS suffix
46+
47+
In `g` mode, use `ARS` prefix rather than `g`.
48+
49+
Given the allele as <Allele>
50+
When reducing on the <Level> level with ARS suffix enabled
51+
Then the reduced allele is found to be <Redux Allele>
52+
53+
Examples:
54+
| Allele | Level | Redux Allele |
55+
| A*01:01:01 | lg | A*01:01ARS |
56+
| HLA-A*01:01:01 | lg | HLA-A*01:01ARS |
57+
| DRB1*14:06:01 | lg | DRB1*14:06ARS |
58+
| C*02:02 | lg | C*02:02ARS |
59+
| C*02:10 | lg | C*02:02ARS |

tests/steps/redux_allele.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def step_impl(context, level):
4242
context.redux_allele = context.ard_ping.redux(context.allele, level)
4343

4444

45+
@when("reducing on the {level} level with ARS suffix enabled")
46+
def step_impl(context, level):
47+
context.level = level
48+
context.redux_allele = context.ard_ars.redux(context.allele, level)
49+
50+
4551
@when("reducing on the {level} level (ambiguous)")
4652
def step_impl(context, level):
4753
context.level = level

0 commit comments

Comments
 (0)