aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/metadata.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-06-15 15:40:58 +0300
committerBonfaceKilz2023-06-15 21:27:59 +0300
commit9193597f12631bcf33ce768f2842132bd22a41c3 (patch)
tree50d3d2a66bf82f955d2d997d7bce9cf07d41074c /gn3/api/metadata.py
parentc5b64bd814937c96ef4e7c4aa027fcb03d0d33c2 (diff)
downloadgenenetwork3-9193597f12631bcf33ce768f2842132bd22a41c3.tar.gz
Fetch genotypes from virtuoso
* gn3/api/metadata.py: Import get_genotype_metadata. (genotype): 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/metadata.py')
-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 a2eff05..f21739a 100644
--- a/gn3/api/metadata.py
+++ b/gn3/api/metadata.py
@@ -11,6 +11,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 get_genotype_metadata
from gn3.db.rdf import sparql_query
from gn3.db.rdf import RDF_PREFIXES
@@ -67,6 +68,21 @@ def phenotype(name):
return jsonify({})
+@metadata.route("/genotype/<name>", methods=["GET"])
+def genotype(name):
+ """Fetch a genotype's metadata given it's name"""
+ try:
+ return jsonify(
+ get_genotype_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"""