sbmlutils.validation

Helpers for validation and checking of SBML and libsbml operations.

Module Contents

Classes

ValidationOptions

Options for SBML validator.

ValidationResult

Results of an SBMLDocument validation.

Functions

check(value, message)

Check the libsbml return value and prints message if something happened.

log_sbml_errors_for_doc(doc)

Log errors of current SBMLDocument.

log_sbml_error(error[, index])

Log SBMLError.

error_string(error[, index])

Get string representation and severity of SBMLError.

validate_doc(doc[, options, title])

Validate SBMLDocument.

_check_consistency(doc[, internal_consistency])

Calculate the type of errors.

Attributes

logger

sbmlutils.validation.logger[source]
sbmlutils.validation.check(value, message)[source]

Check the libsbml return value and prints message if something happened.

If ‘value’ is None, prints an error message constructed using

‘message’ and then exits with status code 1. If ‘value’ is an integer, it assumes it is a libSBML return status code. If the code value is LIBSBML_OPERATION_SUCCESS, returns without further action; if it is not, prints an error message constructed using ‘message’ along with text from libSBML explaining the meaning of the code, and exits with status code 1.

Parameters:
  • value (int) –

  • message (str) –

Return type:

bool

class sbmlutils.validation.ValidationOptions[source]

Options for SBML validator.

Controls the consistency checks that are performed when SBMLDocument.checkConsistency() is called.

  • general_consistency: Correctness and consistency of

specific SBML language constructs. Performing this set of checks is highly recommended. With respect to the SBML specification, these concern failures in applying the validation rules numbered 2xxxx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • ìdentifier_consistency: Correctness and consistency of

identifiers used for model entities. An example of inconsistency would be using a species identifier in a reaction rate formula without first having declared the species. With respect to the SBML specification, these concern failures in applying the validation rules numbered 103xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • units_consistency: Consistency of measurement units

associated with quantities in a model. With respect to the SBML specification, these concern failures in applying the validation rules numbered 105xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • mathml_consistency: Syntax of MathML constructs. With

respect to the SBML specification, these concern failures in applying the validation rules numbered 102xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • sbo_consistency: Consistency and validity of SBO

identifiers (if any) used in the model. With respect to the SBML specification, these concern failures in applying the validation rules numbered 107xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • overdetermined_model: Static analysis of whether the

system of equations implied by a model is mathematically overdetermined. With respect to the SBML specification, this is validation rule #10601 in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • modeling_practise: Additional checks for recommended

good modeling practice. (These are tests performed by libSBML and do not have equivalent SBML validation rules.) By default, all validation checks are applied to the model in an SBMLDocument object unless SBMLDocument.setConsistencyChecks() is called to indicate that only a subset should be applied. Further, this default (i.e., performing all checks) applies separately to each new SBMLDocument object created. In other words, each time a model is read using SBMLReader.readSBML(), SBMLReader.readSBMLFromString(), or the global functions readSBML() and readSBMLFromString(), a new SBMLDocument is created and for that document, a call to SBMLDocument.checkConsistency() will default to applying all possible checks. Calling programs must invoke SBMLDocument.setConsistencyChecks() for each such new model if they wish to change the consistency checks applied.

  • internal_consistency: Additional checks that model is consistent XML.

  • log_errors Boolean flag to log errors.

log_errors: bool = True[source]
internal_consistency: bool = True[source]
general_consistency: bool = True[source]
identifier_consistency: bool = True[source]
mathml_consistency: bool = True[source]
units_consistency: bool = True[source]
sbo_consistency: bool = True[source]
overdetermined_model: bool = True[source]
modeling_practice: bool = True[source]
class sbmlutils.validation.ValidationResult(errors=None, warnings=None)[source]

Results of an SBMLDocument validation.

Parameters:
  • errors (Optional[List[libsbml.SBMLError]]) –

  • warnings (Optional[List[libsbml.SBMLError]]) –

property error_count: int[source]

Get number of errors.

Return type:

int

property warning_count: int[source]

Get number of warnings.

Return type:

int

property all_count: int[source]

Get number of errors and warnings.

Return type:

int

static from_results(results)[source]

Parse from ValidationResult.

Parameters:

results (Iterable[ValidationResult]) –

Return type:

ValidationResult

log()[source]

Log errors and warnings.

Return type:

None

is_valid()[source]

Get valid status (valid model), i.e., no errors.

Return type:

bool

is_perfect()[source]

Get perfect status (perfect model), i.e., no errors and warnings.

Return type:

bool

sbmlutils.validation.log_sbml_errors_for_doc(doc)[source]

Log errors of current SBMLDocument.

Parameters:

doc (libsbml.SBMLDocument) –

Return type:

None

sbmlutils.validation.log_sbml_error(error, index=None)[source]

Log SBMLError.

Parameters:
  • error (libsbml.SBMLError) –

  • index (Optional[int]) –

Return type:

None

sbmlutils.validation.error_string(error, index=None)[source]

Get string representation and severity of SBMLError.

Parameters:
  • error (libsbml.SBMLError) –

  • index (Optional[int]) –

Return type:

tuple

sbmlutils.validation.validate_doc(doc, options=None, title=None)[source]

Validate SBMLDocument.

Parameters:
  • doc (libsbml.SBMLDocument) – SBMLDocument to check

  • title (Optional[str]) – identifier or path for validation report

  • options (Optional[ValidationOptions]) – validation options and settings.

Returns:

ValidationResult

Return type:

ValidationResult

sbmlutils.validation._check_consistency(doc, internal_consistency=False)[source]

Calculate the type of errors.

Parameters:
  • doc (libsbml.SBMLDocument) – SBMLDocument

  • internal_consistency (bool) – flag for internal consistency

Returns:

ValidationResult

Return type:

ValidationResult