Skip to content

Commit 9da850c

Browse files
committed
Add /similar endpoint
- Return alleles/MACs starting with the given prefix - upgrade flask connection
1 parent 741c8fe commit 9da850c

File tree

4 files changed

+73
-15
lines changed

4 files changed

+73
-15
lines changed

api-spec.yaml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ info:
66
servers:
77
- url: 'http://localhost:8080'
88
tags:
9-
- name: Database
10-
description: IPD-IMGT/HLA DB Information
119
- name: ARD Reduction
1210
description: Reduce GL String to ARD
11+
- name: CWD Reduction
12+
description: Reduce GL String to CWD (version 2)
1313
- name: MAC
1414
description: Expand/Collapse MAC to/from alleles
15-
- name: DRBX Blender
16-
description: Blend DRBX based on DRB1 and DRB3/4/5
1715
- name: Validation
1816
description: Validate a GL String or Allele
17+
- name: DRBX Blender
18+
description: Blend DRBX based on DRB1 and DRB3/4/5
19+
- name: Broad Splits
20+
description: Broad Split Mappings
21+
- name: Database
22+
description: IPD-IMGT/HLA DB Information
1923
paths:
2024
/version:
2125
get:
@@ -462,10 +466,58 @@ paths:
462466
Broad/Split mapping not found for the given allele
463467
content:
464468
application/json:
465-
schema:
466-
type: object
467-
properties:
468-
message:
469-
description: Mapping not found
470-
type: string
471-
example: "Broad/Split not found"
469+
schema:
470+
type: object
471+
properties:
472+
message:
473+
description: Mapping not found
474+
type: string
475+
example: "Broad/Split not found"
476+
/similar/{allele_prefix}:
477+
get:
478+
tags:
479+
- Database
480+
operationId: api.similar_controller
481+
summary: Search For Similar Alleles and MACs
482+
description: |
483+
Given a prefix of an allele or MAC, find all the alleles
484+
beginning with the prefix.
485+
parameters:
486+
- name: allele_prefix
487+
in: path
488+
description: |
489+
Prefix of an Allele/MAC with a minimum of locus and a first field
490+
required: true
491+
schema:
492+
type: string
493+
example: A*01:9
494+
responses:
495+
200:
496+
description: List of alleles with the given prefix
497+
content:
498+
application/json:
499+
schema:
500+
type: array
501+
items:
502+
example:
503+
- A*01:91
504+
- A*01:92
505+
- A*01:93
506+
- A*01:94
507+
- A*01:95
508+
- A*01:96
509+
- A*01:97
510+
- A*01:98
511+
- A*01:99
512+
404:
513+
description: |
514+
No matching alleles or MACs found
515+
content:
516+
application/json:
517+
schema:
518+
type: object
519+
properties:
520+
message:
521+
description: No similar alleles
522+
type: string
523+
example: "No similar alleles"

api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,12 @@ def cwd_redux_controller():
143143

144144
# if no data is sent
145145
return {"message": "No input data provided"}, 404
146+
147+
148+
def similar_controller(allele_prefix: str):
149+
if allele_prefix:
150+
alleles = ard.similar_alleles(allele_prefix)
151+
if alleles:
152+
return alleles, 200
153+
return {"message": "No similar alleles found."}, 400
154+
return {"message": "No input data provided"}, 404

requirements-deploy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
connexion[swagger-ui]==2.13.0
1+
connexion[swagger-ui, flask]==2.14.2
22
gunicorn==20.1.0

scripts/pyard

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def find_similar_alleles(prefix):
4545

4646

4747
def lookup_mac_codes():
48-
global e
4948
try:
5049
mac = ard.lookup_mac(args.lookup_mac)
5150
print(mac)
@@ -55,7 +54,6 @@ def lookup_mac_codes():
5554

5655

5756
def expand_mac_code():
58-
global allele_list, e
5957
try:
6058
allele_list = ard.expand_mac(args.expand_mac)
6159
print(allele_list)
@@ -79,7 +77,6 @@ def show_version():
7977

8078

8179
def perform_cwd_redux():
82-
global cwd_redux
8380
if args.validate:
8481
ard.validate(args.cwd)
8582
cwd_redux = ard.cwd_redux(args.cwd)

0 commit comments

Comments
 (0)