biolink / biolink-model-toolkit

A collection of useful python functions for looking up information and working with the Biolink Model
https://biolink.github.io/biolink-model-toolkit/
BSD 3-Clause "New" or "Revised" License
20 stars 10 forks source link

get_associations() returns an emtpy list #171

Closed hina-shah closed 1 month ago

hina-shah commented 1 month ago

We are trying to use get_associations() and are getting some unexpected results.

A couple of examples I tried: tk.get_associations( subject_categories = ["chemical entity"], predicates = ["affects"], object_categories= ["gene or gene product"] ), and was expecting a "chemical affects gene association" to be returned, but instead got an empty list.

Similarly for: tk.get_associations( subject_categories = ["gene"], predicates = ["member of"], object_categories= ["gene family"] ) I was expecting to get "gene to gene family association", but got an empty list as well.

Is this the right usage for this function?

sierra-moxon commented 1 month ago

Hi @hina-shah - at the moment, the get_associations method works better if you use biolink curie versions of the category and predicate names, e.g. ["biolink:ChemicalEntity"] vs. ["chemical entity"].

def test_get_associations_gene_to_chemical(toolkit):
    associations = toolkit.get_associations(
        subject_categories=["biolink:ChemicalEntity"],
        predicates=["biolink:affects"],
        object_categories=["biolink:GeneOrGeneProduct"],
        # we don't bother testing the 'format' flag simply in confidence
        # that the associated code is already well tested in other contexts
        formatted=True
    )
    assert associations
    assert "biolink:ChemicalAffectsGeneAssociation" in associations
    print(associations)

We can use this issue to check for non-curie versions of the biolink components and add this feature. :) But as a work around, use the full curie and let me know if that works better for you?

hina-shah commented 1 month ago

Thanks @sierra-moxon !!