Biolink modeling language

This project is maintained by biolink

Pyversions PyPi

Binder Link

biolinkml - biolink modeling language

biolinkml is a general purpose modeling language following object-oriented and ontological principles. Models are authored in YAML. A variety of artefacts can be generated from the model, including ShEx, JSON-Schema, OWL, Python dataclasses, UML diagrams, Markdown pages for deployment in a GitHub pages site, and more.

biolinkml is used for development of the BioLink Model, but the framework is general purpose and can be used for any kind of modeling.

This documentation is best seen via the biolinkml site but can also be viewed via the GitHub repository

Quickstart docs:

Further details about the general design of BiolinkML are in the Biolink Modeling Language Specification.

For an example, see the Jupyter notebook example


This project uses pipenv to install. Some IDE’s like PyCharms also have direct support for pipenv. Once pipenv is running, the project may be installed:

> pipenv install biolinkml

Language Features


biolinkml can be used as a modeling language in its own right, or it can be compiled to other schema/modeling languages

We use a basic schema for illustrative purposes:

name: organization

    base: int
    uri: xsd:int
    base: str
    uri: xsd:string


      - id
      - name
      - has boss

    description: A person
      - id
      - first name
      - last name
      - aliases
      - age in years
      last name :
        required: true

    description: An employee who manages others
    is_a: employee
      - has employees

    description: Unique identifier of a person
    identifier: true

    description: human readable name
    range: string

    is_a: name
    description: An alternative name
    multivalued: true

  first name:
    is_a: name
    description: The first name of a person

  last name:
    is_a: name
    description: The last name of a person

  age in years:
    description: The age of a person if living or age of death if not
    range: yearCount

  has employees:
    range: employee
    multivalued: true
    inlined: true

  has boss:
    range: manager
    inlined: true

Note this schema does not illustrate the more advanced features of blml



JSON Schema

JSON Schema is a schema language for JSON documents

JSON schema can be derived from a biolinkml schema, for example:

pipenv run gen-json-schema examples/organization.yaml

Output: examples/organization.schema.json

Note that any JSON that conforms to the derived JSON-Schema can be converted to RDF using the derived JSON-LD context.

JSON-LD Context

JSON-LD contexts provide a mapping from JSON to RDF

A JSON-LD context can be derived from a biolinkml schema, for example:

pipenv run gen-jsonld-context examples/organization.yaml

Output: examples/organization.context.jsonld

You can control this via prefixes declarations and default_curi_maps.

Any JSON that conforms to the derived JSON-Schema (see above) can be converted to RDF using this context. See the Jupyter notebook example for an example.

You can also combine a JSON instance file with a JSON-LD context using simple code or a tool like jq

jq -s '.[0] * .[1]' examples/organization-data.json examples/organization.context.jsonld > examples/organization-data.jsonld

You can then use a standard JSON-LD conversion file to make other RDF syntaxes, e.g.

riot examples/organization-data.jsonld > examples/organization-data.nt

See examples/organization-data.nt

Python DataClasses

pipenv run gen-py-classes examples/organization.yaml > examples/

See examples/

For example:

class Organization(YAMLRoot):
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = URIRef("")
    class_class_curie: ClassVar[str] = None
    class_name: ClassVar[str] = "organization"
    class_model_uri: ClassVar[URIRef] = URIRef("")

    id: Union[str, OrganizationId]
    name: Optional[str] = None
    has_boss: Optional[Union[dict, "Manager"]] = None

    def __post_init__(self, **kwargs: Dict[str, Any]):
        if is None:
            raise ValueError(f"id must be supplied")
        if not isinstance(, OrganizationId):
   = OrganizationId(
        if self.has_boss is not None and not isinstance(self.has_boss, Manager):
            self.has_boss = Manager(self.has_boss)

For more details see PythonGenNotes

The python object can be direcly serialized as RDF. See the Jupyter notebook example for an example.


ShEx - Shape Expressions Langauge

pipenv run gen-shex examples/organization.yaml > examples/organization.shex

PREFIX rdf: <>
PREFIX xsd1: <>

<YearCount> xsd1:int

<String> xsd1:string

<Employee>  (
    CLOSED {
       (  $<Employee_tes> (  <first_name> @<String> ? ;
             <last_name> @<String> ;
             <aliases> @<String> * ;
             <age_in_years> @<YearCount> ?
          ) ;
          rdf:type [ <Employee> ]
    } OR @<Manager>

<Manager> CLOSED {
    (  $<Manager_tes> (  &<Employee_tes> ;
          rdf:type [ <Employee> ] ? ;
          <has_employees> @<Employee> *
       ) ;
       rdf:type [ <Manager> ]

<Organization> CLOSED {
    (  $<Organization_tes> (  <name> @<String> ? ;
          <has_boss> @<Manager> ?
       ) ;
       rdf:type [ <Organization> ]

See examples/organization.shex for full output


Web Ontology Language OWL

pipenv run gen-owl examples/organization.yaml > examples/organization.owl.ttl

<> a owl:Class,
        meta:ClassDefinition ;
    rdfs:label "organization" ;
    rdfs:subClassOf [ a owl:Restriction ;
            owl:onClass <> ;
            owl:onProperty <> ;
            owl:qualifiedCardinality 1 ],
        [ a owl:Restriction ;
            owl:maxQualifiedCardinality 1 ;
            owl:onClass <> ;
            owl:onProperty <> ],
        [ a owl:Restriction ;
            owl:maxQualifiedCardinality 1 ;
            owl:onClass <> ;
            owl:onProperty <> ] .

See examples/organization.owl.ttl for full output

Generating Markdown documentation

pipenv run gen-markdown examples/organization.yaml -d examples/organization-docs/

This will generate a markdown document for every class and slot in the model. These can be used in a static site, e.g. via GitHub pages.



See the specification.

Also see the semantics folder for an experimental specification in terms of FOL.


Why not use X as the modeling framework?

Why invent our own yaml and not use JSON-Schema, SQL, UML, ProtoBuf, OWL, …

each of these is tied to a particular formalisms. E.g. JSON-Schema to trees. OWL to open world logic. There are various impedance mismatches in converting between these. The goal was to develop something simple and more general that is not tied to any one serialization format or set of assumptions.

There are other projects with similar goals, e.g

It may be possible to align with these.

Why not use X as the datamodel

Here X may be bioschemas, some upper ontology (BioTop), UMLS metathesaurus, bio*, various other attempts to model all of biology in an object model.

Currently as far as we know there is no existing reference datamodel that is flexible enough to be used here.

Type Definitions

    domain: type definition
    range: type definition
    description: supertype

    domain: type definition
    description: python base type that implements this type definition
    inherited: true

  type uri:
    domain: type definition
    range: uri
    alias: uri
    description: the URI to be used for the type in semantic web mappings

    domain: type definition
    range: string
    description: the python representation of this type if different than the base type
    inherited: true

Slot Definitions

Developers Notes

Release to Pypi

[A Github action] is set up to automatically release the Pypi package. When it is ready for a new release, create a Github release. The version should be in the vX.X.X format following the semantic versioning specification.

After the release is created, the GitHub action will be triggered to publish to Pypi. The release version will be used to create the Pypi package.

If the Pypi release failed, make fixes, delete the GitHub release, and recreate a release with the same version again.

Additional Documentation

Example Projects