Skip to content

specification

The SBGN specifications: versions, vocabularies and the checks beyond the schema.

The SBGN-ML schema has a single enumeration of glyph classes and of arc classes for all three languages, it does not know which classes belong to which language, and it cannot express that a map declares its language. This module holds what the specifications add on top of the schema:

  • the specification every MapVersion refers to, see SPECIFICATIONS, and the latest specification of every language, see LATEST,
  • the glyph and arc classes of every language, see GLYPH_CLASSES and ARC_CLASSES, and the classes which are deprecated, see DEPRECATED_GLYPH_CLASSES,
  • the language of a map, which is given by its version or by its deprecated language, see map_language,
  • the check of a document against these rules, see check_sbgn.
from pathlib import Path

from libsbgnpy import check_sbgn, read_sbgn_from_file

sbgn = read_sbgn_from_file(Path("map.sbgn"))
for error in check_sbgn(sbgn):
    print(error)

The validation rules of the language specifications, e.g., which arcs may connect which glyphs, are not checked.

Specification dataclass

Specification(
    *, language, level, version, year=None, doi=None
)

A specification of an SBGN language.

Attributes:

Name Type Description
language MapLanguage

the language the specification defines.

level int

the level of the specification.

version str

the version of the specification, "1" stands for the latest version 1.x at the time the identifier was registered.

year int | None

the year the specification was published, None for "1".

doi str | None

the DOI of the journal publication, None for the versions which were only published as a preprint.

name property

name

Short name of the specification, e.g., "PD L1V2.1".

map_language

map_language(map)

Get the language of a map.

SBGN-ML 0.3 deprecated the language of a map in favour of its version, which names the language together with the level and the version of its specification. The language is therefore taken from the version, and from the deprecated language if the map has no version.

Parameters:

Name Type Description Default
map Map

the map.

required

Returns:

Type Description
MapLanguage | None

The language of the map, None if neither its version nor its language is a known value.

language_of

language_of(version, language)

Get the language of a map from its version and its language.

The rule of map_language for the values of the attributes, e.g., as they are in a document which is not bound: the language is taken from the version, else from the language.

Parameters:

Name Type Description Default
version MapVersion | str | None

the version of the map, a member of MapVersion or its value.

required
language MapLanguage | str | None

the language of the map, a member of MapLanguage or its value.

required

Returns:

Type Description
MapLanguage | None

The language, None if neither the version nor the language is a known value.

map_specification

map_specification(map)

Get the specification a map refers to with its version.

Parameters:

Name Type Description Default
map Map

the map.

required

Returns:

Type Description
Specification | None

The specification, None if the map has no known version.

check_map

check_map(map)

Check a map against the rules of the specifications the schema lacks.

The checks are:

  • the map declares its language with a version or a language, one of them is required by SBGN-ML 0.3,
  • the version and the language name the same language,
  • every glyph and every arc has a class of the language of the map.

Classes which are deprecated are allowed, they are logged as a warning. Unknown values of an enumeration are errors of the schema and not repeated here, see validate_xsd.

Parameters:

Name Type Description Default
map Map

the map.

required

Returns:

Type Description
list[str]

The errors, empty if the map follows the rules.

check_sbgn

check_sbgn(sbgn)

Check every map of a document, see check_map.

Parameters:

Name Type Description Default
sbgn Sbgn

the SBGN document.

required

Returns:

Type Description
list[str]

The errors, empty if all maps follow the rules.