SBML - momapy

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`

    93
    94
    95
    96
    97
    98
    99
    @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`

    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    @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