Skip to content

Commit

Permalink
#145 addind owl:versionInfo yyyy-mm-dd to imported and defined entiti…
Browse files Browse the repository at this point in the history
…es through extracting date from related ontology versionIRIs
  • Loading branch information
hkir-dev committed Jul 27, 2021
1 parent 7f218fe commit ca8eaf8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/ontology/bdscratch.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ dosdp_patterns_default: $(SRC) all_imports .FORCE
$(PATTERNDIR)/data/default/%.txt: $(PATTERNDIR)/dosdp-patterns/%.yaml $(PATTERNDIR)/data/default/%.tsv .FORCE
if [ $(PAT) = true ]; then $(DOSDPT) terms --prefixes=template_prefixes.yaml --infile=$(word 2, $^) --template=$< --obo-prefixes=true --outfile=$@; fi

# adding an extra query step to inject version info to imported entities
imports/%_import.owl: mirror/%.owl imports/%_terms_combined.txt
if [ $(IMP) = true ]; then $(ROBOT) query -i $< --update ../sparql/inject-version-info.ru --update ../sparql/preprocess-module.ru \
extract -T imports/$*_terms_combined.txt --force true --copy-ontology-annotations true --individuals exclude --method BOT \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/postprocess-module.ru \
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@; fi

# Full: The full artefacts with imports merged, reasoned. Added extra step to inject version info to entities
$(ONT)-full.owl: $(SRC) $(OTHER_SRC)
$(ROBOT) merge --input $< \
reason --reasoner ELK --equivalent-classes-allowed all --exclude-tautologies structural \
relax \
reduce -r ELK \
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \
query --update ../sparql/inject-version-info.ru \
--output $@.tmp.owl && mv $@.tmp.owl $@

# hard wiring for now. Work on patsubst later
mirror/ensmusg.owl: ../templates/ensmusg.tsv
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) template --input bdscratch-edit.owl --template $< \
Expand Down
26 changes: 26 additions & 0 deletions src/sparql/inject-version-info.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
PREFIX : <http://www.test.com/ns/test#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

INSERT {
?individual owl:versionInfo ?versionStr .
?class owl:versionInfo ?versionStr .
}
WHERE {
?ontology rdf:type owl:Ontology ;
owl:versionIRI ?versionIRI .
# regex matches date and the previous text in the iri. When replaced string after the date remains
BIND (REPLACE(str(?versionIRI), "^.*\\d{4}[\\-]\\d{2}[\\-]\\d{2}", "") AS ?dateTrailingStr)
# regex matches date and the trailing text in the iri. When replaced string before the date remains
BIND (REPLACE(str(?versionIRI), "\\d{4}[\\-]\\d{2}[\\-]\\d{2}.*$", "") AS ?dateHeadingStr)
# replace heading and trailing text in the versionIRI to remain only the date
BIND (REPLACE(str(?versionIRI), ?dateTrailingStr, "") AS ?versionSubStr)
BIND (REPLACE(str(?versionSubStr), ?dateHeadingStr, "") AS ?versionStr)

?class rdf:type owl:Class .
OPTIONAL { ?individual rdf:type owl:NamedIndividual . FILTER NOT EXISTS {?individual owl:versionInfo ?o1} }
FILTER (!isBlank(?class))
FILTER NOT EXISTS {?class owl:versionInfo ?o2}
}

0 comments on commit ca8eaf8

Please sign in to comment.