Importers¶
Importers take either a representation of a schema in a different language or example data and bootstraps a schema.
Importers are the opposite of Generators in the core LinkML framework
Warning
Generally importers take a less expressive language than LinkML and attempts to create the corresponding
LinkML schema. This may be less optimal than a hand-crafted schema. For example, when converting to a
representation that lacks inheritance, no is_a slots
will be created.
Importing from JSON-Schema¶
The import-json-schema command can be used:
schemauto import-json-schema tests/resources/model_card.schema.json
Importing from Kwalify¶
The import-kwalify command can be used:
schemauto import-kwalify tests/resources/test.kwalify.yaml
Importing from OWL¶
You can import from a schema-style OWL ontology. This must be in functional syntax
Use robot to convert ahead of time:
robot convert -i schemaorg.ttl -o schemaorg.ofn
schemauto import-owl schemaorg.ofn
Importing from SQL¶
You can import a schema from a SQL database
The default is to assume a SQLite database:
schemauto import-sql path/to/my.db
You can also connect to any database server provided you have the necessary client software installed, using a SQL Alchemy connection path.
For example, for the RNA Central public database
schemauto import-sql postgresql+psycopg2://reader:NWDMCE5xdipIjRrp@hh-pgsql-public.ebi.ac.uk:5432/pfmegrnargs
Importing from caDSR¶
caDSR is an ISO-11179 compliant metadata registry. The ISO-11179 conceptual model can be mapped to LinkML. The canonical mapping maps a CDE onto a LinkML slot.
NCI implements a JSON serialization of ISO-11197. You can import this JSON and convert to LinkML:
schemauto import-cadsr "cdes/*.json"
Importing from DBML¶
DBML is a simple DSL for defining database schemas. It is a subset of SQL DDL.
Packages for importing¶
- class schema_automator.importers.JsonSchemaImportEngine(use_attributes: bool = False, is_openapi: bool = False)[source]¶
- An ImportEngine that imports a JSON-Schema representation to a LinkML Schema 
- class schema_automator.importers.OwlImportEngine(mappings: dict | None = None)[source]¶
- An ImportEngine that takes schema-style OWL and converts it to a LinkML schema 
- class schema_automator.importers.FrictionlessImportEngine[source]¶
- An ImportEngine that imports Frictionless data packages with schema information - See: 
- class schema_automator.importers.DOSDPImportEngine(mappings: dict | None = None)[source]¶
- An ImportEngine that imports Ontology Design Patterns specified as DOSDP Yaml into a LinkML schema - See DOSDPs - Every template maps to a LinkML class, the default name for a template Foo as FooTemplate - convert(files: str, range_as_enums=True, **kwargs) SchemaDefinition[source]¶
- Converts one or more YAML files into a Schema - Parameters:
- files 
- range_as_enums – if True, then class ranges are mapped to Enums 
- kwargs 
 
- Returns:
 
 - create_class(pattern: Pattern, range_as_enums: bool = True, denormalize_labels: bool = True) ClassDefinition[source]¶
- Create a LinkML class from a template/pattern - The class will have name FooTemplate, and will mixin TemplateClass, and will have one slot per var (slots will also be inherited from TemplateClass) - by default, the range of each var will be a class RangeClass, unless treated as enums - Parameters:
- pattern – DOSDP template 
- range_as_enums – if true, ranges will be enums 
- denoramlized – if true, create an optional label for each var 
 
- Returns:
 
 
- class schema_automator.importers.CADSRImportEngine[source]¶
- An ImportEngine that imports NCI CADSR CDEs - Ingests the output of caDSR API. - Note that we include a LinkML schema for this in schema_automator.metamodels.cadsr - Each CDE (DataElement) becomes a unique slot 
- the CDE is added as a lot of a context-specific class 
- the context-specific class is a subclass of the CDE’s DataElementConcept 
 - Note that this creates a lot of 1-1 classes, as in many cases there is no attempt to group concepts. However, this is not always the case. - E.g. the concept with publicId 2012668 (Access Route) is used in 5 contexts (AHRQ, CCR, …) - Each context-specific concept has its own set of CDEs - See also https://github.com/monarch-initiative/cde-harmonization