From 6155b646448fc62639f70db80b6b0ee513d7af51 Mon Sep 17 00:00:00 2001 From: Deepak Unni Date: Mon, 5 Mar 2018 10:23:18 -0800 Subject: [PATCH 1/2] allow option to define relationship type in /goterm//genes/ endpoint --- biolink/api/bio/endpoints/bioentity.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/biolink/api/bio/endpoints/bioentity.py b/biolink/api/bio/endpoints/bioentity.py index 206ad827..bd9acee6 100644 --- a/biolink/api/bio/endpoints/bioentity.py +++ b/biolink/api/bio/endpoints/bioentity.py @@ -29,6 +29,12 @@ or a specific publication or other supporting ibject, e.g. ZFIN:ZDB-PUB-060503-2. """) +GENES_IN_PATHWAY = 'genes in pathway' +GENES_REGULATING_PATHWAY = 'genes regulating pathway' +core_parser_with_rel = core_parser.copy() +core_parser_with_rel.add_argument('relationship_type', required=False, default='genes in pathway', help="relationship type ('{}' or '{}')".format(GENES_IN_PATHWAY, GENES_REGULATING_PATHWAY)) + + scigraph = SciGraph('https://scigraph-data.monarchinitiative.org/scigraph/') homol_rel = HomologyTypes.Homolog.value @@ -459,15 +465,24 @@ def get(self, id): @ns.route('/goterm//genes/') class GotermGeneAssociations(Resource): - @api.expect(core_parser) + @api.expect(core_parser_with_rel) @api.marshal_with(association_results) def get(self, id): """ Returns associations to GO terms for a gene """ - return search_associations( - subject_category='gene', object_category='function', - subject=id, invert_subject_object=True, **core_parser.parse_args()) + args = core_parser_with_rel.parse_args() + if args['relationship_type'] == GENES_REGULATING_PATHWAY: + # Temporary fix until https://github.com/geneontology/amigo/pull/469 + # and https://github.com/owlcollab/owltools/issues/241 are resolved + return search_associations( + subject_category = 'gene', object_category = 'function', + fq = {'regulates_closure': id, '-isa_partof_closure': id}, + invert_subject_object=True, **args) + else: + return search_associations( + subject_category='gene', object_category='function', + subject=id, invert_subject_object=True, **core_parser.parse_args()) @ns.route('/pathway/') @api.doc(params={'id': 'CURIE any pathway element. May be a GO ID or a pathway database ID'}) @@ -806,4 +821,3 @@ def get(self, id): """ obj = scigraph.bioobject(id) return obj - From 47aa6fd4538de47f58e29706a1cb438da3159dba Mon Sep 17 00:00:00 2001 From: Deepak Unni Date: Mon, 5 Mar 2018 13:03:27 -0800 Subject: [PATCH 2/2] use proper relationship_type names involved_in => isa_partof_closure involved_in_regulation_of => regulates_closure - isa_partof_closure acts_upstream_of_or_within => regulates_closure --- biolink/api/bio/endpoints/bioentity.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/biolink/api/bio/endpoints/bioentity.py b/biolink/api/bio/endpoints/bioentity.py index bd9acee6..84d961a7 100644 --- a/biolink/api/bio/endpoints/bioentity.py +++ b/biolink/api/bio/endpoints/bioentity.py @@ -29,10 +29,12 @@ or a specific publication or other supporting ibject, e.g. ZFIN:ZDB-PUB-060503-2. """) -GENES_IN_PATHWAY = 'genes in pathway' -GENES_REGULATING_PATHWAY = 'genes regulating pathway' +INVOLVED_IN = 'involved_in' +INVOLVED_IN_REGULATION_OF = 'involved_in_regulation_of' +ACTS_UPSTREAM_OF_OR_WITHIN = 'acts_upstream_of_or_within' + core_parser_with_rel = core_parser.copy() -core_parser_with_rel.add_argument('relationship_type', required=False, default='genes in pathway', help="relationship type ('{}' or '{}')".format(GENES_IN_PATHWAY, GENES_REGULATING_PATHWAY)) +core_parser_with_rel.add_argument('relationship_type', required=False, default='involved_in', help="relationship type ('{}', '{}' or '{}')".format(INVOLVED_IN, INVOLVED_IN_REGULATION_OF, ACTS_UPSTREAM_OF_OR_WITHIN)) scigraph = SciGraph('https://scigraph-data.monarchinitiative.org/scigraph/') @@ -472,14 +474,19 @@ def get(self, id): Returns associations to GO terms for a gene """ args = core_parser_with_rel.parse_args() - if args['relationship_type'] == GENES_REGULATING_PATHWAY: + if args['relationship_type'] == ACTS_UPSTREAM_OF_OR_WITHIN: + return search_associations( + subject_category='gene', object_category='function', + fq = {'regulates_closure': id}, + invert_subject_object=True, **args) + elif args['relationship_type'] == INVOLVED_IN_REGULATION_OF: # Temporary fix until https://github.com/geneontology/amigo/pull/469 # and https://github.com/owlcollab/owltools/issues/241 are resolved return search_associations( subject_category = 'gene', object_category = 'function', fq = {'regulates_closure': id, '-isa_partof_closure': id}, invert_subject_object=True, **args) - else: + elif args['relationship_type'] == INVOLVED_IN: return search_associations( subject_category='gene', object_category='function', subject=id, invert_subject_object=True, **core_parser.parse_args())