Skip to content

Commit

Permalink
Merge pull request #326 from pbashyal-nmdp/ping_duplicate_alleles
Browse files Browse the repository at this point in the history
Ping reductions for duplicates
  • Loading branch information
mmaiers-nmdp committed May 31, 2024
2 parents 8ea841e + ada80f3 commit 7b55ab6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL MAINTAINER="Pradeep Bashyal"

WORKDIR /app

ARG PY_ARD_VERSION=1.2.0
ARG PY_ARD_VERSION=1.2.1

COPY requirements.txt /app
RUN pip install --no-cache-dir --upgrade pip && \
Expand Down
2 changes: 1 addition & 1 deletion api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: ARD Reduction
description: Reduce to ARD Level
version: "1.2.0"
version: "1.2.1"
servers:
- url: 'http://localhost:8080'
tags:
Expand Down
2 changes: 1 addition & 1 deletion pyard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from .misc import get_imgt_db_versions as db_versions

__author__ = """NMDP Bioinformatics"""
__version__ = "1.2.0"
__version__ = "1.2.1"


def init(
Expand Down
16 changes: 12 additions & 4 deletions pyard/ard.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,18 @@ def _redux_allele(
no_suffix_allele = redux_allele
if (
no_suffix_allele == allele
or "/" in no_suffix_allele
or no_suffix_allele in self.ars_mappings.p_not_g.values()
):
return redux_allele
redux_allele = self._redux_allele(
no_suffix_allele, redux_type, True

twice_redux_allele = self._redux_allele(
no_suffix_allele, redux_type, False
)
if self._is_valid_allele(redux_allele):
return redux_allele
if "/" in twice_redux_allele:
return twice_redux_allele
if self._is_valid_allele(twice_redux_allele):
return twice_redux_allele

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

def _add_lg_suffix(self, redux_allele):
if "/" in redux_allele:
return "/".join(
[self._add_lg_suffix(allele) for allele in redux_allele.split("/")]
)
# ARS suffix maybe used instead of g
if self._config["ARS_as_lg"]:
return redux_allele + "ARS"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.0
current_version = 1.2.1
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

setup(
name="py-ard",
version="1.2.0",
version="1.2.1",
description="ARD reduction for HLA with Python",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down
28 changes: 18 additions & 10 deletions tests/features/p_g_group.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ Feature: P and G Groups


Scenario Outline: allele reduction with ping
`ping` is the default.
`ping` is the default.

If there is no G group for the allele, it should use the P group allele.
If there is no G group for the allele, it should use the P group allele.

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

Examples:
| Allele | Level | Redux Allele |
| C*06:17 | lgx | C*06:02 |
| Allele | Level | Redux Allele |
| C*06:17 | lgx | C*06:02 |

Examples: DRB4*01s
| Allele | Level | Redux Allele |
Expand Down Expand Up @@ -83,9 +83,17 @@ Feature: P and G Groups
| DRB4*01:03:02:02 | lgx | DRB4*01:01 |

Examples: C*02:10s
| Allele | Level | Redux Allele |
| C*02:10:02 | lgx | C*02:02 |
| C*02:02 | lg | C*02:02g |
| C*02:02 | lgx | C*02:02 |
| C*02:10 | lg | C*02:02g |
| C*02:10 | lgx | C*02:02 |
| Allele | Level | Redux Allele |
| C*02:10:02 | lgx | C*02:02 |
| C*02:02 | lg | C*02:02g |
| C*02:02 | lgx | C*02:02 |
| C*02:10 | lg | C*02:02g |
| C*02:10 | lgx | C*02:02 |

Examples: lgx with duplicates
| Allele | Level | Redux Allele |
| DPA1*02:12 | lgx | DPA1*02:02/DPA1*02:07 |
| DPA1*02:12 | lg | DPA1*02:02g/DPA1*02:07g |
| DQA1*03:03 | lgx | DQA1*03:01 |
| DQA1*03:03 | lg | DQA1*03:01g |
| DQA1*03:03:09 | lg | DQA1*03:03g |

0 comments on commit 7b55ab6

Please sign in to comment.