Skip to content

Commit

Permalink
fix!: xrefs should have exactMatch for ConceptMapping.relation (#…
Browse files Browse the repository at this point in the history
…397)

close #396
  • Loading branch information
korikuzma authored Jan 28, 2025
1 parent 5c2af55 commit 80bc5d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
17 changes: 10 additions & 7 deletions src/gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,17 @@ def _get_concept_mapping(
conceptType="Gene",
)

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

associated_with = record.get("associated_with", [])
gene_obj.mappings.extend(
_get_concept_mapping(associated_with_id, relation=Relation.RELATED_MATCH)
for associated_with_id in associated_with
)

# extensions
extensions = []
Expand Down
4 changes: 2 additions & 2 deletions src/gene/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ class NormalizeService(BaseNormalizationService):
"code": "673",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"id": "ensembl:ENSG00000157764",
"code": "ENSG00000157764",
"system": "https://www.ensembl.org/id/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def normalized_ache():
"code": "ENSG00000087085",
"system": "https://www.ensembl.org/id/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"id": "ncbigene:43",
"code": "43",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down Expand Up @@ -197,15 +197,15 @@ def normalized_braf():
"code": "673",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"id": "ensembl:ENSG00000157764",
"code": "ENSG00000157764",
"system": "https://www.ensembl.org/id/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down Expand Up @@ -369,15 +369,15 @@ def normalized_abl1():
"code": "ENSG00000097007",
"system": "https://www.ensembl.org/id/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"id": "ncbigene:25",
"code": "25",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down Expand Up @@ -557,15 +557,15 @@ def normalized_p150():
"code": "ENSG00000167670",
"system": "https://www.ensembl.org/id/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
"id": "ncbigene:10036",
"code": "10036",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def normalized_ifnr():
"code": "3466",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "relatedMatch",
"relation": "exactMatch",
},
{
"coding": {
Expand Down

0 comments on commit 80bc5d5

Please sign in to comment.