|
1 | 1 | # Auto generated from fair_mappings_schema.yaml by pythongen.py version: 0.0.1 |
2 | | -# Generation date: 2025-10-04T08:59:50 |
| 2 | +# Generation date: 2025-10-04T12:17:23 |
3 | 3 | # Schema: fair-mappings-schema |
4 | 4 | # |
5 | 5 | # id: https://w3id.org/mapping-commons/fair-mappings-schema |
6 | | -# description: A basic metadata schema for FAIR mapping specifications |
| 6 | +# description: A minimal metadata schema for FAIR mapping specifications |
7 | 7 | # license: Apache-2.0 |
8 | 8 |
|
9 | 9 | import dataclasses |
|
56 | 56 | URIRef |
57 | 57 | ) |
58 | 58 |
|
59 | | -from linkml_runtime.linkml_model.types import Date, Integer, String, Uriorcurie |
60 | | -from linkml_runtime.utils.metamodelcore import URIorCURIE, XSDDate |
| 59 | +from linkml_runtime.linkml_model.types import String |
61 | 60 |
|
62 | 61 | metamodel_version = "1.7.0" |
63 | 62 | version = None |
|
75 | 74 | # Types |
76 | 75 |
|
77 | 76 | # Class references |
78 | | -class NamedThingId(URIorCURIE): |
79 | | - pass |
80 | | - |
81 | | - |
82 | | -class PersonId(NamedThingId): |
| 77 | +class AgentId(extended_str): |
83 | 78 | pass |
84 | 79 |
|
85 | 80 |
|
86 | 81 | @dataclass(repr=False) |
87 | | -class NamedThing(YAMLRoot): |
| 82 | +class Agent(YAMLRoot): |
88 | 83 | """ |
89 | | - A generic grouping for any identifiable entity |
| 84 | + An entity that can create or contribute to a digital object, such as an author or creator. |
90 | 85 | """ |
91 | 86 | _inherited_slots: ClassVar[list[str]] = [] |
92 | 87 |
|
93 | | - class_class_uri: ClassVar[URIRef] = SCHEMA["Thing"] |
94 | | - class_class_curie: ClassVar[str] = "schema:Thing" |
95 | | - class_name: ClassVar[str] = "NamedThing" |
96 | | - class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.NamedThing |
| 88 | + class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Agent"] |
| 89 | + class_class_curie: ClassVar[str] = "fair_mappings_schema:Agent" |
| 90 | + class_name: ClassVar[str] = "Agent" |
| 91 | + class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Agent |
97 | 92 |
|
98 | | - id: Union[str, NamedThingId] = None |
| 93 | + id: Union[str, AgentId] = None |
99 | 94 | name: Optional[str] = None |
100 | | - description: Optional[str] = None |
101 | 95 |
|
102 | 96 | def __post_init__(self, *_: str, **kwargs: Any): |
103 | 97 | if self._is_empty(self.id): |
104 | 98 | self.MissingRequiredField("id") |
105 | | - if not isinstance(self.id, NamedThingId): |
106 | | - self.id = NamedThingId(self.id) |
| 99 | + if not isinstance(self.id, AgentId): |
| 100 | + self.id = AgentId(self.id) |
107 | 101 |
|
108 | 102 | if self.name is not None and not isinstance(self.name, str): |
109 | 103 | self.name = str(self.name) |
110 | 104 |
|
111 | | - if self.description is not None and not isinstance(self.description, str): |
112 | | - self.description = str(self.description) |
113 | | - |
114 | 105 | super().__post_init__(**kwargs) |
115 | 106 |
|
116 | 107 |
|
117 | 108 | @dataclass(repr=False) |
118 | | -class Person(NamedThing): |
| 109 | +class Source(YAMLRoot): |
119 | 110 | """ |
120 | | - Represents a Person |
| 111 | + A data source from which entities are drawn, such as a database, ontology, or vocabulary. |
121 | 112 | """ |
122 | 113 | _inherited_slots: ClassVar[list[str]] = [] |
123 | 114 |
|
124 | | - class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Person"] |
125 | | - class_class_curie: ClassVar[str] = "fair_mappings_schema:Person" |
126 | | - class_name: ClassVar[str] = "Person" |
127 | | - class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Person |
| 115 | + class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Source"] |
| 116 | + class_class_curie: ClassVar[str] = "fair_mappings_schema:Source" |
| 117 | + class_name: ClassVar[str] = "Source" |
| 118 | + class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Source |
128 | 119 |
|
129 | | - id: Union[str, PersonId] = None |
130 | | - primary_email: Optional[str] = None |
131 | | - birth_date: Optional[Union[str, XSDDate]] = None |
132 | | - age_in_years: Optional[int] = None |
133 | | - vital_status: Optional[Union[str, "PersonStatus"]] = None |
| 120 | + name: Optional[str] = None |
| 121 | + version: Optional[str] = None |
| 122 | + type: Optional[str] = None |
| 123 | + documentation: Optional[str] = None |
| 124 | + content: Optional[str] = None |
| 125 | + content_type: Optional[str] = None |
134 | 126 |
|
135 | 127 | def __post_init__(self, *_: str, **kwargs: Any): |
136 | | - if self._is_empty(self.id): |
137 | | - self.MissingRequiredField("id") |
138 | | - if not isinstance(self.id, PersonId): |
139 | | - self.id = PersonId(self.id) |
| 128 | + if self.name is not None and not isinstance(self.name, str): |
| 129 | + self.name = str(self.name) |
| 130 | + |
| 131 | + if self.version is not None and not isinstance(self.version, str): |
| 132 | + self.version = str(self.version) |
140 | 133 |
|
141 | | - if self.primary_email is not None and not isinstance(self.primary_email, str): |
142 | | - self.primary_email = str(self.primary_email) |
| 134 | + if self.type is not None and not isinstance(self.type, str): |
| 135 | + self.type = str(self.type) |
143 | 136 |
|
144 | | - if self.birth_date is not None and not isinstance(self.birth_date, XSDDate): |
145 | | - self.birth_date = XSDDate(self.birth_date) |
| 137 | + if self.documentation is not None and not isinstance(self.documentation, str): |
| 138 | + self.documentation = str(self.documentation) |
146 | 139 |
|
147 | | - if self.age_in_years is not None and not isinstance(self.age_in_years, int): |
148 | | - self.age_in_years = int(self.age_in_years) |
| 140 | + if self.content is not None and not isinstance(self.content, str): |
| 141 | + self.content = str(self.content) |
149 | 142 |
|
150 | | - if self.vital_status is not None and not isinstance(self.vital_status, PersonStatus): |
151 | | - self.vital_status = PersonStatus(self.vital_status) |
| 143 | + if self.content_type is not None and not isinstance(self.content_type, str): |
| 144 | + self.content_type = str(self.content_type) |
152 | 145 |
|
153 | 146 | super().__post_init__(**kwargs) |
154 | 147 |
|
155 | 148 |
|
156 | 149 | @dataclass(repr=False) |
157 | | -class PersonCollection(YAMLRoot): |
| 150 | +class MappingSpecification(YAMLRoot): |
158 | 151 | """ |
159 | | - A holder for Person objects |
| 152 | + A formal description of correspondences between entities in a source and a target, expressed as rules, functions, |
| 153 | + or mapping statements. |
160 | 154 | """ |
161 | 155 | _inherited_slots: ClassVar[list[str]] = [] |
162 | 156 |
|
163 | | - class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["PersonCollection"] |
164 | | - class_class_curie: ClassVar[str] = "fair_mappings_schema:PersonCollection" |
165 | | - class_name: ClassVar[str] = "PersonCollection" |
166 | | - class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.PersonCollection |
| 157 | + class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["MappingSpecification"] |
| 158 | + class_class_curie: ClassVar[str] = "fair_mappings_schema:MappingSpecification" |
| 159 | + class_name: ClassVar[str] = "MappingSpecification" |
| 160 | + class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.MappingSpecification |
167 | 161 |
|
168 | | - entries: Optional[Union[dict[Union[str, PersonId], Union[dict, Person]], list[Union[dict, Person]]]] = empty_dict() |
| 162 | + author: Optional[Union[dict, Agent]] = None |
| 163 | + creator: Optional[Union[dict, Agent]] = None |
| 164 | + publication_date: Optional[str] = None |
| 165 | + license: Optional[str] = None |
| 166 | + version: Optional[str] = None |
| 167 | + description: Optional[str] = None |
| 168 | + type: Optional[str] = None |
| 169 | + mapping_method: Optional[str] = None |
| 170 | + documentation: Optional[str] = None |
| 171 | + content: Optional[str] = None |
| 172 | + subject_source: Optional[Union[dict, Source]] = None |
| 173 | + object_source: Optional[Union[dict, Source]] = None |
169 | 174 |
|
170 | 175 | def __post_init__(self, *_: str, **kwargs: Any): |
171 | | - self._normalize_inlined_as_list(slot_name="entries", slot_type=Person, key_name="id", keyed=True) |
| 176 | + if self.author is not None and not isinstance(self.author, Agent): |
| 177 | + self.author = Agent(**as_dict(self.author)) |
| 178 | + |
| 179 | + if self.creator is not None and not isinstance(self.creator, Agent): |
| 180 | + self.creator = Agent(**as_dict(self.creator)) |
| 181 | + |
| 182 | + if self.publication_date is not None and not isinstance(self.publication_date, str): |
| 183 | + self.publication_date = str(self.publication_date) |
| 184 | + |
| 185 | + if self.license is not None and not isinstance(self.license, str): |
| 186 | + self.license = str(self.license) |
| 187 | + |
| 188 | + if self.version is not None and not isinstance(self.version, str): |
| 189 | + self.version = str(self.version) |
| 190 | + |
| 191 | + if self.description is not None and not isinstance(self.description, str): |
| 192 | + self.description = str(self.description) |
| 193 | + |
| 194 | + if self.type is not None and not isinstance(self.type, str): |
| 195 | + self.type = str(self.type) |
| 196 | + |
| 197 | + if self.mapping_method is not None and not isinstance(self.mapping_method, str): |
| 198 | + self.mapping_method = str(self.mapping_method) |
| 199 | + |
| 200 | + if self.documentation is not None and not isinstance(self.documentation, str): |
| 201 | + self.documentation = str(self.documentation) |
| 202 | + |
| 203 | + if self.content is not None and not isinstance(self.content, str): |
| 204 | + self.content = str(self.content) |
| 205 | + |
| 206 | + if self.subject_source is not None and not isinstance(self.subject_source, Source): |
| 207 | + self.subject_source = Source(**as_dict(self.subject_source)) |
| 208 | + |
| 209 | + if self.object_source is not None and not isinstance(self.object_source, Source): |
| 210 | + self.object_source = Source(**as_dict(self.object_source)) |
172 | 211 |
|
173 | 212 | super().__post_init__(**kwargs) |
174 | 213 |
|
175 | 214 |
|
176 | 215 | # Enumerations |
177 | | -class PersonStatus(EnumDefinitionImpl): |
178 | | - |
179 | | - ALIVE = PermissibleValue( |
180 | | - text="ALIVE", |
181 | | - description="the person is living", |
182 | | - meaning=PATO["0001421"]) |
183 | | - DEAD = PermissibleValue( |
184 | | - text="DEAD", |
185 | | - description="the person is deceased", |
186 | | - meaning=PATO["0001422"]) |
187 | | - UNKNOWN = PermissibleValue( |
188 | | - text="UNKNOWN", |
189 | | - description="the vital status is not known") |
190 | | - |
191 | | - _defn = EnumDefinition( |
192 | | - name="PersonStatus", |
193 | | - ) |
| 216 | + |
194 | 217 |
|
195 | 218 | # Slots |
196 | 219 | class slots: |
197 | 220 | pass |
198 | 221 |
|
199 | | -slots.id = Slot(uri=SCHEMA.identifier, name="id", curie=SCHEMA.curie('identifier'), |
| 222 | +slots.id = Slot(uri=FAIR_MAPPINGS_SCHEMA.id, name="id", curie=FAIR_MAPPINGS_SCHEMA.curie('id'), |
200 | 223 | model_uri=FAIR_MAPPINGS_SCHEMA.id, domain=None, range=URIRef) |
201 | 224 |
|
202 | | -slots.name = Slot(uri=SCHEMA.name, name="name", curie=SCHEMA.curie('name'), |
| 225 | +slots.name = Slot(uri=FAIR_MAPPINGS_SCHEMA.name, name="name", curie=FAIR_MAPPINGS_SCHEMA.curie('name'), |
203 | 226 | model_uri=FAIR_MAPPINGS_SCHEMA.name, domain=None, range=Optional[str]) |
204 | 227 |
|
205 | | -slots.description = Slot(uri=SCHEMA.description, name="description", curie=SCHEMA.curie('description'), |
| 228 | +slots.creator = Slot(uri=FAIR_MAPPINGS_SCHEMA.creator, name="creator", curie=FAIR_MAPPINGS_SCHEMA.curie('creator'), |
| 229 | + model_uri=FAIR_MAPPINGS_SCHEMA.creator, domain=None, range=Optional[Union[dict, Agent]]) |
| 230 | + |
| 231 | +slots.author = Slot(uri=FAIR_MAPPINGS_SCHEMA.author, name="author", curie=FAIR_MAPPINGS_SCHEMA.curie('author'), |
| 232 | + model_uri=FAIR_MAPPINGS_SCHEMA.author, domain=None, range=Optional[Union[dict, Agent]]) |
| 233 | + |
| 234 | +slots.publication_date = Slot(uri=FAIR_MAPPINGS_SCHEMA.publication_date, name="publication_date", curie=FAIR_MAPPINGS_SCHEMA.curie('publication_date'), |
| 235 | + model_uri=FAIR_MAPPINGS_SCHEMA.publication_date, domain=None, range=Optional[str]) |
| 236 | + |
| 237 | +slots.license = Slot(uri=FAIR_MAPPINGS_SCHEMA.license, name="license", curie=FAIR_MAPPINGS_SCHEMA.curie('license'), |
| 238 | + model_uri=FAIR_MAPPINGS_SCHEMA.license, domain=None, range=Optional[str]) |
| 239 | + |
| 240 | +slots.version = Slot(uri=FAIR_MAPPINGS_SCHEMA.version, name="version", curie=FAIR_MAPPINGS_SCHEMA.curie('version'), |
| 241 | + model_uri=FAIR_MAPPINGS_SCHEMA.version, domain=None, range=Optional[str]) |
| 242 | + |
| 243 | +slots.description = Slot(uri=FAIR_MAPPINGS_SCHEMA.description, name="description", curie=FAIR_MAPPINGS_SCHEMA.curie('description'), |
206 | 244 | model_uri=FAIR_MAPPINGS_SCHEMA.description, domain=None, range=Optional[str]) |
207 | 245 |
|
208 | | -slots.primary_email = Slot(uri=SCHEMA.email, name="primary_email", curie=SCHEMA.curie('email'), |
209 | | - model_uri=FAIR_MAPPINGS_SCHEMA.primary_email, domain=None, range=Optional[str]) |
| 246 | +slots.type = Slot(uri=FAIR_MAPPINGS_SCHEMA.type, name="type", curie=FAIR_MAPPINGS_SCHEMA.curie('type'), |
| 247 | + model_uri=FAIR_MAPPINGS_SCHEMA.type, domain=None, range=Optional[str]) |
| 248 | + |
| 249 | +slots.mapping_method = Slot(uri=FAIR_MAPPINGS_SCHEMA.mapping_method, name="mapping_method", curie=FAIR_MAPPINGS_SCHEMA.curie('mapping_method'), |
| 250 | + model_uri=FAIR_MAPPINGS_SCHEMA.mapping_method, domain=None, range=Optional[str]) |
210 | 251 |
|
211 | | -slots.birth_date = Slot(uri=SCHEMA.birthDate, name="birth_date", curie=SCHEMA.curie('birthDate'), |
212 | | - model_uri=FAIR_MAPPINGS_SCHEMA.birth_date, domain=None, range=Optional[Union[str, XSDDate]]) |
| 252 | +slots.documentation = Slot(uri=FAIR_MAPPINGS_SCHEMA.documentation, name="documentation", curie=FAIR_MAPPINGS_SCHEMA.curie('documentation'), |
| 253 | + model_uri=FAIR_MAPPINGS_SCHEMA.documentation, domain=None, range=Optional[str]) |
213 | 254 |
|
214 | | -slots.age_in_years = Slot(uri=FAIR_MAPPINGS_SCHEMA.age_in_years, name="age_in_years", curie=FAIR_MAPPINGS_SCHEMA.curie('age_in_years'), |
215 | | - model_uri=FAIR_MAPPINGS_SCHEMA.age_in_years, domain=None, range=Optional[int]) |
| 255 | +slots.content = Slot(uri=FAIR_MAPPINGS_SCHEMA.content, name="content", curie=FAIR_MAPPINGS_SCHEMA.curie('content'), |
| 256 | + model_uri=FAIR_MAPPINGS_SCHEMA.content, domain=None, range=Optional[str]) |
216 | 257 |
|
217 | | -slots.vital_status = Slot(uri=FAIR_MAPPINGS_SCHEMA.vital_status, name="vital_status", curie=FAIR_MAPPINGS_SCHEMA.curie('vital_status'), |
218 | | - model_uri=FAIR_MAPPINGS_SCHEMA.vital_status, domain=None, range=Optional[Union[str, "PersonStatus"]]) |
| 258 | +slots.content_type = Slot(uri=FAIR_MAPPINGS_SCHEMA.content_type, name="content_type", curie=FAIR_MAPPINGS_SCHEMA.curie('content_type'), |
| 259 | + model_uri=FAIR_MAPPINGS_SCHEMA.content_type, domain=None, range=Optional[str]) |
219 | 260 |
|
220 | | -slots.personCollection__entries = Slot(uri=FAIR_MAPPINGS_SCHEMA.entries, name="personCollection__entries", curie=FAIR_MAPPINGS_SCHEMA.curie('entries'), |
221 | | - model_uri=FAIR_MAPPINGS_SCHEMA.personCollection__entries, domain=None, range=Optional[Union[dict[Union[str, PersonId], Union[dict, Person]], list[Union[dict, Person]]]]) |
| 261 | +slots.subject_source = Slot(uri=FAIR_MAPPINGS_SCHEMA.subject_source, name="subject_source", curie=FAIR_MAPPINGS_SCHEMA.curie('subject_source'), |
| 262 | + model_uri=FAIR_MAPPINGS_SCHEMA.subject_source, domain=None, range=Optional[Union[dict, Source]]) |
222 | 263 |
|
223 | | -slots.Person_primary_email = Slot(uri=SCHEMA.email, name="Person_primary_email", curie=SCHEMA.curie('email'), |
224 | | - model_uri=FAIR_MAPPINGS_SCHEMA.Person_primary_email, domain=Person, range=Optional[str], |
225 | | - pattern=re.compile(r'^\S+@[\S+\.]+\S+')) |
| 264 | +slots.object_source = Slot(uri=FAIR_MAPPINGS_SCHEMA.object_source, name="object_source", curie=FAIR_MAPPINGS_SCHEMA.curie('object_source'), |
| 265 | + model_uri=FAIR_MAPPINGS_SCHEMA.object_source, domain=None, range=Optional[Union[dict, Source]]) |
0 commit comments