rust¶
The reader and the converter in rust (crates/, issue #68).
The rust crates convert a CellML document to SBML and an SBML document to
CellML without libcellml and without libsbml, which the module
sbml2cellml._rust (crates/python, built into the wheel by maturin) makes
available in the process. It is the default engine of
cellml2sbml.convert_cellml2sbml and of sbml2cellml.convert_sbml2cellml:
the conversion is faster than the one through libcellml by two orders of
magnitude, and it is the code which runs in a browser next to sbmlsim-core.
What the rust converter does not do is left to libcellml and libsbml by the
caller: the imports of a CellML document (has_imports, which cellml2sbml
flattens with libcellml before it hands the document over), the submodels of
a hierarchical SBML model (which sbml2cellml flattens with libsbml) and
the hierarchical conversion to the comp package of SBML. The metadata of
the elements is written and applied for both engines: a conversion gives
the SBML element of every CellML element which stands for one (Origin,
Mapping), which the python package turns into the RDF of the CellML model
and back onto the elements of the SBML model.
RustError
¶
Bases: ValueError
The rust reader or the rust converter refused a document.
convert_cellml_to_sbml
¶
Convert a CellML document to SBML level 3 version 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
the CellML document, with its imports resolved. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The SBML document, the warnings of the conversion and the SBML |
list[str]
|
element of every CellML element with an id ( |
list[Mapping]
|
metadata of the conversion needs. |
Raises:
| Type | Description |
|---|---|
RustError
|
if the document cannot be read or converted. |
convert_sbml_to_cellml
¶
Convert an SBML document to CellML 2.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
the SBML document of any level and version, with the submodels of a hierarchical model flattened. |
required |
name
|
str
|
the name of the CellML model when the SBML model has no id. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The CellML document, the warnings of the conversion and the SBML |
list[str]
|
element of every element of the CellML model which stands for one |
list[Origin]
|
( |
Raises:
| Type | Description |
|---|---|
RustError
|
if the document cannot be read or converted. |
cellml_version
¶
The version of CellML a document is written in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
the CellML document. |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
Raises:
| Type | Description |
|---|---|
RustError
|
if the document is no CellML model. |
has_imports
¶
Whether a document imports a component or units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
the CellML document. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
resolved. |
Raises:
| Type | Description |
|---|---|
RustError
|
if the document is no CellML model. |