parser¶
Parse SBML and antimony into the Model of sbmlutils.factory.
sbml_to_model is the inverse of create_model. A round trip
SBML -> sbml_to_model -> create_model -> SBML preserves SBML core, see
https://github.com/matthiaskoenig/sbmlutils/issues/469. It reads the unit
definitions, the model units and conversionFactor, the function definitions,
compartments, species and parameters, the reactions with their species
references, modifiers and kinetic laws with local parameters, the initial
assignments, rules, events with their trigger, priority, delay and event
assignments, and constraints, and on each of these its id, name, metaid,
sboTerm, notes, annotations and fbc key-value pairs. An element without math,
which SBML allows from L3V2 on, is read without math. It also reads
fbc:strict of the model, its gene products and objectives with their flux
objectives, the gene product association of a reaction, as an infix string of
gene product ids, its flux bounds, the charge and chemical formula of a
species, and the user-defined constraints of the model with their components.
A document which declares fbc version 1 is converted to fbc version 2 before
it is read, see _convert_fbc_v1. Of distrib it reads the uncertainties of
every element, with their uncert parameters and spans in the order of the
document, and on each of those its type, value, variable, bounds, unit,
definitionURL, math and the uncert parameters of an external distribution, see
_parse_uncertainties. Of comp it reads the submodels of a model with their
deletions, its ports, the replaced elements and the replacedBy of every
element, each with the whole nested sBaseRef chain below it, and the model
definitions and external model definitions of the document; a model definition
is read by recursing into _parse_model_body, so everything of every package
inside it is read as it is for the model of the document. An external model
definition is preserved as the reference it is, source, modelRef and md5:
the file it names is not opened and its content is not resolved into the
document.
Not read are the model history, the content of the groups and layout
packages, an uncertainty on an element which cannot carry one and a
<comp:replacedBy> on an element which cannot carry one, both of which are
reported (_drop_uncertainties, _drop_replaced_by; of the elements libsbml
reads a replacement from at all, a species reference and a local parameter
are the two whose replacement is dropped), a
<comp:replacedElement> of an element which has neither an id nor a metaid,
which sbmlutils.factory has no way to name and which is reported
(_parse_replaced_elements), the comp:substanceConversionFactor libsbml
reads on a submodel although comp version 1 does not define it, and of fbc
the metadata of a gene product association and of the and, or and
geneProductRef nodes of its association, which the infix string has no place
for, and the fbc version 3 reaction2 of a flux objective and variable2 of
a user-defined constraint component, which the factory has no field for. The
fbc, distrib and comp packages a document declares are declared on the
model.
Math is read as an L3 infix string, in which an id named like a MathML
constant or csymbol (pi, INF, NaN, time, avogadro) cannot be told
apart from the constant, so such an id does not round trip.
antimony_to_model
¶
Parse antimony model.
sbml_to_model
¶
Parse an SBML document into the Model of sbmlutils.factory, see the module docstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | str
|
an SBML file path, an SBML string, or a URL, passed through
to |
required |
validate
|
bool
|
whether to validate the document while reading it |
False
|
promote
|
bool
|
whether to promote local parameters to global parameters |
False
|
validation_options
|
ValidationOptions | None
|
which validation checks to run, only used when
|
None
|
Returns:
| Type | Description |
|---|---|
Model
|
the parsed |
Model
|
written back out without the authoring hints of a model definition |
Raises:
| Type | Description |
|---|---|
AttributeError
|
if |
ValueError
|
if the document declares fbc version 1 and libsbml cannot convert it to fbc version 2 |