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 a COBRA metabolic model and extract its core components. |
|
Create graph from COBRA metabolic model. |
|
Import a COBRA model from an SBML file and convert it to a CORNETO graph. |
|
Create graph from MIOM metabolic model. |
|
Plain parsed SBML records, independent of CORNETO. |
|
Read supported metabolic SBML into plain Python records. |
|
Convert parsed SBML records to a CORNETO metabolic hypergraph. |
|
Read supported SBML and convert it to a CORNETO metabolic graph. |
Signaling#
|
Create a graph from a local, remote, or file-like SIF source. |
|
Create graph from iterable of SIF tuples. |