Skip to content

Commit d8c9b58

Browse files
committed
ARS_as_lg as a config flag to allow **ARS** suffix instead of **g** for lg reduction mode.
1 parent 85b7c11 commit d8c9b58

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

pyard/ard.py

Lines changed: 4 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,8 @@ 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+
if self._config["ARS_as_lg"]:
219+
return redux_allele + "ARS"
217220
# lg mode has g appended with lgx reduction
218221
return redux_allele + "g"
219222
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,20 @@ Feature: Alleles
4040
| C*02:10 | lg | C*02:02g |
4141
| C*02:10 | lgx | C*02:02 |
4242
| 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)