monarch-initiative / biolink-api

API for linked biological knowledge
https://api.monarchinitiative.org/api/
BSD 3-Clause "New" or "Revised" License
64 stars 25 forks source link

GET /bioentity/{id}/associations/ #84

Open lhannest opened 7 years ago

lhannest commented 7 years ago

I assume that the point of this query is to search for an association with either a subject or object that matches with id, but in fact it's only matching subjects.

https://github.com/biolink/biolink-api/blob/master/biolink/api/bio/endpoints/bioentity.py:

@ns.route('/<id>/associations/')
class GenericAssociations(Resource):
    @api.expect(core_parser)
    @api.marshal_with(association_results)
    def get(self, id):
        """
        Returns associations for an entity regardless of the type
        """
        return search_associations(subject=id, **core_parser.parse_args())

Moreover, this above method appears to be doing more or less the same thing as the following:

https://github.com/biolink/biolink-api/blob/master/biolink/api/link/endpoints/associations_from.py

@ns.route('/from/<subject>')
@api.doc(params={'subject': 'Return associations emanating from this node, e.g. specifying NCBIGene:84570 will return gene-phenotype, gene-function etc for this gene'})
class AssociationsFrom(Resource):
    @api.expect(parser)
    @api.marshal_list_with(association_results)
    def get(self, subject):
        """
        Returns list of matching associations starting from a given subject (source)
        """
        args = parser.parse_args()
        return search_associations(subject=subject, **args)

It looks like the solr query being sent for /<id>/associations/ is:

{'facet.mincount': 1, 'start': 1, 'fq': ['subject_closure:"NCBIGene:84570"'], 'q': '*:*', 'facet': 'on', 'facet.field': ['subject_taxon_label', 'object_closure'], 'facet.limit': 25, 'rows': 1, 'fl': 'id,is_defined_by,source,subject,subject_label,subject_taxon,subject_taxon_label,relation,relation_label,object,object_label,object_taxon,object_taxon_label,evidence_object,evidence_graph'}

It looks like 'fq' ought to be mapped to [''object_closure:"NCBIGene:84570"' OR subject_closure:"NCBIGene:84570"'] so as to match both subject and object ID's.

cmungall commented 7 years ago

Good point, it's a bit underspecified. I think the former would be more useful and intuitive if it did the union as you suggest.