# amici.sbml_import.SbmlImporter¶

class amici.sbml_import.SbmlImporter(sbml_source, show_sbml_warnings=False, from_file=True)[source]

Class to generate AMICI C++ files for a model provided in the Systems Biology Markup Language (SBML).

Variables
• show_sbml_warnings – indicates whether libSBML warnings should be displayed

• symbols – dict carrying symbolic definitions

Warning

Not storing this may result in a segfault.

• sbml_doc

document carrying the sbml definition

Warning

Not storing this may result in a segfault.

• sbml – SBML model to import

• compartments – dict of compartment ids and compartment volumes

• stoichiometric_matrix – stoichiometric matrix of the model

• flux_vector – reaction kinetic laws

• _local_symbols – model symbols for sympy to consider during sympification see localsargument in sympy.sympify

• species_assignment_rules – Assignment rules for species. Key is symbolic identifier and value is assignment value

• compartment_assignment_rules – Assignment rules for compartments. Key is symbolic identifier and value is assignment value

• parameter_assignment_rules – assignment rules for parameters, these parameters are not permissible for sensitivity analysis

• initial_assignments – initial assignments for parameters, these parameters are not permissible for sensitivity analysis

• sbml_parser_settings – sets behaviour of SBML Formula parsing

__init__(sbml_source, show_sbml_warnings=False, from_file=True)[source]

Create a new Model instance.

Parameters
• sbml_source (typing.Union[str, libsbml.Model]) – Either a path to SBML file where the model is specified, or a model string as created by sbml.sbmlWriter( ).writeSBMLToString() or an instance of libsbml.Model.

• show_sbml_warnings (bool) – Indicates whether libSBML warnings should be displayed.

• from_file (bool) – Whether sbml_source is a file name (True, default), or an SBML string

Methods Summary

 __init__(sbml_source[, show_sbml_warnings, …]) Create a new Model instance. add_d_dt(d_dt, variable, variable0, name) Creates or modifies species, to implement rate rules for compartments and species, respectively. add_local_symbol(key, value) Add local symbols with some sanity checking for duplication which would indicate redefinition of internals, which SBML permits, but we don’t. Check possible events in the model, as AMICI does currently not support Check whether all required SBML features are supported. is_assignment_rule_target(element) Checks if an element has a valid assignment rule in the specified model. is_rate_rule_target(element) Checks if an element has a valid assignment rule in the specified model. process_conservation_laws(ode_model, …) Find conservation laws in reactions and species. sbml2amici([model_name, output_dir, …]) Generate and compile AMICI C++ files for the model provided to the constructor.

Methods

__init__(sbml_source, show_sbml_warnings=False, from_file=True)[source]

Create a new Model instance.

Parameters
• sbml_source (typing.Union[str, libsbml.Model]) – Either a path to SBML file where the model is specified, or a model string as created by sbml.sbmlWriter( ).writeSBMLToString() or an instance of libsbml.Model.

• show_sbml_warnings (bool) – Indicates whether libSBML warnings should be displayed.

• from_file (bool) – Whether sbml_source is a file name (True, default), or an SBML string

add_d_dt(d_dt, variable, variable0, name)[source]

Creates or modifies species, to implement rate rules for compartments and species, respectively.

Parameters
Return type

None

add_local_symbol(key, value)[source]

Add local symbols with some sanity checking for duplication which would indicate redefinition of internals, which SBML permits, but we don’t.

Parameters
check_event_support()[source]

Check possible events in the model, as AMICI does currently not support

• delays in events

• priorities of events

• events fired at initial time

Furthermore, event triggers are optional (e.g., if an event is fired at initial time, no trigger function is necessary). In this case, warn that this event will have no effect.

Return type

None

check_support()[source]

Check whether all required SBML features are supported. Also ensures that the SBML contains at least one reaction, or rate rule, or assignment rule, to produce change in the system over time.

Return type

None

is_assignment_rule_target(element)[source]

Checks if an element has a valid assignment rule in the specified model.

Parameters

element (libsbml.SBase) – SBML variable

Return type

bool

Returns

boolean indicating truth of function name

is_rate_rule_target(element)[source]

Checks if an element has a valid assignment rule in the specified model.

Parameters

element (libsbml.SBase) – SBML variable

Return type

bool

Returns

boolean indicating truth of function name

process_conservation_laws(ode_model, volume_updates)[source]

Find conservation laws in reactions and species.

Parameters
• ode_model – ODEModel object with basic definitions

• volume_updates – List with updates for the stoichiometric matrix accounting for compartment volumes

List (according to reduced stoichiometry) with updates for the stoichiometric matrix accounting for compartment volumes

Return type

typing.List

sbml2amici(model_name=None, output_dir=None, observables=None, constant_parameters=None, sigmas=None, noise_distributions=None, verbose=40, assume_pow_positivity=False, compiler=None, allow_reinit_fixpar_initcond=True, compile=True, compute_conservation_laws=True, simplify=<function SbmlImporter.<lambda>>, log_as_log10=True, generate_sensitivity_code=True, **kwargs)[source]

Generate and compile AMICI C++ files for the model provided to the constructor.

The resulting model can be imported as a regular Python module (if compile=True), or used from Matlab or C++ as described in the documentation of the respective AMICI interface.

Note that this generates model ODEs for changes in concentrations, not amounts unless the hasOnlySubstanceUnits attribute has been defined for a particular species.

Sensitivity analysis for local parameters is enabled by creating global parameters _{reactionId}_{localParameterName}.

Parameters
Return type

None