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
MapVersionrefers to, seeSPECIFICATIONS, and the latest specification of every language, seeLATEST, - the glyph and arc classes of every language, see
GLYPH_CLASSESandARC_CLASSES, and the classes which are deprecated, seeDEPRECATED_GLYPH_CLASSES, - the language of a map, which is given by its
versionor by its deprecatedlanguage, seemap_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
¶
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, |
year |
int | None
|
the year the specification was published, None for |
doi |
str | None
|
the DOI of the journal publication, None for the versions which were only published as a preprint. |
map_language
¶
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
¶
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 |
required |
language
|
MapLanguage | str | None
|
the language of the map, a member of |
required |
Returns:
| Type | Description |
|---|---|
MapLanguage | None
|
The language, None if neither the version nor the language is a known value. |
map_specification
¶
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 a map against the rules of the specifications the schema lacks.
The checks are:
- the map declares its language with a
versionor alanguage, one of them is required by SBGN-ML 0.3, - the
versionand thelanguagename 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. |