aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-06-08 14:44:38 +0300
committerBonfaceKilz2023-06-12 15:35:40 +0300
commitfa2ce410d4730b136f24555c049cef3d6dac1102 (patch)
treef155fe2c8e441ba9eb2cd251131b0dfb30e29b9e /gn3/api
parente4489c48bf5d1c9cb72b8cc1eccc603f1178ecbf (diff)
downloadgenenetwork3-fa2ce410d4730b136f24555c049cef3d6dac1102.tar.gz
Fetch phenotypes from virtuoso
* gn3/api/metadata.py: Import get_phenotype_metadata. (phenotype): New end-point. * gn3/db/rdf.py (get_phenotype_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/metadata.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py
index 49c6798..a2eff05 100644
--- a/gn3/api/metadata.py
+++ b/gn3/api/metadata.py
@@ -10,6 +10,7 @@ from SPARQLWrapper import SPARQLWrapper
from gn3.db.rdf import get_dataset_metadata
from gn3.db.rdf import get_publication_metadata
+from gn3.db.rdf import get_phenotype_metadata
from gn3.db.rdf import sparql_query
from gn3.db.rdf import RDF_PREFIXES
@@ -51,6 +52,21 @@ def publication(name):
return jsonify({})
+@metadata.route("/phenotype/<name>", methods=["GET"])
+def phenotype(name):
+ """Fetch a phenotype's metadata given it's name"""
+ try:
+ return jsonify(
+ get_phenotype_metadata(
+ SPARQLWrapper(current_app.config.get("SPARQL_ENDPOINT")),
+ name,
+ ).data
+ )
+ # The virtuoso server is misconfigured or it isn't running at all
+ except (RemoteDisconnected, URLError):
+ return jsonify({})
+
+
@metadata.route("/genewiki/<symbol>", methods=["GET"])
def get_genewiki_entries(symbol):
"""Fetch the GN and NCBI GeneRIF entries"""