Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jan 18, 2025
1 parent 39a5f35 commit 0b8ba49
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
9 changes: 7 additions & 2 deletions src/disease/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _add_merged_meta(self, response: dict) -> dict:

sources = []
for m in disease.mappings or []:
ns = m.coding.id.split(":")[0]
ns = m.coding.id.split(":")[0].lower()
if ns in PREFIX_LOOKUP:
sources.append(PREFIX_LOOKUP[ns])

Expand Down Expand Up @@ -348,7 +348,12 @@ def _create_concept_mapping(
err_msg = f"Namespace prefix not supported: {source}"
raise ValueError(err_msg) from e

system = NAMESPACE_TO_SYSTEM_URI.get(source, source)
if source == NamespacePrefix.MONDO:
source_code = concept_id.upper()
elif source == NamespacePrefix.DOID:
source_code = concept_id

system = NAMESPACE_TO_SYSTEM_URI[source]

return ConceptMapping(
coding=Coding(id=concept_id, code=code(source_code), system=system),
Expand Down
10 changes: 7 additions & 3 deletions src/disease/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,32 @@ class NormalizationService(BaseModel):
"mappings": [
{
"coding": {
"code": "ncit:C4989",
"id": "ncit:C4989",
"code": "C4989",
"system": "https://www.ebi.ac.uk/ols4/ontologies/ncit/classes?short_form=NCIT_",
},
"relation": "exactMatch",
},
{
"coding": {
"code": "mondo:0004355",
"id": "mondo:0004355",
"code": "MONDO:0004355",
"system": "http://purl.obolibrary.org/obo/mondo.owl",
},
"relation": "relatedMatch",
},
{
"coding": {
"id": "DOID:7757",
"code": "DOID:7757",
"system": "https://disease-ontology.org/?id=",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "umls:C1332977",
"id": "umls:C1332977",
"code": "C1332977",
"system": "https://www.nlm.nih.gov/research/umls/index.html",
},
"relation": "relatedMatch",
Expand Down
55 changes: 38 additions & 17 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,96 @@ def neuroblastoma():
mappings=[
{
"coding": {
"code": "ncit:C3270",
"id": "ncit:C3270",
"code": "C3270",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
},
{
"coding": {
"code": "mondo:0005072",
"id": "mondo:0005072",
"code": "MONDO:0005072",
"system": "http://purl.obolibrary.org/obo/mondo.owl",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "oncotree:NBL",
"id": "oncotree:NBL",
"code": "NBL",
"system": "https://oncotree.mskcc.org/?version=oncotree_latest_stable&field=CODE&search=",
},
"relation": "relatedMatch",
},
{
"coding": {
"id": "DOID:769",
"code": "DOID:769",
"system": "https://disease-ontology.org/?id=",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "umls:C0027819",
"id": "umls:C0027819",
"code": "C0027819",
"system": "https://www.nlm.nih.gov/research/umls/index.html",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "icdo:9500/3",
"id": "icdo:9500/3",
"code": "9500/3",
"system": "https://www.who.int/standards/classifications/other-classifications/international-classification-of-diseases-for-oncology/",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "efo:0000621",
"id": "efo:0000621",
"code": "0000621",
"system": "http://www.ebi.ac.uk/efo/EFO_",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "gard:7185",
"id": "gard:7185",
"code": "7185",
"system": "https://rarediseases.info.nih.gov",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "mesh:D009447",
"id": "mesh:D009447",
"code": "D009447",
"system": "https://meshb.nlm.nih.gov/record/ui?ui=",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "orphanet:635",
"id": "orphanet:635",
"code": "635",
"system": "https://www.orpha.net",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "umls:C2751421",
"id": "umls:C2751421",
"code": "C2751421",
"system": "https://www.nlm.nih.gov/research/umls/index.html",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "medgen:18012",
"id": "medgen:18012",
"code": "18012",
"system": "https://www.ncbi.nlm.nih.gov/medgen/",
},
"relation": "relatedMatch",
Expand Down Expand Up @@ -142,7 +154,8 @@ def skin_myo():
mappings=[
{
"coding": {
"code": "ncit:C167370",
"id": "ncit:C167370",
"code": "C167370",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
Expand All @@ -165,32 +178,40 @@ def mafd2():
mappings=[
{
"coding": {
"code": "mondo:0010648",
"id": "mondo:0010648",
"code": "MONDO:0010648",
"system": "http://purl.obolibrary.org/obo/mondo.owl",
},
"relation": "exactMatch",
},
{
"coding": {"code": "MIM:309200", "system": "https://omim.org/entry/"},
"coding": {
"id": "MIM:309200",
"code": "309200",
"system": "https://omim.org/entry/",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "mesh:C564108",
"id": "mesh:C564108",
"code": "C564108",
"system": "https://meshb.nlm.nih.gov/record/ui?ui=",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "medgen:326975",
"id": "medgen:326975",
"code": "326975",
"system": "https://www.ncbi.nlm.nih.gov/medgen/",
},
"relation": "relatedMatch",
},
{
"coding": {
"code": "umls:C1839839",
"id": "umls:C1839839",
"code": "C1839839",
"system": "https://www.nlm.nih.gov/research/umls/index.html",
},
"relation": "relatedMatch",
Expand Down

0 comments on commit 0b8ba49

Please sign in to comment.