Skip to content

Commit 048b85b

Browse files
Merge pull request #50 from ber-data/recommended_required
Add in recommended/required labels for attributes in attribute-value objects
2 parents 55294b2 + 3cf2477 commit 048b85b

File tree

4 files changed

+125
-51
lines changed

4 files changed

+125
-51
lines changed

src/schema/datamodel/bertron_schema_pydantic.py

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ def __contains__(self, key:str) -> bool:
7979
'prefix_reference': 'https://w3id.org/ber-data/bertron-schema/'},
8080
'linkml': {'prefix_prefix': 'linkml',
8181
'prefix_reference': 'https://w3id.org/linkml/'},
82-
'nmdc': {'prefix_prefix': 'nmdc',
83-
'prefix_reference': 'https://w3id.org/nmdc/'},
8482
'schema': {'prefix_prefix': 'schema',
8583
'prefix_reference': 'http://schema.org/'}},
8684
'see_also': ['https://ber-data.github.io/bertron-schema'],
@@ -157,18 +155,20 @@ class AttributeValue(ConfiguredBaseModel):
157155
'class_uri': 'nmdc:AttributeValue',
158156
'from_schema': 'https://w3id.org/ber-data/bertron_types'})
159157

160-
attribute: Optional[Attribute] = Field(default=None, description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
161-
raw_value: Optional[str] = Field(default=None, description="""The raw value.""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue']} })
158+
attribute: Attribute = Field(default=..., description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
159+
raw_value: Optional[str] = Field(default=None, description="""The raw value.""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue', 'NamedQuantityValue']} })
162160

163161

164162
class Attribute(ConfiguredBaseModel):
165163
"""
166-
A domain, measurement, attribute, property, or any descriptor for additional properties to be added to an entity.
164+
A domain, measurement, attribute, property, or any descriptor for additional properties to be added to an entity. Where available, please use OBO Foundry ontologies or other controlled vocabularies for attributes; the label should be the term name from the ontology and the id should be the fully-qualified CURIE.
167165
"""
168166
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/ber-data/bertron_types'})
169167

170-
id: Optional[str] = Field(default=None, description="""A CURIE for the attribute, should one exist.""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Attribute', 'Entity', 'DataCollection']} })
171-
label: Optional[str] = Field(default=None, description="""Text string to describe the attribute.""", json_schema_extra = { "linkml_meta": {'alias': 'label', 'aliases': ['name', 'title'], 'domain_of': ['Attribute']} })
168+
id: Optional[str] = Field(default=None, description="""A CURIE for the attribute, should one exist. Where available, please use OBO Foundry ontologies or other controlled vocabularies for labelling attributes; the id should be the term ID from the ontology.""", json_schema_extra = { "linkml_meta": {'alias': 'id',
169+
'domain_of': ['Attribute', 'Entity', 'DataCollection'],
170+
'recommended': True} })
171+
label: str = Field(default=..., description="""Text string to describe the attribute. Where available, please use OBO Foundry ontologies or other controlled vocabularies for labelling attributes; the label should be the term name from the ontology.""", json_schema_extra = { "linkml_meta": {'alias': 'label', 'aliases': ['name', 'title'], 'domain_of': ['Attribute']} })
172172

173173

174174
class QuantityValue(AttributeValue):
@@ -189,22 +189,48 @@ class QuantityValue(AttributeValue):
189189
'name': 'unit'}}})
190190

191191
maximum_numeric_value: Optional[float] = Field(default=None, description="""The maximum value part, expressed as number, of the quantity value when the value covers a range.""", json_schema_extra = { "linkml_meta": {'alias': 'maximum_numeric_value',
192-
'domain_of': ['QuantityValue'],
192+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
193193
'is_a': 'numeric_value',
194194
'mappings': ['nmdc:maximum_numeric_value']} })
195195
minimum_numeric_value: Optional[float] = Field(default=None, description="""The minimum value part, expressed as number, of the quantity value when the value covers a range.""", json_schema_extra = { "linkml_meta": {'alias': 'minimum_numeric_value',
196-
'domain_of': ['QuantityValue'],
196+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
197197
'is_a': 'numeric_value',
198198
'mappings': ['nmdc:minimum_numeric_value']} })
199199
numeric_value: Optional[float] = Field(default=None, description="""The number part of the quantity""", json_schema_extra = { "linkml_meta": {'alias': 'numeric_value',
200-
'domain_of': ['QuantityValue'],
200+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
201201
'mappings': ['nmdc:numeric_value', 'qud:quantityValue', 'schema:value']} })
202202
unit: Optional[str] = Field(default=None, description="""The unit of the quantity""", json_schema_extra = { "linkml_meta": {'alias': 'unit',
203203
'aliases': ['scale'],
204-
'domain_of': ['QuantityValue'],
204+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
205+
'mappings': ['nmdc:unit', 'qud:unit', 'schema:unitCode']} })
206+
attribute: Attribute = Field(default=..., description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
207+
raw_value: Optional[str] = Field(default=None, description="""Unnormalized atomic string representation, suggested syntax {number} {unit}""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue', 'NamedQuantityValue']} })
208+
209+
210+
class NamedQuantityValue(ConfiguredBaseModel):
211+
"""
212+
A quantity value where the attribute is already specified.
213+
"""
214+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/ber-data/bertron_types'})
215+
216+
maximum_numeric_value: Optional[float] = Field(default=None, description="""The maximum value part, expressed as number, of the quantity value when the value covers a range.""", json_schema_extra = { "linkml_meta": {'alias': 'maximum_numeric_value',
217+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
218+
'is_a': 'numeric_value',
219+
'mappings': ['nmdc:maximum_numeric_value']} })
220+
minimum_numeric_value: Optional[float] = Field(default=None, description="""The minimum value part, expressed as number, of the quantity value when the value covers a range.""", json_schema_extra = { "linkml_meta": {'alias': 'minimum_numeric_value',
221+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
222+
'is_a': 'numeric_value',
223+
'mappings': ['nmdc:minimum_numeric_value']} })
224+
numeric_value: Optional[float] = Field(default=None, description="""Links a quantity value to a number""", json_schema_extra = { "linkml_meta": {'alias': 'numeric_value',
225+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
226+
'mappings': ['nmdc:numeric_value', 'qud:quantityValue', 'schema:value']} })
227+
unit: Optional[str] = Field(default=None, description="""Links a QuantityValue to a unit. Units should be taken from the UCUM unit collection or the Unit Ontology.""", json_schema_extra = { "linkml_meta": {'alias': 'unit',
228+
'aliases': ['scale'],
229+
'domain_of': ['QuantityValue', 'NamedQuantityValue'],
205230
'mappings': ['nmdc:unit', 'qud:unit', 'schema:unitCode']} })
206-
attribute: Optional[Attribute] = Field(default=None, description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
207-
raw_value: Optional[str] = Field(default=None, description="""Unnormalized atomic string representation, suggested syntax {number} {unit}""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue']} })
231+
raw_value: Optional[str] = Field(default=None, description="""The value that was specified for an annotation in raw form, i.e. a string. E.g. \"2 cm\" or \"2-4 cm\"""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value',
232+
'domain_of': ['AttributeValue', 'NamedQuantityValue'],
233+
'mappings': ['nmdc:raw_value']} })
208234

209235

210236
class TextValue(AttributeValue):
@@ -216,8 +242,8 @@ class TextValue(AttributeValue):
216242

217243
value: Optional[str] = Field(default=None, description="""The value, as a text string.""", json_schema_extra = { "linkml_meta": {'alias': 'value', 'domain_of': ['TextValue']} })
218244
value_cv_id: Optional[str] = Field(default=None, description="""For values that are in a controlled vocabulary (CV), this attribute should capture the controlled vocabulary ID for the value.""", json_schema_extra = { "linkml_meta": {'alias': 'value_cv_id', 'domain_of': ['TextValue']} })
219-
attribute: Optional[Attribute] = Field(default=None, description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
220-
raw_value: Optional[str] = Field(default=None, description="""The raw value.""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue']} })
245+
attribute: Attribute = Field(default=..., description="""The attribute being represented.""", json_schema_extra = { "linkml_meta": {'alias': 'attribute', 'domain_of': ['AttributeValue']} })
246+
raw_value: Optional[str] = Field(default=None, description="""The raw value.""", json_schema_extra = { "linkml_meta": {'alias': 'raw_value', 'domain_of': ['AttributeValue', 'NamedQuantityValue']} })
221247

222248

223249
class Entity(ConfiguredBaseModel):
@@ -290,20 +316,20 @@ class Coordinates(ConfiguredBaseModel):
290316
"""
291317
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/ber-data/bertron-schema'})
292318

293-
altitude: Optional[QuantityValue] = Field(default=None, title="altitude", description="""Altitude is a term used to identify heights of objects such as airplanes, space shuttles, rockets, atmospheric balloons and heights of places such as atmospheric layers and clouds. It is used to measure the height of an object which is above the earth's surface. In this context, the altitude measurement is the vertical distance between the earth's surface above sea level and the sampled position in the air""", json_schema_extra = { "linkml_meta": {'alias': 'altitude',
319+
altitude: Optional[NamedQuantityValue] = Field(default=None, title="altitude", description="""Altitude is a term used to identify heights of objects such as airplanes, space shuttles, rockets, atmospheric balloons and heights of places such as atmospheric layers and clouds. It is used to measure the height of an object which is above the earth's surface. In this context, the altitude measurement is the vertical distance between the earth's surface above sea level and the sampled position in the air""", json_schema_extra = { "linkml_meta": {'alias': 'altitude',
294320
'annotations': {'expected_value': {'tag': 'expected_value',
295321
'value': 'measurement value'}},
296322
'domain_of': ['Coordinates'],
297323
'examples': [{'value': '100 meter'}],
298324
'slot_uri': 'MIXS:0000094'} })
299-
depth: Optional[QuantityValue] = Field(default=None, title="depth", description="""The vertical distance below local surface, e.g. for sediment or soil samples depth is measured from sediment or soil surface, respectively. Depth can be reported as an interval for subsurface samples.""", json_schema_extra = { "linkml_meta": {'alias': 'depth',
325+
depth: Optional[NamedQuantityValue] = Field(default=None, title="depth", description="""The vertical distance below local surface, e.g. for sediment or soil samples depth is measured from sediment or soil surface, respectively. Depth can be reported as an interval for subsurface samples.""", json_schema_extra = { "linkml_meta": {'alias': 'depth',
300326
'aliases': ['depth'],
301327
'annotations': {'expected_value': {'tag': 'expected_value',
302328
'value': 'measurement value'}},
303329
'domain_of': ['Coordinates'],
304330
'examples': [{'value': '10 meter'}],
305331
'slot_uri': 'MIXS:0000018'} })
306-
elevation: Optional[QuantityValue] = Field(default=None, title="elevation", description="""Elevation of the sampling site is its height above a fixed reference point, most commonly the mean sea level. Elevation is mainly used when referring to points on the earth's surface, while altitude is used for points above the surface, such as an aircraft in flight or a spacecraft in orbit.""", json_schema_extra = { "linkml_meta": {'alias': 'elevation',
332+
elevation: Optional[NamedQuantityValue] = Field(default=None, title="elevation", description="""Elevation of the sampling site is its height above a fixed reference point, most commonly the mean sea level. Elevation is mainly used when referring to points on the earth's surface, while altitude is used for points above the surface, such as an aircraft in flight or a spacecraft in orbit.""", json_schema_extra = { "linkml_meta": {'alias': 'elevation',
307333
'aliases': ['elevation'],
308334
'annotations': {'expected_value': {'tag': 'expected_value',
309335
'value': 'measurement value'}},
@@ -382,6 +408,7 @@ class DataCollection(ConfiguredBaseModel):
382408
AttributeValue.model_rebuild()
383409
Attribute.model_rebuild()
384410
QuantityValue.model_rebuild()
411+
NamedQuantityValue.model_rebuild()
385412
TextValue.model_rebuild()
386413
Entity.model_rebuild()
387414
Coordinates.model_rebuild()

src/schema/jsonschema/bertron_schema.json

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
},
1515
"Attribute": {
1616
"additionalProperties": false,
17-
"description": "A domain, measurement, attribute, property, or any descriptor for additional properties to be added to an entity.",
17+
"description": "A domain, measurement, attribute, property, or any descriptor for additional properties to be added to an entity. Where available, please use OBO Foundry ontologies or other controlled vocabularies for attributes; the label should be the term name from the ontology and the id should be the fully-qualified CURIE.",
1818
"properties": {
1919
"id": {
20-
"description": "A CURIE for the attribute, should one exist.",
20+
"description": "A CURIE for the attribute, should one exist. Where available, please use OBO Foundry ontologies or other controlled vocabularies for labelling attributes; the id should be the term ID from the ontology.",
2121
"type": [
2222
"string",
2323
"null"
2424
]
2525
},
2626
"label": {
27-
"description": "Text string to describe the attribute.",
28-
"type": [
29-
"string",
30-
"null"
31-
]
27+
"description": "Text string to describe the attribute. Where available, please use OBO Foundry ontologies or other controlled vocabularies for labelling attributes; the label should be the term name from the ontology.",
28+
"type": "string"
3229
}
3330
},
31+
"required": [
32+
"label"
33+
],
3434
"title": "Attribute",
3535
"type": "object"
3636
},
@@ -53,7 +53,7 @@
5353
"altitude": {
5454
"anyOf": [
5555
{
56-
"$ref": "#/$defs/QuantityValue"
56+
"$ref": "#/$defs/NamedQuantityValue"
5757
},
5858
{
5959
"type": "null"
@@ -64,7 +64,7 @@
6464
"depth": {
6565
"anyOf": [
6666
{
67-
"$ref": "#/$defs/QuantityValue"
67+
"$ref": "#/$defs/NamedQuantityValue"
6868
},
6969
{
7070
"type": "null"
@@ -75,7 +75,7 @@
7575
"elevation": {
7676
"anyOf": [
7777
{
78-
"$ref": "#/$defs/QuantityValue"
78+
"$ref": "#/$defs/NamedQuantityValue"
7979
},
8080
{
8181
"type": "null"
@@ -304,19 +304,55 @@
304304
"title": "NameType",
305305
"type": "string"
306306
},
307+
"NamedQuantityValue": {
308+
"additionalProperties": false,
309+
"description": "A quantity value where the attribute is already specified.",
310+
"properties": {
311+
"maximum_numeric_value": {
312+
"description": "The maximum value part, expressed as number, of the quantity value when the value covers a range.",
313+
"type": [
314+
"number",
315+
"null"
316+
]
317+
},
318+
"minimum_numeric_value": {
319+
"description": "The minimum value part, expressed as number, of the quantity value when the value covers a range.",
320+
"type": [
321+
"number",
322+
"null"
323+
]
324+
},
325+
"numeric_value": {
326+
"description": "Links a quantity value to a number",
327+
"type": [
328+
"number",
329+
"null"
330+
]
331+
},
332+
"raw_value": {
333+
"description": "The value that was specified for an annotation in raw form, i.e. a string. E.g. \"2 cm\" or \"2-4 cm\"",
334+
"type": [
335+
"string",
336+
"null"
337+
]
338+
},
339+
"unit": {
340+
"description": "Links a QuantityValue to a unit. Units should be taken from the UCUM unit collection or the Unit Ontology.",
341+
"type": [
342+
"string",
343+
"null"
344+
]
345+
}
346+
},
347+
"title": "NamedQuantityValue",
348+
"type": "object"
349+
},
307350
"QuantityValue": {
308351
"additionalProperties": false,
309352
"description": "A simple quantity, e.g. 2cm",
310353
"properties": {
311354
"attribute": {
312-
"anyOf": [
313-
{
314-
"$ref": "#/$defs/Attribute"
315-
},
316-
{
317-
"type": "null"
318-
}
319-
],
355+
"$ref": "#/$defs/Attribute",
320356
"description": "The attribute being represented."
321357
},
322358
"maximum_numeric_value": {
@@ -355,6 +391,9 @@
355391
]
356392
}
357393
},
394+
"required": [
395+
"attribute"
396+
],
358397
"title": "QuantityValue",
359398
"type": "object"
360399
},
@@ -363,14 +402,7 @@
363402
"description": "A quality, described using a text string.",
364403
"properties": {
365404
"attribute": {
366-
"anyOf": [
367-
{
368-
"$ref": "#/$defs/Attribute"
369-
},
370-
{
371-
"type": "null"
372-
}
373-
],
405+
"$ref": "#/$defs/Attribute",
374406
"description": "The attribute being represented."
375407
},
376408
"raw_value": {
@@ -395,6 +427,9 @@
395427
]
396428
}
397429
},
430+
"required": [
431+
"attribute"
432+
],
398433
"title": "TextValue",
399434
"type": "object"
400435
}

0 commit comments

Comments
 (0)