Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Update to Biolink 3 and add support for qualifiers #549

Open
balhoff opened this issue Aug 5, 2022 · 2 comments · May be fixed by #635
Open

Update to Biolink 3 and add support for qualifiers #549

balhoff opened this issue Aug 5, 2022 · 2 comments · May be fixed by #635

Comments

@balhoff
Copy link
Contributor

balhoff commented Aug 5, 2022

This will need to happen in the pipeline first.

@gaurav gaurav changed the title Update to Biolink 3.0 Update to Biolink 3 and add support for qualifiers Nov 29, 2022
@gaurav
Copy link
Member

gaurav commented Dec 1, 2022

We currently map ontology properties directly to Biolink properties:

// TODO:
// - Change this to cached queries (see mapQueryBiolinkPredicatesToRelations for example)
def mapRelationsToLabelAndBiolink(relations: Set[IRI]): RIO[ZConfig[AppConfig] with HttpClient, Map[IRI, (Option[String], IRI)]] = {
final case class RelationInfo(relation: IRI, biolinkSlot: IRI, label: Option[String])
val queryText = sparql"""
SELECT DISTINCT ?relation ?biolinkSlot ?label
WHERE {
VALUES ?relation { ${relations.asValues} }
?relation $SlotMapping ?biolinkSlot .
?biolinkSlot a $BiolinkMLSlotDefinition .
OPTIONAL { ?relation $RDFSLabel ?label . }
FILTER NOT EXISTS {
?relation $SlotMapping ?other .
?other $BiolinkMLIsA+/$BiolinkMLMixins* ?biolinkSlot .
}
}"""
SPARQLQueryExecutor.runSelectQueryAs[RelationInfo](queryText.toQuery).map { res =>
res.groupMap(_.relation)(info => (info.label, info.biolinkSlot)).map { case (relationIRI, infos) => relationIRI -> infos.head }
}
}

However, in order to support queries, I think we will need to provide support for more complex mappings (see Biolink predicate transformation examples (PDF)).

@gaurav gaurav linked a pull request Mar 17, 2023 that will close this issue
@gaurav
Copy link
Member

gaurav commented Mar 28, 2023

Okay, we have a working Biolink 3 instance at https://cam-kp-api-dev.renci.org/1.3.0/docs/index.html?url=docs.yaml#/default/postQuery

For example, it accepts the following query:

{
    "message": {
        "query_graph": {
            "nodes": {
                "gene": {
                    "categories": [
                        "biolink:Gene"
                    ],
                    "ids": [
                        "NCBIGene:340061"
                    ]
                },
                "chemical": {
                    "categories": [
                        "biolink:ChemicalEntity"
                    ]
                }
            },
            "edges": {
                "t_edge": {
                    "object": "gene",
                    "subject": "chemical",
                    "predicates": [
                        "biolink:affects"
                    ],
                    "knowledge_type": "inferred",
                    "qualifier_constraints": [
                        {
                            "qualifier_set": [
                                {
                                    "qualifier_type_id": "biolink:object_aspect_qualifier",
                                    "qualifier_value": "activity_or_abundance"
                                },
                                {
                                    "qualifier_type_id": "biolink:object_direction_qualifier",
                                    "qualifier_value": "increased"
                                }
                            ]
                        }
                    ]
                }
            }
        }
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants