crnt4sbml.GeneralApproach

class crnt4sbml.GeneralApproach(cgraph, get_physiological_range)[source]

Class for constructing a more general approach to bistability detection for systems with mass action kinetics.

__init__(cgraph, get_physiological_range)[source]

Initialization of GeneralApproach class.

Methods

__init__(cgraph, get_physiological_range) Initialization of GeneralApproach class.
initialize_general_approach([signal, …]) Function for initializing the necessary variables for the general approach.
generate_report() Prints out helpful details constructed by crnt4sbml.GeneralApproach.run_optimization(), crnt4sbml.GeneralApproach.run_continuity_analysis(), and crnt4sbml.GeneralApproach.run_greedy_continuity_analysis().
get_conservation_laws() Returns a string representation of the conservation laws.
get_input_vector() Returns a list of SymPy variables that specifies the ordering of the reactions and species for which bounds need to be provided.
get_decision_vector() Returns a list of SymPy variables that specifies the ordering of the reactions and species of the decision vector used in optimization.
get_optimization_bounds() Returns a list of tuples that corresponds to the determined physiological bounds chosen for the problem.
get_ode_lambda_functions() Returns a list of lambda functions where each index corresponds to the lambda function for the corresponding ODE, where the species corresponds to the list of species of the network.
get_independent_odes() Returns a Sympy Matrix representing the independent ODE system without conservation laws substituted in.
get_independent_odes_subs() Returns a Sympy Matrix representing the independent ODE system with conservation laws substituted in.
get_independent_species() Returns a list of SymPy variables that reflects the independent species chosen for the general approach.
get_fixed_reactions() Returns a list of SymPy variables that describe the reactions that were chosen to be fixed when ensuring a steady-state solution exists.
get_solutions_to_fixed_reactions() Returns a list of SymPy expressions corresponding to the fixed reactions.
get_jacobian() Returns a Sympy expression of the Jacobian, where the Jacobian is with respect to the independent species.
get_jac_lambda_function() Returns a lambda function of the Jacobian, where the Jacobian is with respect to full system and species.
get_determinant_of_jacobian() Returns a Sympy expression of the determinant of the Jacobian, where the Jacobian is with respect to the independent species.
get_comm() Returns a mpi4py communicator if it has been initialized and None otherwise.
get_my_rank() Returns the rank assigned by mpi4py if it is initialized, otherwise None will be returned.
run_optimization([bounds, iterations, seed, …]) Function for running the optimization problem for the general approach.
run_continuity_analysis([species, …]) Function for running the numerical continuation and bistability analysis portions of the general approach.
run_greedy_continuity_analysis([species, …]) Function for running the greedy numerical continuation and bistability analysis portions of the general approach.
run_direct_simulation([…]) Function for running direct simulation to conduct bistability analysis of the general approach.
generate_report()[source]

Prints out helpful details constructed by crnt4sbml.GeneralApproach.run_optimization(), crnt4sbml.GeneralApproach.run_continuity_analysis(), and crnt4sbml.GeneralApproach.run_greedy_continuity_analysis().

Example

See also General Approach Example and General Approach Walkthrough

get_comm()[source]

Returns a mpi4py communicator if it has been initialized and None otherwise.

get_conservation_laws()[source]

Returns a string representation of the conservation laws. Here the values on the left hand side of each equation are the constants of the conservation laws.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> print(GA.get_conservation_laws())
get_decision_vector()[source]

Returns a list of SymPy variables that specifies the ordering of the reactions and species of the decision vector used in optimization. Note: this method should not be used to create bounds for the optimization routine, rather crnt4sbml.GeneralApproach.get_input_vector() should be used.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> print(GA.get_decision_vector())
get_determinant_of_jacobian()[source]

Returns a Sympy expression of the determinant of the Jacobian, where the Jacobian is with respect to the independent species.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_determinant_of_jacobian()
get_fixed_reactions()[source]

Returns a list of SymPy variables that describe the reactions that were chosen to be fixed when ensuring a steady-state solution exists. Note that fixed_reactions must be set to True in crnt4sbml.GeneralApproach.initialize_general_approach().

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response, fix_reactions=True)
>>> GA.get_fixed_reactions()
get_independent_odes()[source]

Returns a Sympy Matrix representing the independent ODE system without conservation laws substituted in. Each row corresponds to the ODE for the species corresponding to the list provided by crnt4sbml.GeneralApproach.get_independent_species().

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_independent_odes()
get_independent_odes_subs()[source]

Returns a Sympy Matrix representing the independent ODE system with conservation laws substituted in. Each row corresponds to the ODE for the species corresponding to the list provided by crnt4sbml.GeneralApproach.get_independent_species().

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_independent_odes_subs()
get_independent_species()[source]

Returns a list of SymPy variables that reflects the independent species chosen for the general approach.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_independent_species()
get_input_vector()[source]

Returns a list of SymPy variables that specifies the ordering of the reactions and species for which bounds need to be provided.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> print(GA.get_input_vector())
get_jac_lambda_function()[source]

Returns a lambda function of the Jacobian, where the Jacobian is with respect to full system and species.

get_jacobian()[source]

Returns a Sympy expression of the Jacobian, where the Jacobian is with respect to the independent species.

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_jacobian()
get_my_rank()[source]

Returns the rank assigned by mpi4py if it is initialized, otherwise None will be returned.

get_ode_lambda_functions()[source]

Returns a list of lambda functions where each index corresponds to the lambda function for the corresponding ODE, where the species corresponds to the list of species of the network.

get_optimization_bounds()[source]

Returns a list of tuples that corresponds to the determined physiological bounds chosen for the problem. Each entry corresponds to the list provided by crnt4sbml.GeneralApproach.get_input_vector().

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)
>>> GA.get_optimization_bounds()
get_solutions_to_fixed_reactions()[source]

Returns a list of SymPy expressions corresponding to the fixed reactions. The ordering of the elements corresponds to the list returned by crnt4sbml.GeneralApproach.get_fixed_reactions(). Note that fixed_reactions must be set to True in crnt4sbml.GeneralApproach.initialize_general_approach().

Example

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response, fix_reactions=True)
>>> GA.get_solutions_to_fixed_reactions()
initialize_general_approach(signal=None, response=None, fix_reactions=False)[source]

Function for initializing the necessary variables for the general approach.

Parameters:
  • signal (String) – A string stating the conservation law that is the x-axis of the bifurcation diagram.
  • response (String) – A string stating the species that is the y-axis of the bifurcation diagram.
  • fix_reactions (bool) – A bool that determines if a steady state is enforced by fixing the reactions. See General Approach Walkthrough for specific details.

Examples

>>> import crnt4sbml
>>> network = crnt4sbml.CRNT("path/to/sbml_file.xml")
>>> GA = network.get_general_approach()
>>> signal = "C1"
>>> response = "s1"
>>> GA.initialize_general_approach(signal=signal, response=response)

See also General Approach Example and General Approach Walkthrough.

run_continuity_analysis(species=None, parameters=None, dir_path='./num_cont_graphs', print_lbls_flag=False, auto_parameters=None, plot_labels=None)[source]

Function for running the numerical continuation and bistability analysis portions of the general approach.

Note: A parallel version of this routine is not available.

Parameters:
  • species (string) – A string stating the species that is the y-axis of the bifurcation diagram.
  • parameters (list of numpy arrays) – A list of numpy arrays corresponding to the decision vectors that produce a small objective function value.
  • dir_path (string) – A string stating the path where the bifurcation diagrams should be saved.
  • print_lbls_flag (bool) – If True the routine will print the special points found by AUTO 2000 and False will not print any special points.
  • auto_parameters (dict) – Dictionary defining the parameters for the AUTO 2000 run. Please note that one should not set ‘SBML’ or ‘ScanDirection’ in these parameters as these are automatically assigned. It is absolutely necessary to set PrincipalContinuationParameter in this dictionary. For more information on these parameters refer to AUTO parameters. ‘NMX’ will default to 10000 and ‘ITMX’ to 100.
  • plot_labels (list of strings) – A list of strings defining the labels for the x-axis, y-axis, and title. Where the first element is the label for x-axis, second is the y-axis label, and the last element is the title label. If you would like to use the default settings for some of the labels, simply provide None for that element.
Returns:

  • multistable_param_ind (list of integers) – A list of those indices in ‘parameters’ that produce multistable plots.
  • plot_specifications (list of lists) – A list whose elements correspond to the plot specifications of each element in multistable_param_ind. Each element is a list where the first element specifies the range used for the x-axis, the second element is the range for the y-axis, and the last element provides the x-y values and special point label for each special point in the plot.

Example

See General Approach Example and General Approach Walkthrough..

run_direct_simulation(params_for_global_min=None, dir_path='./dir_sim_graphs', change_in_relative_error=1e-06, parallel_flag=False, print_flag=False, left_multiplier=0.5, right_multiplier=0.5)[source]

Function for running direct simulation to conduct bistability analysis of the general approach.

Note: This routine is more expensive than the numerical continuation routines, but can provide solutions when the Jacobian of the ODE system is always singular. A parallel version of this routine is available. The routine automatically produces plots of the direct simulation runs and puts them in the user specified dir_path.

Parameters:
  • params_for_global_min (list of numpy arrays) – A list of numpy arrays corresponding to the input vectors that produce a small objective function value.
  • dir_path (string) – A string stating the path where the bifurcation diagrams should be saved.
  • change_in_relative_error (float) – A float value that determines how small the relative error should be in order for the solution of the ODE system to be considered at a steady state. Note: a smaller value will run faster, but may produce an ODE system that is not at a steady state.
  • parallel_flag (bool) – If set to True a parallel version of direct simulation is ran. If False, a serial version of the routine is ran. See Parallel General Approach for further information.
  • print_flag (bool) – If set to True information about the direct simulation routine will be printed. If False, no output will be provided.
  • left_multiplier (float) – A float value that determines the percentage of the signal that will be searched to the left of the signal value. For example, the lowerbound for the signal range will be signal_value - signal_value*left_multiplier.
  • right_multiplier (float) – A float value that determines the percentage of the signal that will be searched to the right of the signal value. For example, the upperbound for the signal range will be signal_value + signal_value*right_multiplier.
Returns:

list_of_ggplots

Return type:

list of ggplots produced by plotnine

Example

See General Approach Walkthrough.

run_greedy_continuity_analysis(species=None, parameters=None, dir_path='./num_cont_graphs', print_lbls_flag=False, auto_parameters=None, plot_labels=None)[source]

Function for running the greedy numerical continuation and bistability analysis portions of the general approach. This routine uses the initial value of the principal continuation parameter to construct AUTO parameters and then tests varying fixed step sizes for the continuation problem. Note that this routine may produce jagged or missing sections in the plots provided. To produce better plots one should use the information provided by this routine to run crnt4sbml.GeneralApproach.run_continuity_analysis().

Note: A parallel version of this routine is not available.

Parameters:
  • species (string) – A string stating the species that is the y-axis of the bifurcation diagram.
  • parameters (list of numpy arrays) – A list of numpy arrays corresponding to the decision vectors that produce a small objective function value.
  • dir_path (string) – A string stating the path where the bifurcation diagrams should be saved.
  • print_lbls_flag (bool) – If True the routine will print the special points found by AUTO 2000 and False will not print any special points.
  • auto_parameters (dict) – Dictionary defining the parameters for the AUTO 2000 run. Please note that only the PrincipalContinuationParameter in this dictionary should be defined, no other AUTO parameters should be set. For more information on these parameters refer to AUTO parameters.
  • plot_labels (list of strings) – A list of strings defining the labels for the x-axis, y-axis, and title. Where the first element is the label for x-axis, second is the y-axis label, and the last element is the title label. If you would like to use the default settings for some of the labels, simply provide None for that element.
Returns:

  • multistable_param_ind (list of integers) – A list of those indices in ‘parameters’ that produce multistable plots.
  • plot_specifications (list of lists) – A list whose elements correspond to the plot specifications of each element in multistable_param_ind. Each element is a list where the first element specifies the range used for the x-axis, the second element is the range for the y-axis, and the last element provides the x-y values and special point label for each special point in the plot.

Example

See General Approach Example and General Approach Walkthrough.

run_optimization(bounds=None, iterations=10, seed=0, print_flag=False, dual_annealing_iters=1000, confidence_level_flag=False, change_in_rel_error=0.1, constraints=None, parallel_flag=False)[source]

Function for running the optimization problem for the general approach.

Parameters:
  • bounds (list of tuples) – A list defining the lower and upper bounds for each variable in the input vector. See crnt4sbml.GeneralApproach.get_input_vector().
  • iterations (int) – The number of iterations to run the multistart method.
  • seed (int) – Seed for the random number generator. None should be used if a random generation is desired.
  • print_flag (bool) – Should be set to True if the user wants the objective function values found in the optimization problem and False otherwise.
  • dual_annealing_iters (integer) – The number of iterations that should be ran for dual annealing routine in optimization.
  • confidence_level_flag (bool) – If True a confidence level for the objective function will be given.
  • change_in_rel_error (float) – The maximum relative error that should be allowed to consider f_k in the neighborhood of \widetilde{f}.
  • constraints (list of dictionaries) – Each dictionary is of the form {‘type’: ‘…’, ‘fun’: lambda x: … }, where ‘type’ can be set to ‘ineq’ or ‘eq’ and the lambda function to be defined by the user. The ‘ineq’ refers to an inequality constraint c(x) with c(x) <= 0. For the lambda function the input x refers to the input vector of the optimization routine. See General Approach Walkthrough for further details.
  • parallel_flag (bool) – If set to True a parallel version of the optimization routine is ran. If False, a serial version of the optimization routine is ran. See Parallel General Approach.
Returns:

  • params_for_global_min (list of numpy arrays) – A list of numpy arrays that correspond to the input vectors of the problem.
  • obj_fun_val_for_params (list of floats) – A list of objective function values produced by the corresponding input vectors in params_for_global_min.

Examples

See General Approach Example and General Approach Walkthrough.