Skip to content

validator

Validation of SBGN documents.

validate_xsd validates against the SBGN XSD schema, the packaged SBGN-ML 0.3 schema in libsbgnpy/schema/SBGN.xsd. Documents in the earlier namespaces are upconverted before they are validated, i.e., the same documents are read and validated. validate adds the rules of the SBGN specifications which the schema cannot express, see libsbgnpy.specification. The schematron rules of the SBGN languages are checked separately, see libsbgnpy.schematron.

from pathlib import Path

from libsbgnpy import validate

errors = validate(Path("map.sbgn"))
if errors:
    for error in errors:
        print(error)

validate_xsd

validate_xsd(f)

Validate an SBGN file against the SBGN XSD schema.

The file is decoded with the encoding its XML declaration names, UTF-8 by default; a file which is no well-formed XML is reported as a single error.

Parameters:

Name Type Description Default
f Path

path of the SBGN file

required

Returns:

Type Description
list[str]

The validation errors, empty if the document is valid.

Raises:

Type Description
OSError

if the file cannot be read

validate

validate(f)

Validate an SBGN file against the schema and the SBGN specifications.

The errors of validate_xsd are followed by the errors of check_sbgn, i.e., of the rules of the specifications which the schema cannot express. A document which cannot be read is only checked against the schema.

Parameters:

Name Type Description Default
f Path

path of the SBGN file

required

Returns:

Type Description
list[str]

The validation errors, empty if the document is valid.

Raises:

Type Description
OSError

if the file cannot be read