From e294926df1ffd5074ea0a7ea82a3edc3d64e877a Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Mon, 15 Jul 2024 09:08:24 -0400 Subject: [PATCH] build!: update ga4gh.vrs version (#193) --- pyproject.toml | 2 +- src/disease/query.py | 16 ++++++++-------- src/disease/schemas.py | 5 ++--- tests/unit/test_query.py | 20 ++++++++++---------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0d6ea2c..6ba00ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "uvicorn", "click", "boto3", - "ga4gh.vrs~=2.0.0a1", + "ga4gh.vrs~=2.0.0a8", ] dynamic = ["version"] diff --git a/src/disease/query.py b/src/disease/query.py index a6d4d91..4e26cbf 100644 --- a/src/disease/query.py +++ b/src/disease/query.py @@ -5,7 +5,7 @@ import re from botocore.exceptions import ClientError -from ga4gh.core import core_models +from ga4gh.core import domain_models, entity_models from disease import NAMESPACE_LOOKUP, PREFIX_LOOKUP, SOURCES_LOWER_LOOKUP from disease.database.database import AbstractDatabase @@ -320,7 +320,7 @@ def _add_disease( :param match_type: type of match achieved :return: completed normalized response object ready to return to user """ - disease_obj = core_models.Disease( + disease_obj = domain_models.Disease( id=f"normalize.disease.{record['concept_id']}", label=record["label"] ) @@ -329,22 +329,22 @@ def _add_disease( for source_id in source_ids: system, code = source_id.split(":") mappings.append( - core_models.Mapping( - coding=core_models.Coding( - code=core_models.Code(code), system=system.lower() + entity_models.ConceptMapping( + coding=entity_models.Coding( + code=entity_models.Code(code), system=system.lower() ), - relation=core_models.Relation.RELATED_MATCH, + relation=entity_models.Relation.RELATED_MATCH, ) ) if mappings: disease_obj.mappings = mappings if "aliases" in record: - disease_obj.aliases = record["aliases"] + disease_obj.alternativeLabels = record["aliases"] if "pediatric_disease" in record and record["pediatric_disease"] is not None: disease_obj.extensions = [ - core_models.Extension( + entity_models.Extension( name="pediatric_disease", value=record["pediatric_disease"], ) diff --git a/src/disease/schemas.py b/src/disease/schemas.py index fa7da39..348fed7 100644 --- a/src/disease/schemas.py +++ b/src/disease/schemas.py @@ -4,7 +4,7 @@ from enum import Enum, IntEnum from typing import Literal -from ga4gh.core import core_models +from ga4gh.core import domain_models from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr from disease.version import __version__ @@ -261,7 +261,7 @@ class NormalizationService(BaseModel): warnings: dict | None = None match_type: MatchType normalized_id: str | None = None - disease: core_models.Disease | None = None + disease: domain_models.Disease | None = None source_meta_: dict[SourceName, SourceMeta] | None = None service_meta_: ServiceMeta @@ -299,7 +299,6 @@ class NormalizationService(BaseModel): ], "extensions": [ { - "type": "Extension", "name": "pediatric_disease", "value": True, }, diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index 64ab4ba..289fe26 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -3,7 +3,7 @@ from datetime import datetime import pytest -from ga4gh.core import core_models +from ga4gh.core import domain_models from disease.query import InvalidParameterException, QueryHandler from disease.schemas import MatchType, SourceName @@ -18,7 +18,7 @@ def query_handler(database): @pytest.fixture(scope="module") def neuroblastoma(): """Create neuroblastoma fixture.""" - return core_models.Disease( + return domain_models.Disease( type="Disease", id="normalize.disease.ncit:C3270", label="Neuroblastoma", @@ -68,7 +68,7 @@ def neuroblastoma(): "relation": "relatedMatch", }, ], - aliases=[ + alternativeLabels=[ "NB", "neuroblastoma", "Neural Crest Tumor, Malignant", @@ -87,11 +87,11 @@ def neuroblastoma(): @pytest.fixture(scope="module") def skin_myo(): """Create a test fixture for skin myopithelioma""" - return core_models.Disease( + return domain_models.Disease( type="Disease", id="normalize.disease.ncit:C167370", label="Skin Myoepithelioma", - aliases=["Cutaneous Myoepithelioma"], + alternativeLabels=["Cutaneous Myoepithelioma"], ) @@ -100,11 +100,11 @@ def mafd2(): """Create a test fixture for major affective disorder 2. Query should not include a "pediatric_disease" Extension object. """ - return core_models.Disease( + return domain_models.Disease( type="Disease", id="normalize.disease.mondo:0010648", label="major affective disorder 2", - aliases=[ + alternativeLabels=[ "MAFD2", "MDI", "MDX", @@ -158,9 +158,9 @@ def compare_disease(actual, fixture): assert no_matches == [], no_matches assert len(actual.mappings) == len(fixture.mappings) - assert bool(actual.aliases) == bool(fixture.aliases) - if actual.aliases: - assert set(actual.aliases) == set(fixture.aliases) + assert bool(actual.alternativeLabels) == bool(fixture.alternativeLabels) + if actual.alternativeLabels: + assert set(actual.alternativeLabels) == set(fixture.alternativeLabels) def get_extension(extensions, name): matches = [e for e in extensions if e.name == name]