Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ servers:
tags:
- name: ARD Reduction
description: Reduce GL String to ARD
- name: MAC Expansion
description: Expand MAC to alleles
paths:
/redux:
post:
Expand Down Expand Up @@ -60,6 +62,55 @@ paths:
description: Describes what went wrong
type: string
example: "Invalid HLA locus"
/mac/{allele_code}:
get:
tags:
- MAC Expansion
operationId: api.mac_expand_controller
summary: Expand MAC (Allele Code)
description: |
Given a MAC Code, expand its allele components
parameters:
- name: allele_code
in: path
description: A valid MAC (Allele Code)
required: true
schema:
type: string
example: "HLA-A*01:AB"
responses:
200:
description: Alleles corresponding to MAC
content:
application/json:
schema:
type: object
properties:
mac:
description: MAC
type: string
example: "HLA-A*01:AB"
gl_string:
description: GL String version of expanded MAC
type: string
example: "HLA-A*01:01/HLA-A*01:02"
expansion:
description: Alleles corresponding to MAC
type: array
example:
- "HLA-A*01:01"
- "HLA-A*01:02"
400:
description: Invalid MAC Code
content:
application/json:
schema:
type: object
properties:
message:
description: MAC Code is not valid
type: string
example: "Invalid MAC Code"
/validate:
post:
tags:
Expand Down
15 changes: 15 additions & 0 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,18 @@ def redux_controller():

# if no data is sent
return {"message": "No input data provided"}, 404


def mac_expand_controller(allele_code: str):
try:
if ard.is_mac(allele_code):
alleles = ard.expand_mac(allele_code)
return {
"mac": allele_code,
"alleles": alleles,
"gl_string": "/".join(alleles),
}, 200
else:
return {"message": f"{allele_code} is not a valid MAC"}, 404
except PyArdError as e:
return {"message": e.message}, 400