Ejemplo n.º 1
0
def _check_consistency(doc: libsbml.SBMLDocument, internalConsistency=False, show_errors=True):
    Nerr = 0  # error count
    Nwarn = 0  # warning count
    if internalConsistency:
        Nall = doc.checkInternalConsistency()
    else:
        Nall = doc.checkConsistency()

    if Nall > 0:
        for i in range(Nall):
            severity = doc.getError(i).getSeverity()
            if (severity == libsbml.LIBSBML_SEV_ERROR) or (severity == libsbml.LIBSBML_SEV_FATAL):
                Nerr += 1
            else:
                Nwarn += 1

        doc.printErrors()

    return Nall, Nerr, Nwarn
Ejemplo n.º 2
0
def is_sbml_consistent(sbml_document: libsbml.SBMLDocument, check_units=False):
    """Check for SBML validity / consistency

    Arguments:
        sbml_document: SBML document to check
        check_units: Also check for unit-related issues
    Returns:
        False if problems were detected, otherwise True
    """

    if not check_units:
        sbml_document.setConsistencyChecks(
            libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, False)

    has_problems = sbml_document.checkConsistency()
    if has_problems:
        log_sbml_errors(sbml_document)
        logger.warning(
            'WARNING: Generated invalid SBML model. Check messages above.')

    return not has_problems