Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jul 11, 2024
1 parent d9ac25f commit fee46cb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 167 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ dependencies = [
"uvicorn",
"click",
"boto3",
"ga4gh.vrs~=2.0.0a1",
# "ga4gh.vrs~=2.0.0a1",
]
dynamic = ["version"]

[project.optional-dependencies]
etl = [
"disease-normalizer[etl]~=0.4.0.dev0",
# "disease-normalizer[etl]~=0.4.0.dev0",
"owlready2",
"rdflib",
"wikibaseintegrator>=0.12.0",
Expand Down
30 changes: 15 additions & 15 deletions src/therapy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar, Union

from botocore.exceptions import ClientError
from ga4gh.core import core_models
from ga4gh.core import domain_models, entity_models
from uvicorn.config import logger

from therapy import NAMESPACE_LUIS, PREFIX_LOOKUP, SOURCES
Expand Down Expand Up @@ -391,7 +391,7 @@ def _add_therapeutic_agent(
:param MatchType match_type: type of match achieved
:return: completed response object ready to return to user
"""
therapeutic_agent_obj = core_models.TherapeuticAgent(
therapeutic_agent_obj = domain_models.TherapeuticAgent(
id=f"normalize.therapy.{record['concept_id']}", label=record.get("label")
)

Expand All @@ -400,18 +400,18 @@ def _add_therapeutic_agent(
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:
therapeutic_agent_obj.mappings = mappings

if "aliases" in record:
therapeutic_agent_obj.aliases = record["aliases"]
therapeutic_agent_obj.alternativeLabels = record["aliases"]

extensions = []
if any(
Expand All @@ -438,39 +438,39 @@ def _add_therapeutic_agent(
if indication.normalized_disease_id:
system, code = indication.normalized_disease_id.split(":")
mappings = [
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,
)
]
else:
mappings = []
ind_disease_obj = core_models.Disease(
ind_disease_obj = domain_models.Disease(
id=indication.disease_id,
label=indication.disease_label,
mappings=mappings or None,
)

if indication.supplemental_info:
ind_disease_obj.extensions = [
core_models.Extension(name=k, value=v)
entity_models.Extension(name=k, value=v)
for k, v in indication.supplemental_info.items()
]
inds_list.append(ind_disease_obj.model_dump(exclude_none=True))
if inds_list:
approv_value["has_indication"] = inds_list

approv = core_models.Extension(
approv = entity_models.Extension(
name="regulatory_approval", value=approv_value
)
extensions.append(approv)

trade_names = record.get("trade_names")
if trade_names:
extensions.append(
core_models.Extension(name="trade_names", value=trade_names)
entity_models.Extension(name="trade_names", value=trade_names)
)

if extensions:
Expand Down
7 changes: 3 additions & 4 deletions src/therapy/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from enum import Enum, IntEnum
from typing import Any, Dict, List, Literal, Optional, Set, Union

from ga4gh.core import core_models
from ga4gh.core import domain_models
from pydantic import BaseModel, ConfigDict, StrictBool, constr

from therapy.version import __version__
Expand Down Expand Up @@ -484,7 +484,7 @@ class NormalizationService(BaseNormalizationService):
"""Response containing one or more merged records and source data."""

normalized_id: Optional[str] = None
therapeutic_agent: Optional[core_models.TherapeuticAgent] = None
therapeutic_agent: Optional[domain_models.TherapeuticAgent] = None
source_meta_: Optional[Dict[SourceName, SourceMeta]] = None

model_config = ConfigDict(
Expand Down Expand Up @@ -560,7 +560,7 @@ class NormalizationService(BaseNormalizationService):
"relation": "relatedMatch",
},
],
"aliases": [
"alternativeLabels": [
"CIS-DDP",
"cis Platinum",
"DDP",
Expand All @@ -583,7 +583,6 @@ class NormalizationService(BaseNormalizationService):
],
"extensions": [
{
"type": "Extension",
"name": "trade_names",
"value": ["Platinol", "Cisplatin"],
},
Expand Down
Loading

0 comments on commit fee46cb

Please sign in to comment.