Skip to content

SBML

Read and write SBML models. A reaction becomes a directed hyperedge: the reactants are on one side, the products on the other, and the stoichiometric coefficients are kept on the edge. A boundary reaction becomes a one-sided edge with the is_boundary edge attribute.

from_sbml reads the file with python-libsbml. from_sbml_cobra and from_cobra_model read through COBRApy, from a file or from a COBRApy model object.

annnet.io.sbml.from_sbml

from_sbml(
    path,
    graph=None,
    *,
    slice="default",
    preserve_stoichiometry=True,
    layer=None
)

Read an SBML file into an AnnNet hypergraph.

Parameters:

Name Type Description Default
path str

Path to the .xml / .sbml file.

required
graph AnnNet | None

Optional existing AnnNet to merge into.

None
slice str

AnnNet slice name for default placement. Compartment-specific species will additionally appear in their compartment slice.

'default'
preserve_stoichiometry bool

Write signed stoichiometric coefficients into the incidence matrix via set_edge_coeffs (reactants negative, products positive, modifiers -1). Default True.

True

annnet.io.sbml.to_sbml

to_sbml(graph, path, *, model_id='annnet', sidecar=True)

Write the graph as an SBML Level 3 document.

from_sbml_cobra

from_sbml(
    path,
    graph=None,
    *,
    slice="default",
    preserve_stoichiometry=True
)

Read SBML using COBRApy if available.

annnet.io.sbml_cobra.from_cobra_model

from_cobra_model(
    model,
    graph=None,
    *,
    slice="default",
    preserve_stoichiometry=True
)

Convert a COBRApy model to AnnNet. Requires cobra.util.array.create_stoichiometric_matrix.

Edge attributes added: name, default_lb, default_ub, gpr (Gene-Protein-Reaction rule [GPR]).