Skip to content

Commit 7b55ab6

Browse files
authored
Merge pull request #326 from pbashyal-nmdp/ping_duplicate_alleles
Ping reductions for duplicates
2 parents 8ea841e + ada80f3 commit 7b55ab6

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LABEL MAINTAINER="Pradeep Bashyal"
44

55
WORKDIR /app
66

7-
ARG PY_ARD_VERSION=1.2.0
7+
ARG PY_ARD_VERSION=1.2.1
88

99
COPY requirements.txt /app
1010
RUN pip install --no-cache-dir --upgrade pip && \

api-spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ openapi: 3.0.3
22
info:
33
title: ARD Reduction
44
description: Reduce to ARD Level
5-
version: "1.2.0"
5+
version: "1.2.1"
66
servers:
77
- url: 'http://localhost:8080'
88
tags:

pyard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .misc import get_imgt_db_versions as db_versions
2727

2828
__author__ = """NMDP Bioinformatics"""
29-
__version__ = "1.2.0"
29+
__version__ = "1.2.1"
3030

3131

3232
def init(

pyard/ard.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,18 @@ def _redux_allele(
225225
no_suffix_allele = redux_allele
226226
if (
227227
no_suffix_allele == allele
228+
or "/" in no_suffix_allele
228229
or no_suffix_allele in self.ars_mappings.p_not_g.values()
229230
):
230231
return redux_allele
231-
redux_allele = self._redux_allele(
232-
no_suffix_allele, redux_type, True
232+
233+
twice_redux_allele = self._redux_allele(
234+
no_suffix_allele, redux_type, False
233235
)
234-
if self._is_valid_allele(redux_allele):
235-
return redux_allele
236+
if "/" in twice_redux_allele:
237+
return twice_redux_allele
238+
if self._is_valid_allele(twice_redux_allele):
239+
return twice_redux_allele
236240

237241
if redux_type == "G" and allele in self.ars_mappings.g_group:
238242
if allele in self.ars_mappings.dup_g:
@@ -338,6 +342,10 @@ def _redux_allele(
338342
raise InvalidAlleleError(f"{allele} is an invalid allele.")
339343

340344
def _add_lg_suffix(self, redux_allele):
345+
if "/" in redux_allele:
346+
return "/".join(
347+
[self._add_lg_suffix(allele) for allele in redux_allele.split("/")]
348+
)
341349
# ARS suffix maybe used instead of g
342350
if self._config["ARS_as_lg"]:
343351
return redux_allele + "ARS"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.2.0
2+
current_version = 1.2.1
33
commit = True
44
tag = True
55

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
setup(
3838
name="py-ard",
39-
version="1.2.0",
39+
version="1.2.1",
4040
description="ARD reduction for HLA with Python",
4141
long_description=readme,
4242
long_description_content_type="text/markdown",

tests/features/p_g_group.feature

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ Feature: P and G Groups
1313

1414

1515
Scenario Outline: allele reduction with ping
16-
`ping` is the default.
16+
`ping` is the default.
1717

18-
If there is no G group for the allele, it should use the P group allele.
18+
If there is no G group for the allele, it should use the P group allele.
1919

2020
Given the allele as <Allele>
2121
When reducing on the <Level> level with ping
2222
Then the reduced allele is found to be <Redux Allele>
2323

2424
Examples:
25-
| Allele | Level | Redux Allele |
26-
| C*06:17 | lgx | C*06:02 |
25+
| Allele | Level | Redux Allele |
26+
| C*06:17 | lgx | C*06:02 |
2727

2828
Examples: DRB4*01s
2929
| Allele | Level | Redux Allele |
@@ -83,9 +83,17 @@ Feature: P and G Groups
8383
| DRB4*01:03:02:02 | lgx | DRB4*01:01 |
8484

8585
Examples: C*02:10s
86-
| Allele | Level | Redux Allele |
87-
| C*02:10:02 | lgx | C*02:02 |
88-
| C*02:02 | lg | C*02:02g |
89-
| C*02:02 | lgx | C*02:02 |
90-
| C*02:10 | lg | C*02:02g |
91-
| C*02:10 | lgx | C*02:02 |
86+
| Allele | Level | Redux Allele |
87+
| C*02:10:02 | lgx | C*02:02 |
88+
| C*02:02 | lg | C*02:02g |
89+
| C*02:02 | lgx | C*02:02 |
90+
| C*02:10 | lg | C*02:02g |
91+
| C*02:10 | lgx | C*02:02 |
92+
93+
Examples: lgx with duplicates
94+
| Allele | Level | Redux Allele |
95+
| DPA1*02:12 | lgx | DPA1*02:02/DPA1*02:07 |
96+
| DPA1*02:12 | lg | DPA1*02:02g/DPA1*02:07g |
97+
| DQA1*03:03 | lgx | DQA1*03:01 |
98+
| DQA1*03:03 | lg | DQA1*03:01g |
99+
| DQA1*03:03:09 | lg | DQA1*03:03g |

0 commit comments

Comments
 (0)