Skip to content

Commit

Permalink
Merge pull request #58 from cancervariants/issue-55
Browse files Browse the repository at this point in the history
Issue 55
  • Loading branch information
korikuzma authored Sep 7, 2021
2 parents 9087b56 + aeb685a commit 1b5c894
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 222 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ uvloop = "*"
websockets = "*"
httptools = "*"
typing-extensions = "*"
"ga4gh.vrsatile.pydantic" = "*"
11 changes: 4 additions & 7 deletions disease/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ def _add_merged_meta(self, response: Dict) -> Dict:
:return: completed response object.
"""
sources_meta = {}
vod = response['value_object_descriptor']
ids = [vod['value']['id']] + vod.get('xrefs', [])
vod = response['disease_descriptor']
ids = [vod['disease_id']] + vod.get('xrefs', [])
for concept_id in ids:
prefix = concept_id.split(':')[0]
src_name = PREFIX_LOOKUP[prefix.lower()]
Expand All @@ -337,10 +337,7 @@ def _add_vod(self, response: Dict, record: Dict, query: str,
vod = {
'id': f'normalize.disease:{quote(query)}',
'type': 'DiseaseDescriptor',
'value': {
'type': 'Disease',
'id': record['concept_id']
},
'disease_id': record['concept_id'],
'label': record['label'],
'extensions': [],
}
Expand All @@ -364,7 +361,7 @@ def _add_vod(self, response: Dict, record: Dict, query: str,
if not vod['extensions']:
del vod['extensions']
response['match_type'] = match_type
response['value_object_descriptor'] = vod
response['disease_descriptor'] = vod
response = self._add_merged_meta(response)
return response

Expand Down
124 changes: 4 additions & 120 deletions disease/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""
from typing import Any, Dict, Type, List, Optional, Union
from enum import Enum, IntEnum
from pydantic import BaseModel, StrictBool, validator
from pydantic import BaseModel, StrictBool
from datetime import datetime
from ga4gh.vrsatile.pydantic.vrsatile_model import ValueObjectDescriptor


class MatchType(IntEnum):
Expand Down Expand Up @@ -282,120 +283,6 @@ def schema_extra(schema: Dict[str, Any],
}


class DiseaseValue(BaseModel):
"""Class for Disease Value within VOD."""

type: str = "Disease"
id: str

@validator('type')
def check_type(cls, type_value):
"""Check that `type` field has value 'Disease'"""
if type_value != "Disease":
raise ValueError("DiseaseValue.type must be 'Disease'")
return type_value

class Config:
"""Configure model."""

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['Extension']) -> None:
"""Configure schema display."""
schema['example'] = {
"type": "Disease",
"id": "ncit:C3211"
}


class Extension(BaseModel):
"""Value Object Descriptor Extension class."""

type: str
name: str
value: Union[bool, List[str]]

class Config:
"""Configure model."""

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['Extension']) -> None:
"""Configure schema display."""
schema['example'] = {
"type": "Extension",
"name": "associated_with",
"value": [
"icd:C95.90",
"mesh:D007938",
"icd9:207.80",
"icd9.cm:208",
"umls:C0023418",
"icd10.cm:C95.90"
]
}


class ValueObjectDescriptor(BaseModel):
"""VOD class."""

id: str
type: str
value: DiseaseValue
label: str
xrefs: Optional[List[str]]
alternate_labels: Optional[List[str]]
extensions: Optional[List[Extension]]

class Config:
"""Configure model."""

@staticmethod
def schema_extra(schema: Dict[str, Any],
model: Type['Extension']) -> None:
"""Configure schema display."""
schema['example'] = {
"id": "normalize:non-hodgkin's lymphoma",
"type": "DiseaseDescriptor",
"value": {
"type": "Disease",
"id": "ncit:C3211"
},
"label": "Non-Hodgkin Lymphoma",
"xrefs": [
"mondo:0018908",
"oncotree:NHL",
"DOID:0060060"
],
"alternate_labels": [
"NHL",
"non-Hodgkin's lymphoma",
"non-Hodgkin's lymphoma (NHL)",
"NHL, NOS",
"non-Hodgkins lymphoma",
"Non-Hodgkin's Lymphoma (NHL)",
"non-Hodgkin lymphoma",
"Non-Hodgkin's Lymphoma",
"Non-Hodgkin lymphoma, NOS"
],
"extensions": [
{
"type": "Extension",
"name": "associated_with",
"value": [
"icdo:9591/3",
"umls:C0024305",
"omim:605027",
"orphanet:547",
"efo:0005952",
"meddra:10029547",
"mesh:D008228"
]
}
]
}


class ServiceMeta(BaseModel):
"""Metadata regarding the disease-normalization service."""

Expand Down Expand Up @@ -448,13 +335,10 @@ def schema_extra(schema: Dict[str, Any],
"query": "childhood leukemia",
"warnings": None,
"match_type": 80,
"value_object_descriptor": {
"disease_descriptor": {
"id": "normalize:childhood%20leukemia",
"type": "DiseaseDescriptor",
"value": {
"type": "Disease",
"id": "ncit:C4989"
},
"disease_id": "ncit:C4989",
"label": "Childhood Leukemia",
"xrefs": [
"mondo:0004355",
Expand Down
2 changes: 1 addition & 1 deletion disease/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.8"
__version__ = "0.2.9"
105 changes: 56 additions & 49 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,79 +10,86 @@

-i https://pypi.org/simple
-e .
appdirs==1.4.4
appnope==0.1.2; sys_platform == 'darwin' and platform_system == 'Darwin'
attrs==20.3.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
asgiref==3.4.1; python_version >= '3.6'
attrs==21.2.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
backcall==0.2.0
boto3==1.17.40
botocore==1.20.40; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
certifi==2020.12.5
cfgv==3.2.0; python_full_version >= '3.6.1'
chardet==4.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
click==7.1.2
backports.entry-points-selectable==1.1.0; python_version >= '2.7'
boto3==1.18.36
botocore==1.21.36; python_version >= '3.6'
certifi==2021.5.30
cfgv==3.3.1; python_full_version >= '3.6.1'
charset-normalizer==2.0.4; python_version >= '3'
click==8.0.1
coverage==5.5
coveralls==3.0.1
coveralls==3.2.0
cycler==0.10.0
decorator==4.4.2
distlib==0.3.1
debugpy==1.4.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
decorator==5.0.9; python_version >= '3.5'
distlib==0.3.2
docopt==0.6.2
fastapi==0.63.0
entrypoints==0.3; python_version >= '2.7'
fastapi==0.68.1
filelock==3.0.12
flake8-docstrings==1.6.0
flake8==3.9.0
flake8==3.9.2
ga4gh.vrsatile.pydantic==0.0.2
h11==0.12.0; python_version >= '3.6'
httptools==0.1.1
identify==2.2.2; python_full_version >= '3.6.1'
idna==2.10; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
httptools==0.3.0
identify==2.2.13; python_full_version >= '3.6.1'
idna==3.2; python_version >= '3'
iniconfig==1.1.1
ipykernel==5.5.0
ipykernel==6.3.1
ipython-genutils==0.2.0
ipython==7.22.0; python_version >= '3.7'
ipython==7.27.0; python_version >= '3.7'
isodate==0.6.0
jedi==0.18.0; python_version >= '3.6'
jmespath==0.10.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
jupyter-client==6.1.12; python_version >= '3.5'
jupyter-client==7.0.2; python_full_version >= '3.6.1'
jupyter-core==4.7.1; python_version >= '3.6'
kiwisolver==1.3.1; python_version >= '3.6'
matplotlib==3.4.0
kiwisolver==1.3.2; python_version >= '3.7'
matplotlib-inline==0.1.2; python_version >= '3.5'
matplotlib==3.4.3
mccabe==0.6.1
nodeenv==1.5.0
numpy==1.20.2; python_version >= '3.7'
owlready2==0.29
packaging==20.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
parso==0.8.1; python_version >= '3.6'
nest-asyncio==1.5.1; python_version >= '3.5'
nodeenv==1.6.0
numpy==1.21.2; python_version < '3.11' and python_version >= '3.7'
owlready2==0.33
packaging==21.0; python_version >= '3.6'
parso==0.8.2; python_version >= '3.6'
pexpect==4.8.0; sys_platform != 'win32'
pickleshare==0.7.5
pillow==8.1.2; python_version >= '3.6'
pluggy==0.13.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pre-commit==2.11.1
prompt-toolkit==3.0.18; python_full_version >= '3.6.1'
pillow==8.3.2; python_version >= '3.6'
platformdirs==2.3.0; python_version >= '3.6'
pluggy==1.0.0; python_version >= '3.6'
pre-commit==2.15.0
prompt-toolkit==3.0.20; python_full_version >= '3.6.2'
ptyprocess==0.7.0
py==1.10.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pycodestyle==2.7.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pydantic==1.8.1
pydocstyle==6.0.0; python_version >= '3.6'
pydantic==1.8.2
pydocstyle==6.1.1; python_version >= '3.6'
pyflakes==2.3.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pygments==2.8.1; python_version >= '3.5'
pygments==2.10.0; python_version >= '3.5'
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
pytest-cov==2.11.1
pytest==6.2.2
python-dateutil==2.8.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pytest-cov==2.12.1
pytest==6.2.5
python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pyyaml==5.4.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
pyzmq==22.0.3; python_version >= '3.6'
rdflib==5.0.0
requests==2.25.1
s3transfer==0.3.6
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pyzmq==22.2.1; python_version >= '3.6'
rdflib==6.0.0
requests==2.26.0
s3transfer==0.5.0; python_version >= '3.6'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
snowballstemmer==2.1.0
starlette==0.13.6; python_version >= '3.6'
starlette==0.14.2; python_version >= '3.6'
toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
tornado==6.1; python_version >= '3.5'
traitlets==5.0.5; python_version >= '3.7'
typing-extensions==3.7.4.3
urllib3==1.26.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
uvicorn==0.13.4
uvloop==0.15.2
virtualenv==20.4.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
traitlets==5.1.0; python_version >= '3.7'
typing-extensions==3.10.0.2
urllib3==1.26.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
uvicorn==0.15.0
uvloop==0.16.0
virtualenv==20.7.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
wcwidth==0.2.5
websockets==8.1
websockets==9.1
44 changes: 23 additions & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@
#

-i https://pypi.org/simple
boto3==1.17.40
botocore==1.20.40; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
certifi==2020.12.5
chardet==4.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
click==7.1.2
fastapi==0.63.0
asgiref==3.4.1; python_version >= '3.6'
boto3==1.18.36
botocore==1.21.36; python_version >= '3.6'
certifi==2021.5.30
charset-normalizer==2.0.4; python_version >= '3'
click==8.0.1
fastapi==0.68.1
ga4gh.vrsatile.pydantic==0.0.2
h11==0.12.0; python_version >= '3.6'
httptools==0.1.1
idna==2.10; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
httptools==0.3.0
idna==3.2; python_version >= '3'
isodate==0.6.0
jmespath==0.10.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
owlready2==0.29
pydantic==1.8.1
owlready2==0.33
pydantic==1.8.2
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
python-dateutil==2.8.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
rdflib==5.0.0
requests==2.25.1
s3transfer==0.3.6
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
starlette==0.13.6; python_version >= '3.6'
typing-extensions==3.7.4.3
urllib3==1.26.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
uvicorn==0.13.4
uvloop==0.15.2
websockets==8.1
python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
rdflib==6.0.0
requests==2.26.0
s3transfer==0.5.0; python_version >= '3.6'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
starlette==0.14.2; python_version >= '3.6'
typing-extensions==3.10.0.2
urllib3==1.26.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
uvicorn==0.15.0
uvloop==0.16.0
websockets==9.1
Loading

0 comments on commit 1b5c894

Please sign in to comment.