Skip to content

Commit

Permalink
fix: add support for civic ash source type
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Apr 2, 2024
1 parent f8dbd4e commit 442aa40
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/metakb/transform/civic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""A module for to transform CIViC."""
import logging
import re
from enum import StrEnum
from enum import Enum
from pathlib import Path
from typing import Dict, List, Optional, Tuple

Expand Down Expand Up @@ -84,11 +84,12 @@ class _VariationCache(BaseModel):
members: Optional[List[models.Variation]] = None


class SourcePrefix(StrEnum):
class SourcePrefix(str, Enum):
"""Define constraints for source prefixes."""

PUBMED = "PUBMED"
ASCO = "asco"
ASCO = "ASCO"
ASH = "ASH"


class CivicTransform(Transform):
Expand Down Expand Up @@ -282,6 +283,8 @@ def _add_variant_therapeutic_response_studies(

# Add document
document = self._add_eid_document(r["source"])
if not document:
continue

# Get strength
direction = self._get_evidence_direction(r["evidence_direction"])
Expand Down Expand Up @@ -885,9 +888,10 @@ def _add_eid_document(self, source: Dict) -> Optional[Document]:
:return: Document for Evidence Item if source type is supported
"""
source_type = source["source_type"].upper()
source_id = source["id"]
if source_type in SourcePrefix.__members__:
document = Document(
id=f"civic.source:{source['id']}",
id=f"civic.source:{source_id}",
label=source["citation"],
title=source["title"],
).model_dump(exclude_none=True)
Expand All @@ -898,7 +902,11 @@ def _add_eid_document(self, source: Dict) -> Optional[Document]:
if document not in self.documents:
self.documents.append(document)
else:
logger.debug("%s not in schemas.SourcePrefix", source_type)
logger.debug(
"Document, %s, not supported. %s not in SourcePrefix",
source_id,
source_type,
)
document = None

return document

0 comments on commit 442aa40

Please sign in to comment.