Skip to content

Commit

Permalink
build!: update ga4gh.vrs version (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma authored Jul 15, 2024
1 parent 7001b31 commit e294926
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"uvicorn",
"click",
"boto3",
"ga4gh.vrs~=2.0.0a1",
"ga4gh.vrs~=2.0.0a8",
]
dynamic = ["version"]

Expand Down
16 changes: 8 additions & 8 deletions src/disease/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
)

Expand All @@ -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"],
)
Expand Down
5 changes: 2 additions & 3 deletions src/disease/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -299,7 +299,6 @@ class NormalizationService(BaseModel):
],
"extensions": [
{
"type": "Extension",
"name": "pediatric_disease",
"value": True,
},
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -68,7 +68,7 @@ def neuroblastoma():
"relation": "relatedMatch",
},
],
aliases=[
alternativeLabels=[
"NB",
"neuroblastoma",
"Neural Crest Tumor, Malignant",
Expand All @@ -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"],
)


Expand All @@ -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",
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit e294926

Please sign in to comment.