Biolink Model Subsetting

This notebook demonstrates how to subset the Biolink Model using the Biolink Model schema and a transformation specification in two different ways: first using a transformation specification defined manually in YAML and loaded from the filesystem, and second, using a subset of classes retrieved using SchemaView dynamically.

First, we import several LinkML helper packages including SchemaView: https://linkml.io/linkml/developers/schemaview.html SchemaView is a LinkML schema introspection tool that provides helpful functions to retrieve model elements by name. It also supports navigating ancestors and descendants of any model element, including classes, slots, types, and permissible values in enumerations.

from pathlib import Path
from pprint import pprint

from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.utils.formatutils import camelcase, underscore
from linkml_runtime.utils.schemaview import SchemaView

from linkml_map import load_specification
from linkml_map.datamodel.transformer_model import (
    ClassDerivation,
    CopyDirective,
    SlotDerivation,
    TransformationSpecification,
)
from linkml_map.inference.schema_mapper import SchemaMapper

EXAMPLES = Path.cwd().parent.parent / "tests/input/examples"

SchemaView can accept a variety of imports to initialize, including a Path or string representation of a Path or (as we do in this case), a URL of a raw LinkML schema.

# Pinned to v4.2.5, the last release published as a single file; later releases import
# a separate module that a derived schema can't resolve from here.
schema_url = "https://raw.githubusercontent.com/biolink/biolink-model/v4.2.5/biolink-model.yaml"
sv = SchemaView(schema_url)

Creating a Transformation Specification Manually in YAML format.

In our first example, we develop a "Transform Specification" for Biolink Model using Class and Slot Derivations as defined by the linkml-map transformation language. More about that in the data model reference.

transform_file = EXAMPLES / "biolink/transform/biolink-example-profile.transform.yaml"
tr_spec = load_specification(transform_file)

target_schema_obj = SchemaMapper(source_schemaview=sv).derive_schema(
    specification=tr_spec,
    target_schema_id="biolink-profile",
    target_schema_name="BiolinkProfile",
)
transformed_sv = SchemaView(yaml_dumper.dumps(target_schema_obj))

for class_name in transformed_sv.all_classes():
    print(class_name)
print()
for slot_name in transformed_sv.all_slots():
    print(slot_name)
NamedThing
Gene
Disease
PhenotypicFeature
Association
GeneToPhenotypicFeatureAssociation

id
name
category
symbol
subject
predicate
object

To generate Pydantic models from the profile, save it with yaml_dumper.dump(target_schema_obj, "biolink-profile.yaml") and run:

gen-pydantic biolink-profile.yaml

Note: * Still in development is the tracing of provenance between a source schema and a destination schema. Right now there is no provenance.
* If a class, slot, enum, or type is not included at all in the Derivation, it will not be pushed forward to the destination schema. In development is an option to pull all non-specified components of the source model into the destination model. * You can do transformations on a derivation as well; see Using expressions. * Custom types are not pulled forward; this is a result of an error at the moment.

Creating a TransformationSpecification using SchemaView and an existing model.

In our second example, we use the Biolink Model directly to derive classes and slots programmatically according to a simple list of "subset classes" that we want to extract from the main model in order to produce a subset model according to our specification.

First, we write a method to extract the classes and slots from Biolink Model using SchemaView

def get_biolink_class_derivations(sv, subset_classes) -> dict:
    """
    Function to get Biolink class definitions

    :param sv: SchemaView object
    :param subset_classes: List of classes to subset
    :return: Dictionary of class derivations incl slot derivations
    """
    # Example implementation to fetch class definitions
    # This should be replaced with the actual implementation
    class_derivations ={}
    for class_name in subset_classes:
        class_derivation = ClassDerivation(populated_from=class_name,
                                           name=camelcase(class_name))
        induced_slots = sv.class_induced_slots(class_name)
        for slot in induced_slots:
            slot_derivation = SlotDerivation(populated_from=slot.name, name=underscore(slot.name))
            class_derivation.slot_derivations[underscore(slot.name)] = slot_derivation
        class_derivations[camelcase(class_name)] = class_derivation
    return class_derivations
def get_biolink_class_derivations_direct(sv, subset_classes) -> dict:
    """
    Function to get Biolink class definitions

    :param sv: SchemaView object
    :param subset_classes: List of classes to subset
    :return: Dictionary of class derivations incl slot derivations
    """
    # Example implementation to fetch class definitions
    # This should be replaced with the actual implementation
    class_derivations ={}
    for class_name in subset_classes:
        class_derivation = ClassDerivation(populated_from=class_name,
                                           name=camelcase(class_name))
        for slot in sv.get_class(class_name).slots:
            slot_derivation = SlotDerivation(populated_from=slot, name=underscore(slot))
            class_derivation.slot_derivations[underscore(slot)] = slot_derivation
        class_derivations[camelcase(class_name)] = class_derivation
    return class_derivations
subset_classes = [
        "gene",
        "disease",
        "case to phenotypic feature association",
        "gene to disease association",
        "gene to phenotypic feature association",
        "case",
        "phenotypic feature",
    ]

class_derivations = get_biolink_class_derivations_direct(sv, subset_classes)
copy_type_directives = {
    type_name: CopyDirective(element_name=type_name, copy_all=False)
    for type_name, type_def in sv.all_types().items()
}

ts = TransformationSpecification(class_derivations=class_derivations, copy_directives=copy_type_directives)

target_schema_obj = SchemaMapper(source_schemaview=sv).derive_schema(
    specification=ts, target_schema_id="biolink-subset", target_schema_name="BiolinkSubset"
)

# The copy directives don't bring Biolink's types across yet, so copy them directly
target_schema_obj.types = sv.all_types()

transformed_sv = SchemaView(yaml_dumper.dumps(target_schema_obj))

for class_name in transformed_sv.all_classes():
    print("class derived: ", class_name)
for slot_name in transformed_sv.all_slots():
    print("slot derived: ", slot_name)
for type_name in transformed_sv.all_types():
    print("type copied: ", type_name)
class derived:  Gene
class derived:  Disease
class derived:  CaseToPhenotypicFeatureAssociation
class derived:  GeneToDiseaseAssociation
class derived:  GeneToPhenotypicFeatureAssociation
class derived:  Case
class derived:  PhenotypicFeature
slot derived:  symbol
slot derived:  xref
type copied:  string
type copied:  integer
type copied:  boolean
type copied:  float
type copied:  double
type copied:  decimal
type copied:  time
type copied:  date
type copied:  datetime
type copied:  date_or_datetime
type copied:  uriorcurie
type copied:  curie
type copied:  uri
type copied:  ncname
type copied:  objectidentifier
type copied:  nodeidentifier
type copied:  jsonpointer
type copied:  jsonpath
type copied:  sparqlpath
type copied:  chemical formula value
type copied:  iri type
type copied:  label type
type copied:  predicate type
type copied:  narrative text
type copied:  symbol type
type copied:  frequency value
type copied:  percentage frequency value
type copied:  quotient
type copied:  unit
type copied:  time type
type copied:  biological sequence

# print the content of the new schema in LinkML YAML format to view here in the notebook
yaml_content = yaml_dumper.dumps(target_schema_obj)  # Serialize to a string
print(yaml_content)
name: BiolinkSubset
id: biolink-subset
imports:
- linkml:types
prefixes:
  AGRKB:
    prefix_prefix: AGRKB
    prefix_reference: https://www.alliancegenome.org/
  apollo:
    prefix_prefix: apollo
    prefix_reference: https://github.com/GMOD/Apollo
  AspGD:
    prefix_prefix: AspGD
    prefix_reference: http://www.aspergillusgenome.org/cgi-bin/locus.pl?dbid=
  biolink:
    prefix_prefix: biolink
    prefix_reference: https://w3id.org/biolink/vocab/
  bioschemas:
    prefix_prefix: bioschemas
    prefix_reference: https://bioschemas.org/
  linkml:
    prefix_prefix: linkml
    prefix_reference: https://w3id.org/linkml/
  CAID:
    prefix_prefix: CAID
    prefix_reference: http://reg.clinicalgenome.org/redmine/projects/registry/genboree_registry/by_caid?caid=
  CHADO:
    prefix_prefix: CHADO
    prefix_reference: http://gmod.org/wiki/Chado/
  ChemBank:
    prefix_prefix: ChemBank
    prefix_reference: http://chembank.broadinstitute.org/chemistry/viewMolecule.htm?cbid=
  CHEMBL.MECHANISM:
    prefix_prefix: CHEMBL.MECHANISM
    prefix_reference: https://www.ebi.ac.uk/chembl/mechanism/inspect/
  CID:
    prefix_prefix: CID
    prefix_reference: http://pubchem.ncbi.nlm.nih.gov/compound/
  CLINVAR:
    prefix_prefix: CLINVAR
    prefix_reference: http://identifiers.org/clinvar
  COAR_RESOURCE:
    prefix_prefix: COAR_RESOURCE
    prefix_reference: http://purl.org/coar/resource_type/
  COG:
    prefix_prefix: COG
    prefix_reference: https://www.ncbi.nlm.nih.gov/research/cog-project/
  ComplexPortal:
    prefix_prefix: ComplexPortal
    prefix_reference: https://www.ebi.ac.uk/complexportal/complex/
  CPT:
    prefix_prefix: CPT
    prefix_reference: https://www.ama-assn.org/practice-management/cpt/
  CTD.CHEMICAL:
    prefix_prefix: CTD.CHEMICAL
    prefix_reference: http://ctdbase.org/detail.go?type=chem&acc=
  CTD.DISEASE:
    prefix_prefix: CTD.DISEASE
    prefix_reference: http://ctdbase.org/detail.go?type=disease&db=MESH&acc=
  CTD.GENE:
    prefix_prefix: CTD.GENE
    prefix_reference: http://ctdbase.org/detail.go?type=gene&acc=
  CTD:
    prefix_prefix: CTD
    prefix_reference: http://ctdbase.org/
  DGIdb:
    prefix_prefix: DGIdb
    prefix_reference: https://www.dgidb.org/interaction_types
  dcat:
    prefix_prefix: dcat
    prefix_reference: http://www.w3.org/ns/dcat#
  dct:
    prefix_prefix: dct
    prefix_reference: http://purl.org/dc/terms/
  dcid:
    prefix_prefix: dcid
    prefix_reference: https://datacommons.org/browser/
  doi:
    prefix_prefix: doi
    prefix_reference: https://doi.org/
  DOID-PROPERTY:
    prefix_prefix: DOID-PROPERTY
    prefix_reference: http://purl.obolibrary.org/obo/doid#
  DrugCentral:
    prefix_prefix: DrugCentral
    prefix_reference: http://drugcentral.org/drugcard/
  ECTO:
    prefix_prefix: ECTO
    prefix_reference: http://purl.obolibrary.org/obo/ECTO_
  EDAM-DATA:
    prefix_prefix: EDAM-DATA
    prefix_reference: http://edamontology.org/data_
  EDAM-FORMAT:
    prefix_prefix: EDAM-FORMAT
    prefix_reference: http://edamontology.org/format_
  EDAM-OPERATION:
    prefix_prefix: EDAM-OPERATION
    prefix_reference: http://edamontology.org/operation_
  EDAM-TOPIC:
    prefix_prefix: EDAM-TOPIC
    prefix_reference: http://edamontology.org/topic_
  EFO:
    prefix_prefix: EFO
    prefix_reference: http://www.ebi.ac.uk/efo/EFO_
  ExO:
    prefix_prefix: ExO
    prefix_reference: http://purl.obolibrary.org/obo/ExO_
  fabio:
    prefix_prefix: fabio
    prefix_reference: http://purl.org/spar/fabio/
  foaf:
    prefix_prefix: foaf
    prefix_reference: http://xmlns.com/foaf/0.1/
  foodb.compound:
    prefix_prefix: foodb.compound
    prefix_reference: http://foodb.ca/compounds/
  foodb.food:
    prefix_prefix: foodb.food
    prefix_reference: http://foodb.ca/foods/
  FYECO:
    prefix_prefix: FYECO
    prefix_reference: https://www.pombase.org/term/
  FYPO:
    prefix_prefix: FYPO
    prefix_reference: http://purl.obolibrary.org/obo/FYPO_
  gff3:
    prefix_prefix: gff3
    prefix_reference: https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md#
  GOREL:
    prefix_prefix: GOREL
    prefix_reference: http://purl.obolibrary.org/obo/GOREL_
  GOP:
    prefix_prefix: GOP
    prefix_reference: http://purl.obolibrary.org/obo/go#
  gpi:
    prefix_prefix: gpi
    prefix_reference: https://github.com/geneontology/go-annotation/blob/master/specs/gpad-gpi-2-0.md#
  GSID:
    prefix_prefix: GSID
    prefix_reference: https://scholar.google.com/citations?user=
  GTEx:
    prefix_prefix: GTEx
    prefix_reference: https://www.gtexportal.org/home/gene/
  GTOPDB:
    prefix_prefix: GTOPDB
    prefix_reference: https://www.guidetopharmacology.org/GRAC/LigandDisplayForward?ligandId=
  gtpo:
    prefix_prefix: gtpo
    prefix_reference: https://rdf.guidetopharmacology.org/ns/gtpo#
  HANCESTRO:
    prefix_prefix: HANCESTRO
    prefix_reference: http://www.ebi.ac.uk/ancestro/ancestro_
  HCPCS:
    prefix_prefix: HCPCS
    prefix_reference: http://purl.bioontology.org/ontology/HCPCS/
  HsapDv:
    prefix_prefix: HsapDv
    prefix_reference: http://purl.obolibrary.org/obo/HsapDv_
  ICD10:
    prefix_prefix: ICD10
    prefix_reference: https://icd.codes/icd9cm/
  ICD9:
    prefix_prefix: ICD9
    prefix_reference: http://translator.ncats.nih.gov/ICD9_
  interpro:
    prefix_prefix: interpro
    prefix_reference: https://www.ebi.ac.uk/interpro/entry/
  INO:
    prefix_prefix: INO
    prefix_reference: http://purl.obolibrary.org/obo/INO_
  isbn:
    prefix_prefix: isbn
    prefix_reference: https://www.isbn-international.org/identifier/
  isni:
    prefix_prefix: isni
    prefix_reference: https://isni.org/isni/
  issn:
    prefix_prefix: issn
    prefix_reference: https://portal.issn.org/resource/ISSN/
  ncats.drug:
    prefix_prefix: ncats.drug
    prefix_reference: https://drugs.ncats.io/drug/
  KEGG.BRITE:
    prefix_prefix: KEGG.BRITE
    prefix_reference: 'https://bioregistry.io/kegg.brite:'
  KEGG:
    prefix_prefix: KEGG
    prefix_reference: http://www.kegg.jp/entry/
  KEGG.GENES:
    prefix_prefix: KEGG.GENES
    prefix_reference: 'https://bioregistry.io/kegg.genes:bsu:'
  KEGG.PATHWAY:
    prefix_prefix: KEGG.PATHWAY
    prefix_reference: 'https://bioregistry.io/kegg.pathway:'
  KEGG.RCLASS:
    prefix_prefix: KEGG.RCLASS
    prefix_reference: 'https://www.genome.jp/dbget-bin/www_bget?rc:'
  LOINC:
    prefix_prefix: LOINC
    prefix_reference: http://loinc.org/rdf/
  MAXO:
    prefix_prefix: MAXO
    prefix_reference: http://purl.obolibrary.org/obo/MAXO_
  medgen:
    prefix_prefix: medgen
    prefix_reference: https://www.ncbi.nlm.nih.gov/medgen/
  metacyc.reaction:
    prefix_prefix: metacyc.reaction
    prefix_reference: 'http://identifiers.org/metacyc.reaction:'
  METANETX.REACTION:
    prefix_prefix: METANETX.REACTION
    prefix_reference: https://www.metanetx.org/equa_info/
  MESH:
    prefix_prefix: MESH
    prefix_reference: http://id.nlm.nih.gov/mesh/
  MI:
    prefix_prefix: MI
    prefix_reference: http://purl.obolibrary.org/obo/MI_
  mirbase:
    prefix_prefix: mirbase
    prefix_reference: http://identifiers.org/mirbase
  mmmp.biomaps:
    prefix_prefix: mmmp.biomaps
    prefix_reference: 'https://bioregistry.io/mmmp.biomaps:'
  MmusDv:
    prefix_prefix: MmusDv
    prefix_reference: http://purl.obolibrary.org/obo/MMUSDV_
  MSigDB:
    prefix_prefix: MSigDB
    prefix_reference: https://www.gsea-msigdb.org/gsea/msigdb/
  NBO-PROPERTY:
    prefix_prefix: NBO-PROPERTY
    prefix_reference: http://purl.obolibrary.org/obo/nbo#
  ncats.bioplanet:
    prefix_prefix: ncats.bioplanet
    prefix_reference: https://tripod.nih.gov/bioplanet/detail.jsp?pid=
  NCBIGene:
    prefix_prefix: NCBIGene
    prefix_reference: http://identifiers.org/ncbigene/
  NCIT-OBO:
    prefix_prefix: NCIT-OBO
    prefix_reference: http://purl.obolibrary.org/obo/ncit#
  NDDF:
    prefix_prefix: NDDF
    prefix_reference: http://purl.bioontology.org/ontology/NDDF/
  NLMID:
    prefix_prefix: NLMID
    prefix_reference: https://www.ncbi.nlm.nih.gov/nlmcatalog/?term=
  OBAN:
    prefix_prefix: OBAN
    prefix_reference: http://purl.org/oban/
  OMIM.PS:
    prefix_prefix: OMIM.PS
    prefix_reference: https://www.omim.org/phenotypicSeries/
  ORCID:
    prefix_prefix: ORCID
    prefix_reference: https://orcid.org/
  orphanet:
    prefix_prefix: orphanet
    prefix_reference: http://www.orpha.net/ORDO/Orphanet_
  os:
    prefix_prefix: os
    prefix_reference: https://github.com/cmungall/owlstar/blob/master/owlstar.ttl
  PANTHER.FAMILY:
    prefix_prefix: PANTHER.FAMILY
    prefix_reference: http://www.pantherdb.org/panther/family.do?clsAccession=
  PathWhiz:
    prefix_prefix: PathWhiz
    prefix_reference: http://smpdb.ca/pathways/#
  pav:
    prefix_prefix: pav
    prefix_reference: http://purl.org/pav/
  PHARMGKB.DRUG:
    prefix_prefix: PHARMGKB.DRUG
    prefix_reference: https://www.pharmgkb.org/chemical/
  PHARMGKB.DISEASE:
    prefix_prefix: PHARMGKB.DISEASE
    prefix_reference: https://www.pharmgkb.org/disease/
  PHARMGKB.GENE:
    prefix_prefix: PHARMGKB.GENE
    prefix_reference: https://www.pharmgkb.org/gene/
  PHARMGKB.PATHWAYS:
    prefix_prefix: PHARMGKB.PATHWAYS
    prefix_reference: https://www.pharmgkb.org/pathway/
  PHARMGKB.VARIANT:
    prefix_prefix: PHARMGKB.VARIANT
    prefix_reference: https://www.pharmgkb.org/variant/
  PHAROS:
    prefix_prefix: PHAROS
    prefix_reference: http://pharos.nih.gov
  PomBase:
    prefix_prefix: PomBase
    prefix_reference: https://www.pombase.org/gene/
  prov:
    prefix_prefix: prov
    prefix_reference: http://www.w3.org/ns/prov#
  qud:
    prefix_prefix: qud
    prefix_reference: http://qudt.org/1.1/schema/qudt#
  REPODB:
    prefix_prefix: REPODB
    prefix_reference: http://apps.chiragjpgroup.org/repoDB/
  ResearchID:
    prefix_prefix: ResearchID
    prefix_reference: https://publons.com/researcher/
  RO:
    prefix_prefix: RO
    prefix_reference: http://purl.obolibrary.org/obo/RO_
  RXNORM:
    prefix_prefix: RXNORM
    prefix_reference: http://purl.bioontology.org/ontology/RXNORM/
  RXCUI:
    prefix_prefix: RXCUI
    prefix_reference: https://mor.nlm.nih.gov/RxNav/search?searchBy=RXCUI&searchTerm=
  schema:
    prefix_prefix: schema
    prefix_reference: http://schema.org/
  ScopusID:
    prefix_prefix: ScopusID
    prefix_reference: https://www.scopus.com/authid/detail.uri?authorId=
  SEED.REACTION:
    prefix_prefix: SEED.REACTION
    prefix_reference: https://modelseed.org/biochem/reactions/
  SEMMEDDB:
    prefix_prefix: SEMMEDDB
    prefix_reference: https://skr3.nlm.nih.gov/SemMedDB
  SIO:
    prefix_prefix: SIO
    prefix_reference: http://semanticscience.org/resource/SIO_
  SNOMEDCT:
    prefix_prefix: SNOMEDCT
    prefix_reference: http://snomed.info/id/
  SPDI:
    prefix_prefix: SPDI
    prefix_reference: https://api.ncbi.nlm.nih.gov/variation/v0/spdi/
  UBERGRAPH:
    prefix_prefix: UBERGRAPH
    prefix_reference: http://translator.renci.org/ubergraph-axioms.ofn#
  UBERON_CORE:
    prefix_prefix: UBERON_CORE
    prefix_reference: http://purl.obolibrary.org/obo/uberon/core#
  UBERON_NONAMESPACE:
    prefix_prefix: UBERON_NONAMESPACE
    prefix_reference: http://purl.obolibrary.org/obo/core#
  STY:
    prefix_prefix: STY
    prefix_reference: http://purl.bioontology.org/ontology/STY/
  UMLSSG:
    prefix_prefix: UMLSSG
    prefix_reference: https://lhncbc.nlm.nih.gov/semanticnetwork/download/sg_archive/SemGroups-v04.txt
  UniProtKB:
    prefix_prefix: UniProtKB
    prefix_reference: http://purl.uniprot.org/uniprot/
  UNIPROT.ISOFORM:
    prefix_prefix: UNIPROT.ISOFORM
    prefix_reference: http://purl.uniprot.org/isoforms/
  VANDF:
    prefix_prefix: VANDF
    prefix_reference: https://www.nlm.nih.gov/research/umls/sourcereleasedocs/current/VANDF/
  UO-PROPERTY:
    prefix_prefix: UO-PROPERTY
    prefix_reference: http://purl.obolibrary.org/obo/uo#
  VMC:
    prefix_prefix: VMC
    prefix_reference: https://github.com/ga4gh/vr-spec/
  WBls:
    prefix_prefix: WBls
    prefix_reference: http://purl.obolibrary.org/obo/WBls_
  WBbt:
    prefix_prefix: WBbt
    prefix_reference: http://purl.obolibrary.org/obo/WBbt_
  WBVocab:
    prefix_prefix: WBVocab
    prefix_reference: http://bio2rdf.org/wormbase_vocabulary
  WIKIDATA:
    prefix_prefix: WIKIDATA
    prefix_reference: https://www.wikidata.org/entity/
  WIKIDATA_PROPERTY:
    prefix_prefix: WIKIDATA_PROPERTY
    prefix_reference: https://www.wikidata.org/prop/
  wgs:
    prefix_prefix: wgs
    prefix_reference: http://www.w3.org/2003/01/geo/wgs84_pos
  XPO:
    prefix_prefix: XPO
    prefix_reference: http://purl.obolibrary.org/obo/XPO_
  Xenbase:
    prefix_prefix: Xenbase
    prefix_reference: http://www.xenbase.org/gene/showgene.do?method=display&geneId=
  PMC:
    prefix_prefix: PMC
    prefix_reference: http://europepmc.org/articles/PMC
default_prefix: biolink-subset/
default_range: string
types:
  string:
    name: string
    description: A character string
    notes:
    - In RDF serializations, a slot with range of string is treated as a literal or
      type xsd:string. If you are authoring schemas in LinkML YAML, the type is referenced
      with the lower case "string".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Text
    base: str
    uri: xsd:string
  integer:
    name: integer
    description: An integer
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "integer".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Integer
    base: int
    uri: xsd:integer
  boolean:
    name: boolean
    description: A binary (true or false) value
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "boolean".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Boolean
    base: Bool
    uri: xsd:boolean
    repr: bool
  float:
    name: float
    description: A real number that conforms to the xsd:float specification
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "float".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Float
    base: float
    uri: xsd:float
  double:
    name: double
    description: A real number that conforms to the xsd:double specification
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "double".
    from_schema: https://w3id.org/linkml/types
    close_mappings:
    - schema:Float
    base: float
    uri: xsd:double
  decimal:
    name: decimal
    description: A real number with arbitrary precision that conforms to the xsd:decimal
      specification
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "decimal".
    from_schema: https://w3id.org/linkml/types
    broad_mappings:
    - schema:Number
    base: Decimal
    uri: xsd:decimal
  time:
    name: time
    description: A time object represents a (local) time of day, independent of any
      particular day
    notes:
    - URI is dateTime because OWL reasoners do not work with straight date or time
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "time".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Time
    base: XSDTime
    uri: xsd:time
    repr: str
  date:
    name: date
    description: a date (year, month and day) in an idealized calendar
    notes:
    - URI is dateTime because OWL reasoners don't work with straight date or time
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "date".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:Date
    base: XSDDate
    uri: xsd:date
    repr: str
  datetime:
    name: datetime
    description: The combination of a date and time
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "datetime".
    from_schema: https://w3id.org/linkml/types
    exact_mappings:
    - schema:DateTime
    base: XSDDateTime
    uri: xsd:dateTime
    repr: str
  date_or_datetime:
    name: date_or_datetime
    description: Either a date or a datetime
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "date_or_datetime".
    from_schema: https://w3id.org/linkml/types
    base: str
    uri: linkml:DateOrDatetime
    repr: str
  uriorcurie:
    name: uriorcurie
    description: a URI or a CURIE
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "uriorcurie".
    from_schema: https://w3id.org/linkml/types
    base: URIorCURIE
    uri: xsd:anyURI
    repr: str
  curie:
    name: curie
    conforms_to: https://www.w3.org/TR/curie/
    description: a compact URI
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "curie".
    comments:
    - in RDF serializations this MUST be expanded to a URI
    - in non-RDF serializations MAY be serialized as the compact representation
    from_schema: https://w3id.org/linkml/types
    base: Curie
    uri: xsd:string
    repr: str
  uri:
    name: uri
    conforms_to: https://www.ietf.org/rfc/rfc3987.txt
    description: a complete URI
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "uri".
    comments:
    - in RDF serializations a slot with range of uri is treated as a literal or type
      xsd:anyURI unless it is an identifier or a reference to an identifier, in which
      case it is translated directly to a node
    from_schema: https://w3id.org/linkml/types
    close_mappings:
    - schema:URL
    base: URI
    uri: xsd:anyURI
    repr: str
  ncname:
    name: ncname
    description: Prefix part of CURIE
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "ncname".
    from_schema: https://w3id.org/linkml/types
    base: NCName
    uri: xsd:string
    repr: str
  objectidentifier:
    name: objectidentifier
    description: A URI or CURIE that represents an object in the model.
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "objectidentifier".
    comments:
    - Used for inheritance and type checking
    from_schema: https://w3id.org/linkml/types
    base: ElementIdentifier
    uri: shex:iri
    repr: str
  nodeidentifier:
    name: nodeidentifier
    description: A URI, CURIE or BNODE that represents a node in a model.
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "nodeidentifier".
    from_schema: https://w3id.org/linkml/types
    base: NodeIdentifier
    uri: shex:nonLiteral
    repr: str
  jsonpointer:
    name: jsonpointer
    conforms_to: https://datatracker.ietf.org/doc/html/rfc6901
    description: A string encoding a JSON Pointer. The value of the string MUST conform
      to JSON Point syntax and SHOULD dereference to a valid object within the current
      instance document when encoded in tree form.
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "jsonpointer".
    from_schema: https://w3id.org/linkml/types
    base: str
    uri: xsd:string
    repr: str
  jsonpath:
    name: jsonpath
    conforms_to: https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html
    description: A string encoding a JSON Path. The value of the string MUST conform
      to JSON Point syntax and SHOULD dereference to zero or more valid objects within
      the current instance document when encoded in tree form.
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "jsonpath".
    from_schema: https://w3id.org/linkml/types
    base: str
    uri: xsd:string
    repr: str
  sparqlpath:
    name: sparqlpath
    conforms_to: https://www.w3.org/TR/sparql11-query/#propertypaths
    description: A string encoding a SPARQL Property Path. The value of the string
      MUST conform to SPARQL syntax and SHOULD dereference to zero or more valid objects
      within the current instance document when encoded as RDF.
    notes:
    - If you are authoring schemas in LinkML YAML, the type is referenced with the
      lower case "sparqlpath".
    from_schema: https://w3id.org/linkml/types
    base: str
    uri: xsd:string
    repr: str
  chemical formula value:
    name: chemical formula value
    description: A chemical formula
    notes:
    - Should be implemented as a stronger type
    from_schema: https://w3id.org/biolink/biolink-model
    base: str
    uri: xsd:string
  iri type:
    name: iri type
    description: An IRI
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: uriorcurie
    uri: xsd:string
  label type:
    name: label type
    description: A string that provides a human-readable name for an entity
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: string
    uri: xsd:string
  predicate type:
    name: predicate type
    description: A CURIE from the biolink related_to hierarchy. For example, biolink:related_to,
      biolink:causes, biolink:treats.
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: uriorcurie
    uri: xsd:string
  narrative text:
    name: narrative text
    description: A string that provides a human-readable description of something
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: string
    uri: xsd:string
  symbol type:
    name: symbol type
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: string
    uri: xsd:string
  frequency value:
    name: frequency value
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: string
    uri: UO:0000105
  percentage frequency value:
    name: percentage frequency value
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: double
    uri: UO:0000187
  quotient:
    name: quotient
    from_schema: https://w3id.org/biolink/biolink-model
    aliases:
    - ratio
    typeof: double
    uri: UO:0010006
  unit:
    name: unit
    id_prefixes:
    - UO
    from_schema: https://w3id.org/biolink/biolink-model
    exact_mappings:
    - qud:Unit
    typeof: string
    uri: UO:0000000
  time type:
    name: time type
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: time
    uri: xsd:time
  biological sequence:
    name: biological sequence
    from_schema: https://w3id.org/biolink/biolink-model
    typeof: string
    uri: xsd:string
classes:
  Gene:
    name: Gene
    id_prefixes:
    - NCBIGene
    - ENSEMBL
    - HGNC
    - MGI
    - ZFIN
    - dictyBase
    - WB
    - WormBase
    - FB
    - RGD
    - SGD
    - PomBase
    - OMIM
    - KEGG.GENES
    - UMLS
    - Xenbase
    - AspGD
    - PHARMGKB.GENE
    description: A region (or regions) that includes all of the sequence elements
      necessary to encode a functional transcript. A gene locus may include regulatory
      regions, transcribed regions and/or other functional sequence regions.
    in_subset:
    - translator_minimal
    - model_organism_database
    exact_mappings:
    - SO:0000704
    - SIO:010035
    - WIKIDATA:Q7187
    - dcid:Gene
    narrow_mappings:
    - bioschemas:gene
    broad_mappings:
    - NCIT:C45822
    attributes:
      symbol:
        name: symbol
        description: Symbol for a particular thing
        exact_mappings:
        - AGRKB:symbol
        - gpi:DB_Object_Symbol
        is_a: node property
        domain: named thing
      xref:
        name: xref
        description: A database cross reference or alternative identifier for a NamedThing
          or edge between two NamedThings.  This property should point to a database
          record or webpage that supports the existence of the edge, or gives more
          detail about the edge. This property can be used on a node or edge to provide
          multiple URIs or CURIE cross references.
        in_subset:
        - translator_minimal
        aliases:
        - dbxref
        - Dbxref
        - DbXref
        - record_url
        - source_record_urls
        narrow_mappings:
        - gff3:Dbxref
        - gpi:DB_Xrefs
        domain: named thing
        range: uriorcurie
        multivalued: true
  Disease:
    name: Disease
    id_prefixes:
    - MONDO
    - DOID
    - OMIM
    - OMIM.PS
    - orphanet
    - EFO
    - UMLS
    - MESH
    - MEDDRA
    - NCIT
    - SNOMEDCT
    - medgen
    - ICD10
    - ICD9
    - KEGG.DISEASE
    - HP
    - MP
    - PHARMGKB.DISEASE
    description: A disorder of structure or function, especially one that produces
      specific signs, phenotypes or symptoms or that affects a specific location and
      is not simply a direct result of physical injury.  A disposition to undergo
      pathological processes that exists in an organism because of one or more disorders
      in that organism.
    in_subset:
    - model_organism_database
    - translator_minimal
    aliases:
    - condition
    - disorder
    - medical condition
    exact_mappings:
    - MONDO:0000001
    - DOID:4
    - NCIT:C2991
    - WIKIDATA:Q12136
    - SIO:010299
    - UMLSSG:DISO
    - STY:T047
    - dcid:Disease
    narrow_mappings:
    - STY:T019
    - STY:T020
    - STY:T048
    - STY:T049
    - STY:T191
    - MONDO:0042489
  CaseToPhenotypicFeatureAssociation:
    name: CaseToPhenotypicFeatureAssociation
    description: An association between a case (e.g. individual patient) and a phenotypic
      feature in which the individual has or has had the phenotype.
    defining_slots:
    - subject
    - object
  GeneToDiseaseAssociation:
    name: GeneToDiseaseAssociation
    comments:
    - NCIT:R176 refers to the inverse relationship
    exact_mappings:
    - SIO:000983
    close_mappings:
    - dcid:DiseaseGeneAssociation
    defining_slots:
    - subject
    - object
  GeneToPhenotypicFeatureAssociation:
    name: GeneToPhenotypicFeatureAssociation
    exact_mappings:
    - WBVocab:Gene-Phenotype-Association
    defining_slots:
    - subject
    - object
  Case:
    name: Case
    description: An individual (human) organism that has a patient role in some clinical
      context.
    aliases:
    - patient
    - proband
  PhenotypicFeature:
    name: PhenotypicFeature
    id_prefixes:
    - HP
    - EFO
    - NCIT
    - UMLS
    - MEDDRA
    - MP
    - ZP
    - UPHENO
    - APO
    - FBcv
    - WBPhenotype
    - SNOMEDCT
    - MESH
    - XPO
    - FYPO
    - TO
    description: A combination of entity and quality that makes up a phenotyping statement.
      An observable characteristic of an individual resulting from the interaction
      of its genotype with its molecular and physical environment.
    examples:
    - value: MP:0001262
      description: decreased body weight
    in_subset:
    - model_organism_database
    aliases:
    - sign
    - symptom
    - phenotype
    - trait
    - endophenotype
    exact_mappings:
    - UPHENO:0001001
    - SIO:010056
    - WIKIDATA:Q104053
    - UMLS:C4021819
    - NCIT:C16977
    - SNOMEDCT:8116006
    - MESH:D010641
    narrow_mappings:
    - STY:T184
    - WIKIDATA:Q169872
    - WIKIDATA:Q25203551
    - ZP:00000000
    - FBcv:0001347
    - HP:0000118
    - MP:0000001
    - WBPhenotype:0000886
    - XPO:00000000
    - FYPO:0000001
    - APO:0000017
    - TO:0000387
    - STY:T190
    broad_mappings:
    - BFO:0000019
    - PATO:0000001


Notes: * notice that if we remove a parent class from this, e.g. remove "NamedThing" - the is_a path in the descendent classes will be absent. this is to prevent unreachable element errors. * notice that helpful defaults are brought in like prefixes, descriptions, aliases, mappings, etc. * there will likely be cases where metamodel elements in LinkML are not automatically transferred to the derived schema (as will all our generators, we are working towards feature parity).
* notice that the transformation automatically makes what were, independent slot definitions in Biolink Model into attributes. These are more or less functionally equivalent in LinkML, however if you want to specify a slot that can be reused outside of a particular class, it is still best practice to do so with a slot definition rather than an attribute as to not repeat slot definitions.

Use derived schema to generate different serializations of the derived model

Saved as YAML (yaml_dumper.dump(target_schema_obj, "biolink-subset.yaml")), the derived model works with standard LinkML tooling, to produce: * python dataclasses and pydantic models of our derived schema * navigate our derived schema with a SchemaView instance * create and deploy automated documentation with the derived schema (see https://github.com/linkml/linkml-project-cookiecutter for more details on using the derived schema in a standard setup)

gen-pydantic biolink-subset.yaml
gen-doc biolink-subset.yaml -d docs