Skip to content

Commit 52dd79e

Browse files
authored
Merge pull request #193 from linkml/enum-bindings
Adding enum bindings
2 parents 9a25069 + ca4275c commit 52dd79e

File tree

2 files changed

+187
-2
lines changed

2 files changed

+187
-2
lines changed

linkml_model/model/schema/meta.yaml

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ slots:
616616
- BasicSubset
617617

618618
pv_formula:
619-
domain: enum_expression
620619
range: pv_formula_options
621620
description: >-
622621
Defines the specific formula to be used to generate the permissible values.
@@ -1541,7 +1540,7 @@ slots:
15411540
domain: slot_definition
15421541
range: presence_enum
15431542
inherited: true
1544-
description: if true then a value must be present (for lists there must be at least one value). If false then a value must be absent (for lists, must be empty)
1543+
description: if PRESENT then a value must be present (for lists there must be at least one value). If ABSENT then a value must be absent (for lists, must be empty)
15451544
comments:
15461545
- if set to true this has the same effect as required=true. In contrast, required=false allows a value to be present
15471546
status: unstable
@@ -2096,6 +2095,42 @@ slots:
20962095
in_subset:
20972096
- SpecificationSubset
20982097

2098+
bindings:
2099+
domain: element
2100+
range: enum_binding
2101+
multivalued: true
2102+
inlined: true
2103+
status: testing
2104+
description: >-
2105+
A collection of enum bindings that specify how a slot can be bound to a permissible value
2106+
from an enumeration.
2107+
2108+
LinkML provides enums to allow string values to be restricted to one of a set of permissible
2109+
values (specified statically or dynamically).
2110+
2111+
Enum bindings allow enums to be bound to any object, including complex nested objects. For
2112+
example, given a (generic) class Concept with slots id and label, it may be desirable to restrict the
2113+
values the id takes on in a given context. For example, a HumanSample class may have a slot for
2114+
representing sample site, with a range of concept, but the values of that slot may be restricted to
2115+
concepts from a particular branch of an anatomy ontology.
2116+
in_subset:
2117+
- SpecificationSubset
2118+
2119+
binds_value_of:
2120+
domain: enum_binding
2121+
range: string
2122+
description: >-
2123+
A path to a slot that is being bound to a permissible value from an enumeration.
2124+
in_subset:
2125+
- SpecificationSubset
2126+
2127+
obligation_level:
2128+
range: obligation_level_enum
2129+
description: >-
2130+
The level of obligation or recommendation strength for a metadata element
2131+
in_subset:
2132+
- SpecificationSubset
2133+
20992134

21002135
# -----------------------------------
21012136
# Slots for type definition
@@ -2518,6 +2553,7 @@ classes:
25182553
- generation_date
25192554
- slot_names_unique
25202555
- settings
2556+
- bindings
25212557
see_also:
25222558
- https://en.wikipedia.org/wiki/Data_dictionary
25232559
close_mappings:
@@ -2671,6 +2707,24 @@ classes:
26712707
slots:
26722708
- enum_uri
26732709

2710+
enum_binding:
2711+
description: >-
2712+
A binding of a slot or a class to a permissible value from an enumeration.
2713+
slots:
2714+
- range
2715+
- obligation_level
2716+
- binds_value_of
2717+
- pv_formula
2718+
slot_usage:
2719+
range:
2720+
range: enum_definition
2721+
in_subset:
2722+
- SpecificationSubset
2723+
mixins:
2724+
- extensible
2725+
- annotatable
2726+
- common_metadata
2727+
26742728
match_query:
26752729
description: >-
26762730
A query that is used on an enum expression to dynamically obtain a set of permissivle values via a query that
@@ -2770,6 +2824,7 @@ classes:
27702824
- range
27712825
- range_expression
27722826
- enum_range
2827+
- bindings
27732828
- required
27742829
- recommended
27752830
- inlined
@@ -3194,3 +3249,28 @@ enums:
31943249
meaning: skos:broaderMatch
31953250
NARROW_SYNONYM:
31963251
meaning: skos:narrowerMatch
3252+
3253+
obligation_level_enum:
3254+
rank: 10
3255+
description: >-
3256+
The level of obligation or recommendation strength for a metadata element
3257+
permissible_values:
3258+
REQUIRED:
3259+
description: >-
3260+
The metadata element is required to be present in the model
3261+
RECOMMENDED:
3262+
aliases:
3263+
- ENCOURAGED
3264+
description: >-
3265+
The metadata element is recommended to be present in the model
3266+
OPTIONAL:
3267+
description: >-
3268+
The metadata element is optional to be present in the model
3269+
EXAMPLE:
3270+
description: >-
3271+
The metadata element is an example of how to use the model
3272+
DISCOURAGED:
3273+
description: >-
3274+
The metadata element is allowed but discouraged to be present in the model
3275+
in_subset:
3276+
- SpecificationSubset
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
id: https://example.org/enum_bindings
2+
name: enum_bindings_example
3+
title: Enum Bindings Example
4+
description: |-
5+
Example LinkML schema to demonstrate Enum bindings.
6+
7+
Here we define a generic Sample class which has a range indicating
8+
the material type of the sample. In an environmental context this
9+
could be soil, seawater, etc. In a medical context it may be human
10+
tissue.
11+
12+
In both cases we want to use a generic Concept class
13+
license: MIT
14+
15+
prefixes:
16+
linkml: https://w3id.org/linkml/
17+
example: https://example.org/
18+
19+
default_prefix: example
20+
21+
imports:
22+
- linkml:types
23+
24+
classes:
25+
26+
Concept:
27+
description: A generic class for representing an element from a vocabulary or ontology.
28+
attributes:
29+
id:
30+
identifier: true
31+
description: CURIE/identifier for the concept. E.g. ENVO:1234567
32+
name:
33+
description: human-readable label of the concept. E.g. "blood"
34+
vocabulary:
35+
description: E.g. UBERON, PO, ENVO, NCIT
36+
37+
38+
Sample:
39+
description: Abstract grouping for different sample types
40+
abstract: true
41+
attributes:
42+
name:
43+
description: E.g. my blood sample
44+
sample_material_type:
45+
description: The material type for the sample - depending on the type of sample, could be tissue (e.g. blood, muscle) or environmental (rock, soil, ...)
46+
range: Concept
47+
48+
EnvironmentalMaterialSample:
49+
description: A sample taken from the environment
50+
slot_usage:
51+
sample_material_type:
52+
description: Environmental material type
53+
bindings:
54+
- binds_value_of: id
55+
range: ENVOMaterialEnum
56+
obligation_level: RECOMMENDED
57+
description: Material type from the ENVO ontology
58+
59+
HumanSampleSample:
60+
description: A sample taken from a human subject
61+
slot_usage:
62+
sample_material_type:
63+
description: Tissue material type
64+
bindings:
65+
- binds_value_of: id
66+
range: AnatomyMaterialEnum
67+
obligation_level: RECOMMENDED
68+
description: Material type from an anatomy ontology
69+
70+
AlternateHumanSampleSample:
71+
description: A sample taken from a human subject (alternative example for illustrative purposes)
72+
slot_usage:
73+
sample_material_type:
74+
description: Does not constrain the ID that is used, but restricts the vocabulary field to a fixed enum
75+
bindings:
76+
- binds_value_of: vocabulary
77+
range: HumanSampleVocabularyEnum
78+
obligation_level: RECOMMENDED
79+
80+
enums:
81+
ENVOMaterialEnum:
82+
description: Material type from the ENVO ontology
83+
reachable_from:
84+
source_ontology: obo:envo
85+
source_nodes:
86+
- ENVO:00010483 ## environmental material
87+
is_direct: false
88+
relationship_types:
89+
- rdfs:subClassOf
90+
AnatomyMaterialEnum:
91+
description: Material type from the UBERON anatomy ontology
92+
reachable_from:
93+
source_ontology: obo:uberon
94+
source_nodes:
95+
- UBERON:0000465 ## material anatomical entity
96+
is_direct: false
97+
relationship_types:
98+
- rdfs:subClassOf
99+
HumanSampleVocabularyEnum:
100+
permissible_values:
101+
UBERON:
102+
FMA:
103+
NCIT:
104+
105+

0 commit comments

Comments
 (0)