diff --git a/api-spec.yaml b/api-spec.yaml index b10cfe2..ba15f85 100644 --- a/api-spec.yaml +++ b/api-spec.yaml @@ -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: @@ -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" diff --git a/api.py b/api.py index d93fc8d..c09d737 100644 --- a/api.py +++ b/api.py @@ -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 diff --git a/requirements-deploy.txt b/requirements-deploy.txt index 0e1ec03..0095330 100644 --- a/requirements-deploy.txt +++ b/requirements-deploy.txt @@ -1,2 +1,2 @@ -connexion[swagger-ui]==2.13.0 +connexion[swagger-ui, flask]==2.14.2 gunicorn==20.1.0 diff --git a/scripts/pyard b/scripts/pyard index 9d25e23..630d212 100755 --- a/scripts/pyard +++ b/scripts/pyard @@ -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) @@ -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) @@ -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)