efmlrs.preprocessing package¶
Subpackages¶
Submodules¶
efmlrs.preprocessing.boundaries module¶
-
efmlrs.preprocessing.boundaries.
add_boundary_names
(bounds_info)[source]¶ Extends reaction name for reactions with additional bounds by adding “min” or “max” to lower respectively upper bounds.
Parameters: bounds_info – dictionary containing information on reaction and associated bounds Returns: dictionary containing information on reaction bounds with extended reaction name
-
efmlrs.preprocessing.boundaries.
build_new_metas
(bounds, meta_ori)[source]¶ Builds new list of metabolite names including slack metabolites.
Parameters: - bounds – dictionary with bound information
- meta_ori – list of metabolite names
Returns: new_metas list of metabolite names including added slack metabolites
-
efmlrs.preprocessing.boundaries.
build_new_reas
(bounds, reas_ori)[source]¶ Builds new list of reaction names including slack metabolites.
Parameters: - bounds – dictionary with bound information
- reas_ori – list of reactions names
Returns: new_reas list reaction names including added slack reactions
-
efmlrs.preprocessing.boundaries.
build_new_reversibilities
(bounds, revs_ori)[source]¶ Builds new list of reaction reversibilities. All added reaction are irreversible.
Parameters: - bounds – dictionary with bound information
- revs_ori – list of reaction reversibilities
Returns: new_revs list of reaction reversibilities including added slack reactions
-
efmlrs.preprocessing.boundaries.
build_new_smatrix
(smatrix, bounds, reactions)[source]¶ Extends stoichiometric matrix according to additional bounds with slack reactions and slack metabolites. Builds and adds slack reactions and metabolites to stoichiometric matrix. Converts matrix coefficients to fractions.
Parameters: - smatrix – stoichiometric matrix
- bounds – dictionary with bound information
- reactions – list of reaction names
Returns: extended stoichiometric matrix
-
efmlrs.preprocessing.boundaries.
build_slack_metas_01
(bounds, reactions)[source]¶ Builds first part of slack metabolites. Length equals length of original stoichiometric matrix. Adds 1 or -1 as coefficient at index of slack metabolite for upper respectively lower bound.
Parameters: - bounds – dictionary with bound information
- reactions – list of reaction names
Returns: list of lists with new build slack reactions
-
efmlrs.preprocessing.boundaries.
build_slack_metas_02
(bounds)[source]¶ Builds entries for entries for slack reactions length equals number of additional bounds.
Parameters: bounds – dictionary with bound information Returns: list slack_reas_2 of lists with entries for slack reactions
-
efmlrs.preprocessing.boundaries.
build_slack_metas_03
(bounds)[source]¶ Builds last part of slack metabolite (= lambda column) with actual reaction bound as coefficient.
Parameters: bounds – dictionary with bound information Returns: list slack_metas_3 of list with actual reaction bound as entry
-
efmlrs.preprocessing.boundaries.
building_slack_metabolites
(bounds, reactions)[source]¶ Builds slack metabolites. Consists of three parts. First part builds list with length of original matrix and coefficients according to lower or upper bound. Second part build entries for slack reactions length equals number of additional bounds. Third part builds entry for lambda reaction, length always 1, entry is the actual reaction bound.
Parameters: - bounds – dictionary with bound information
- reactions – list of reaction names
Returns: list slack_metas of lists with new build slack metabolites
-
efmlrs.preprocessing.boundaries.
extend_smatrix_1
(matrix, bounds)[source]¶ Extends columns of stoichiometric matrix by number of bounds plus 1 with arrays containing only zeros.
Parameters: - matrix – stoichiometric matrix
- bounds – dictionary with bound information
Returns: extended stoichiometric matrix
-
efmlrs.preprocessing.boundaries.
extend_smatrix_2
(slack_metas, smatrix_extended)[source]¶ Extends stoichiometric matrix by new build slack metabolites.
Parameters: - slack_metas (list) – list of lists with new build slack metabolites
- smatrix_extended_1 – stoichiometric matrix that has been extended by columns containing only zero
Returns: new build smatrix with slack reactions and slack metabolites
-
efmlrs.preprocessing.boundaries.
format_bounds
(bounds_info)[source]¶ Changes bound information for additional reaction bounds stored in bounds_info from str (cobrapy format) to int.
Parameters: bounds_info – dictionary containing information on reaction and associated bounds Returns: dictionary containing information on reaction bounds with extended reaction name and int as bounds
-
efmlrs.preprocessing.boundaries.
get_bounds_index
(reas, bounds)[source]¶ Gets index for addtional bounds according to list of reaction names.
Parameters: - reas (list) – list of reaction names
- bounds – dictionary with bound information
Returns: list of indicis of reaction bounds
-
efmlrs.preprocessing.boundaries.
run
(model, smatrix, reactions, reversibilities, metabolites)[source]¶ Entry point for boundaries. Searched for additional reaction bounds. Adds slack reaction and metabolites to the stoichiometric matrix, the lists of reaction names and metabolie names and the list of reaction reversibilities.
Parameters: - model – cobrapy model
- smatrix – stoichiometric matrix
- reactions – list of reaction names
- reversibilities – list of reaction reversibilities
- metabolites – list of metabolite names
Returns: - smatrix - sympy matrix reduced stoichiometric matrix
- reactions - list of reactions names
- reversibilities - list of reaction reversibilities
- metabolites - list of metabolite names
- bound_counter - integer number of added bounds
-
efmlrs.preprocessing.boundaries.
search_bounds
(model)[source]¶ Searches cobrapy model for additional reaction bounds.
Parameters: model – cobrapy model Returns: dictionary containing information on reactions with additional bounds (reaction id, lower and upper bound) or returns None if no additional reaction bounds were found in the model.
efmlrs.preprocessing.get_data module¶
-
efmlrs.preprocessing.get_data.
check_bounds
(model, smatrix, reactions, reversibilities, metabolites)[source]¶ Calls boundaries script.
Parameters: - model – cobrapy model
- smatrix – stoichiometric matrix
- reactions – list of reaction names
- reversibilities – list of reaction reversibilities
- metabolites – list of metabolite names
Returns: - smatrix - matrix stoichiometric matrix
- reactions - list of reactions names
- reversibilities - list of reaction reversibilities
- metabolites - list of metabolite names
- bound_counter - integer number of added bounds
-
efmlrs.preprocessing.get_data.
compartments_2_rm
(model, comp_list: list)[source]¶ Checks if compartment were specified to ignore and removes metabolites that belong to specified compartments.
Parameters: - model – cobrapy model
- comp_list (list) – list of compartments that will be removed
Returns: model: altered cobrapy model
-
efmlrs.preprocessing.get_data.
get_smatrix
(model)[source]¶ Gets stoichiometric matrix from cobrapy model using the cobrapy function “cobra.util.array.create_stoichiometric_matrix”.
Parameters: model – cobrapy model Returns: matrix: stoichiometric matrix
-
efmlrs.preprocessing.get_data.
orphaned_metas_rm
(model)[source]¶ Searches and removes orphaned metabolites from cobrapy model. Orphaned metabolites are not involved in any reaction.
Parameters: model – cobrapy model Returns: model: altered cobrapy model
-
efmlrs.preprocessing.get_data.
read_model
(input_filename)[source]¶ Reads metabolic model from sbml file using the ‘cobra.io.read_sbml_model’ functions. Reads io string during reading model and catches exchange reactions added by cobrapy. These reactions are going to be removed from the model again. :param input_filename: sbml file with cobrapy compatible metabolic model :return:
- model - cobrapy model
- reas_added - list of reactions added by cobrapy
-
efmlrs.preprocessing.get_data.
rm_metas_in_specified_compartment
(comp, model)[source]¶ Removes metabolites in specified compartment.
Parameters: - comp (str) – comparment to ignore
- model – cobrapy model
Returns: model: altered cobrapy model
-
efmlrs.preprocessing.get_data.
rm_reactions
(model, rea_list)[source]¶ Removes exchange reaction that were added by cobrapy.
Parameters: - model – cobrapy model
- rea_list (list) – list of reaction names that will be removed
Returns: - model - altered cobrapy model
-
efmlrs.preprocessing.get_data.
run
(inputfile, ignore_compartments, boundflag)[source]¶ Entry point for get_data. Takes sbml file as input. Removes exchange reactions that were added by cobrapy during reading. Using cobrapy the model name and properties are extracted. Removes orphaned metabolites. As specified by user input ignores compartments a and creates boundary reactions and metabolites. Converts stoichiometric matrix coefficients into fractions for precise arithmetic in later calculations and converts stoichiometric matrix from list of lists to sympy matrix. Creates the following files: sfile (smatrix), mfile (metabolite names), rfile (reaction names), rvfile (reaction reversibilities) and info file.
Parameters: - inputfile – sbml file with cobrapy compatible metabolic model
- ignore_compartments (str) – (optional) user input as string with compartment name that will be ignored
- boundflag (bool) – (optional) user input as bool flag if boundaries from sbml file will be taken into account
Returns: - smatrix - sympy matrix of stoichiometric matrix
- reactions - list of reactions names
- reversibilities - list of reaction reversibilities
- metabolites - list of metabolite names
- model - cobrapy model
- core_name - path to input file without extensions
efmlrs.preprocessing.mplrs_output module¶
-
efmlrs.preprocessing.mplrs_output.
run_cmp
(core_name)[source]¶ Entry point for mplrs_output. Creates input file from sfile and rvfile suitable for mplrs algorithm.
Parameters: core_name – path to input file without extensions Returns: None
-
efmlrs.preprocessing.mplrs_output.
run_uncmp
(core_name)[source]¶ Entry point for mplrs_output. Creates input file from sfile and rvfile suitable for mplrs algorithm.
Parameters: core_name – path to input file without extensions Returns: None
-
efmlrs.preprocessing.mplrs_output.
split_reversible_reas
(smatrix, reversibilities)[source]¶ Splits all reversible reactions into two single reactions. One for forward and one for backward.
Parameters: - smatrix – list of lists of stoichiometric matrix
- reversibilities – list of reaction reversibilities
Returns: list of lists of reconfigured stoichiometric matrix
-
efmlrs.preprocessing.mplrs_output.
write_header
(mplrs_file, core_name)[source]¶ Writes header for mplrs input file.
Parameters: - mplrs_file – path to mplrs input file
- core_name – path to input file without extensions
Returns: None
-
efmlrs.preprocessing.mplrs_output.
write_lrs
(core_name, reconf_smatrix)[source]¶ Write input file for mplrs algorithm.
Parameters: - core_name – path to input file without extensions
- reconf_smatrix – list of lists of reconfigured stoichiometric matrix
Returns: None
-
efmlrs.preprocessing.mplrs_output.
write_lrs_cmp
(core_name, reconf_smatrix)[source]¶ Write input file for mplrs algorithm.
Parameters: - core_name – path to input file without extensions
- reconf_smatrix – list of lists of reconfigured stoichiometric matrix
Returns: None
-
efmlrs.preprocessing.mplrs_output.
write_smatrix
(mplrs_file, reconf_smatrix)[source]¶ Writes reconfigured stoichiometric matrix, unity matrix and ending to mplrs input file.
Parameters: - mplrs_file – path to mplrs input file
- reconf_smatrix – list of lists of reconfigured stoichiometric matrix
Returns: None