Skip to content

Commit a0f2a0f

Browse files
authored
Merge pull request #335 from pbashyal-nmdp/ard_endpoint
`/ard/{allele}` endpoint for `lgx` reduction
2 parents 67b77cc + 98cc66a commit a0f2a0f

File tree

6 files changed

+96
-13
lines changed

6 files changed

+96
-13
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.5.2
7+
ARG PY_ARD_VERSION=1.5.3
88

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

api-spec.yaml

Lines changed: 72 additions & 7 deletions
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.5.2"
5+
version: "1.5.3"
66
servers:
77
- url: 'http://localhost:8080'
88
tags:
@@ -36,22 +36,35 @@ paths:
3636
application/json:
3737
schema:
3838
properties:
39-
ipd-version:
39+
ipd_version:
4040
description: IPD-IMGT/HLA DB Version
4141
type: integer
42-
example: 3560
43-
py-ard-version:
42+
example: 3580
43+
pyard_version:
4444
description: py-ard library version
4545
type: string
46-
example: "1.2.1"
46+
example: "1.5.0"
4747
/redux:
4848
post:
4949
tags:
5050
- ARD Reduction
5151
operationId: api.redux_controller
52-
summary: Reduce to ARD
52+
summary: Reduce GL String at various level
5353
description: |
54-
Given a GL String and a reduction method perform ARD Reduction
54+
Given a GL String and a reduction method perform Reduction.
55+
56+
Valid Reduction Method:
57+
| Reduction Type | Description |
58+
|----------------|-----------------------------------------------------------|
59+
| `G` | Reduce to G Group Level |
60+
| `P` | Reduce to P Group Level |
61+
| `lg` | Reduce to 2 field ARD level (append `g`) |
62+
| `lgx` | Reduce to 2 field ARD level |
63+
| `W` | Reduce/Expand to full field(4,3,2) WHO nomenclature level |
64+
| `exon` | Reduce/Expand to 3 field level |
65+
| `U2` | Reduce to 2 field unambiguous level |
66+
| `S` | Reduce to Serological level |
67+
5568
requestBody:
5669
content:
5770
application/json:
@@ -97,6 +110,58 @@ paths:
97110
description: Describes what went wrong
98111
type: string
99112
example: "Invalid HLA locus"
113+
/ard/{allele}:
114+
get:
115+
tags:
116+
- ARD Reduction
117+
operationId: api.lgx_controller
118+
summary: Reduce to ARD
119+
description: |
120+
Get ARD Reduction for an Allele
121+
parameters:
122+
- name: allele
123+
in: path
124+
description: An allele or MAC
125+
required: true
126+
schema:
127+
type: string
128+
example: "DPA1*02:07:01"
129+
responses:
130+
200:
131+
description: ARD Reduction Result
132+
content:
133+
application/json:
134+
schema:
135+
type: object
136+
properties:
137+
allele:
138+
description: Allele
139+
type: string
140+
example: "DPA1*02:07:01"
141+
ard:
142+
description: ARD version
143+
type: string
144+
example: "DPA1*02:02"
145+
ipd_version:
146+
description: IPD-IMGT/HLA DB Version
147+
type: integer
148+
example: 3580
149+
pyard_version:
150+
description: py-ard library version
151+
type: string
152+
example: "1.2.1"
153+
154+
400:
155+
description: Invalid Allele
156+
content:
157+
application/json:
158+
schema:
159+
type: object
160+
properties:
161+
message:
162+
description: Describes what went wrong
163+
type: string
164+
example: "Invalid HLA locus"
100165
/cwd-redux:
101166
post:
102167
tags:

api.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ def redux_controller():
5858
return {"message": "No input data provided"}, 404
5959

6060

61+
def lgx_controller(allele):
62+
# Perform redux
63+
if allele:
64+
try:
65+
redux_string = ard.redux(allele, "lgx")
66+
ipd_version = ard.get_db_version()
67+
return {
68+
"ipd_version": ipd_version,
69+
"pyard_version": pyard.__version__,
70+
"allele": allele,
71+
"ard": redux_string,
72+
}, 200
73+
except PyArdError as e:
74+
return {"message": e.message}, 400
75+
else:
76+
return {"message": f"No allele provided"}, 404
77+
78+
6179
def mac_expand_controller(allele_code: str):
6280
try:
6381
if ard.is_mac(allele_code):
@@ -107,8 +125,8 @@ def drbx_blender_controller():
107125
def version_controller():
108126
ipd_version = ard.get_db_version()
109127
return {
110-
"ipd-version": ipd_version,
111-
"py-ard-version": pyard.__version__,
128+
"ipd_version": ipd_version,
129+
"pyard_version": pyard.__version__,
112130
}, 200
113131

114132

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.5.2"
29+
__version__ = "1.5.3"
3030

3131

3232
def init(

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.5.2
2+
current_version = 1.5.3
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.5.2",
39+
version="1.5.3",
4040
description="ARD reduction for HLA with Python",
4141
long_description=readme,
4242
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)