Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: xrefs should have exactMatch for ConceptMapping.relation
Browse files Browse the repository at this point in the history
close #222
korikuzma committed Jan 28, 2025
1 parent fcc59a1 commit 775e88a
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/disease/query.py
Original file line number Diff line number Diff line change
@@ -363,12 +363,17 @@ def _create_concept_mapping(
extensions=[],
)

# mappings
xrefs = [record["concept_id"], *record.get("xrefs", [])]
mappings = [
_create_concept_mapping(record["concept_id"], relation=Relation.EXACT_MATCH)
_create_concept_mapping(xref_id, relation=Relation.EXACT_MATCH)
for xref_id in xrefs
]
source_ids = record.get("xrefs", []) + record.get("associated_with", [])
mappings.extend(_create_concept_mapping(source_id) for source_id in source_ids)

associated_with = record.get("associated_with", [])
mappings.extend(
_create_concept_mapping(associated_with_id, relation=Relation.RELATED_MATCH)
for associated_with_id in associated_with
)
if mappings:
disease_obj.mappings = mappings

4 changes: 2 additions & 2 deletions src/disease/schemas.py
Original file line number Diff line number Diff line change
@@ -324,14 +324,14 @@ class NormalizationService(BaseModel):
"code": "mondo:0004355",
"system": "http://purl.obolibrary.org/obo/mondo.owl",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"code": "DOID:7757",
"system": "http://purl.obolibrary.org/obo/doid.owl",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
8 changes: 4 additions & 4 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
@@ -36,21 +36,21 @@ def neuroblastoma():
"code": "mondo:0005072",
"system": "http://purl.obolibrary.org/obo/mondo.owl",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"code": "oncotree:NBL",
"system": "https://oncotree.mskcc.org",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"code": "DOID:769",
"system": "http://purl.obolibrary.org/obo/doid.owl",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
@@ -172,7 +172,7 @@ def mafd2():
},
{
"coding": {"code": "MIM:309200", "system": "https://www.omim.org"},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {

0 comments on commit 775e88a

Please sign in to comment.