ID assignment
When reading an SBGN-ML file, every element follows a consistent pattern:
- Model
id_=f"{xml_id}_model" - Layout
id_=xml_id
Both xml_id_to_model_element and xml_id_to_layout_element are keyed by the raw xml_id.
| Element type | Model id_ |
Layout id_ |
Registered | Notes |
|---|---|---|---|---|
| Compartment | f"{glyph_id}_model" |
glyph_id |
yes | |
| EntityPool / Subunit | f"{glyph_id}_model" |
glyph_id |
yes | |
| Activity | f"{glyph_id}_model" |
glyph_id |
yes | |
| StateVariable | f"{glyph_id}_model" |
glyph_id |
yes | Frozen child |
| UnitOfInformation | f"{glyph_id}_model" |
glyph_id |
yes | Frozen child |
| Submap | f"{glyph_id}_model" |
glyph_id |
yes | |
| Terminal / Tag | f"{glyph_id}_model" |
glyph_id |
yes | |
| TerminalRef / TagRef | f"{arc_id}_model" |
arc_id |
yes | Frozen child |
| StoichiometricProcess | f"{glyph_id}_model" |
glyph_id |
yes | |
| Reactant | f"{arc_id}_model" |
arc_id |
yes | Frozen child |
| Product | f"{arc_id}_model" |
arc_id |
yes | Frozen child |
| LogicalOperator | f"{glyph_id}_model" |
glyph_id |
yes | |
| LogicalOperatorInput | f"{arc_id}_model" |
arc_id |
yes | Frozen child |
| Modulation | f"{arc_id}_model" |
arc_id |
yes | |
| Phenotype | f"{glyph_id}_model" |
glyph_id |
yes | In model.processes |
Map, model, and layout IDs come from <map id="...">:
map_.id_=map_idmodel.id_=f"{map_id}_model"layout.id_=f"{map_id}_layout"
These are only set for SBGN-ML 0.3. SBGN-ML 0.2 has no map id, so the builder falls back to UUID defaults.
API
momapy.sbgn.io.sbgnml
Classes for reading and writing SBGN-ML files.
Modules:
| Name | Description |
|---|---|
reader |
SBGN-ML reader classes. |
writer |
SBGN-ML writer classes. |
Classes:
| Name | Description |
|---|---|
SBGNML0_2Reader |
Class for SBGN-ML 0.2 reader objects |
SBGNML0_3Reader |
Class for SBGN-ML 0.3 reader objects |
SBGNML0_3Writer |
Class for SBGN-ML 0.3 writer objects. |
SBGNML0_2Reader
Bases: _SBGNMLReader
Class for SBGN-ML 0.2 reader objects
Methods:
| Name | Description |
|---|---|
check_file |
Return |
read |
Read an SBGN-ML file and return a reader result object |
check_file
classmethod
Return true if the given file is an SBGN-ML 0.2 document, false otherwise
Source code in src/momapy/sbgn/io/sbgnml/reader.py
read
classmethod
read(file_path: str | PathLike, return_type: Literal['map', 'model', 'layout'] = 'map', with_model: bool = True, with_layout: bool = True, with_annotations: bool = True, with_notes: bool = True, xsep: float = 0, ysep: float = 0) -> ReaderResult
Read an SBGN-ML file and return a reader result object
Source code in src/momapy/sbgn/io/sbgnml/reader.py
SBGNML0_3Reader
Bases: _SBGNMLReader
Class for SBGN-ML 0.3 reader objects
Methods:
| Name | Description |
|---|---|
check_file |
Return |
read |
Read an SBGN-ML file and return a reader result object |
check_file
classmethod
Return true if the given file is an SBGN-ML 0.3 document, false otherwise
Source code in src/momapy/sbgn/io/sbgnml/reader.py
read
classmethod
read(file_path: str | PathLike, return_type: Literal['map', 'model', 'layout'] = 'map', with_model: bool = True, with_layout: bool = True, with_annotations: bool = True, with_notes: bool = True, xsep: float = 0, ysep: float = 0) -> ReaderResult
Read an SBGN-ML file and return a reader result object
Source code in src/momapy/sbgn/io/sbgnml/reader.py
SBGNML0_3Writer
Bases: _SBGNMLWriter
Class for SBGN-ML 0.3 writer objects.
Methods:
| Name | Description |
|---|---|
write |
Write an SBGN map to an SBGN-ML file. |
write
classmethod
write(obj: SBGNMap, file_path: str | PathLike, element_to_annotations: dict | None = None, element_to_notes: dict | None = None, source_id_to_model_element: dict | None = None, source_id_to_layout_element: dict | None = None, with_render_information: bool = True, with_annotations: bool = True, with_notes: bool = True) -> None
Write an SBGN map to an SBGN-ML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
SBGNMap
|
The SBGN map to serialize. |
required |
file_path
|
str | PathLike
|
Destination file path. |
required |
element_to_annotations
|
dict | None
|
Optional per-element annotation dict. |
None
|
element_to_notes
|
dict | None
|
Optional per-element notes dict. |
None
|
source_id_to_model_element
|
dict | None
|
Optional source ID to model element mapping from ReaderResult. |
None
|
source_id_to_layout_element
|
dict | None
|
Optional source ID to layout element mapping from ReaderResult. |
None
|
with_render_information
|
bool
|
Ignored (kept for API compat). |
True
|
with_annotations
|
bool
|
Whether to write annotations. |
True
|
with_notes
|
bool
|
Whether to write notes. |
True
|