aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-06-07 09:39:58 +0300
committerBonfaceKilz2023-06-07 09:42:25 +0300
commit4da80ca9c17bdd28e2689895ab6acb1ec0c70d33 (patch)
treea7854686d22a4f6bd64c2ecbb71aa405c7df1cb0 /gn3/api
parentc68d64a2966750283ecd1290d26eee2797fedcad (diff)
downloadgenenetwork3-4da80ca9c17bdd28e2689895ab6acb1ec0c70d33.tar.gz
Add publication end-point
* gn3/api/metadata.py: Import get_publication_metadata (publication): New endpoint. * gn3/db/rdf.py (get_dataset_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/metadata.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py
index b54f032..1330b6f 100644
--- a/gn3/api/metadata.py
+++ b/gn3/api/metadata.py
@@ -9,6 +9,7 @@ from flask import current_app
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 sparql_query
from gn3.db.rdf import RDF_PREFIXES
@@ -31,9 +32,18 @@ def dataset(name):
return jsonify({})
+@metadata.route("/publication/<name>", methods=["GET"])
+def publication(name):
+ """Fetch a dataset's metadata given it's ACCESSION_ID"""
try:
+ if "unpublished" in name:
+ name = f"gn:{name}"
+ else:
+ name = f"publication:{name}"
return jsonify(
+ get_publication_metadata(
SPARQLWrapper(current_app.config.get("SPARQL_ENDPOINT")),
+ name,
).data
)
# The virtuoso server is misconfigured or it isn't running at all