Skip to content

Commit

Permalink
Add /ard GET endpoint that lgx reduces the allele in path.
Browse files Browse the repository at this point in the history
e.g. `http://127.0.0.1:8080/ard/DPA1*02:07:01`

Makes it easy to create a lgx reduction URL.
  • Loading branch information
pbashyal-nmdp committed Oct 30, 2024
1 parent 67b77cc commit a29eb17
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 8 deletions.
77 changes: 71 additions & 6 deletions api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,35 @@ paths:
application/json:
schema:
properties:
ipd-version:
ipd_version:
description: IPD-IMGT/HLA DB Version
type: integer
example: 3560
py-ard-version:
example: 3580
pyard_version:
description: py-ard library version
type: string
example: "1.2.1"
example: "1.5.0"
/redux:
post:
tags:
- ARD Reduction
operationId: api.redux_controller
summary: Reduce to ARD
summary: Reduce GL String at various level
description: |
Given a GL String and a reduction method perform ARD Reduction
Given a GL String and a reduction method perform Reduction.
Valid Reduction Method:
| Reduction Type | Description |
|----------------|-----------------------------------------------------------|
| `G` | Reduce to G Group Level |
| `P` | Reduce to P Group Level |
| `lg` | Reduce to 2 field ARD level (append `g`) |
| `lgx` | Reduce to 2 field ARD level |
| `W` | Reduce/Expand to full field(4,3,2) WHO nomenclature level |
| `exon` | Reduce/Expand to 3 field level |
| `U2` | Reduce to 2 field unambiguous level |
| `S` | Reduce to Serological level |
requestBody:
content:
application/json:
Expand Down Expand Up @@ -97,6 +110,58 @@ paths:
description: Describes what went wrong
type: string
example: "Invalid HLA locus"
/ard/{allele}:
get:
tags:
- ARD Reduction
operationId: api.lgx_controller
summary: Reduce to ARD
description: |
Get ARD Reduction for an Allele
parameters:
- name: allele
in: path
description: An allele or MAC
required: true
schema:
type: string
example: "DPA1*02:07:01"
responses:
200:
description: ARD Reduction Result
content:
application/json:
schema:
type: object
properties:
allele:
description: Allele
type: string
example: "DPA1*02:07:01"
ard:
description: ARD version
type: string
example: "DPA1*02:02"
ipd_version:
description: IPD-IMGT/HLA DB Version
type: integer
example: 3580
pyard_version:
description: py-ard library version
type: string
example: "1.2.1"

400:
description: Invalid Allele
content:
application/json:
schema:
type: object
properties:
message:
description: Describes what went wrong
type: string
example: "Invalid HLA locus"
/cwd-redux:
post:
tags:
Expand Down
22 changes: 20 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ def redux_controller():
return {"message": "No input data provided"}, 404


def lgx_controller(allele):
# Perform redux
if allele:
try:
redux_string = ard.redux(allele, "lgx")
ipd_version = ard.get_db_version()
return {
"ipd_version": ipd_version,
"pyard_version": pyard.__version__,
"allele": allele,
"ard": redux_string,
}, 200
except PyArdError as e:
return {"message": e.message}, 400
else:
return {"message": f"No allele provided"}, 404


def mac_expand_controller(allele_code: str):
try:
if ard.is_mac(allele_code):
Expand Down Expand Up @@ -107,8 +125,8 @@ def drbx_blender_controller():
def version_controller():
ipd_version = ard.get_db_version()
return {
"ipd-version": ipd_version,
"py-ard-version": pyard.__version__,
"ipd_version": ipd_version,
"pyard_version": pyard.__version__,
}, 200


Expand Down

0 comments on commit a29eb17

Please sign in to comment.