Skip to content

SBML

momapy.sbml.io.sbml

Classes:

Name Description
SBMLReader

SBMLReader

Bases: Reader

Methods:

Name Description
check_file

Return true if the given file is supported by the reader, false otherwise

read

Read a file and return a reader result using the reader

check_file classmethod

check_file(file_path: str | PathLike)

Return true if the given file is supported by the reader, false otherwise

Source code in src/momapy/sbml/io/sbml.py
@classmethod
def check_file(cls, file_path: str | os.PathLike):
    with open(file_path) as f:
        for line in f:
            if "<sbml " in line:
                return True
    return False

read classmethod

read(
    file_path: str | PathLike,
    with_annotations=True,
    with_notes=True,
) -> ReaderResult

Read a file and return a reader result using the reader

Source code in src/momapy/sbml/io/sbml.py
@classmethod
def read(
    cls,
    file_path: str | os.PathLike,
    with_annotations=True,
    with_notes=True,
) -> momapy.io.ReaderResult:
    sbml_document = lxml.objectify.parse(file_path)
    sbml = sbml_document.getroot()
    obj, annotations, notes, ids = cls._make_main_obj_from_sbml_model(
        sbml_model=sbml.model,
        with_annotations=with_annotations,
        with_notes=with_notes,
    )
    result = momapy.io.ReaderResult(
        obj=obj,
        notes=notes,
        annotations=annotations,
        file_path=file_path,
        ids=ids,
    )
    return result