From a6a67d14d5ed6053c167ab446deaef74c1689203 Mon Sep 17 00:00:00 2001 From: Chris Mungall Date: Thu, 30 May 2024 00:31:41 -0700 Subject: [PATCH] use literals for data properties --- linkml_owl/dumpers/owl_dumper.py | 15 +- tests/inputs/monsters_and_magic.expected.ofn | 57 +++++ tests/output/chromo.schema.owl.ttl | 246 +++++++++---------- tests/test_examples/test_enums.py | 10 +- 4 files changed, 200 insertions(+), 128 deletions(-) diff --git a/linkml_owl/dumpers/owl_dumper.py b/linkml_owl/dumpers/owl_dumper.py index 3191985..d0e9fb2 100644 --- a/linkml_owl/dumpers/owl_dumper.py +++ b/linkml_owl/dumpers/owl_dumper.py @@ -210,16 +210,23 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o if element is None: return None try: + # naive method to test if an object is an enum: + # try accessing the `meaning` field. If this fails, + # an exception is thrown, and we carry on. + # (when owl_duper is refactored to not be dependent on + # python dataclasses this will no longer be necessary) meaning = element.meaning - # translate Enum - if is_element_an_object or True: + if is_element_an_object: + # enum is used in an object context: translate to URI if not meaning: enum_uri = schema.default_prefix + ":" + type(element).__name__ meaning = enum_uri + "#" + str(element).replace(" ", "+") return self._get_IRI_str(meaning) else: + # enum is used in a data context - stringify return str(element) except AttributeError: + # not an enum - carry on pass if not self._instance_of_linkml_class(element): # TODO: better way of detecting atoms @@ -330,8 +337,8 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o slot_interps = self._get_slot_interpretations(slot, linkml_class_name) logging.debug(f'OWL interpretations for {k}={slot_interps}') is_object_ref = slot.range in self.schema.classes - #if "ObjectPropertyAssertion" in slot_interps or "ObjectProperty" in slot_interps: - # is_object_ref = True + if "ObjectPropertyAssertion" in slot_interps or "ObjectProperty" in slot_interps: + is_object_ref = True # normalize input_vals to a list, then recursively transform if isinstance(v, list): input_vals = v diff --git a/tests/inputs/monsters_and_magic.expected.ofn b/tests/inputs/monsters_and_magic.expected.ofn index 194b75d..c6372eb 100644 --- a/tests/inputs/monsters_and_magic.expected.ofn +++ b/tests/inputs/monsters_and_magic.expected.ofn @@ -19,9 +19,23 @@ Ontology( SubClassOf( mnm:Humanoid mnm:Creature ) Declaration( Class( mnm:Orc ) ) AnnotationAssertion( schema:description mnm:Orc "An orc is a humanoid creature from Middle-earth." ) + DataPropertyAssertion( mnm:armor_class mnm:Orc "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Orc "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Orc "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Orc "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Orc "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Orc "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Orc "8"^^xsd:integer ) SubClassOf( mnm:Orc mnm:Humanoid ) Declaration( Class( mnm:Goblin ) ) AnnotationAssertion( schema:description mnm:Goblin "A goblin is a humanoid creature from Middle-earth." ) + DataPropertyAssertion( mnm:armor_class mnm:Goblin "15"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Goblin "8"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Goblin "14"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Goblin "10"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Goblin "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Goblin "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Goblin "8"^^xsd:integer ) SubClassOf( mnm:Goblin mnm:Humanoid ) Declaration( Class( mnm:SerpentineCreature ) ) AnnotationAssertion( schema:description mnm:SerpentineCreature "A serpentine creature is a creature that has a snake-like body." ) @@ -67,24 +81,66 @@ Ontology( SubClassOf( mnm:MagicallyCreatedCreature mnm:Creature ) Declaration( Class( mnm:RugOfSmothering ) ) AnnotationAssertion( schema:description mnm:RugOfSmothering "A rug of smothering is a rug that can be used to suffocate a creature." ) + DataPropertyAssertion( mnm:armor_class mnm:RugOfSmothering "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:RugOfSmothering "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:RugOfSmothering "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:RugOfSmothering "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:RugOfSmothering "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:RugOfSmothering "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:RugOfSmothering "8"^^xsd:integer ) SubClassOf( mnm:RugOfSmothering mnm:MagicallyCreatedCreature ) Declaration( Class( mnm:Basilisk ) ) AnnotationAssertion( schema:description mnm:Basilisk "A basilisk is a legendary serpent-like creature with the body of a snake and the head of a king cobra." ) + DataPropertyAssertion( mnm:armor_class mnm:Basilisk "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Basilisk "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Basilisk "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Basilisk "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Basilisk "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Basilisk "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Basilisk "8"^^xsd:integer ) SubClassOf( mnm:Basilisk mnm:SerpentineCreature ) Declaration( Class( mnm:UndeadCreature ) ) AnnotationAssertion( schema:description mnm:UndeadCreature "An undead creature is a creature that is dead, but has been brought back to life by magic." ) SubClassOf( mnm:UndeadCreature mnm:Humanoid ) Declaration( Class( mnm:WhiteWalker ) ) AnnotationAssertion( schema:description mnm:WhiteWalker "A white walker is an undead creature from the Game of Thrones universe." ) + DataPropertyAssertion( mnm:armor_class mnm:WhiteWalker "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:WhiteWalker "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:WhiteWalker "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:WhiteWalker "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:WhiteWalker "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:WhiteWalker "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:WhiteWalker "8"^^xsd:integer ) SubClassOf( mnm:WhiteWalker mnm:UndeadCreature ) Declaration( Class( mnm:Lich ) ) AnnotationAssertion( schema:description mnm:Lich "A lich is a fictional undead creature in the Dungeons & Dragons fantasy role-playing game." ) + DataPropertyAssertion( mnm:armor_class mnm:Lich "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Lich "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Lich "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Lich "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Lich "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Lich "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Lich "8"^^xsd:integer ) SubClassOf( mnm:Lich mnm:UndeadCreature ) Declaration( Class( mnm:Vampire ) ) AnnotationAssertion( schema:description mnm:Vampire "A vampire is a fictional undead creature in the Dungeons & Dragons fantasy role-playing game." ) + DataPropertyAssertion( mnm:armor_class mnm:Vampire "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Vampire "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Vampire "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Vampire "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Vampire "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Vampire "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Vampire "8"^^xsd:integer ) SubClassOf( mnm:Vampire mnm:UndeadCreature ) Declaration( Class( mnm:Zombie ) ) AnnotationAssertion( schema:description mnm:Zombie "A zombie is a fictional undead creature in the Dungeons & Dragons fantasy role-playing game." ) + DataPropertyAssertion( mnm:armor_class mnm:Zombie "13"^^xsd:integer ) + DataPropertyAssertion( mnm:strength mnm:Zombie "16"^^xsd:integer ) + DataPropertyAssertion( mnm:dexterity mnm:Zombie "11"^^xsd:integer ) + DataPropertyAssertion( mnm:constitution mnm:Zombie "12"^^xsd:integer ) + DataPropertyAssertion( mnm:intelligence mnm:Zombie "10"^^xsd:integer ) + DataPropertyAssertion( mnm:wisdom mnm:Zombie "8"^^xsd:integer ) + DataPropertyAssertion( mnm:charisma mnm:Zombie "8"^^xsd:integer ) SubClassOf( mnm:Zombie mnm:UndeadCreature ) Declaration( NamedIndividual( mnm:Smaug ) ) Declaration( Class( mnm:Smaug ) ) @@ -98,6 +154,7 @@ Ontology( ClassAssertion( mnm:WhiteWalker mnm:TheNightKing ) Declaration( Class( mnm:Paladin ) ) AnnotationAssertion( schema:description mnm:Paladin "A paladin is a holy warrior who fights evil using divine magic." ) + DataPropertyAssertion( mnm:hit_dice mnm:Paladin "D10" ) Declaration( Class( mnm:Wizard ) ) AnnotationAssertion( schema:description mnm:Wizard "A wizard is a person who practices magic." ) Declaration( Class( mnm:Rogue ) ) diff --git a/tests/output/chromo.schema.owl.ttl b/tests/output/chromo.schema.owl.ttl index 321afd6..77ebcf4 100644 --- a/tests/output/chromo.schema.owl.ttl +++ b/tests/output/chromo.schema.owl.ttl @@ -14,17 +14,11 @@ chromoschema:ChromosomePartCollection a owl:Class, linkml:ClassDefinition ; rdfs:label "ChromosomePartCollection" ; rdfs:subClassOf [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:name ], + owl:allValuesFrom chromoschema:Genome ; + owl:onProperty chromoschema:genomes ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:taxons ], - [ a owl:Restriction ; - owl:allValuesFrom owl:Thing ; owl:onProperty chromoschema:name ], - [ a owl:Restriction ; - owl:minCardinality 0 ; - owl:onProperty chromoschema:has ], [ a owl:Restriction ; owl:allValuesFrom chromoschema:ChromosomePart ; owl:onProperty chromoschema:has ], @@ -33,13 +27,19 @@ chromoschema:ChromosomePartCollection a owl:Class, owl:onProperty chromoschema:taxons ], [ a owl:Restriction ; owl:minCardinality 0 ; + owl:onProperty chromoschema:genomes ], + [ a owl:Restriction ; + owl:allValuesFrom owl:Thing ; + owl:onProperty chromoschema:name ], + [ a owl:Restriction ; + owl:maxCardinality 1 ; owl:onProperty chromoschema:name ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:genomes ], + owl:onProperty chromoschema:taxons ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:Genome ; - owl:onProperty chromoschema:genomes ] ; + owl:minCardinality 0 ; + owl:onProperty chromoschema:has ] ; skos:inScheme . chromoschema:download_url a owl:ObjectProperty, @@ -59,14 +59,14 @@ chromoschema:Genome a owl:Class, linkml:ClassDefinition ; rdfs:label "Genome" ; rdfs:subClassOf [ a owl:Restriction ; - owl:minCardinality 1 ; + owl:allValuesFrom chromoschema:LabelType ; owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:minCardinality 1 ; - owl:onProperty chromoschema:id ], + owl:minCardinality 0 ; + owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:build ], + owl:minCardinality 1 ; + owl:onProperty chromoschema:name ], [ a owl:Restriction ; owl:allValuesFrom chromoschema:GenomeBuild ; owl:onProperty chromoschema:previous_builds ], @@ -74,30 +74,30 @@ chromoschema:Genome a owl:Class, owl:minCardinality 0 ; owl:onProperty chromoschema:previous_builds ], [ a owl:Restriction ; - owl:allValuesFrom [ a rdfs:Datatype ; - owl:onDatatype xsd:string ; - owl:withRestrictions ( [ xsd:pattern "^\\\\w+$" ] ) ] ; - owl:onProperty chromoschema:id ], + owl:maxCardinality 1 ; + owl:onProperty chromoschema:build ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:LabelType ; - owl:onProperty chromoschema:name ], + owl:allValuesFrom chromoschema:GenomeBuild ; + owl:onProperty chromoschema:build ], [ a owl:Restriction ; owl:maxCardinality 1 ; owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:minCardinality 0 ; - owl:onProperty chromoschema:taxon ], + owl:minCardinality 1 ; + owl:onProperty chromoschema:id ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:GenomeBuild ; - owl:onProperty chromoschema:build ], + owl:allValuesFrom [ a rdfs:Datatype ; + owl:onDatatype xsd:string ; + owl:withRestrictions ( [ xsd:pattern "^\\\\w+$" ] ) ] ; + owl:onProperty chromoschema:id ], [ a owl:Restriction ; - owl:maxCardinality 1 ; + owl:allValuesFrom chromoschema:TaxonIdentifier ; owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; owl:maxCardinality 1 ; owl:onProperty chromoschema:id ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:TaxonIdentifier ; + owl:maxCardinality 1 ; owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; owl:minCardinality 0 ; @@ -110,34 +110,34 @@ chromoschema:OrganismTaxon a owl:Class, linkml:ClassDefinition ; rdfs:label "OrganismTaxon" ; rdfs:subClassOf [ a owl:Restriction ; - owl:allValuesFrom [ a rdfs:Datatype ; - owl:onDatatype xsd:string ; - owl:withRestrictions ( [ xsd:pattern "^CHR:\\\\S+$" ] ) ] ; - owl:onProperty chromoschema:id ], - [ a owl:Restriction ; owl:minCardinality 0 ; + owl:onProperty chromoschema:common_name ], + [ a owl:Restriction ; + owl:allValuesFrom chromoschema:LabelType ; owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:minCardinality 1 ; + owl:maxCardinality 1 ; owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:maxCardinality 1 ; + owl:onProperty chromoschema:common_name ], + [ a owl:Restriction ; + owl:allValuesFrom [ a rdfs:Datatype ; + owl:onDatatype xsd:string ; + owl:withRestrictions ( [ xsd:pattern "^CHR:\\\\S+$" ] ) ] ; owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:common_name ], - [ a owl:Restriction ; - owl:allValuesFrom chromoschema:LabelType ; owl:onProperty chromoschema:name ], - [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:common_name ], [ a owl:Restriction ; owl:allValuesFrom chromoschema:LabelType ; owl:onProperty chromoschema:common_name ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:name ] ; + owl:onProperty chromoschema:name ], + [ a owl:Restriction ; + owl:minCardinality 1 ; + owl:onProperty chromoschema:id ] ; skos:definition "Represents a species, e.g. Homo sapiens" ; skos:exactMatch biolink:OrganismTaxon ; skos:inScheme . @@ -349,148 +349,148 @@ chromoschema:ChromosomePart a owl:Class, linkml:ClassDefinition ; rdfs:label "ChromosomePart" ; rdfs:subClassOf [ a owl:Restriction ; - owl:allValuesFrom chromoschema:LocationType ; - owl:onProperty chromoschema:cell_location ], - [ a owl:Restriction ; - owl:allValuesFrom chromoschema:BandDescriptor ; - owl:onProperty chromoschema:band_descriptor ], - [ a owl:Restriction ; - owl:allValuesFrom owl:Thing ; - owl:onProperty chromoschema:exact_synonyms ], + owl:allValuesFrom chromoschema:TaxonIdentifier ; + owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; - owl:allValuesFrom owl:Thing ; - owl:onProperty chromoschema:broad_synonyms ], + owl:allValuesFrom linkml:Integer ; + owl:onProperty chromoschema:start ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:ChromosomeNameType ; - owl:onProperty chromoschema:chromosome_name ], + owl:maxCardinality 1 ; + owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; - owl:allValuesFrom linkml:Uriorcurie ; - owl:onProperty chromoschema:exact_mappings ], + owl:allValuesFrom chromoschema:LabelType ; + owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:allValuesFrom linkml:Integer ; - owl:onProperty chromoschema:end ], + owl:allValuesFrom chromoschema:EntityType ; + owl:onProperty chromoschema:type ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:chromosome_name ], - [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:build ], + owl:onProperty chromoschema:start ], [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:end ], + owl:allValuesFrom [ a rdfs:Datatype ; + owl:onDatatype xsd:string ; + owl:withRestrictions ( [ xsd:pattern "^CHR:\\\\S+$" ] ) ] ; + owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:sex_chromosome_type ], + owl:onProperty chromoschema:end ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:broad_synonyms ], + owl:onProperty chromoschema:children ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:TaxonIdentifier ; - owl:onProperty chromoschema:taxon ], + owl:maxCardinality 1 ; + owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:minCardinality 0 ; + owl:allValuesFrom chromoschema:LocationType ; owl:onProperty chromoschema:cell_location ], [ a owl:Restriction ; owl:maxCardinality 1 ; owl:onProperty chromoschema:start ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:parent ], - [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:somal_type ], + owl:onProperty chromoschema:cell_location ], [ a owl:Restriction ; - owl:maxCardinality 1 ; + owl:minCardinality 1 ; owl:onProperty chromoschema:id ], + [ a owl:Restriction ; + owl:allValuesFrom chromoschema:ChromosomeNameType ; + owl:onProperty chromoschema:chromosome_name ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:exact_mappings ], + owl:onProperty chromoschema:band_descriptor ], [ a owl:Restriction ; - owl:minCardinality 1 ; - owl:onProperty chromoschema:id ], + owl:allValuesFrom chromoschema:ChromosomePart ; + owl:onProperty chromoschema:parent ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:EntityType ; - owl:onProperty chromoschema:type ], + owl:allValuesFrom chromoschema:ChromosomePart ; + owl:onProperty chromoschema:children ], [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:cell_location ], + owl:allValuesFrom chromoschema:GenomeBuild ; + owl:onProperty chromoschema:build ], [ a owl:Restriction ; - owl:minCardinality 0 ; - owl:onProperty chromoschema:somal_type ], + owl:allValuesFrom owl:Thing ; + owl:onProperty chromoschema:broad_synonyms ], [ a owl:Restriction ; - owl:minCardinality 0 ; + owl:maxCardinality 1 ; owl:onProperty chromoschema:end ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:taxon ], - [ a owl:Restriction ; - owl:allValuesFrom chromoschema:AutosomeVsSexChromosome ; - owl:onProperty chromoschema:somal_type ], - [ a owl:Restriction ; - owl:allValuesFrom linkml:Integer ; - owl:onProperty chromoschema:start ], - [ a owl:Restriction ; - owl:allValuesFrom chromoschema:LabelType ; - owl:onProperty chromoschema:name ], + owl:onProperty chromoschema:chromosome_name ], [ a owl:Restriction ; owl:minCardinality 0 ; owl:onProperty chromoschema:type ], [ a owl:Restriction ; - owl:minCardinality 0 ; - owl:onProperty chromoschema:name ], + owl:allValuesFrom chromoschema:AutosomeVsSexChromosome ; + owl:onProperty chromoschema:somal_type ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:build ], + owl:onProperty chromoschema:exact_mappings ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:band_descriptor ], + owl:onProperty chromoschema:somal_type ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:name ], + owl:onProperty chromoschema:sex_chromosome_type ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:chromosome_name ], + owl:onProperty chromoschema:build ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:ChromosomePart ; - owl:onProperty chromoschema:parent ], + owl:allValuesFrom owl:Thing ; + owl:onProperty chromoschema:exact_synonyms ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:ChromosomePart ; - owl:onProperty chromoschema:children ], + owl:minCardinality 0 ; + owl:onProperty chromoschema:chromosome_name ], [ a owl:Restriction ; - owl:maxCardinality 1 ; + owl:minCardinality 0 ; owl:onProperty chromoschema:sex_chromosome_type ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:children ], + owl:onProperty chromoschema:taxon ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:GenomeBuild ; + owl:minCardinality 0 ; owl:onProperty chromoschema:build ], + [ a owl:Restriction ; + owl:maxCardinality 1 ; + owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:start ], + owl:onProperty chromoschema:name ], [ a owl:Restriction ; - owl:allValuesFrom [ a rdfs:Datatype ; - owl:onDatatype xsd:string ; - owl:withRestrictions ( [ xsd:pattern "^CHR:\\\\S+$" ] ) ] ; - owl:onProperty chromoschema:id ], + owl:minCardinality 0 ; + owl:onProperty chromoschema:somal_type ], + [ a owl:Restriction ; + owl:allValuesFrom linkml:Integer ; + owl:onProperty chromoschema:end ], + [ a owl:Restriction ; + owl:allValuesFrom chromoschema:SexChromosomeType ; + owl:onProperty chromoschema:sex_chromosome_type ], [ a owl:Restriction ; owl:minCardinality 0 ; - owl:onProperty chromoschema:exact_synonyms ], + owl:onProperty chromoschema:cell_location ], [ a owl:Restriction ; owl:minCardinality 0 ; owl:onProperty chromoschema:parent ], [ a owl:Restriction ; - owl:minCardinality 0 ; - owl:onProperty chromoschema:taxon ], + owl:maxCardinality 1 ; + owl:onProperty chromoschema:type ], + [ a owl:Restriction ; + owl:allValuesFrom linkml:Uriorcurie ; + owl:onProperty chromoschema:exact_mappings ], [ a owl:Restriction ; owl:minCardinality 0 ; + owl:onProperty chromoschema:exact_synonyms ], + [ a owl:Restriction ; + owl:maxCardinality 1 ; owl:onProperty chromoschema:band_descriptor ], [ a owl:Restriction ; - owl:allValuesFrom chromoschema:SexChromosomeType ; - owl:onProperty chromoschema:sex_chromosome_type ], + owl:allValuesFrom chromoschema:BandDescriptor ; + owl:onProperty chromoschema:band_descriptor ], [ a owl:Restriction ; owl:maxCardinality 1 ; - owl:onProperty chromoschema:type ] ; + owl:onProperty chromoschema:parent ], + [ a owl:Restriction ; + owl:minCardinality 0 ; + owl:onProperty chromoschema:broad_synonyms ] ; skos:definition "A Chromosome or a part of a chromosome (includes whole chromosomes, arms, and bands)" ; skos:inScheme ; skos:note """OWL Notes: when translated to OWL, instances of this class will be treated as @@ -501,24 +501,24 @@ chromoschema:GenomeBuild a owl:Class, linkml:ClassDefinition ; rdfs:label "GenomeBuild" ; rdfs:subClassOf [ a owl:Restriction ; - owl:allValuesFrom chromoschema:LabelType ; - owl:onProperty chromoschema:name ], - [ a owl:Restriction ; owl:maxCardinality 1 ; owl:onProperty chromoschema:name ], [ a owl:Restriction ; owl:minCardinality 1 ; owl:onProperty chromoschema:id ], - [ a owl:Restriction ; - owl:maxCardinality 1 ; - owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:allValuesFrom [ a rdfs:Datatype ; owl:onDatatype xsd:string ; owl:withRestrictions ( [ xsd:pattern "^CHR:\\\\S+$" ] ) ] ; owl:onProperty chromoschema:id ], + [ a owl:Restriction ; + owl:maxCardinality 1 ; + owl:onProperty chromoschema:id ], [ a owl:Restriction ; owl:minCardinality 0 ; + owl:onProperty chromoschema:name ], + [ a owl:Restriction ; + owl:allValuesFrom chromoschema:LabelType ; owl:onProperty chromoschema:name ] ; skos:closeMatch edam:operation_0525 ; skos:definition "Represents a specific build of a sequenced genome" ; diff --git a/tests/test_examples/test_enums.py b/tests/test_examples/test_enums.py index 390b26a..6754a4f 100644 --- a/tests/test_examples/test_enums.py +++ b/tests/test_examples/test_enums.py @@ -26,10 +26,18 @@ ("2", {"id": "ex:2", "job": "Bricklayer"}, {"job": EX["JobEnum#Bricklayer"]}), ("3", {"id": "ex:3", "job": "Chimney Sweep"}, {"job": EX["JobEnum#Chimney+Sweep"]}), ("4", {"id": "ex:4", "job_str": "Welder"}, {"job_str": Literal("Welder")}), + ("5", {"id": "ex:5", "job_str": "Bricklayer"}, {"job_str": Literal("Bricklayer")}), + ("6", {"id": "ex:6", "job_str": "Chimney Sweep"}, {"job_str": Literal("Chimney Sweep")}), ]) def test_enums(data_name, data, expected): """ - Test varieties of enums + Test mapping of permissible values in enums. + + If the enum slot is an object slot, then a URI is generated + (using ``meaning`` if present, otherwise construct a URI by appending a hash url encoding + of the PV to the enum) + + If the enum slot is a data slot, then a literal is created from the PV string """ sv = SchemaView(SCHEMA_IN) python_module = PythonGenerator(SCHEMA_IN).compile_module()