From 4d82124fcd243ae0b8da8ca4706e73e407a67c02 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 10 Jun 2024 22:43:13 +0300 Subject: Generate a SHA256 checksum for the generif graph. Signed-off-by: Munyoki Kilyungi --- scripts/index-genenetwork | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'scripts') 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: +PREFIX rdfs: +PREFIX gnt: +PREFIX gnc: + +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: -- cgit v1.2.3