Skip to content

Commit a1074d7

Browse files
authored
Merge pull request #169 from pbashyal-nmdp/expand_mac_api
/mac Endpoint to expand MAC to alleles
2 parents a7efff8 + 8ee8561 commit a1074d7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

api-spec.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ servers:
88
tags:
99
- name: ARD Reduction
1010
description: Reduce GL String to ARD
11+
- name: MAC Expansion
12+
description: Expand MAC to alleles
1113
paths:
1214
/redux:
1315
post:
@@ -60,6 +62,55 @@ paths:
6062
description: Describes what went wrong
6163
type: string
6264
example: "Invalid HLA locus"
65+
/mac/{allele_code}:
66+
get:
67+
tags:
68+
- MAC Expansion
69+
operationId: api.mac_expand_controller
70+
summary: Expand MAC (Allele Code)
71+
description: |
72+
Given a MAC Code, expand its allele components
73+
parameters:
74+
- name: allele_code
75+
in: path
76+
description: A valid MAC (Allele Code)
77+
required: true
78+
schema:
79+
type: string
80+
example: "HLA-A*01:AB"
81+
responses:
82+
200:
83+
description: Alleles corresponding to MAC
84+
content:
85+
application/json:
86+
schema:
87+
type: object
88+
properties:
89+
mac:
90+
description: MAC
91+
type: string
92+
example: "HLA-A*01:AB"
93+
gl_string:
94+
description: GL String version of expanded MAC
95+
type: string
96+
example: "HLA-A*01:01/HLA-A*01:02"
97+
expansion:
98+
description: Alleles corresponding to MAC
99+
type: array
100+
example:
101+
- "HLA-A*01:01"
102+
- "HLA-A*01:02"
103+
400:
104+
description: Invalid MAC Code
105+
content:
106+
application/json:
107+
schema:
108+
type: object
109+
properties:
110+
message:
111+
description: MAC Code is not valid
112+
type: string
113+
example: "Invalid MAC Code"
63114
/validate:
64115
post:
65116
tags:

api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@ def redux_controller():
4545

4646
# if no data is sent
4747
return {"message": "No input data provided"}, 404
48+
49+
50+
def mac_expand_controller(allele_code: str):
51+
try:
52+
if ard.is_mac(allele_code):
53+
alleles = ard.expand_mac(allele_code)
54+
return {
55+
"mac": allele_code,
56+
"alleles": alleles,
57+
"gl_string": "/".join(alleles),
58+
}, 200
59+
else:
60+
return {"message": f"{allele_code} is not a valid MAC"}, 404
61+
except PyArdError as e:
62+
return {"message": e.message}, 400

0 commit comments

Comments
 (0)