booldog.io.sbml
Read-write SBML-qual files
Notes
SBML-qual code is inspired by:
- loadSBML.R of BoolNet (January 2024)
https://github.com/cran/BoolNet/blob/af3a714c5bfa72ee7507db9c4eaf90ba2cd91809/R/loadSBML.R
- sbmlqual.py of CellNOpt (January 2024)
Attributes
Exceptions
Custom Exception for SBML parsing |
Classes
Parse SBML transition to bnet format |
|
Parse MathML to bnet format |
|
Functions
|
Create Network from a SBML-qual file |
|
Module Contents
- booldog.io.sbml._SBML_AVAILABLE = True
- booldog.io.sbml.logger
- booldog.io.sbml.SBML_INT_MAX = 2147483647
- booldog.io.sbml.TOKEN_REGEX
- exception booldog.io.sbml.BoolDogSBMLException
Bases:
ExceptionCustom Exception for SBML parsing
- class booldog.io.sbml.SBMLQualReader(file)
- file
- document
- model
- model_id
- plugin
- all_species
- species_names
- transitions
- rules
- _get_qual_plugin()
- _get_all_species()
- _get_all_transitions()
- _get_all_rules()
- to_bnet()
Converts the SBML-qual file to a bnet format.
- Returns:
bnet – bnet representation of the Boolean network.
- Return type:
str
- class booldog.io.sbml.TransitionParser
Parse SBML transition to bnet format
- static parse_io(transition, all_species)
Extract transition inputs and outputs.
- Parameters:
transition (libsbml::Transition) – Transition specifying the logical rule associated with the Transition outputs.
all_species (list) – List ids of all species present in model
- Returns:
inputs (dict) – Dictionary of id: species information for this transition’s inputs
outputs (list) – List of this transition’s outputs (dependents)
- static parse_function(transition, all_species, inputs)
Parse transition function to a logical rule.
- Parameters:
transition (libsbml::Transition) – Transition specifying the logical rule associated with the Transition outputs.
all_species (list) – List ids of all species present in model
inputs (dict) – Dictionary of id: species information for this transition’s inputs
- Returns:
logic_rule – Logic rule of this transition (in bnet format)
- Return type:
str
- class booldog.io.sbml.MathMLParser
Parse MathML to bnet format
- static parse(node, all_species, inputs, level=0)
- static _handle_operator(operator, children, level)
- static _handle_xor(children)
Create disjunctive normal form (DNF) of an xor
- static _handle_comparison(operator, children)
Return bnet form of an (mathml) operator between two children.
- class booldog.io.sbml.SBMLQualWriter(network, level=3, version=1, qual_version=1)
- network
- mplugin
- node_dict
- doc
- write(outfile)
- _add_species()
- _add_transitions()
- _rule_to_formula(rule, input_node_dict)
Rule (as in bnet) to a formula as supported by parseL3Formula
Notes
Replaces:
& with &&
| with ||
To support thresholds, we need to replace the bnet format with a format supported by libsbml’s parseL3Formula:
A to (A >= theta_A) f”({node_dict[node]} >= {input_node_dict[node]})”
!A to (A < theta_A) f”({node_dict[node]} < {input_node_dict[node]})”
This is currently NOT implemented.
- booldog.io.sbml.read_sbmlqual(file)
Create Network from a SBML-qual file
- Parameters:
file (str) – Path to SBML-qual file.
Notes
The SBML-qual file is converted to a Boolean network using libsbml, via the bnet format. To access the bnet format directly, you can use py:booldog.io.sbmlqual2bnet.
- booldog.io.sbml.write_sbmlqual(model, outfile, **kwargs)