Skip to content

Commit

Permalink
Add /similar endpoint
Browse files Browse the repository at this point in the history
 - Return alleles/MACs starting with the given prefix
 - upgrade flask connection
  • Loading branch information
pbashyal-nmdp committed Nov 13, 2023
1 parent 741c8fe commit 9da850c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 15 deletions.
74 changes: 63 additions & 11 deletions api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ info:
servers:
- url: 'http://localhost:8080'
tags:
- name: Database
description: IPD-IMGT/HLA DB Information
- name: ARD Reduction
description: Reduce GL String to ARD
- name: CWD Reduction
description: Reduce GL String to CWD (version 2)
- name: MAC
description: Expand/Collapse MAC to/from alleles
- name: DRBX Blender
description: Blend DRBX based on DRB1 and DRB3/4/5
- name: Validation
description: Validate a GL String or Allele
- name: DRBX Blender
description: Blend DRBX based on DRB1 and DRB3/4/5
- name: Broad Splits
description: Broad Split Mappings
- name: Database
description: IPD-IMGT/HLA DB Information
paths:
/version:
get:
Expand Down Expand Up @@ -462,10 +466,58 @@ paths:
Broad/Split mapping not found for the given allele
content:
application/json:
schema:
type: object
properties:
message:
description: Mapping not found
type: string
example: "Broad/Split not found"
schema:
type: object
properties:
message:
description: Mapping not found
type: string
example: "Broad/Split not found"
/similar/{allele_prefix}:
get:
tags:
- Database
operationId: api.similar_controller
summary: Search For Similar Alleles and MACs
description: |
Given a prefix of an allele or MAC, find all the alleles
beginning with the prefix.
parameters:
- name: allele_prefix
in: path
description: |
Prefix of an Allele/MAC with a minimum of locus and a first field
required: true
schema:
type: string
example: A*01:9
responses:
200:
description: List of alleles with the given prefix
content:
application/json:
schema:
type: array
items:
example:
- A*01:91
- A*01:92
- A*01:93
- A*01:94
- A*01:95
- A*01:96
- A*01:97
- A*01:98
- A*01:99
404:
description: |
No matching alleles or MACs found
content:
application/json:
schema:
type: object
properties:
message:
description: No similar alleles
type: string
example: "No similar alleles"
9 changes: 9 additions & 0 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,12 @@ def cwd_redux_controller():

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


def similar_controller(allele_prefix: str):
if allele_prefix:
alleles = ard.similar_alleles(allele_prefix)
if alleles:
return alleles, 200
return {"message": "No similar alleles found."}, 400
return {"message": "No input data provided"}, 404
2 changes: 1 addition & 1 deletion requirements-deploy.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
connexion[swagger-ui]==2.13.0
connexion[swagger-ui, flask]==2.14.2
gunicorn==20.1.0
3 changes: 0 additions & 3 deletions scripts/pyard
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def find_similar_alleles(prefix):


def lookup_mac_codes():
global e
try:
mac = ard.lookup_mac(args.lookup_mac)
print(mac)
Expand All @@ -55,7 +54,6 @@ def lookup_mac_codes():


def expand_mac_code():
global allele_list, e
try:
allele_list = ard.expand_mac(args.expand_mac)
print(allele_list)
Expand All @@ -79,7 +77,6 @@ def show_version():


def perform_cwd_redux():
global cwd_redux
if args.validate:
ard.validate(args.cwd)
cwd_redux = ard.cwd_redux(args.cwd)
Expand Down

0 comments on commit 9da850c

Please sign in to comment.