Skip to content

Commit

Permalink
add some examples on indexing preston provenance logs; related to bio…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Dec 16, 2023
1 parent 44bb276 commit e431046
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
13 changes: 13 additions & 0 deletions query/4fa7b334-ce0d-4e88-aaae-2e0c138d049e.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT ?archiveUrl ?seenAt ?contentId
WHERE {
graph ?g1 {
<urn:uuid:4fa7b334-ce0d-4e88-aaae-2e0c138d049e> <http://www.w3.org/ns/prov#hadMember> ?archiveUrl .
?archiveUrl <http://purl.org/dc/elements/1.1/format> "application/dwca" .
}
graph ?activity {
?activity <http://www.w3.org/ns/prov#used> ?archiveUrl .
?activity <http://www.w3.org/ns/prov#generatedAtTime> ?seenAt .
?contentId <http://www.w3.org/ns/prov#qualifiedGeneration> ?activity .
}
} limit 10

20 changes: 20 additions & 0 deletions query/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
2023-12-15
Jorrit Poelen

This directory contains examples on how query preston provenance logs using SPARQL:

Step 1.
Stream preston provenance logs into a triple-store.

Step 2.
Write a query in sparql.

Step 3.
Execute query.

Step 4.
Inspect results.


See https://github.com/bio-guoda/preston/issues/199#issuecomment-1858618208 for context and examples.

8 changes: 8 additions & 0 deletions query/all-versions.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

SELECT ?s ?p ?o
WHERE {
GRAPH ?g {
?s <http://purl.org/pav/hasVersion> ?o .
}
}

32 changes: 32 additions & 0 deletions query/ebird.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?contentId ?seenAt ?archiveUrl WHERE
{
{
SELECT ?contentId ?seenAt ?archiveUrl
WHERE {
graph ?g1 {
<urn:uuid:4fa7b334-ce0d-4e88-aaae-2e0c138d049e> <http://www.w3.org/ns/prov#hadMember> ?archiveUrl .
?archiveUrl <http://purl.org/dc/elements/1.1/format> "application/dwca" .
}
graph ?activity {
?activity <http://www.w3.org/ns/prov#used> ?archiveUrl .
?activity <http://www.w3.org/ns/prov#generatedAtTime> ?seenAt .
?contentId <http://www.w3.org/ns/prov#qualifiedGeneration> ?activity .
}
}
}
UNION
{
SELECT ?contentId ?seenAt ?archiveUrl
WHERE {
<urn:uuid:4fa7b334-ce0d-4e88-aaae-2e0c138d049e> <http://www.w3.org/ns/prov#hadMember> ?archiveUrl .
?archiveUrl <http://purl.org/dc/elements/1.1/format> "application/dwca" .
?activity <http://www.w3.org/ns/prov#used> ?archiveUrl .
?activity <http://www.w3.org/ns/prov#generatedAtTime> ?seenAt .
?contentId <http://www.w3.org/ns/prov#qualifiedGeneration> ?activity .
}
}
} ORDER BY ?seenAt

15 changes: 15 additions & 0 deletions query/index-provenance-graph.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# index provenance graph associated with an anchor
# into oxigraph
#


preston ls\
--anchor hash://sha256/5b7fa37bf8b64e7c935c4ff3389e36f8dd162f0705410dd719fd089e1ea253cd\
--remote https://linker.bio\
| sed -E 's/(<)([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})([^ ]*)(>)/<urn:uuid:\2>/g'\
| pv -l\
| ./oxigraph_server_v0.3.22_x86_64_linux_gnu load --lenient --format nq --location preston-gib


9 changes: 9 additions & 0 deletions query/versions-of-url.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?o
WHERE {
<http://collections.mnhn.fr/ipt/archive.do?r=mnhn-ar> <http://purl.org/pav/hasVersion> ?o .
} limit 10


0 comments on commit e431046

Please sign in to comment.