aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-06-10 22:43:13 +0300
committerBonfaceKilz2024-06-12 19:21:50 +0300
commit4d82124fcd243ae0b8da8ca4706e73e407a67c02 (patch)
tree6e56e96b95c4dcf632ebbf81744cce29ab173b5d /scripts
parent2663ed5ae406c0a99a0a610f08f4866d46107eca (diff)
downloadgenenetwork3-4d82124fcd243ae0b8da8ca4706e73e407a67c02.tar.gz
Generate a SHA256 checksum for the generif graph.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/index-genenetwork30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork
index 8769689..52a48df 100755
--- a/scripts/index-genenetwork
+++ b/scripts/index-genenetwork
@@ -198,6 +198,36 @@ _:node rdf:type gnc:GNWikiEntry ;
return cache
+def hash_generif_graph():
+ sparql = SPARQLWrapper(
+ "http://localhost:8982/sparql"
+ )
+ sparql.setReturnFormat(JSON)
+ query = """
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX gnt: <http://genenetwork.org/term/>
+PREFIX gnc: <http://genenetwork.org/category/>
+
+SELECT SHA256(GROUP_CONCAT(?entries ; separator=\"\\n\")) AS ?hash WHERE {
+ {{
+ SELECT ?type CONCAT(?symbolName, ",", ?speciesName, \"\\n\",GROUP_CONCAT(?comment ; separator=\"\\n\")) AS ?entries WHERE {
+ ?symbol rdfs:comment _:node ;
+ rdfs:label ?symbolName .
+_:node rdf:type gnc:GNWikiEntry ;
+ rdf:type ?type ;
+ gnt:belongsToSpecies ?species ;
+ rdfs:comment ?comment .
+?species gnt:shortName ?speciesName .
+} GROUP BY ?speciesName ?symbolName ?type
+ }}
+ } GROUP BY ?type
+"""
+ sparql.setQuery(query)
+ results = sparql.queryAndConvert()["results"]["bindings"]
+ return results[0]["hash"]["value"]
+
+
# pylint: disable=invalid-name
def write_document(db: xapian.WritableDatabase, identifier: str,
doctype: str, doc: xapian.Document) -> None: