Skip to content

Commit

Permalink
Rename endpoints and names (#17)
Browse files Browse the repository at this point in the history
* Rename endpoints and names
 - Change to *IPD-IMGT/HLA*
 - Change endpoint to `ipd-imgt-hla-versions`

* Upgrade Docker python to 3.10

* Fix quotes

* Fix quotes

* Bump version: 0.0.1 → 1.0.0

* Bump version: 1.0.0 → 2.0.0

* Fix name

* Fix keyname

* Fix package copy
  • Loading branch information
pbashyal-nmdp authored Aug 29, 2023
1 parent 0e3d4cd commit 60fc027
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 60 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ and "help wanted" is open to whoever wants to implement it.
Write Documentation
~~~~~~~~~~~~~~~~~~~

My Project Template could always use more documentation, whether as part of the
official My Project Template docs, in docstrings, or even on the web in blog posts,
GFE Service could always use more documentation, whether as part of the
official GFE Service docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim-buster
FROM python:3.10-slim-buster

LABEL MAINTAINER="Pradeep Bashyal"

Expand All @@ -13,7 +13,7 @@ RUN pip install --no-cache-dir -r requirements-deploy.txt
COPY api-spec.yaml /app/
COPY app.py /app/
COPY api.py /app/
COPY query.py /app/
COPY gfe_service /app/gfe_service/
COPY neo4j.yaml /app/

CMD ["gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]
2 changes: 1 addition & 1 deletion HEADER.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# gfe_service My Project Template.
# gfe_service GFE Service.
# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
Expand Down
44 changes: 22 additions & 22 deletions api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ servers:
- url: 'http://localhost:8080'
tags:
- name: IMGT
description: "Available IMGT DB releases"
description: "Available IPD-IMGT/HLA Database releases"
- name: GFE
description: Create and Retrieve GFE
- name: "Sequence Annotation"
description: Annotation by sequence (Coming Soon)
paths:
/imgt-versions:
/ipd-imgt-hla-versions:
get:
summary: IMGT DB versions in the DB
summary: IPD-IMGT/HLA Database versions in the GFE-DB
tags:
- IMGT
operationId: api.imgt_versions
description: Versions of IMGT DB Alleles in GFE DB
description: Versions of IPD-IMGT/HLA Database Alleles in GFE DB

responses:
200:
description: Version Numbers of Available IMGT DB
description: Version Numbers of Available IPD-IMGT/HLA Database
content:
application/json:
schema:
type: object
properties:
imgt_versions:
description: IMGT DB Versions
description: IPD-IMGT/HLA Database Versions
type: array
items:
type: string
Expand All @@ -56,25 +56,25 @@ paths:
type: string
example: "Database Unreachable"

/who/{who_name}:
/ipd/{ipd_name}:
get:
summary: Get GFE for a WHO name
summary: Get GFE for a IPD-IMGT/HLA HLA name
tags:
- GFE
operationId: api.gfe_from_who
description: For a given WHO Allele name, return the corresponding GFE
operationId: api.gfe_from_ipd
description: For a given IPD-IMGT/HLA Allele name, return the corresponding GFE
parameters:
- name: who_name
- name: ipd_name
in: path
description: WHO Allele name
description: IPD-IMGT/HLA Database Allele name
required: true
schema:
type: string
style: simple
example: "HLA-A*01:01:01:08"
responses:
200:
description: GFE from WHO allele name
description: GFE from IPD-IMGT/HLA allele name
content:
application/json:
schema:
Expand All @@ -88,12 +88,12 @@ paths:
description: GFE Name
type: string
example: "HLA-Aw878-8-363-912-830-2901-1044-581-151-324-198-9-316-80-508-43-151"
who:
description: WHO Name
allele:
description: IPD-IMGT/HLA Allele Name
type: string
example: "HLA-A*01:01:01:08"
imgt_versions:
description: IMGT Versions
description: IPD-IMGT/HLA Database Versions
type: array
items:
type: string
Expand All @@ -103,23 +103,23 @@ paths:

/gfe/locus/{gene}:
get:
summary: GFEs and WHO Names for a gene
summary: GFEs and IPD Allele Names for a gene
tags:
- GFE
operationId: api.all_locus_gfe
description: Get all GFEs and WHO Names for a gene
description: Get all GFEs and IPD Allele Names for a gene
parameters:
- name: gene
in: path
description: WHO Gene Name
description: IPD Allele Gene Name
required: true
schema:
type: string
style: simple
example: "HLA-A"
responses:
200:
description: List of WHO allele names and their corresponding GFEs
description: List of IPD Allele names and their corresponding GFEs
content:
application/json:
schema:
Expand All @@ -130,7 +130,7 @@ paths:
type: string
example: "HLA-A"
GFEs:
description: List of WHO alleles and GFE
description: List of IPD Alleles and GFE
type: array
items:
type: object
Expand All @@ -140,7 +140,7 @@ paths:
type: string
example: "HLA-Aw878-8-363-912-830-2901-1044-581-151-324-198-9-316-80-508-43-151"
who:
description: WHO Allele Name
description: IPD Allele Name
type: string
example: "HLA-A*01:01:01:08"

Expand Down
12 changes: 6 additions & 6 deletions api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import yaml
from py2neo import Graph

import query
from gfe_service import query

with open("neo4j.yaml", "r") as neo4j_file:
neo_dict = yaml.safe_load(neo4j_file)
Expand All @@ -20,14 +20,14 @@ def imgt_versions():
return {"imgt_versions": dbs}, 200


def gfe_from_who(who_name: str):
cypher = query.gfe_from_who()
response = graph.run(cypher, {"who_name": who_name})
def gfe_from_ipd(ipd_name: str):
cypher = query.gfe_from_ipd()
response = graph.run(cypher, {"ipd_name": ipd_name})
result = response.next()
return {
"locus": result["locus"],
"gfe": result["gfe"],
"who": result["who"],
"allele": result["allele"],
"imgt_versions": result["imgt_versions"],
}, 200

Expand All @@ -37,7 +37,7 @@ def all_locus_gfe(gene: str):
response = graph.run(cypher, {"locus": gene})
allele_gfe_list = []
for result in response:
allele_gfe_list.append({"allele": result["who"], "GFE": result["gfe"]})
allele_gfe_list.append({"allele": result["allele"], "GFE": result["gfe"]})
return {"gene": gene, "GFEs": allele_gfe_list}


Expand Down
6 changes: 3 additions & 3 deletions gfe_service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

#
# gfe_service My Project Template.
# gfe_service GFE Service.
# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@
#


"""Top-level package for My Project Template."""
"""Top-level package for gfe-service."""

__organization__ = "NMDP/CIBMTR Bioinformatics"
__version__ = "2.0.1"
__version__ = "2.0.0"
2 changes: 1 addition & 1 deletion gfe_service/gfe_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

#
# gfe_service My Project Template.
# gfe_service GFE Service.
# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
Expand Down
16 changes: 8 additions & 8 deletions query.py → gfe_service/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def imgt_db_versions():
query = """
MATCH (g:GFE)-[e:HAS_WHO]-(w:WHO)
MATCH (g:GFE)-[e:HAS_IPD_Allele]-(a:IPD_Allele)
WITH COLLECT(DISTINCT e.releases) AS releases
UNWIND REDUCE(output=[], r IN releases| output + r) as dbs
RETURN COLLECT(DISTINCT dbs) as HLA_DB_VERSIONS
Expand All @@ -9,20 +9,20 @@ def imgt_db_versions():
return query


def gfe_from_who():
def gfe_from_ipd():
query = """
MATCH (g:GFE)-[r:HAS_WHO]-(w:WHO)
WHERE w.name = $who_name
RETURN g.locus AS locus, g.gfe_name AS gfe, w.name AS who, r.releases AS imgt_versions
MATCH (g:GFE)-[r:HAS_IPD_Allele]-(a:IPD_Allele)
WHERE a.name = $allele
RETURN g.locus AS locus, g.gfe_name AS gfe, a.name AS allele, r.releases AS imgt_versions
"""
return query


def all_gfe_from_locus():
query = """
MATCH (g:GFE)-[:HAS_WHO]-(w:WHO)
MATCH (g:GFE)-[:HAS_IPD_Allele]-(a:IPD_Allele)
WHERE g.locus = $locus
RETURN g.gfe_name AS gfe, w.name AS who
RETURN g.gfe_name AS gfe, a.name AS allele
limit 100
"""
return query
Expand All @@ -31,6 +31,6 @@ def all_gfe_from_locus():
def sequence_from_gfe():
query = """
MATCH (g:GFE)-[:HAS_SEQUENCE]-(s:Sequence)
WHERE g.gfe_name = $gfe return s.sequence as sequence;
WHERE g.name = $gfe return s.sequence as sequence;
"""
return query
3 changes: 1 addition & 2 deletions neo4j.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
user: "neo4j"
password: "gfedb"
# neo4j_url: "http://0.0.0.0:7474"
neo4j_url: "http://dev-gfedb.b12x.org:7474"
neo4j_url: "http://workshop-gfedb.b12x.org:7474"
4 changes: 2 additions & 2 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==6.2.5
pytest==7.1.2
behave==1.2.6
PyHamcrest==2.0.2
PyHamcrest==2.0.3
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
py2neo==2021.2.3
13 changes: 6 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[bumpversion]
current_version = 0.0.1
current_version = 2.0.0
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
search = version="{current_version}"
replace = version="{new_version}"

[bumpversion:file:my_project_template/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
[bumpversion:file:gfe_service/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bdist_wheel]
universal = 1
Expand All @@ -18,5 +18,4 @@ universal = 1
exclude = docs

[aliases]
# Define setup.py command aliases here
test = pytest
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

#
# gfe_service My Project Template.
# gfe_service GFE Service.
# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -57,12 +57,12 @@
license="LGPL 3.0",
long_description=readme + "\n\n" + history,
include_package_data=True,
keywords="gfe_service",
keywords="GFE,HLA",
name="gfe_service",
packages=find_packages(include=["gfe_service"]),
test_suite="tests",
tests_require=test_requirements,
url="https://github.com/nmdp-bioinformatics/my_project_template",
version="0.0.1",
version="2.0.0",
zip_safe=False,
)
2 changes: 1 addition & 1 deletion tests/unit/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

#
# gfe_service My Project Template.
# gfe_service GFE Service.
# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
Expand Down

0 comments on commit 60fc027

Please sign in to comment.