Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for RO #19

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions linkml_owl/util/loader_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def load_structured_file(source: Union[str, dict, TextIO], target_class: Union[s
- if the schema specified a tree_root, this is used
- if the objects contain a type designator, this is used

TODO: add tests

:param source: path or data or stream
:param target_class: class to be instantiated, either name or the python class
:param fmt: Any of yaml, json, csv, ttl. inferred if None and source is a file path
Expand Down
60 changes: 60 additions & 0 deletions tests/inputs/expected_ro.ofn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ Prefix( skos: = <http://www.w3.org/2004/02/skos/core#> )
Prefix( dcterms: = <http://purl.org/dc/terms/> )

Ontology( <http://purl.obolibrary.org/obo/ro/ro-metamodel.yaml>
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_00000115> <http://purl.obolibrary.org/obo/BFO_0000051> "Inverse of BFO:0000050 part of" )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/BFO_0000050> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/BFO_0000050> "part of" )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_0000115> <http://purl.obolibrary.org/obo/BFO_0000050> "a core relation that holds between a part and its whole" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/BFO_0000050> rometa:ObjectProperty )
SubObjectPropertyOf( <http://purl.obolibrary.org/obo/BFO_0000050> <http://purl.obolibrary.org/obo/RO_0002131> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/BFO_0000051> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/BFO_0000051> "has part" )
InverseObjectProperties( <http://purl.obolibrary.org/obo/BFO_0000050> <http://purl.obolibrary.org/obo/BFO_0000051> )
TransitiveObjectProperty( <http://purl.obolibrary.org/obo/BFO_0000050> )
SubObjectPropertyOf( ObjectPropertyChain(
<http://purl.obolibrary.org/obo/BFO_0000051>
<http://purl.obolibrary.org/obo/BFO_0000050>
) <http://purl.obolibrary.org/obo/RO_0002131> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002131> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002131> "overlaps" )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_0000115> <http://purl.obolibrary.org/obo/RO_0002131> "a core relation that holds between a part and its whole" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/RO_0002131> rometa:DefinedObjectPropertyByChain )
SubObjectPropertyOf( <http://purl.obolibrary.org/obo/RO_0002131> <http://purl.obolibrary.org/obo/RO_0002323> )
SymmetricObjectProperty( <http://purl.obolibrary.org/obo/RO_0002131> )
SubObjectPropertyOf( ObjectPropertyChain(
<http://purl.obolibrary.org/obo/RO_0000052>
<http://purl.obolibrary.org/obo/BFO_0000050>
) <http://purl.obolibrary.org/obo/RO_0002314> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002314> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002314> "characteristic of part of" )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_0000115> <http://purl.obolibrary.org/obo/RO_0002314> "A relationship between a characteristic and an entity where the characteristic is of either the entity itself or a part of the entity" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/RO_0002314> rometa:DefinedObjectPropertyByChain )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_00000115> <http://purl.obolibrary.org/obo/RO_0002203> "Inverse of RO:0002202 develops from" )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002202> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002202> "develops from" )
Expand All @@ -31,16 +59,48 @@ Ontology( <http://purl.obolibrary.org/obo/ro/ro-metamodel.yaml>
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002203> "develops into" )
InverseObjectProperties( <http://purl.obolibrary.org/obo/RO_0002202> <http://purl.obolibrary.org/obo/RO_0002203> )
TransitiveObjectProperty( <http://purl.obolibrary.org/obo/RO_0002202> )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_00000115> <http://purl.obolibrary.org/obo/RO_9999998> "Inverse of RO:0002012 occurrent part of" )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002012> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002012> "occurrent part of" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/RO_0002012> rometa:DefinedObjectPropertyByDomainAndRange )
SubObjectPropertyOf( <http://purl.obolibrary.org/obo/RO_0002012> <http://purl.obolibrary.org/obo/BFO_0000050> )
ObjectPropertyDomain( <http://purl.obolibrary.org/obo/RO_0002012> <http://purl.obolibrary.org/obo/BFO_0000003> )
ObjectPropertyRange( <http://purl.obolibrary.org/obo/RO_0002012> <http://purl.obolibrary.org/obo/BFO_0000003> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_9999998> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_9999998> "has occurrent part" )
InverseObjectProperties( <http://purl.obolibrary.org/obo/RO_0002012> <http://purl.obolibrary.org/obo/RO_9999998> )
SubObjectPropertyOf( ObjectPropertyChain(
<http://purl.obolibrary.org/obo/RO_0002215>
<http://purl.obolibrary.org/obo/RO_0002481>
<http://purl.obolibrary.org/obo/RO_0002400>
) <http://purl.obolibrary.org/obo/RO_0002447> )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_00000115> <http://purl.obolibrary.org/obo/RO_9999999> "Inverse of RO:0002447 phosphorylates" )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002447> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002447> "phosphorylates" )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_0000115> <http://purl.obolibrary.org/obo/RO_0002447> "A molecularly-interacts-with relationship between two entities, where the subject catalyzes a kinase activity that takes the object as input" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/RO_0002447> rometa:ObjectPropertyDefinedByInteractionProcess )
SubObjectPropertyOf( <http://purl.obolibrary.org/obo/RO_0002447> <http://purl.obolibrary.org/obo/RO_0002436> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_9999999> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_9999999> "phosphorylated by" )
InverseObjectProperties( <http://purl.obolibrary.org/obo/RO_0002447> <http://purl.obolibrary.org/obo/RO_9999999> )
SubClassOf( <http://purl.obolibrary.org/obo/GO_0016301> ObjectHasSelf( <http://purl.obolibrary.org/obo/RO_0002481> ) )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0002481> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0002481> "is kinase activity" )
SubObjectPropertyOf( ObjectPropertyChain(
<http://purl.obolibrary.org/obo/RO_0002215>
<http://purl.obolibrary.org/obo/RO_0018001>
<http://purl.obolibrary.org/obo/RO_0002400>
) <http://purl.obolibrary.org/obo/RO_0018002> )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_00000115> <http://purl.obolibrary.org/obo/RO_0018003> "Inverse of RO:0018002 myristoylates" )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0018002> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0018002> "myristoylates" )
AnnotationAssertion( <http://purl.obolibrary.org/obo/IAO_0000115> <http://purl.obolibrary.org/obo/RO_0018002> "A molecularly-interacts-with relationship between two entities, where the subject catalyzes a myristoylation activity that takes the object as input" )
AnnotationAssertion( dcterms:conformsTo <http://purl.obolibrary.org/obo/RO_0018002> rometa:ObjectPropertyDefinedByInteractionProcess )
SubObjectPropertyOf( <http://purl.obolibrary.org/obo/RO_0018002> <http://purl.obolibrary.org/obo/RO_0002436> )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0018003> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0018003> "myristoylated by" )
InverseObjectProperties( <http://purl.obolibrary.org/obo/RO_0018002> <http://purl.obolibrary.org/obo/RO_0018003> )
SubClassOf( <http://purl.obolibrary.org/obo/GO_0019107> ObjectHasSelf( <http://purl.obolibrary.org/obo/RO_0018001> ) )
Declaration( ObjectProperty( <http://purl.obolibrary.org/obo/RO_0018001> ) )
AnnotationAssertion( rdfs:label <http://purl.obolibrary.org/obo/RO_0018001> "is myristoyltransferase activity" )
)
86 changes: 81 additions & 5 deletions tests/inputs/ro-data.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## basic example

- id: BFO:0000050
conforms_to: ObjectProperty
label: part of
inverse_of:
id: BFO:0000051
label: has part
subproperty_of: RO:0002131 ## overlaps
definition: a core relation that holds between a part and its whole
transitive: true
locally_reflexive: true

## chains

- id: RO:0002131
conforms_to: DefinedObjectPropertyByChain
label: overlaps
subproperty_of: RO:0002323
definition: a core relation that holds between a part and its whole
symmetric: true
subproperty_of_pairwise_chain:
- first_member: BFO:0000051
last_member: BFO:0000050

## chains to reflexive, see https://oborel.github.io/obo-relations/reflexivity/

- id: RO:0002314
conforms_to: DefinedObjectPropertyByChain
#conforms_to: DefinedObjectPropertyByChainToReflexive ### TODO
label: characteristic of part of
definition: A relationship between a characteristic and an entity where the characteristic is of either the entity itself or a part of the entity
subproperty_of_pairwise_chain:
- first_member: RO:0000052
last_member: BFO:0000050

## test for transitive form, e.g. develops-from is transitive form of directly-develops-from

- id: RO:0002202
conforms_to: TransitiveForm
label: develops from
Expand All @@ -12,17 +50,55 @@
domain: BFO:0000004
range: BFO:0000004
transitive: true

## See https://github.com/oborel/obo-relations/pull/522

- id: RO:0002012
conforms_to: DefinedObjectPropertyByDomainAndRange
label: occurrent part of
subproperty_of: BFO:0000050
inverse_of:
id: RO:9999998
label: has occurrent part
domain: BFO:0000003
range: BFO:0000003


## https://github.com/oborel/obo-relations/pull/522

# this one exists in RO
- id: RO:0002447
conforms_to: ObjectPropertyDefinedByInteractionProcess
label: phosphorylates
subproperty_of: RO:0002436
#inverse_of:
# id: TODO
# label: phosphorylated by
definition: >-
A molecularly-interacts-with relationship between two entities,
where the subject catalyzes a kinase activity that takes the object as input
subproperty_of: RO:0002436 ## molecularly interacts with
inverse_of:
id: RO:9999999
label: phosphorylated by
subject_to_process_property: RO:0002215 ## capable of
uses_rolified_property:
id: RO:0002481
label: is kinase activity
rolification_of: GO:0016301
object_to_process_property: RO:0002400 ## has direct input
process_to_object_property: RO:0002400 ## has direct input

# new one proposed in https://github.com/oborel/obo-relations/pull/522
- id: RO:0018002
conforms_to: ObjectPropertyDefinedByInteractionProcess
label: myristoylates
definition: >-
A molecularly-interacts-with relationship between two entities,
where the subject catalyzes a myristoylation activity that takes the object as input
subproperty_of: RO:0002436 ## molecularly interacts with
inverse_of:
id: RO:0018003
label: myristoylated by
subject_to_process_property: RO:0002215 ## capable of
uses_rolified_property:
id: RO:0018001
label: is myristoyltransferase activity
rolification_of: GO:0019107
process_to_object_property: RO:0002400 ## has direct input

92 changes: 81 additions & 11 deletions tests/inputs/ro-metamodel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ default_prefix: rometa
default_curi_maps:
- semweb_context

enums:
ActivationStateEnum:
permissible_values:
ACTIVATED:
meaning: PATO:0002354
INACTIVATED:
meaning: PATO:0002355

types:
label type:
typeof: string
Expand Down Expand Up @@ -121,6 +113,9 @@ slots:
slot_uri: rdfs:range
multivalued: false
range: Class
subproperty_of_pairwise_chain:
multivalued: true
range: PairwisePropertyChain
operands:
range: NamedThing
multivalued: true
Expand Down Expand Up @@ -209,6 +204,24 @@ slots:

classes:

Expression:
abstract: true

PropertyChain:
abstract: true
todos:
- implement for more than pairwise

PairwisePropertyChain:
description: a property chain of length 2
attributes:
first_member:
range: ObjectProperty
#required: true
last_member:
range: ObjectProperty
#required: true

NamedThing:
slots:
- id
Expand Down Expand Up @@ -254,6 +267,7 @@ classes:
- reflexive
- locally_reflexive
- has_transitive_form
- subproperty_of_pairwise_chain
slot_usage:
genus:
range: ObjectProperty
Expand All @@ -277,6 +291,13 @@ classes:
{% if inverse_of and not inverse_of.definition %}
AnnotationAssertion( IAO:00000115 {{inverse_of.id}} "Inverse of {{id}} {{label}}")
{% endif %}
{% for chain in subproperty_of_pairwise_chain %}
SubObjectPropertyOf(
ObjectPropertyChain({{chain.first_member}}
{{chain.last_member}})
{{id}})
{% endfor %}

GroupingObjectProperty:
is_a: ObjectProperty
description: An ObjectProperty that has is used for grouping purposes and should not be instantiated
Expand Down Expand Up @@ -305,36 +326,78 @@ classes:
DefinedObjectPropertyByDomain:
is_a: DefinedObjectProperty
description: An ObjectProperty that is defined by a parent property and a domain
slot_usage:
definition:
string_serialization: "A {genus} that holds between a {domain} and something"
comments:
- hidden GCI analogs not supported (i.e. adding a more specific domain that is used for classification)
todos:
- rolification
see_also:
- https://oborel.github.io/obo-relations/domain-or-range-specific-relation/
annotations:
swrl: |-
{{genus}}(?s, ?o), {{domain}}(?s) -> {{id}}(?s, ?o)
DefinedObjectPropertyByRange:
is_a: DefinedObjectProperty
description: An ObjectProperty that is defined by a parent property and a range
slot_usage:
definition:
string_serialization: "A {genus} that holds between something and a {range}"
comments:
- hidden GCI analogs not supported (i.e. adding a more specific domain that is used for classification)
todos:
- rolification
see_also:
- https://oborel.github.io/obo-relations/domain-or-range-specific-relation/
annotations:
swrl: |-
{{genus}}(?s, ?o), {{range}}(?o) -> {{id}}(?s, ?o)
DefinedObjectPropertyByDomainAndRange:
is_a: DefinedObjectProperty
description: An ObjectProperty that is defined by a parent property and a domain and a range
slot_usage:
definition:
string_serialization: "A {genus} that holds between a {domain} and a {range}"
comments:
- hidden GCI analogs not supported (i.e. adding a more specific domain that is used for classification)
todos:
- SWRL rule
- rolification
see_also:
- https://oborel.github.io/obo-relations/domain-or-range-specific-relation/
annotations:
swrl: |-
{{genus}}(?s, ?o), {{range}}(?o), {{domain}}(?s) -> {{id}}(?s, ?o)
DefinedObjectPropertyByChain:
is_a: DefinedObjectProperty
description: An ObjectProperty that is defined by a chain of relations
description: An ObjectProperty that is defined by a chain of two properties
slot_usage:
subproperty_of_pairwise_chain:
required: true
examples:
- value: overlaps
description: overlaps is defined as the chain of has-part followed by part-of
todos:
- this currently assumes chains of length 2
- swrl
DefinedObjectPropertyByChainToReflexive:
is_a: DefinedObjectPropertyByChain
description: |-
An ObjectProperty that is defined by a chain of two properties where the second/final member
is used in a reflexive sense (regardless of whether it is actually reflexive). This has
the effect of making the chain relation a subproperty of the first member of the chain
slot_usage:
subproperty_of_pairwise_chain:
required: true
examples:
- value: characteristic of part of
todos:
- this currently assumes chains of length 2
- swrl
#annotations:
# owl.template: |-
# SubObjectPropertyOf( {{subproperty_of_pairwise_chain.last_member}} {{id}} )
TransitiveForm:
is_a: DefinedObjectProperty
description: An ObjectProperty that is defined as the transitive form of another relation
Expand Down Expand Up @@ -363,21 +426,28 @@ classes:
attributes:
subject_to_process_property:
range: ObjectProperty
object_to_process_property:
process_to_object_property:
range: ObjectProperty
uses_rolified_property:
range: RolifiedObjectProperty
inlined: true
see_also:
- https://oborel.github.io/obo-relations/interaction-relations/
- http://ontologydesignpatterns.org/wiki/Submissions:N-Ary_Relation_Pattern_%28OWL_2%29
- https://github.com/oborel/obo-relations/pull/522
- https://github.com/oborel/obo-relations/issues/521
annotations:
owl.template: |-
SubObjectPropertyOf(
ObjectPropertyChain({{subject_to_process_property}}
{{uses_rolified_property.id}}
{{object_to_process_property}})
{{process_to_object_property}})
{{id}})
swrl: |-
{{subject_to_process_property}}(?s, ?proc),
{{uses_rolified_property.rolification_of}}(?proc),
{{process_to_object_property}}(?o, ?proc)
-> {{id}}(?s, ?o)



Expand Down
Loading