(defvar *small-piece-of-go* '(!go:GO_0000060 (!go:GO_0000189 !go:GO_0000201 !go:GO_0000208) !go:GO_0007184 !go:GO_0007262 (!go:GO_0035105 !go:GO_0006993))) (define-ontology type-hierarchy () (value-partition *small-piece-of-go* :disjoint nil :covering nil)) (define-ontology existential-hierarchy () (object-property !go:go_isa :transitive ) (existential-hierarchy !go:go_isa *small-piece-of-go* ) (class !go:probe :complete (restriction !go:go_isa (some-values-from !go:GO_0000060))) ) (define-ontology individual-hierarchy () (class !go:term :partial) (object-property !go:go_isa :transitive) (individual-hierarchy !go:term !go:go_isa *small-piece-of-go*) ) (defun demonstrate-hierarchy () "Print all sub(types|exists|individals) of !go:GO_0000060" (princ (abstract-syntax type-hierarchy)) (sparql '(:select (?term) () (?term !rdfs:subClassOf !go:GO_0000060) (:filter (and (not (equal ?term !owl:Nothing)) (not (equal ?term !go:GO_0000060))))) :use-reasoner :jena :kb (kb type-hierarchy) :flatten t :trace "Query the type hierarchy for all subclass of !go:GO_0000060") (princ (abstract-syntax existential-hierarchy)) (sparql '(:select (?term) () (?term !rdfs:subClassOf !go:probe) (:filter (and (not (equal ?term !owl:Nothing)) (not (equal ?term !go:probe)))) ) :use-reasoner :jena :kb (kb existential-hierarchy) :flatten t :trace "Query the existential hierarchy for all classes that are a subclass of the probe, defined as having some go:go_isa !go:GO_0000060") (format t "Can also call DIG-like query \"descendants\", instead of probe~%") (format t "(descendants (restriction !go:go_isa (some-values-from !go:GO_0000060)))~%") (format t "~{~a~%~}" (descendants (restriction !go:go_isa (some-values-from !go:GO_0000060)) (kb existential-hierarchy))) (sparql '(:select (?term) () (?term !rdfs:subClassOf :_restriction) (:_restriction !owl:onProperty !go:go_isa) (:_restriction !owl:someValuesFrom !go:GO_0000060)) :use-reasoner :jena :kb (kb existential-hierarchy) :flatten t :trace "Query the existential hierarchy for all classes that are expressed as restrictions go_isa go:GO_0000060") (princ (abstract-syntax individual-hierarchy)) (sparql '(:select (?term) (:distinct t) (?term !go:go_isa !go:GO_0000060) ) :use-reasoner :jena :kb (kb individual-hierarchy) :flatten t :trace "Query the individual hierarchy for all individual that are go_isa !go:GO_0000060"))