Show allShow sourceontol_db.pro -- ontology classes and instances

Synopsis

:- use_module(bio(ontol_db)).
:- use_module(bio(io)).

% find all superclasses of a particular class
demo:-
  load_bioresource(go),
  class(ID,'transcription factor activity'),
  setof(Parent,subclassRT(ID,Parent),Parents),
  writeln(parents=Parents).

Package

This module is part of the blipkit ontol package. See README.txt

Description

This module contains defines extensional and intensional data predicates that model ontology and instance data. The data model is obo-like, and can easily be mapped to an OWL ontology (see bridge)

The basic querying is such things as transitive relationships and detecting illegal cycles or redundant relationships. It requires ontology prolog fact files containing at least the following facts:

class/2
belongs/2
subclass/2
restriction/3

Any cycles over subclass/2 or restriction/3 will cause non-terminating behavior

Importing and exporting data

This is a data module. Facts can be imported and exported from both prolog fact databases and other formats

Import

The following file formats can be read in using load_biofile/2 and load_bioresource/1

ontology(?Ontology, ?Name, ?Desc) is nondet
ontology(?Ontology, ?Name)
see ontology/3
class(?Class) is nondet
class declaration - true if Class is a class
class(?Class, ?Label) is nondet
combines class/1 and entity_label/2
subclass(?Class, ?SuperClass) is nondet
An asserted is_a (subtype, subsumption) relationship equivalent to owl:subClassOf transitive form is subclassT/2
equivalent_class(?Class1, ?Class2) is nondet
corresponds to owl:equivalentClass
subclassN(?Name, ?SuperTermName) is nondet
combines entity_label/2 and subclass/2
subclassTN(+Name, ?SuperTermNameTransitive) is nondet
transitive version of subclassN/2
subclassRTN(+Name, ?SuperTermNameReflexiveTransitive) is nondet
reflexive transitive version of subclassN/2
restriction(?Class, ?Relation, ?ToClass) is nondet
A relationship between two classes such that all instances of ?Class stand in ?Relation to some instance of ?ToClass
restriction(?Class, ?Relation, ?ToClass, ?Arg3) is nondet
ternary relations
restriction(?Class, ?Relation, ?ToClass, ?Arg3, ?Arg4) is nondet
quaternary relations
cardinality_restriction(?Class, ?Relation, ?Card, ?ToClass) is nondet
A relationship between two classes such that all instances of ?Class stand in ?Relation to ?Card instance(s) of ?ToClass
min_cardinality_restriction(?Class, ?Relation, ?Min_card, ?ToClass) is nondet
A relationship between two classes such that all instances of ?Class stand in ?Relation to at least ?Min instance(s) of ?ToClass
max_cardinality_restriction(?Class, ?Relation, ?Max_card, ?ToClass) is nondet
A relationship between two classes such that all instances of ?Class stand in ?Relation to at most ?Max instance(s) of ?ToClass
restrictionN(?Name, ?RelationName, ?SuperTermName) is nondet
combines entity_label/2 and restriction/3
child(?Parent, ?Child) is nondet
child(?Parent, ?Relation, ?Child) is nondet
node_link(Node, Relation, Link) is nondet
true if parent/3 or inst_rel/3
parent(?Class, ?SuperClass) is nondet
as parent/3
parent(?Class, ?Relation, ?ParentClass) is nondet
combines subclass/2 and restriction/3 also genus/2 differentia/3 true if Relation=subclass and subclass(Class,ParentClass) or if restriction(?Class,?Relation,?ParentClass)
parentT(?Class, ?ParentClass) is nondet
see parentT/3
parentT(?Class, ?RelationList, ?ParentClass) is nondet
transitive parent/3
parentT(?ID, +RelationList, ?SuperClass, +ViaRelation) is nondet
DEPRECATED? consider parent_overT/3 transitive parent relation via some relation
parentRT(?Class, ?ParentClass) is nondet
reflexive transitive parent/2. See parentRT/3
parentRT(?Class, ?Relation, ?ParentClass) is nondet
reflexive transitive parent/3
parent_over(+R, ?Class, ?ParentClass) is nondet
as parent_over/4
parent_over(+R, ?Via, ?Class, ?ParentClass) is nondet
true if ParentClass is a parent of Class by relation R uses subclass/2 rules: X R Y if X subclassRT X1 and X1 R Y1 and Y1 subclassRT Y

notes: this will loop forever if there are subclass/2 cycles

parent_overT(+R, ?Class, ?ParentClass) is nondet
transitive closure over parent_over/3
parent_over_nr(+R, ?ID, ?PID) is nondet
as parent_over_nr/4
parent_over_nr(+R, ?Via, ?ID, ?PID) is nondet
nonredundant version of parent_over/4

eliminates redundancy; for example, if X part_of organelle, and nucleus is_a+ organelle, and X can be inferred to be part_of a nucleus, then X part_of organelle is redundant

 X --[p]--> nucleus --[is_a]--> organelle
 |                                  ^
 |                                  |
 +----------[p]---------------------+
belongs(?Entity, ?Ontology) is nondet
true if Entity belongs to Ontology - equivalent to entity_resource/2 may be deprecated in future - consider entity_resource/2
synonym(?Class, ?Scope, ?Synonym) is nondet
may be deprecated in future - consider entity_synonym/2 and entity_synonym_scope/3 Scope='' if no scope is specified
class_xref(?Class, ?DBXref) is nondet
def_xref(?Class, ?DBXref) is nondet
true if DBXRef is the source of the def/2 fact for Class this is currently not defined in terms of entity_xref/2
class_comment(?Class, ?Comment) is nondet
Combines class/1 and entity_comment/2 holds when class(Class) and entity_comment(Class,Comment)
def(?Class, ?DefinitionText) is nondet
true if DefinitionText is the natural language definition of Class or Relation % def(+Class,?DefinitionText) is semidet
disjoint_from(?Class, ?DisjointClass)
true if there is nothing that instantiates both Class and DisjointClass
class_disjoint_union_list(?Class, ?JEPDClassList) is nondet
inferred from disjoint_from/2 and class_union_element/2
genus(?Class, ?Genus) is nondet
A logical definition of Class refines Genus via some discriminating characteristic (differentium/3); e.g. a Class is a Genus which Differentia hold
differentium(?Class, ?Rel, ?ToClass) is nondet
Must be used in conjunction with genus/2
class_union_element(?Class, ?Element) is nondet
for covering axioms. same as owl:unionOf
class_intersection_element(?Class, ?Element) is nondet
for definitions. same as owl:intersectionOf
property_intersection_element(?Property, ?Element) is nondet
we write the relation intersection p^q as two facts property_intersection_element('p^q',p). property_intersection_element('p^q',q). no equivalent in OWL or OWL2
property_intersection_elements(?Property, ?Elements) is semidet
property_union_element(?Property, ?Element) is nondet
we write the relation union p^q as two facts property_union_element('p^q',p). property_union_element('p^q',q). no equivalent in OWL or OWL2
property_union_elements(?Property, ?Elements) is semidet
relation(?Rel)
disjunction of property/1 and slot/1 holds if Rel is a property or slot
property(?Relation) is nondet
holds when Relation is the ID of an entity which defines a relationship which holds between two classes (arg2 of restriction/3) or between two instance (arg2 of inst_rel/3) equivalent to owl:ObjectProperty
property(?Relation, ?Name) is nondet
combines property/1 and entity_label/2 holds when property(?Relation) and entity_label(?Relation,?Name) see entity_label/2
property_domain(?Relation, ?Class) is nondet
all instances that are the subject of Relation instantiate Class note: also for slot/1
property_range(?Relation, ?Class) is nondet
all instances that are the object of Relation instantiate Class note: also for slot/1
complement_of(?NegRel, ?Rel)
slot(?Slot) is nondet
declares that Slot is a relation that links instances to datatype equivalent to owl:DatatypeProperty
slot(?Slot, ?Name) is nondet
combines and slot/1 entity_label/2 holds when slot(?Slot) and entity_label(?Slot,?Name)
lexical_category(?Class, ?Type) is nondet
DEPRECATED
is_anonymous(?Entity) is nondet
true if Entity is unnamed equivalent to bNode in RDF
is_unsatisfiable(?Class) is nondet
true if Class is defined in such a way it can never be instantiated; for example, being a subclass of two disjoint classes
inverse_of(?Relation, ?Inverse) is nondet
true if Inverse is the inverse of Relation, such that the inverse is held between instances formally: inst_rel(X,R,Y),inverse(R,R1) => inst_rel(Y,R1,X)
inverse_of_on_instance_level(?Relation, ?Inverse) is nondet
true if all_some(Relation,InstRelation),inverse_of(InstRelation,InstRelationInv),all_some(InstRelationInv,Inverse) (always asserted)
class_level_inverse_of(?Relation, ?Inverse) is nondet
DEPRECATED: just use inverse_of true if Inverse is the inverse of Relation, such that the inverse is held between classes formally: restriction(X,R,Y),class_inverse(R,R1) => restriction(Y,R1,X)
holds_bidirectionally_for(?IntegralRelation, ?Relation) is nondet
holds_bidirectionally_for(SR,R), X SR Y, R inverse_of RI => X R Y and Y RI X DEPRECATED. Use holds_bidirectionally_for/3
holds_bidirectionally_for(?IntegralRelation, ?Relation, ?InverseRelation) is nondet
holds_bidirectionally_for(SR,R,Inv), X SR Y => X R Y and Y Inv X
is_metadata_tag(?Relation) is nondet
does this relation only hold at the class metadata level? same as owl:AnnotationProperty
is_class_level(?Relation) is nondet
Relation only holds between classes: also is non-inheritable
is_transitive(?Relation) is nondet
formally: X R Y, Y R Z, is_transitive(R) => X R Z
metaproperty(?Relation, ?Property) is nondet
reified unary relation predicates. @param Property one of is_transitive/1, is_symmetric/1, is_cyclic/1, is_asymmetric/1, is_anti_symmetric/1, is_functional/1, is_inverse_functional/1
transitive_over(?Relation, ?Over) is nondet
true if Relation is transitive over Over formally: X R Y, Y R1 Z, transitive_over(R,R1) => X R Z
holds_over_chain(?Relation, ?RelationList) is nondet
true if Relation is transitive over the chain of relations in RelationList e.g. if holds_over_chain(R,[R1,R2, ..., Rn]) then X R Y <= X R1 Z1, Z1 R2 Z2, ..., Zn-1 Rn Y
equivalent_to_chain(?Relation, ?RelationList) is nondet
true if Relation is equivalent the chain of relations in RelationList e.g. if equivalent_to_chain(R,[R1,R2, ..., Rn]) then X R Y <=> X R1 Z1, Z1 R2 Z2, ..., Zn-1 Rn Y
is_symmetric(?Relation) is semidet
class level. formally: X R Y,is_symmetric(R) => Y R X, X and Y are classes
is_asymmetric(?Relation) is semidet
is_reflexive(?Relation) is semidet
formally: forall(X), is_reflexive(R) => X R X
is_anti_symmetric(?Relation) is semidet
is_cyclic(?Relation) is semidet
is_functional(?Relation) is semidet
is_inverse_functional(?Relation) is semidet
is_nondangling(?Relation) is semidet
is_proper(?Relation) is nondet
transitive_form_of(?TransitiveRel, ?Rel) is nondet
strictly required? We can make the Rel a subproperty of TransitiveRel instead, but this is less intuitive
proper_form_of(?ProperRel, ?Rel) is nondet
cyclic_form_of(?CyclicRel, ?Rel) is nondet
cyclic_over(?CyclicRel, ?Rel) is nondet
reflexive_over(?RRel, ?Rel) is nondet
directed_simple_path_over(?CyclicRel, ?Rel) is nondet
directed_path_over(?CyclicRel, ?Rel) is nondet
id_axiom(?Relation, ?Axiom) is nondet
Axiom can be any term
all_some(?Relation) is nondet
DEPRECATED: see below - but used in ontol_reasoner :- extensional(all_some/1).
disjoint_over(?Rel, ?RelOver)
property_relationship(?P, ?Rel, ?Filler) is notnet
Parameters:
?- Rel = all_some_all_times ; all_some_some_times ; all_some_tr
holds_for_all_times(?Relation) is nondet
obsolete(?Class, ?Name, ?Ontology) is nondet
DEPRECATED: combines entity_label/2, entity_obsolete/1 and belongs/2
obsolete_class(?Class, ?Name) is nondet
DEPRECATED combines entity_label/2, entity_obsolete/1
idspace(?IDSpace, ?IDSpaceLong) is nondet
DPRECATED: use idspace_uri/2 instead
inst(?Instance) is nondet
true if Instance is declared to be an instance of some class
inst(?Instance, ?Name) is nondet
combines inst/1 and entity_label/2 holds when inst(?Instance) and entity_label(?Instance,?Name)
inst_of(?Instance, ?Class) is nondet
true if Instance is a direct instaniation of Class
inst_of_at(?Instance, ?Class, ?Time) is nondet
true if Instance is a direct instaniation of Class at Time time-indexed version of inst_of/2 see also inst_rel/4
inst_ofRT(?Instance, ?Class) is nondet
true if Instance is an instance of Class, taking into account transitivity combines inst_of/2 and subclassRT/2
inst_rel(?Instance, ?Relation, ?ToInstance) is nondet
true if Instance stands in Relation to ToInstance
inst_rel_at(?Instance, ?Relation, ?ToInstance, ?Time) is nondet
true if Instance stands in Relation to ToInstance at/during Time. time is not explicitly modeled in the ontology language; Time will be an instance of an appropriate class in an upper ontology (eg BFO or owl-time). deprecated: use inst_rel/4 instead
inst_rel_type(?I, ?Rel, ?Type)
true if I is related by Rel to some instance of type Type
inst_rel_anon(?Instance, ?Relation, ?Class) is nondet
true if Instance stands in Relation to some unnamed instance of Class
inst_sv(?Instance, ?Slot, ?Value, ?DataType) is nondet
true if Instance has a Slot with Value, where Value is of DataType
inst_sv(?Inst, ?Relation, ?Relatum) is nondet
disjunction of inst_sv/4 and inst_rel/3 true if inst_sv(Inst,Relation,Reulatum) or inst_rel(Inst,Relation,Relatum)
class_instrule(?Class, ?HeadVars, ?PrologRuleBody)
class_reified_rulebody(?Class, HeadVars, ?HeadConjTerms)
reified form of class_instrule/3
reification(?Statement, ?Term) is nondet
true if Statement identifies the fact Term currently Term must be restriction/3 or inst_rel/3
entailed_by(?Statement, ?Rule) is nondet
true if Statement is entailed (logically inferred) by Rule Expression may be 'true' if deduction provenance is not maintained
entailed_by(?Statement, ?Rule, ?Expression) is nondet
logicalformula(?ID, ?FormulaAtom, ?Language) is nondet
class_by_name_or_synonym(+N, ?ID) is nondet
DEPRECATED
class_label(?Class, ?Label, ?Type)
true if Class has name or synonym Label (case-insensitive) Label='exact' for names and exact synonyms; otherwise synonym type see class/2 and synonym/3
id_name(Entity, Name) is nondet
DEPRECATED
referenced_id(?ID, ?RefID)
ID references RefID if RefID appears as object of subclass/restriction/intersection relation
topclass(?Class) is nondet
true if Class is top of subclass hierarchy
topclass(?Class, ?Ontology)
true if Class is top of subclass hierarchy within Ontology
noparent(?Class)
true if Class is top of union of subclass and restriction hierarchy
noparent_and_haschild(?Class)
true if noparent and not nochild
noparent(?Class, ?Ontology)
true if Class is top of union of subclass and restriction hierarchy within Ontology
noparent_and_haschild(?Class, ?Ontology)
true if noparent and not nochild
noparent_by_type(?Relation, ?Class)
true if Class is a class with no parents over Relation uses parent_over/3
nochild(?Class)
true if Class is bottom of union of subclass and restriction hierarchy
nochild(?Class, ?Ontology)
true if Class is bottom of union of subclass and restriction hierarchy within Ontologyy
redundant_subclass(?Class, ?Parent, ?Intermediate) is nondet
true if Class is direct subclass/2 of Parent, and Class is a subclassT/2 of Intermediate which is a subclassT/2 of Parent
redundant_parent(?ID, ?RelationshipType, ?IDp, ?IDz, ?Path) is nondet
multiple_parent(?ID, ?T, ?PID1, ?PID2)
finds classes with multiple parents of the same time

takes into account the rule:

if X is_a* Y and Y part_of Z then X part_of Z

(substitute part_of for any other relation T here)

PID1 must be a direct part_of ID, but PID2 can be an indirect part

does not report if PID1 is_a* PID2 (because they are not distinct parts)

Note that this will unify with duplicate results as PID1 and PID2 are symmeryical. When PID1 and PID2 are unground, you can de-duplicate like this:

multiple_parent(ID,part_of,PID1,PID2),
PID1@<PID2.
multiple_parent(?ID, ?T, ?PID1, ?PID2, ?ViaID)
As multiple_parent/4 but also provides the ID of the class ViaID such that PID2 is a direct part_of ViaID (and ViaID is a superclass* of ID)

PID1 is always a direct part_of ID

(substitute part_of for any other relation T here)

subclass_underlap(?C, ?P1, ?P2) is nondet
C is_a P1 and C is_a P2 P1 and P2 are non-disjoint because o C
subclass_cycle(+ID, ?Path) is nondet
check for cyclical paths, going up from ID

subclass cycles are always illegal, and will cause non-terminating behaviour

parent_cycle(+ID, ?Path) is nondet
check for cyclical paths, going up from ID a parent is defined by subclass/2 or restriction/3

parent cycles will cause non-terminating behavior example: parent_cycle(X,Y1),!,reverse(Y1,Y),writeln(Y),member(A-R-B,Y),class(A,AN),class(B,BN),writeln(A-AN-R-B-BN),fail.

class_cdef(?C, ?CDef) is nondet
CDef = cdef(Genus,Diffs) Diffs = [R=To,...]
ontology_segment(+InNodes, ?OutNodes, ?Opts)
ontology_segment(+InNodes, ?Edges, ?OutNodes, ?Opts)
subclass_lca(+IDs, ?LCA) is semidet
class_pair_subclass_lca(+X, +Y, ?LCA)
true if LCA is a common ancestor of X and Y by subclassRT/2, and if there exists no other more recent CA

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

dangling_class(Arg1)
inst_rel(Arg1, Arg2, Arg3, Arg4)
subclassT(Arg1, Arg2)
parent_overRT(Arg1, Arg2, Arg3)
classdef_parent(Arg1, Arg2)
disjoint_over_violation(Arg1, Arg2, Arg3, Arg4)
class_label_exact(Arg1, Arg2)
parentRT(Arg1, Arg2, Arg3, Arg4)
inst_rel(Arg1, Arg2, Arg3, Arg4, Arg5)
classdef_subsumes_id(Arg1, Arg2)
abduced_link(Arg1)
cdef_label(Arg1, Arg2)
inst_rel(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
import_directive(Arg1)
cdef(Arg1, Arg2)
holds_temporally_between(Arg1, Arg2, Arg3)
name_composed_type(Arg1, Arg2)
subclassRT(Arg1, Arg2)
range_cardinality_restriction(Arg1, Arg2, Arg3, Arg4)
abduced_link_nr(Arg1)
import_all_ontologies
holds_atemporally_between(Arg1, Arg2, Arg3)
disjoint_from_violation(Arg1, Arg2, Arg3)