Skip to content

Commit

Permalink
update coding
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jan 24, 2025
1 parent 2553f46 commit 4633157
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 39 deletions.
15 changes: 10 additions & 5 deletions src/metakb/transformers/civic.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ async def _add_variations(self, variants: list[dict]) -> None:
# Get variant types
variant_types_value = [
Coding(
id=vt["so_id"],
code=vt["so_id"],
system=f"{vt['url'].rsplit('/', 1)[0]}/",
label="_".join(vt["name"].lower().split()),
Expand All @@ -598,6 +599,7 @@ async def _add_variations(self, variants: list[dict]) -> None:
mappings = [
ConceptMapping(
coding=Coding(
id=variant_id,
code=str(variant["id"]),
system="https://civicdb.org/variants/",
),
Expand All @@ -610,7 +612,7 @@ async def _add_variations(self, variants: list[dict]) -> None:
ConceptMapping(
coding=Coding(
code=variant["allele_registry_id"],
system="https://reg.clinicalgenome.org/",
system="https://reg.clinicalgenome.org/redmine/projects/registry/genboree_registry/by_canonicalid?canonicalid=",
),
relation=Relation.RELATED_MATCH,
)
Expand Down Expand Up @@ -716,7 +718,8 @@ def _add_genes(self, genes: list[dict]) -> None:
mappings=[
ConceptMapping(
coding=Coding(
code=f"ncbigene:{gene['entrez_id']}",
id=ncbigene,
code=str(gene["entrez_id"]),
system="https://www.ncbi.nlm.nih.gov/gene/",
),
relation=Relation.EXACT_MATCH,
Expand Down Expand Up @@ -777,8 +780,9 @@ def _get_disease(self, disease: dict) -> MappableConcept | None:
mappings.append(
ConceptMapping(
coding=Coding(
id=doid,
code=doid,
system="http://purl.obolibrary.org/obo/doid.owl",
system="https://disease-ontology.org/?id=",
),
relation=Relation.EXACT_MATCH,
)
Expand Down Expand Up @@ -877,8 +881,9 @@ def _get_therapy(self, therapy: dict) -> MappableConcept | None:
mappings.append(
ConceptMapping(
coding=Coding(
code=ncit_id,
system="http://purl.obolibrary.org/obo/ncit.owl",
id=ncit_id,
code=ncit_id.split(":")[-1],
system="https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
),
relation=Relation.EXACT_MATCH,
)
Expand Down
6 changes: 4 additions & 2 deletions src/metakb/transformers/moa.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ async def _add_categorical_variants(self, variants: list[dict]) -> None:
mappings = [
ConceptMapping(
coding=Coding(
id=moa_variant_id,
code=str(variant_id),
system="https://moalmanac.org",
),
Expand Down Expand Up @@ -410,7 +411,7 @@ def _add_documents(self, sources: list) -> None:
ConceptMapping(
coding=Coding(
code=source["nct"],
system="https://clinicaltrials.gov",
system="https://clinicaltrials.gov/search?term=",
),
relation=Relation.EXACT_MATCH,
)
Expand Down Expand Up @@ -601,8 +602,9 @@ def _get_disease(self, disease: dict) -> MappableConcept | None:
mappings.append(
ConceptMapping(
coding=Coding(
id=f"oncotree:{ot_code}",
code=ot_code,
system="https://oncotree.mskcc.org",
system="https://oncotree.mskcc.org/?version=oncotree_latest_stable&field=CODE&search=",
label=ot_term,
),
relation=Relation.EXACT_MATCH,
Expand Down
69 changes: 48 additions & 21 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def civic_mpid33(civic_vid33):
{
"coding": {
"code": "CA126713",
"system": "https://reg.clinicalgenome.org/",
"system": "https://reg.clinicalgenome.org/redmine/projects/registry/genboree_registry/by_canonicalid?canonicalid=",
},
"relation": "relatedMatch",
},
Expand Down Expand Up @@ -288,7 +288,11 @@ def civic_mpid33(civic_vid33):
"relation": "relatedMatch",
},
{
"coding": {"code": "33", "system": "https://civicdb.org/variants/"},
"coding": {
"id": "civic.vid:33",
"code": "33",
"system": "https://civicdb.org/variants/",
},
"relation": "exactMatch",
},
],
Expand Down Expand Up @@ -316,6 +320,7 @@ def civic_mpid33(civic_vid33):
"name": "Variant types",
"value": [
{
"id": "SO:0001583",
"code": "SO:0001583",
"system": "http://www.sequenceontology.org/browser/current_svn/term/",
"label": "missense_variant",
Expand Down Expand Up @@ -381,7 +386,8 @@ def civic_gid5():
"mappings": [
{
"coding": {
"code": "ncbigene:673",
"id": "ncbigene:673",
"code": "673",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "exactMatch",
Expand Down Expand Up @@ -504,7 +510,7 @@ def civic_mpid12(civic_vid12, braf_v600e_genomic):
{
"coding": {
"code": "CA123643",
"system": "https://reg.clinicalgenome.org/",
"system": "https://reg.clinicalgenome.org/redmine/projects/registry/genboree_registry/by_canonicalid?canonicalid=",
},
"relation": "relatedMatch",
},
Expand All @@ -530,7 +536,11 @@ def civic_mpid12(civic_vid12, braf_v600e_genomic):
"relation": "relatedMatch",
},
{
"coding": {"code": "12", "system": "https://civicdb.org/variants/"},
"coding": {
"id": "civic.vid:12",
"code": "12",
"system": "https://civicdb.org/variants/",
},
"relation": "exactMatch",
},
],
Expand Down Expand Up @@ -558,6 +568,7 @@ def civic_mpid12(civic_vid12, braf_v600e_genomic):
"name": "Variant types",
"value": [
{
"id": "SO:0001583",
"code": "SO:0001583",
"system": "http://www.sequenceontology.org/browser/current_svn/term/",
"label": "missense_variant",
Expand Down Expand Up @@ -605,7 +616,8 @@ def civic_gid19():
"mappings": [
{
"coding": {
"code": "ncbigene:1956",
"id": "ncbigene:1956",
"code": "1956",
"system": "https://www.ncbi.nlm.nih.gov/gene/",
},
"relation": "exactMatch",
Expand Down Expand Up @@ -647,8 +659,9 @@ def civic_tid146():
"mappings": [
{
"coding": {
"code": "ncit:C66940",
"system": "http://purl.obolibrary.org/obo/ncit.owl",
"id": "ncit:C66940",
"code": "C66940",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -710,8 +723,9 @@ def civic_did8():
"mappings": [
{
"coding": {
"id": "DOID:3908",
"code": "DOID:3908",
"system": "http://purl.obolibrary.org/obo/doid.owl",
"system": "https://disease-ontology.org/?id=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -750,8 +764,9 @@ def civic_tid28():
"mappings": [
{
"coding": {
"code": "ncit:C1857",
"system": "http://purl.obolibrary.org/obo/ncit.owl",
"id": "ncit:C1857",
"code": "C1857",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -829,8 +844,9 @@ def civic_tid16(cetuximab_extensions):
"mappings": [
{
"coding": {
"code": "ncit:C1723",
"system": "http://purl.obolibrary.org/obo/ncit.owl",
"id": "ncit:C1723",
"code": "C1723",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -880,8 +896,9 @@ def civic_tid483(encorafenib_extensions):
"mappings": [
{
"coding": {
"code": "ncit:C98283",
"system": "http://purl.obolibrary.org/obo/ncit.owl",
"id": "ncit:C98283",
"code": "C98283",
"system": "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&code=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -919,8 +936,9 @@ def civic_did11():
"mappings": [
{
"coding": {
"id": "DOID:9256",
"code": "DOID:9256",
"system": "http://purl.obolibrary.org/obo/doid.owl",
"system": "https://disease-ontology.org/?id=",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -1217,7 +1235,7 @@ def civic_mpid65(civic_vid65):
{
"coding": {
"code": "CA123513",
"system": "https://reg.clinicalgenome.org/",
"system": "https://reg.clinicalgenome.org/redmine/projects/registry/genboree_registry/by_canonicalid?canonicalid=",
},
"relation": "relatedMatch",
},
Expand All @@ -1236,7 +1254,11 @@ def civic_mpid65(civic_vid65):
"relation": "relatedMatch",
},
{
"coding": {"code": "65", "system": "https://civicdb.org/variants/"},
"coding": {
"id": "civic.vid:65",
"code": "65",
"system": "https://civicdb.org/variants/",
},
"relation": "exactMatch",
},
],
Expand Down Expand Up @@ -1264,6 +1286,7 @@ def civic_mpid65(civic_vid65):
"name": "Variant types",
"value": [
{
"id": "SO:0001583",
"code": "SO:0001583",
"system": "http://www.sequenceontology.org/browser/current_svn/term/",
"label": "missense_variant",
Expand Down Expand Up @@ -1294,7 +1317,8 @@ def civic_did3():
"mappings": [
{
"coding": {
"system": "http://purl.obolibrary.org/obo/doid.owl",
"id": "DOID:9119",
"system": "https://disease-ontology.org/?id=",
"code": "DOID:9119",
},
"relation": "exactMatch",
Expand Down Expand Up @@ -1328,7 +1352,8 @@ def civic_gid29():
{
"coding": {
"system": "https://www.ncbi.nlm.nih.gov/gene/",
"code": "ncbigene:3815",
"id": "ncbigene:3815",
"code": "3815",
},
"relation": "exactMatch",
}
Expand Down Expand Up @@ -1472,6 +1497,7 @@ def moa_vid66():
"mappings": [
{
"coding": {
"id": "moa.variant:66",
"system": "https://moalmanac.org",
"code": "66",
},
Expand Down Expand Up @@ -1654,8 +1680,9 @@ def moa_chronic_myelogenous_leukemia():
"mappings": [
{
"coding": {
"id": "oncotree:CML",
"label": "Chronic Myelogenous Leukemia",
"system": "https://oncotree.mskcc.org",
"system": "https://oncotree.mskcc.org/?version=oncotree_latest_stable&field=CODE&search=",
"code": "CML",
},
"relation": "exactMatch",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/database/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_categorical_variant_rules(

variant_types = json.loads(cv["variant_types"])
for vt in variant_types:
assert set(vt.keys()) == {"label", "system", "code"}
assert set(vt.keys()) == {"id", "label", "system", "code"}


def test_location_rules(
Expand Down
Loading

0 comments on commit 4633157

Please sign in to comment.