diff --git a/Pipfile b/Pipfile index 2b17634c..08a75ee7 100644 --- a/Pipfile +++ b/Pipfile @@ -5,7 +5,7 @@ name = "pypi" [packages] pydantic = "*" -fastapi = ">=0.72.0" +fastapi = "*" uvicorn = "*" click = "*" boto3 = "*" @@ -13,13 +13,12 @@ beautifulsoup4 = "*" gffutils = "*" requests = "*" "biocommons.seqrepo" = "*" -"ga4gh.vrs" = {version = ">=0.7.2", extras = ["extras"]} +"ga4gh.vrs" = {version = ">=0.7.5.dev1", extras = ["extras"]} uvloop = "*" websockets = "*" httptools = "*" typing-extensions = "*" -"ga4gh.vrsatile.pydantic" = ">=0.0.5" -jsonschema = ">=2.3, <4.0" +"ga4gh.vrsatile.pydantic" = ">=0.0.10" [dev-packages] gene = {editable = true, path = "."} diff --git a/gene/__init__.py b/gene/__init__.py index 3864de11..fb923279 100644 --- a/gene/__init__.py +++ b/gene/__init__.py @@ -18,6 +18,13 @@ logger.setLevel(logging.DEBUG) logger.handlers = [] +logging.getLogger("boto3").setLevel(logging.INFO) +logging.getLogger("botocore").setLevel(logging.INFO) +logging.getLogger("urllib3").setLevel(logging.INFO) +logging.getLogger("python_jsonschema_objects").setLevel(logging.INFO) +logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel(logging.INFO) # noqa: E501 +logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO) # noqa: E501 + if 'GENE_NORM_EB_PROD' in environ: ch = logging.StreamHandler() ch.setLevel(logging.INFO) diff --git a/gene/query.py b/gene/query.py index dfd40067..102f1bbb 100644 --- a/gene/query.py +++ b/gene/query.py @@ -2,7 +2,6 @@ import re from typing import List, Dict, Set from urllib.parse import quote -from uvicorn.config import logger from .version import __version__ from gene import NAMESPACE_LOOKUP, PREFIX_LOOKUP, ITEM_TYPES from gene.database import Database @@ -12,6 +11,7 @@ from botocore.exceptions import ClientError from boto3.dynamodb.conditions import Key from datetime import datetime +from gene import logger class InvalidParameterException(Exception): @@ -241,7 +241,7 @@ def _get_service_meta() -> ServiceMeta: """ return ServiceMeta( version=__version__, - response_datetime=datetime.now() + response_datetime=str(datetime.now()) ) def search(self, query_str: str, keyed: bool = False, diff --git a/gene/schemas.py b/gene/schemas.py index 3ed832a6..7842d412 100644 --- a/gene/schemas.py +++ b/gene/schemas.py @@ -8,7 +8,6 @@ from ga4gh.vrsatile.pydantic.vrs_models import SequenceLocation, \ ChromosomeLocation, CURIE from ga4gh.vrsatile.pydantic.vrsatile_models import GeneDescriptor -from datetime import datetime from pydantic.types import StrictStr @@ -82,6 +81,8 @@ class Gene(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['Gene']) -> None: @@ -201,6 +202,8 @@ class SourceMeta(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['SourceMeta']) -> None: @@ -235,6 +238,8 @@ class MatchesKeyed(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['MatchesKeyed']) -> None: @@ -276,6 +281,8 @@ class MatchesListed(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['MatchesListed']) -> None: @@ -309,12 +316,14 @@ class ServiceMeta(BaseModel): name = 'gene-normalizer' version: StrictStr - response_datetime: datetime + response_datetime: StrictStr url = 'https://github.com/cancervariants/gene-normalization' class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['ServiceMeta']) -> None: @@ -326,7 +335,7 @@ def schema_extra(schema: Dict[str, Any], schema['example'] = { 'name': 'gene-normalizer', 'version': '0.1.0', - 'response_datetime': '2021-04-05T16:44:15.367831', + 'response_datetime': '2022-03-23 15:57:14.180908', 'url': 'https://github.com/cancervariants/gene-normalization' } @@ -342,6 +351,8 @@ class SearchService(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['SearchService']) -> None: @@ -388,7 +399,7 @@ def schema_extra(schema: Dict[str, Any], "service_meta_": { 'name': 'gene-normalizer', 'version': '0.1.0', - 'response_datetime': '2021-04-05T16:44:15.367831', + 'response_datetime': '2022-03-23 15:57:14.180908', 'url': 'https://github.com/cancervariants/gene-normalization' # noqa: E501 } } @@ -407,6 +418,8 @@ class NormalizeService(BaseModel): class Config: """Configure model example""" + use_enum_values = True + @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['NormalizeService']) -> None: @@ -533,7 +546,7 @@ def schema_extra(schema: Dict[str, Any], "service_meta_": { 'name': 'gene-normalizer', 'version': '0.1.19', - 'response_datetime': '2021-09-06T10:52:20.334720', + 'response_datetime': '2022-03-23 15:57:14.180908', 'url': 'https://github.com/cancervariants/gene-normalization' # noqa: E501 } } diff --git a/gene/version.py b/gene/version.py index f545e732..e206f1dc 100644 --- a/gene/version.py +++ b/gene/version.py @@ -1,2 +1,2 @@ """Gene normalizer version""" -__version__ = "0.1.24" +__version__ = "0.1.25" diff --git a/gene/vrs_locations/chromosome_location.py b/gene/vrs_locations/chromosome_location.py index a753a0d7..e2c36e02 100644 --- a/gene/vrs_locations/chromosome_location.py +++ b/gene/vrs_locations/chromosome_location.py @@ -23,8 +23,10 @@ def add_location(self, location): chr=location['chr'], interval=models.CytobandInterval( start=location['start'], - end=location['end'] - ) + end=location['end'], + type="CytobandInterval" + ), + type="ChromosomeLocation" ) chr_location._id = ga4gh_identify(chr_location) return chr_location.as_dict() diff --git a/gene/vrs_locations/sequence_location.py b/gene/vrs_locations/sequence_location.py index 3deeb2a3..2dcc8f3e 100644 --- a/gene/vrs_locations/sequence_location.py +++ b/gene/vrs_locations/sequence_location.py @@ -38,9 +38,12 @@ def add_location(self, seqid, gene, params, sr): seq_location = models.SequenceLocation( sequence_id=sequence_id, interval=models.SequenceInterval( - start=models.Number(value=gene.start - 1), - end=models.Number(value=gene.end) - ) + start=models.Number(value=gene.start - 1, + type="Number"), + end=models.Number(value=gene.end, type="Number"), + type="SequenceInterval" + ), + type="SequenceLocation" ) seq_location._id = ga4gh_identify(seq_location) location = seq_location.as_dict() diff --git a/requirements-dev.txt b/requirements-dev.txt index b9ee403a..b44f818d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,7 +10,6 @@ -i https://pypi.org/simple -e . --e . anyio==3.5.0; python_full_version >= '3.6.2' appdirs==1.4.4 appnope==0.1.2; sys_platform == 'darwin' @@ -18,7 +17,7 @@ argcomplete==2.0.0; python_version >= '3.6' argh==0.26.2 argon2-cffi-bindings==21.2.0; python_version >= '3.6' argon2-cffi==21.3.0; python_version >= '3.6' -asgiref==3.4.1; python_version >= '3.6' +asgiref==3.5.0; python_version >= '3.7' asttokens==2.0.5 attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' babel==2.9.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' @@ -26,144 +25,142 @@ backcall==0.2.0 beautifulsoup4==4.10.0 biocommons.seqrepo==0.6.5 bioutils==0.5.5; python_version >= '3.6' -black==21.12b0; python_full_version >= '3.6.2' bleach==4.1.0; python_version >= '3.6' -boto3==1.20.37 -botocore==1.23.37; python_version >= '3.6' +boto3==1.21.25 +botocore==1.24.25; python_version >= '3.6' bs4==0.0.1 -canonicaljson==1.5.0; python_version ~= '3.5' +canonicaljson==1.6.0; python_version ~= '3.7' certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1; python_full_version >= '3.6.1' -charset-normalizer==2.0.10; python_version >= '3' -click==8.0.3 +charset-normalizer==2.0.12; python_version >= '3' +click==8.0.4 coloredlogs==15.0.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' configparser==5.2.0; python_version >= '3.6' -coverage==6.2 +coverage==6.3.2 coveralls==3.3.1 cssselect==1.1.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' debugpy==1.5.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' -decorator==5.1.1; python_version >= '3.5' +decorator==5.1.1; python_full_version >= '3.5.0' defusedxml==0.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' distlib==0.3.4 docopt==0.6.2 -entrypoints==0.3; python_version >= '2.7' -executing==0.8.2 +entrypoints==0.4; python_version >= '3.6' +executing==0.8.3 fake-useragent==0.1.11 -fastapi==0.72.0 -filelock==3.4.2; python_version >= '3.7' +fastapi==0.75.0 +filelock==3.6.0; python_version >= '3.7' flake8-docstrings==1.6.0 flake8==4.0.1 -frozendict==2.2.0; python_version >= '3.6' -ga4gh.vrs[extras]==0.7.2 -ga4gh.vrsatile.pydantic==0.0.6 +ga4gh.vrs[extras]==0.8.0.dev0 +ga4gh.vrsatile.pydantic==0.0.10 gffutils==0.10.1 -h11==0.12.0; python_version >= '3.6' +h11==0.13.0; python_version >= '3.6' hgvs==1.5.2 -httptools==0.3.0 +httptools==0.4.0 humanfriendly==10.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' -identify==2.4.4; python_full_version >= '3.6.1' +identify==2.4.12; python_version >= '3.7' idna==3.3; python_version >= '3' -importlib-metadata==4.10.1; python_version < '3.10' -inflection==0.5.1; python_version >= '3.5' +importlib-metadata==4.11.3; python_version < '3.10' +inflection==0.5.1; python_full_version >= '3.5.0' iniconfig==1.1.1 -ipykernel==6.7.0; python_version >= '3.7' +ipykernel==6.9.2; python_version >= '3.7' ipython-genutils==0.2.0 -ipython==8.0.0; python_version >= '3.8' +ipython==8.1.1; python_version >= '3.8' jedi==0.18.1; python_version >= '3.6' jinja2==3.0.3; 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' +jmespath==1.0.0; python_version >= '3.7' json5==0.9.6 jsonschema==3.2.0 -jupyter-client==7.1.1; python_full_version >= '3.6.1' -jupyter-core==4.9.1; python_version >= '3.6' -jupyter-server==1.13.3; python_version >= '3.7' +jupyter-client==7.1.2; python_full_version >= '3.6.1' +jupyter-core==4.9.2; python_version >= '3.6' +jupyter-server==1.15.6; python_version >= '3.7' jupyterlab-pygments==0.1.2 -jupyterlab-server==2.10.3; python_version >= '3.6' -jupyterlab==3.2.8 -lxml==4.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' +jupyterlab-server==2.11.2; python_version >= '3.7' +jupyterlab==3.3.2 +lxml==4.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' markdown==3.3.6; python_version >= '3.6' -markupsafe==2.0.1; python_version >= '3.6' -matplotlib-inline==0.1.3; python_version >= '3.5' +markupsafe==2.1.1; python_version >= '3.7' +matplotlib-inline==0.1.3; python_full_version >= '3.5.0' mccabe==0.6.1 mistune==0.8.4 mock==4.0.3 -mypy-extensions==0.4.3 -nbclassic==0.3.5; python_version >= '3.6' -nbclient==0.5.10; python_version >= '3.7' -nbconvert==6.4.0; python_version >= '3.7' -nbformat==5.1.3; python_version >= '3.5' +nbclassic==0.3.7; python_version >= '3.7' +nbclient==0.5.13; python_version >= '3.7' +nbconvert==6.4.4; python_version >= '3.7' +nbformat==5.2.0; python_version >= '3.7' nest-asyncio==1.5.4; python_version >= '3.5' nodeenv==1.6.0 -notebook==6.4.7; python_version >= '3.6' -numpy==1.22.1; python_version >= '3.8' +notebook-shim==0.1.0; python_version >= '3.7' +notebook==6.4.10; python_version >= '3.6' +numpy==1.22.3; python_version >= '3.8' packaging==21.3; python_version >= '3.6' pandocfilters==1.5.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' parse==1.19.0 parsley==1.3 parso==0.8.3; python_version >= '3.6' -pathspec==0.9.0 pexpect==4.8.0; sys_platform != 'win32' pickleshare==0.7.5 -platformdirs==2.4.1; python_version >= '3.7' +platformdirs==2.5.1; python_version >= '3.7' pluggy==1.0.0; python_version >= '3.6' -pre-commit==2.16.0 -prometheus-client==0.12.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' -prompt-toolkit==3.0.24; python_full_version >= '3.6.2' +pre-commit==2.17.0 +prometheus-client==0.13.1; python_version >= '3.6' +prompt-toolkit==3.0.28; python_full_version >= '3.6.2' +psutil==5.9.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3' psycopg2==2.9.3; python_version >= '3.6' ptyprocess==0.7.0 -pure-eval==0.2.1 +pure-eval==0.2.2 py==1.11.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' pycodestyle==2.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' -pycparser==2.21; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +pycparser==2.21 pydantic==1.9.0 pydocstyle==6.1.1; python_version >= '3.6' pyee==8.2.2 -pyfaidx==0.6.3.1 +pyfaidx==0.6.4 pyflakes==2.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' -pygments==2.11.2; python_version >= '3.5' -pyparsing==3.0.6; python_version >= '3.6' -pyppeteer==1.0.2; python_version >= '3.7' and python_version < '4' +pygments==2.11.2; python_full_version >= '3.5.0' +pyparsing==3.0.7; python_version >= '3.6' +pyppeteer==1.0.2; python_version >= '3.7' and python_version < '4.0' pyquery==1.4.3 pyrsistent==0.18.1; python_version >= '3.7' pysam==0.18.0 pytest-cov==3.0.0 -pytest==6.2.5 +pytest==7.1.1 python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' python-jsonschema-objects==0.4.1 -pytz==2021.3 +pytz==2022.1 pyyaml==6.0; python_version >= '3.6' pyzmq==22.3.0; python_version >= '3.6' requests-html==0.10.0; python_version >= '3.6' requests==2.27.1 -s3transfer==0.5.0; python_version >= '3.6' +s3transfer==0.5.2; python_version >= '3.6' send2trash==1.8.0 -setuptools==60.5.0; python_version >= '3.7' +setuptools==60.10.0; python_version >= '3.7' simplejson==3.17.6; python_version >= '2.5' and python_version not in '3.0, 3.1, 3.2, 3.3' six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' -sniffio==1.2.0; python_version >= '3.5' +sniffio==1.2.0; python_full_version >= '3.5.0' snowballstemmer==2.2.0 soupsieve==2.3.1; python_version >= '3.6' -sqlparse==0.4.2; python_version >= '3.5' -stack-data==0.1.4 +sqlparse==0.4.2; python_full_version >= '3.5.0' +stack-data==0.2.0 starlette==0.17.1; python_version >= '3.6' tabulate==0.8.9 -terminado==0.12.1; python_version >= '3.6' -testpath==0.5.0; python_version >= '3.5' +terminado==0.13.3; python_version >= '3.7' +testpath==0.6.0; python_version >= '3.5' toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3' -tomli==1.2.3; python_version >= '3.6' +tomli==2.0.1; python_version >= '3.7' tornado==6.1; python_version >= '3.5' -tqdm==4.62.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +tqdm==4.63.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' traitlets==5.1.1; python_version >= '3.7' -typing-extensions==4.0.1 -urllib3==1.26.8; 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.17.0 +typing-extensions==4.1.1 +urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0' +uvicorn==0.17.6 uvloop==0.16.0 -virtualenv==20.13.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' +virtualenv==20.13.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' w3lib==1.22.0 wcwidth==0.2.5 webencodings==0.5.1 -websocket-client==1.2.3; python_version >= '3.6' -websockets==10.1 +websocket-client==1.3.1; python_version >= '3.6' +websockets==10.2 yoyo-migrations==7.3.2 zipp==3.7.0; python_version >= '3.7' diff --git a/requirements.txt b/requirements.txt index 90291adc..cefe51b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,64 +11,59 @@ appdirs==1.4.4 appnope==0.1.2; sys_platform == 'darwin' argcomplete==2.0.0; python_version >= '3.6' argh==0.26.2 -asgiref==3.4.1; python_version >= '3.6' +asgiref==3.5.0; python_version >= '3.7' asttokens==2.0.5 attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' backcall==0.2.0 beautifulsoup4==4.10.0 biocommons.seqrepo==0.6.5 bioutils==0.5.5; python_version >= '3.6' -black==21.12b0; python_full_version >= '3.6.2' -boto3==1.20.37 -botocore==1.23.37; python_version >= '3.6' +boto3==1.21.25 +botocore==1.24.25; python_version >= '3.6' bs4==0.0.1 -canonicaljson==1.5.0; python_version ~= '3.5' +canonicaljson==1.6.0; python_version ~= '3.7' certifi==2021.10.8 -charset-normalizer==2.0.10; python_version >= '3' -click==8.0.3 +charset-normalizer==2.0.12; python_version >= '3' +click==8.0.4 coloredlogs==15.0.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' configparser==5.2.0; python_version >= '3.6' cssselect==1.1.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' -decorator==5.1.1; python_version >= '3.5' -executing==0.8.2 +decorator==5.1.1; python_full_version >= '3.5.0' +executing==0.8.3 fake-useragent==0.1.11 -fastapi==0.72.0 -frozendict==2.2.0; python_version >= '3.6' -ga4gh.vrs[extras]==0.7.2 -ga4gh.vrsatile.pydantic==0.0.6 +fastapi==0.75.0 +ga4gh.vrs[extras]==0.8.0.dev0 +ga4gh.vrsatile.pydantic==0.0.10 gffutils==0.10.1 -h11==0.12.0; python_version >= '3.6' +h11==0.13.0; python_version >= '3.6' hgvs==1.5.2 -httptools==0.3.0 +httptools==0.4.0 humanfriendly==10.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' idna==3.3; python_version >= '3' -importlib-metadata==4.10.1; python_version < '3.10' -inflection==0.5.1; python_version >= '3.5' -ipython==8.0.0; python_version >= '3.8' +importlib-metadata==4.11.3; python_version < '3.10' +inflection==0.5.1; python_full_version >= '3.5.0' +ipython==8.1.1; python_version >= '3.8' jedi==0.18.1; 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' +jmespath==1.0.0; python_version >= '3.7' jsonschema==3.2.0 -lxml==4.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' +lxml==4.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' markdown==3.3.6; python_version >= '3.6' -matplotlib-inline==0.1.3; python_version >= '3.5' -mypy-extensions==0.4.3 -numpy==1.22.1; python_version >= '3.8' +matplotlib-inline==0.1.3; python_full_version >= '3.5.0' +numpy==1.22.3; python_version >= '3.8' parse==1.19.0 parsley==1.3 parso==0.8.3; python_version >= '3.6' -pathspec==0.9.0 pexpect==4.8.0; sys_platform != 'win32' pickleshare==0.7.5 -platformdirs==2.4.1; python_version >= '3.7' -prompt-toolkit==3.0.24; python_full_version >= '3.6.2' +prompt-toolkit==3.0.28; python_full_version >= '3.6.2' psycopg2==2.9.3; python_version >= '3.6' ptyprocess==0.7.0 -pure-eval==0.2.1 +pure-eval==0.2.2 pydantic==1.9.0 pyee==8.2.2 -pyfaidx==0.6.3.1 -pygments==2.11.2; python_version >= '3.5' -pyppeteer==1.0.2; python_version >= '3.7' and python_version < '4' +pyfaidx==0.6.4 +pygments==2.11.2; python_full_version >= '3.5.0' +pyppeteer==1.0.2; python_version >= '3.7' and python_version < '4.0' pyquery==1.4.3 pyrsistent==0.18.1; python_version >= '3.7' pysam==0.18.0 @@ -77,25 +72,24 @@ python-jsonschema-objects==0.4.1 pyyaml==6.0; python_version >= '3.6' requests-html==0.10.0; python_version >= '3.6' requests==2.27.1 -s3transfer==0.5.0; python_version >= '3.6' -setuptools==60.5.0; python_version >= '3.7' +s3transfer==0.5.2; python_version >= '3.6' +setuptools==60.10.0; python_version >= '3.7' simplejson==3.17.6; python_version >= '2.5' and python_version not in '3.0, 3.1, 3.2, 3.3' six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' -sniffio==1.2.0; python_version >= '3.5' +sniffio==1.2.0; python_full_version >= '3.5.0' soupsieve==2.3.1; python_version >= '3.6' -sqlparse==0.4.2; python_version >= '3.5' -stack-data==0.1.4 +sqlparse==0.4.2; python_full_version >= '3.5.0' +stack-data==0.2.0 starlette==0.17.1; python_version >= '3.6' tabulate==0.8.9 -tomli==1.2.3; python_version >= '3.6' -tqdm==4.62.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +tqdm==4.63.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' traitlets==5.1.1; python_version >= '3.7' -typing-extensions==4.0.1 -urllib3==1.26.8; 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.17.0 +typing-extensions==4.1.1 +urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0' +uvicorn==0.17.6 uvloop==0.16.0 w3lib==1.22.0 wcwidth==0.2.5 -websockets==10.1 +websockets==10.2 yoyo-migrations==7.3.2 zipp==3.7.0; python_version >= '3.7' diff --git a/setup.cfg b/setup.cfg index 7e21cdaa..1dfcc3c0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ zip_safe = False install_requires = pydantic - fastapi >= 0.72.0 + fastapi uvicorn click boto3 @@ -33,9 +33,8 @@ install_requires = gffutils requests biocommons.seqrepo - ga4gh.vrs[extras] >= 0.7.2 - jsonschema >=2.3, <4.0 - ga4gh.vrsatile.pydantic >= 0.0.5 + ga4gh.vrs[extras] >= 0.7.5.dev1 + ga4gh.vrsatile.pydantic >= 0.0.10 tests_require = @@ -44,4 +43,4 @@ tests_require = mock [tool:pytest] -addopts = --ignore setup.py --doctest-modules --cov-report term-missing --cov . +addopts = --ignore setup.py --ignore codebuild/ --ignore dynamodb_local_latest/ --doctest-modules --cov-report term-missing --cov . diff --git a/tests/unit/test_ensembl_source.py b/tests/unit/test_ensembl_source.py index cf22ef04..d740f3f4 100644 --- a/tests/unit/test_ensembl_source.py +++ b/tests/unit/test_ensembl_source.py @@ -14,7 +14,7 @@ def __init__(self): def search(self, query_str, incl='ensembl'): resp = self.query_handler.search(query_str, keyed=True, incl=incl) - return resp.source_matches[SourceName.ENSEMBL] + return resp.source_matches[SourceName.ENSEMBL.value] e = QueryGetter() return e diff --git a/tests/unit/test_hgnc_source.py b/tests/unit/test_hgnc_source.py index 502d92f4..4a469fcf 100644 --- a/tests/unit/test_hgnc_source.py +++ b/tests/unit/test_hgnc_source.py @@ -15,7 +15,7 @@ def __init__(self): def search(self, query_str, incl='hgnc'): resp = self.query_handler.search(query_str, keyed=True, incl=incl) - return resp.source_matches[SourceName.HGNC] + return resp.source_matches[SourceName.HGNC.value] h = QueryGetter() return h diff --git a/tests/unit/test_ncbi_source.py b/tests/unit/test_ncbi_source.py index c5156431..10d1c199 100644 --- a/tests/unit/test_ncbi_source.py +++ b/tests/unit/test_ncbi_source.py @@ -16,7 +16,7 @@ def __init__(self): def search(self, query_str, incl='ncbi'): resp = self.query_handler.search(query_str, keyed=True, incl=incl) - return resp.source_matches[SourceName.NCBI] + return resp.source_matches[SourceName.NCBI.value] n = QueryGetter() return n diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index 8cda65a0..0b86d030 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -4,7 +4,6 @@ from gene.schemas import SourceName, MatchType import copy import pytest -from datetime import datetime @pytest.fixture(scope='module') @@ -327,7 +326,8 @@ def num_sources(): @pytest.fixture(scope="module") def source_meta(): """Create test fixture for source meta""" - return [SourceName.HGNC, SourceName.ENSEMBL, SourceName.NCBI] + return [SourceName.HGNC.value, SourceName.ENSEMBL.value, + SourceName.NCBI.value] def compare_normalize_resp(resp, expected_query, expected_match_type, @@ -365,7 +365,7 @@ def compare_service_meta(service_meta): """Check that service metadata is correct.""" assert service_meta.name == "gene-normalizer" assert service_meta.version >= "0.1.0" - assert isinstance(service_meta.response_datetime, datetime) + assert isinstance(service_meta.response_datetime, str) assert service_meta.url == \ 'https://github.com/cancervariants/gene-normalization' @@ -430,15 +430,15 @@ def test_search_query_inc_exc(query_handler, num_sources): resp = query_handler.search('BRAF', keyed=True, incl=sources) matches = resp.source_matches assert len(matches) == len(sources.split()) - assert SourceName.HGNC in matches - assert SourceName.NCBI in matches + assert SourceName.HGNC.value in matches + assert SourceName.NCBI.value in matches sources = 'HGnC' resp = query_handler.search('BRAF', keyed=True, excl=sources) matches = resp.source_matches assert len(matches) == num_sources - len(sources.split()) - assert SourceName.ENSEMBL in matches - assert SourceName.NCBI in matches + assert SourceName.ENSEMBL.value in matches + assert SourceName.NCBI.value in matches def test_search_invalid_parameter_exception(query_handler): @@ -456,26 +456,31 @@ def test_ache_query(query_handler, num_sources, normalized_ache, source_meta): resp = query_handler.search('ncbigene:43', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert len(matches[SourceName.ENSEMBL].records) == 0 - assert matches[SourceName.NCBI].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert len(matches[SourceName.ENSEMBL.value].records) == 0 + assert matches[SourceName.NCBI.value].records[0].match_type == \ MatchType.CONCEPT_ID resp = query_handler.search('hgnc:108', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ MatchType.CONCEPT_ID - assert matches[SourceName.ENSEMBL].records[0].match_type == MatchType.XREF - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF resp = query_handler.search('ensembl:ENSG00000087085', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert matches[SourceName.ENSEMBL].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ MatchType.CONCEPT_ID - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF # Normalize q = "ACHE" @@ -546,26 +551,31 @@ def test_braf_query(query_handler, num_sources, normalized_braf, source_meta): resp = query_handler.search('ncbigene:673', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert len(matches[SourceName.ENSEMBL].records) == 0 - assert matches[SourceName.NCBI].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert len(matches[SourceName.ENSEMBL.value].records) == 0 + assert matches[SourceName.NCBI.value].records[0].match_type == \ MatchType.CONCEPT_ID resp = query_handler.search('hgnc:1097', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type ==\ + assert matches[SourceName.HGNC.value].records[0].match_type ==\ MatchType.CONCEPT_ID - assert matches[SourceName.ENSEMBL].records[0].match_type == MatchType.XREF - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF resp = query_handler.search('ensembl:ENSG00000157764', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert matches[SourceName.ENSEMBL].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ MatchType.CONCEPT_ID - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF # Normalize q = "BRAF" @@ -624,26 +634,31 @@ def test_abl1_query(query_handler, num_sources, normalized_abl1, source_meta): resp = query_handler.search('ncbigene:25', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert len(matches[SourceName.ENSEMBL].records) == 0 - assert matches[SourceName.NCBI].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert len(matches[SourceName.ENSEMBL.value].records) == 0 + assert matches[SourceName.NCBI.value].records[0].match_type == \ MatchType.CONCEPT_ID resp = query_handler.search('hgnc:76', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ MatchType.CONCEPT_ID - assert matches[SourceName.ENSEMBL].records[0].match_type == MatchType.XREF - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF resp = query_handler.search('ensembl:ENSG00000097007', keyed=True) matches = resp.source_matches assert len(matches) == num_sources - assert matches[SourceName.HGNC].records[0].match_type == MatchType.XREF - assert matches[SourceName.ENSEMBL].records[0].match_type == \ + assert matches[SourceName.HGNC.value].records[0].match_type == \ + MatchType.XREF + assert matches[SourceName.ENSEMBL.value].records[0].match_type == \ MatchType.CONCEPT_ID - assert matches[SourceName.NCBI].records[0].match_type == MatchType.XREF + assert matches[SourceName.NCBI.value].records[0].match_type == \ + MatchType.XREF # Normalize q = "ABL1" @@ -724,7 +739,7 @@ def test_multiple_norm_concepts(query_handler, normalized_p150, source_meta): def test_invalid_queries(query_handler): """Test invalid queries""" resp = query_handler.normalize("B R A F") - assert resp.match_type is MatchType.NO_MATCH + assert resp.match_type is MatchType.NO_MATCH.value with pytest.raises(TypeError): resp["match_type"]