aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-09-11 11:50:53 +0300
committerJohn Nduli Kilyungi2024-09-18 08:32:34 +0300
commit679bfa89863bae7ea89426e0e0e15e746d4b36fa (patch)
tree76e153b91fd8b25389fa2674d7dd163919eaa642 /gn3/db
parent7842de892b07c1df72bf186ff9efad7eb6955171 (diff)
downloadgenenetwork3-679bfa89863bae7ea89426e0e0e15e746d4b36fa.tar.gz
Run python-black against file.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/rdf/__init__.py73
1 files changed, 37 insertions, 36 deletions
diff --git a/gn3/db/rdf/__init__.py b/gn3/db/rdf/__init__.py
index ffb75e5..6984497 100644
--- a/gn3/db/rdf/__init__.py
+++ b/gn3/db/rdf/__init__.py
@@ -35,8 +35,9 @@ PREFIXES = {
"xsd": "http://www.w3.org/2001/XMLSchema#",
}
-RDF_PREFIXES = "\n".join([f"PREFIX {key}: <{value}>"
- for key, value in PREFIXES.items()])
+RDF_PREFIXES = "\n".join(
+ [f"PREFIX {key}: <{value}>" for key, value in PREFIXES.items()]
+)
BASE_CONTEXT = {
"data": "@graph",
@@ -126,39 +127,40 @@ PUBLICATION_CONTEXT = {
"@id": "fabio:hasPublicationYear",
"@type": "xsd:gYear",
},
- "month": {
- "@id": "prism:publicationDate",
- "@type": "xsd:gMonth"
- },
+ "month": {"@id": "prism:publicationDate", "@type": "xsd:gMonth"},
}
-PHENOTYPE_CONTEXT = BASE_CONTEXT | PUBLICATION_CONTEXT | {
- "skos": "http://www.w3.org/2004/02/skos/core#",
- "dcat": "http://www.w3.org/ns/dcat#",
- "prism": "http://prismstandard.org/namespaces/basic/2.0/",
- "traitName": "skos:altLabel",
- "trait": "rdfs:label",
- "altName": "rdfs:altLabel",
- "description": "dct:description",
- "abbreviation": "gnt:abbreviation",
- "labCode": "gnt:labCode",
- "submitter": "gnt:submitter",
- "dataset": "dcat:Distribution",
- "contributor": "dct:contributor",
- "mean": "gnt:mean",
- "locus": "gnt:locus",
- "lodScore": "gnt:lodScore",
- "references": "dct:isReferencedBy",
- "additive": "gnt:additive",
- "sequence": "gnt:sequence",
- "prefLabel": "skos:prefLabel",
- "identifier": "dct:identifier",
- "chromosome": "gnt:chr",
- "mb": "gnt:mb",
- "peakLocation": "gnt:locus",
- "species": "gnt:belongsToSpecies",
- "group": "gnt:belongsToGroup",
-}
+PHENOTYPE_CONTEXT = (
+ BASE_CONTEXT
+ | PUBLICATION_CONTEXT
+ | {
+ "skos": "http://www.w3.org/2004/02/skos/core#",
+ "dcat": "http://www.w3.org/ns/dcat#",
+ "prism": "http://prismstandard.org/namespaces/basic/2.0/",
+ "traitName": "skos:altLabel",
+ "trait": "rdfs:label",
+ "altName": "rdfs:altLabel",
+ "description": "dct:description",
+ "abbreviation": "gnt:abbreviation",
+ "labCode": "gnt:labCode",
+ "submitter": "gnt:submitter",
+ "dataset": "dcat:Distribution",
+ "contributor": "dct:contributor",
+ "mean": "gnt:mean",
+ "locus": "gnt:locus",
+ "lodScore": "gnt:lodScore",
+ "references": "dct:isReferencedBy",
+ "additive": "gnt:additive",
+ "sequence": "gnt:sequence",
+ "prefLabel": "skos:prefLabel",
+ "identifier": "dct:identifier",
+ "chromosome": "gnt:chr",
+ "mb": "gnt:mb",
+ "peakLocation": "gnt:locus",
+ "species": "gnt:belongsToSpecies",
+ "group": "gnt:belongsToGroup",
+ }
+)
def sparql_construct_query(query: str, endpoint: str) -> dict:
@@ -174,9 +176,8 @@ def query_frame_and_compact(query: str, context: dict, endpoint: str) -> dict:
"""Frame and then compact the results given a context"""
results = sparql_construct_query(query, endpoint)
return jsonld.compact(
- jsonld.frame(results, context),
- context,
- options={"graph": True})
+ jsonld.frame(results, context), context, options={"graph": True}
+ )
def query_and_compact(query: str, context: dict, endpoint: str) -> dict: