BioSANS2020.model.fileconvert.process_sbml
¶
The process_sbml module
This module contains functions that facilitates the conversion of sbml file format into BioSANS topology format. Currently, this module highly relies on string manipulations, sympify, eval, and exec python functions
The following are the list of function in this module
get_exponent_sp
replace_crucial_funct
extract_species
extract_par_num
extract_var_func
extract_function
par_substitution
add2_spaces_sep
sp_substitution
var_substitution
funct_redefine_var
get_sbml_units
get_compartment_details
get_species_details
get_initial_conc
get_param_DETAILS
get_rule_details
process_sbml
Module Contents¶
Functions¶
|
|
|
This function extract the exponent of component or species key |
|
this function converts some problematic operator/logical/function |
|
This function extracts the components or species from a given ex- |
|
This function is currently not used but it can extract the |
|
This function extract the variables from an expression and gives |
|
This function converts a user defined function or function call |
|
This function substitute parameters to modk expression by first |
|
This function adds paddings on both sides of the operators and |
|
This is a redundant function to par_substitution. This function |
|
This function substitute variables to modk expression by first |
|
This function transform the variables in a lambda function to the |
|
Returns units dictionary from sbml file. The model is defined by |
|
Returns compartment dictionary from sbml file. The model is |
|
Returns species dictionary from sbml file. The model is |
|
Returns a dictionary of initial concentration from species |
|
Returns a dictionary of parameter name : [value, unit] |
|
This function returns the assignment rules, rate rules, and |
|
This function read the sbml file and extracts the necessary most |
Attributes¶
- BioSANS2020.model.fileconvert.process_sbml.OPERS_LIST¶
- BioSANS2020.model.fileconvert.process_sbml.OPERS_LIST2¶
- BioSANS2020.model.fileconvert.process_sbml.eval_exp(xvar)¶
- BioSANS2020.model.fileconvert.process_sbml.get_exponent_sp(key, modk)¶
This function extract the exponent of component or species key from a given propensity expression modk. Args:
key : species/component string modk : propensity expression converted to string
example “2*0.5*A*B”
- Returns:
exponent_in_formula : the power of species key
- Example:
modk = (1.0)*(1.0)*S1 key = S1 exponent_in_formula = 1
- BioSANS2020.model.fileconvert.process_sbml.replace_crucial_funct(trep)¶
this function converts some problematic operator/logical/function and etc. to its equivalent in SBML. Args:
- trepresult of SBML formulaToString(xvar.getMath())
xvar is an object in SBML getListOfFunctionDefinitions()
- BioSANS2020.model.fileconvert.process_sbml.extract_species(modk)¶
This function extracts the components or species from a given ex- pression and returns a comma concatenated string of them. Args:
- modkpropensity expression converted to string
example “2*0.5*A*B”
- Returns:
- “,”.join(sp_comp)a string of comma concatenated components
example “A,B”
- BioSANS2020.model.fileconvert.process_sbml.extract_par_num(modk)¶
This function is currently not used but it can extract the numeric values from a given expression Example:
print(extract_par_num(“(5.0)*(6.0)*S1+S2**3”)) will give {‘5.0’, ‘6.0’, ‘3’}
- BioSANS2020.model.fileconvert.process_sbml.extract_var_func(ssv)¶
This function extract the variables from an expression and gives a 2D list containing a comma concatenated string of variable and a string of the expression. Args:
- ssvcomma concatenated string of variables and expression.
example : “x,y,x*y”
- Returns:
- [“comma concatenated variables”,”expression”] :
example : [‘x,y’, ‘x*y’]
- BioSANS2020.model.fileconvert.process_sbml.extract_function(pforms, rbig_params, compartments, functions, functions_str)¶
This function converts a user defined function or function call in the SBML file to actual expression. Args:
- pformsfrom formulaToString(xvar.getMath()) where xvar can be
an object from getListOfRules() in libsbml. example : compartment*multiply(k1,S1)
- rbig_paramsdictionary of parameter nameparameter value
from kinetic rate law expression in sbml
compartments : dictionary of compartments name : [size, units] functions : dictionary of function name : function definition functions_str : the string equivalent of functions above
example : {‘multiply’: ‘lambda x,y : x*y’}
- Returns:
- modkexpanded form of pforms where every function definition
is evaluated example : compartment*1*(S1*k1)
- BioSANS2020.model.fileconvert.process_sbml.par_substitution(modk, parameters, index=0)¶
This function substitute parameters to modk expression by first padding the operators to ensure parameters can be distinguished from the expression. Args:
modk : math expression string parameters : dictionary of parameters name : [value, unit] index : 0 or 1. 0 will give value and 1 will give unit
- Returns:
modk : expression where parameters are now numeric
- BioSANS2020.model.fileconvert.process_sbml.add2_spaces_sep(modk)¶
This function adds paddings on both sides of the operators and return the expression modk with the operators padded. Args:
modk : string math expression
- Returns:
modk : string math expression with the operators padded
- BioSANS2020.model.fileconvert.process_sbml.sp_substitution(modk, parameters)¶
This is a redundant function to par_substitution. This function substitute parameters to modk expression by first padding the operators to ensure parameters can be distinguished fromthe expression. Args:
modk : math expression string parameters : dictionary of parameters name : [value, unit]
Intended for constant parameters
- Returns:
modk : expression where parameters are now numeric
- BioSANS2020.model.fileconvert.process_sbml.var_substitution(modk, rbig_params, parameters, compartments, rate_rules)¶
This function substitute variables to modk expression by first padding the operators to ensure variables can be distinguished from the expression. Args:
modk : math expression string rbig_params : dictionary of parameter name : parameter value
from kinetic rate law expression in sbml
parameters : dictionary of parameters name : [value, unit] compartments : dictionary of compartments name : [size, units] rate_rules : dictionary of variable : variable modifier function
- Returns:
modk : expression where variables are substituted
- BioSANS2020.model.fileconvert.process_sbml.funct_redefine_var(modk, ssv)¶
This function transform the variables in a lambda function to the actual variables needed. Args:
modk : string math lambda expression with abstract variables ssv : sympy symbols
- Returns:
string definition expression with actual varaibles
- BioSANS2020.model.fileconvert.process_sbml.get_sbml_units(model, sbml_units)¶
Returns units dictionary from sbml file. The model is defined by the following python syntax;
model = libsbml.SBMLReader().readSBML(sbml_file).getModel()
- Args:
model : model definition like shown above sbml_units : a dictionary of sbml unit equivalence
- Returns :
units_sbml : dictionary of sbml units associated to the file
- BioSANS2020.model.fileconvert.process_sbml.get_compartments_details(model, molar)¶
Returns compartment dictionary from sbml file. The model is defined by the following python syntax;
model = libsbml.SBMLReader().readSBML(sbml_file).getModel()
- Args:
model : model definition like shown above molar : True if conc. is in molar else False
- Returns:
- compartmentsdictionary of all compartments with the following
example format { ‘c1’ : [size, units]}
- constant_compdictionary of constant compartments
example format { ‘c1’ : [size, units]}
- non_constant_compdictionary of non constant compartments
example format { ‘c1’ : [size, units]}
- orig_sizedictionary of original size of compartment
example format { ‘c1’ : size}
- BioSANS2020.model.fileconvert.process_sbml.get_species_details(model)¶
Returns species dictionary from sbml file. The model is defined by the following python syntax;
model = libsbml.SBMLReader().readSBML(sbml_file).getModel()
- Args:
model : model definition like shown above
- Returns:
- speciesdictionary of all species with the following
example format { id : species_label }
- species_compdictionary of species compartments
example format { species_label : compartment }
- constant_speciesdictionary of constant species
example format { species_label : True }
- has_only_sunitsdictionary of species with only substance as
example format { id : True }
- sp_wcfactordictionary of convertion factor
example format { id : conversion factor }
- BioSANS2020.model.fileconvert.process_sbml.get_initial_conc(species)¶
Returns a dictionary of initial concentration from species
- BioSANS2020.model.fileconvert.process_sbml.get_param_details(model)¶
Returns a dictionary of parameter name : [value, unit]
- BioSANS2020.model.fileconvert.process_sbml.get_rule_details(model, constant_par)¶
This function returns the assignment rules, rate rules, and algebraic rules from sbml model given the disctionary of constant parameters. The constants are already substituted in the return
- BioSANS2020.model.fileconvert.process_sbml.process_sbml(file, molar=False, variables=None)¶
This function read the sbml file and extracts the necessary most of the details to construct the corresponding topology file of the system described by the SBML tags. Args:
file : this is the sbml file molar : True or False, tells if the systems unit molar or not variables : None or constant compartment to show in plot