aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-10-11 17:28:09 +0300
committerBonfaceKilz2023-10-27 13:45:32 +0300
commit50349f7e067bd894d4aa4865ded5589ee1fcd9e9 (patch)
treeaf219a41a281e565257925754b78fdcd01116639 /gn3/db
parent5e17b469b29419098eeb81a5537426f0d0b26aec (diff)
downloadgenenetwork3-50349f7e067bd894d4aa4865ded5589ee1fcd9e9.tar.gz
Implement "GET /metadata/datasets/:name".
* gn3/api/metadata.py: Import json, SPARQLWrapper.{JSON, JSONLD}. (dataset): Rename this to ... (datasets): ... this. Return a well formatted JSONLD result from a dataset. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/rdf.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/gn3/db/rdf.py b/gn3/db/rdf.py
index 472da64..c5a75f2 100644
--- a/gn3/db/rdf.py
+++ b/gn3/db/rdf.py
@@ -213,45 +213,3 @@ CONSTRUCT {
)[0].items():
result[key] = value
return result
-
-
-def get_genotype_metadata(
- sparql_conn: SPARQLWrapper, name: str
-):
- """Return info about a phenotype with a given NAME"""
- __metadata_query = """
-$prefix
-
-CONSTRUCT {
- ?genotype ?pPredicate ?pValue .
- ?genotype gn:speciesName ?speciesName .
- ?genotype gn:inbredSetName ?inbredSetBinomialName .
- ?genotype gn:datasetName ?datasetFullName .
-} WHERE {
- ?genotype ?pPredicate ?pValue .
- OPTIONAL {
- ?genotype gn:genotypeOfDataset ?dataset .
- ?dataset gn:fullName ?datasetFullName .
- }.
- OPTIONAL {
- ?genotype gn:genotypeOfDataset ?dataset .
- ?dataset gn:datasetOfInbredSet ?inbredSet .
- ?inbredSet gn:binomialName ?inbredSetBinomialName .
- ?inbredSet gn:inbredSetOfSpecies ?species .
- ?species gn:displayName ?speciesName .
- } .
- FILTER( ?genotype = genotype:$name ) .
- MINUS {
- ?genotype rdf:type ?pValue .
- }
-}
-"""
- result: MonadicDict = MonadicDict()
- for key, value in sparql_query(
- sparql_conn,
- Template(__metadata_query)
- .substitute(name=name,
- prefix=RDF_PREFIXES)
- )[0].items():
- result[key] = value
- return result