Input and Output (corneto.io)#

This page documents the public API for the corneto.io package.

File-based loaders accept local paths, HTTP(S) URLs, and readable streams. A string is treated as a URL only when it has an HTTP(S) scheme; path-like objects are always local paths. Binary loaders require binary streams, while the SIF loaders also accept text streams. Borrowed streams are read from their current position and remain open after loading. Compression defaults to "auto", which detects gzip, bz2, and xz by magic bytes; pass compression=None to disable decompression or choose an explicit codec. HTTP(S) requests use a 30 second timeout by default, configurable with timeout. It limits each blocking HTTP operation, not the total time for a download. Inline XML or SIF strings are not treated as file contents.

For example, SIF data can be read from a remote URL or an already-open stream:

from io import BytesIO
from corneto.io import load_graph_from_sif

graph_from_url = load_graph_from_sif("https://example.org/network.sif.gz")
graph_from_stream = load_graph_from_sif(BytesIO(b"A\t1\tB\n"))

For static SBML Level 3 Version 1 Core models with FBC Version 2 and optional Groups Version 1, the native import_sbml_model reader parses with the Python standard library and does not require COBRApy. It preserves SBML identifiers and records boundary or constant species in graph metadata while excluding them from mass-balance vertices. The active FBC objective is stored in the graph’s fba_objective attribute using FBA’s minimization convention; pass it explicitly to MultiSampleFBA.build(..., objectives=...) when it should drive optimization. Use import_cobra_model for SBML features outside the native reader’s supported subset.

from corneto.io import import_sbml_model
from corneto.methods.fba import MultiSampleFBA

model = import_sbml_model("metabolic_model.xml")
objective = model.get_graph_attributes()["fba_objective"]
problem = MultiSampleFBA().build(model, objectives=objective)

Corneto I/O module.

This module provides functions for loading and saving biological networks in various formats, including SIF and GML. It also includes functions to convert metabolic and signaling models to network graphs.

Metabolism#

parse_cobra_model(model)

Parse a COBRA metabolic model and extract its core components.

cobra_model_to_graph(model)

Create graph from COBRA metabolic model.

import_cobra_model(path[, quiet, ...])

Import a COBRA model from an SBML file and convert it to a CORNETO graph.

import_miom_model(model_or_path, *[, ...])

Create graph from MIOM metabolic model.

MetabolicModel([model_info, compartments, ...])

Plain parsed SBML records, independent of CORNETO.

read_sbml(source, *[, annotations, ...])

Read supported metabolic SBML into plain Python records.

sbml_model_to_graph(model)

Convert parsed SBML records to a CORNETO metabolic hypergraph.

import_sbml_model(source, *[, annotations, ...])

Read supported SBML and convert it to a CORNETO metabolic graph.

Signaling#

load_graph_from_sif(sif_file[, delimiter, ...])

Create a graph from a local, remote, or file-like SIF source.

load_graph_from_sif_tuples(tuples)

Create graph from iterable of SIF tuples.