diff --git a/api-spec.yaml b/api-spec.yaml index 83ddb6f..954a9cf 100644 --- a/api-spec.yaml +++ b/api-spec.yaml @@ -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: @@ -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: diff --git a/api.py b/api.py index c841366..13291cb 100644 --- a/api.py +++ b/api.py @@ -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): @@ -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