Skip to content

Instantly share code, notes, and snippets.

View balhoff's full-sized avatar

Jim Balhoff balhoff

View GitHub Profile
@balhoff
balhoff / skolemize.ru
Created March 6, 2024 17:10
A SPARQL update to replace blank nodes with IRIs
PREFIX ex: <http://example.org/>
INSERT {
?node ex:skolem ?iri .
}
WHERE {
{
SELECT DISTINCT ?node
WHERE {
{ ?node ?p1 ?o1 . }
@balhoff
balhoff / lists.ttl
Created February 24, 2022 17:23
An example OWL ontology (Turtle syntax) using RDF lists (against the spec)
@prefix : <http://example.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://example.org/> .
<http://example.org/> rdf:type owl:Ontology .
@balhoff
balhoff / lists.ofn
Created February 24, 2022 17:21
An example OWL ontology (functional syntax) using RDF lists (against the spec)
Prefix(:=<http://example.org/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<http://example.org/>
@balhoff
balhoff / ontobot.sh
Created October 7, 2021 15:58
Ontobot script for GO.
#!/bin/bash
#Set ONT_ID
#Set ONT_NAME
ROBOT=1.6.0
DT=0.14
BRANCH_BASE="update-$ONT_ID-import"
#check that ontobot doesn't already have an open PR
@balhoff
balhoff / compare-taxon-constraints.sc
Created September 29, 2021 20:31
Check if provided taxon constraints are implied by those already in an ontology
// scala 2.13.3
// ammonite 2.3.8
import $ivy.`net.sourceforge.owlapi:owlapi-distribution:4.5.20`
import $ivy.`org.semanticweb.elk:elk-owlapi:0.4.3`
import $ivy.`org.phenoscape::scowl:1.3.4`
import $ivy.`com.outr::scribe-slf4j:2.7.12`
import scala.io.Source
import org.phenoscape.scowl._
@balhoff
balhoff / query_elk.sc
Created March 31, 2021 19:30
Demonstrate slowdown in second ELK query
// scala 2.13.3
// ammonite 2.3.8
import $ivy.`net.sourceforge.owlapi:owlapi-distribution:4.5.17`
import $ivy.`org.semanticweb.elk:elk-owlapi:0.4.3`
import $ivy.`com.outr::scribe-slf4j:2.7.12`
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.elk.owlapi.ElkReasonerFactory
import org.semanticweb.owlapi.model.IRI
@balhoff
balhoff / obsolete_references.shex
Created February 16, 2018 20:49
ShEx demonstration for validation of OWL classes which make reference to deprecated classes in their definitional axioms
PREFIX : <http://example.org/>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
:NamedClass IRI {
rdf:type [ owl:Class ] ;
owl:equivalentClass @:Expression * ;
@balhoff
balhoff / layperson.sc
Created July 27, 2017 13:42
Scala Ammonite script to generate graph containing only HPO terms with layperson labels
import $ivy.`org.phenoscape::scowl:1.3`
import $ivy.`net.sourceforge.owlapi:owlapi-distribution:4.3.2`
import $ivy.`org.semanticweb.elk:elk-owlapi:0.4.3`
import java.io.File
import java.util.UUID
import scala.collection.JavaConverters._
import org.phenoscape.scowl._
import org.semanticweb.elk.owlapi.ElkReasonerFactory
import org.semanticweb.owlapi.apibinding.OWLManager
@balhoff
balhoff / test-shapes.ttl
Created June 30, 2016 14:35
Test whether sh:qualifiedValueShape works with sh:inverseProperty
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix sh: <http://www.w3.org/ns/shacl#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@prefix owl: <http://www.w3.org/2002/07/owl#>
@prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
@prefix obo: <http://purl.obolibrary.org/obo/>
@prefix ex: <http://example.org/>
@balhoff
balhoff / nearest_ancestors.rq
Last active September 3, 2021 16:08
Retrieve the nearest common ancestors for two terms using SPARQL
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX Term1: <http://purl.obolibrary.org/obo/PATO_0000587>
PREFIX Term2: <http://purl.obolibrary.org/obo/PATO_0000586>
SELECT ?nearest
FROM <http://purl.obolibrary.org/obo/pato.owl>
WHERE {
Term1: rdfs:subClassOf* ?nearest .
Term2: rdfs:subClassOf* ?nearest .
Term1: rdfs:subClassOf* ?indirect .
Term2: rdfs:subClassOf* ?indirect .