skimpy.core =========== .. py:module:: skimpy.core .. autoapi-nested-parse:: .. module:: skimpy :platform: Unix, Windows :synopsis: Simple Kinetic Models in Python .. moduleauthor:: SKiMPy team [---------] Copyright 2017 Laboratory of Computational Systems Biotechnology (LCSB), Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/skimpy/core/compartments/index /autoapi/skimpy/core/itemsets/index /autoapi/skimpy/core/kinmodel/index /autoapi/skimpy/core/modifiers/index /autoapi/skimpy/core/parameters/index /autoapi/skimpy/core/reactions/index /autoapi/skimpy/core/reactor/index /autoapi/skimpy/core/solution/index Attributes ---------- .. autoapisummary:: skimpy.core.QSSA skimpy.core.TQSSA skimpy.core.MCA skimpy.core.ODE skimpy.core.ELEMENTARY skimpy.core.NUMERICAL skimpy.core.SYMBOLIC skimpy.core.NET skimpy.core.SPLIT skimpy.core.PARAMETER skimpy.core.VARIABLE skimpy.core.KCAL skimpy.core.KJ skimpy.core.JOULE skimpy.core.WATER_FORMULA skimpy.core.QSSA skimpy.core.TQSSA skimpy.core.MCA skimpy.core.ODE skimpy.core.ELEMENTARY skimpy.core.NUMERICAL skimpy.core.SYMBOLIC skimpy.core.NET skimpy.core.SPLIT skimpy.core.PARAMETER skimpy.core.VARIABLE skimpy.core.KCAL skimpy.core.KJ skimpy.core.JOULE skimpy.core.WATER_FORMULA Classes ------- .. autoapisummary:: skimpy.core.KineticModel skimpy.core.KineticMechanism skimpy.core.ExpressionModifier skimpy.core.BoundaryCondition skimpy.core.ConstantConcentration skimpy.core.AdditiveConcentrationRate skimpy.core.BoundaryFlux skimpy.core.FirstOrderSmallMoleculeModifier skimpy.core.DisplacementSmallMoleculeModifier skimpy.core.ActivationModifier skimpy.core.InhibitionModifier skimpy.core.HillActivationModifier skimpy.core.SimpleHillActivationModifier skimpy.core.HillInhibitionModifier skimpy.core.Reaction skimpy.core.TabDict skimpy.core.Item skimpy.core.ItemSet skimpy.core.Parameter skimpy.core.ParameterSet skimpy.core.Reactant skimpy.core.ReactantSet skimpy.core.TabDict skimpy.core.ParameterValues skimpy.core.ParameterValuePopulation Functions --------- .. autoapisummary:: skimpy.core.check_is_symbol skimpy.core.make_parameter_set skimpy.core.make_reactant_set skimpy.core.make_parameter_set skimpy.core.make_reactant_set skimpy.core.load_parameter_population skimpy.core.concat_populations Package Contents ---------------- .. py:class:: KineticModel(reactions=None, boundary_conditions=None, constraints=None, name='Unnamed') Bases: :py:obj:`object` This class contains the kinetic model as described by reaction and boundary conditions and constratins. :param : :return: .. py:attribute:: name :value: 'Unnamed' .. py:attribute:: reactions .. py:attribute:: boundary_conditions .. py:attribute:: constraints .. py:attribute:: initial_conditions .. py:attribute:: logger .. py:attribute:: _simtype :value: None .. py:attribute:: _modified :value: True .. py:attribute:: _recompiled :value: False .. py:attribute:: compartments .. py:property:: reactants .. py:property:: parameters .. py:property:: moieties .. py:method:: add_reaction(reaction) Adds a SKiMPy reaction to the model :param reaction: The reaction to add :type reaction: skimpy.core.Reaction :return: .. py:method:: add_compartment(compartment) :param compartment: :return: .. py:method:: add_constraint(constraint) .. py:method:: add_boundary_condition(boundary_condition) Enforces a boundary condition (e.g. a constant concentration) on the kinetic model :param boundary_condition: the boundary condition to enforce :type boundary_condition: skimpy.core.BoundaryCondition :return: .. py:method:: add_to_tabdict(element, kind) .. py:method:: parametrize_by_reaction(param_dict) If has input: apply as dict to reactions in the model by reaction.parametrize(args) :return: .. py:method:: parametrize(param_dict) .. py:method:: repair() Link inhibitors and activators to reactants FIXME: Any idea to avoid this is dearly welcome :return: .. py:property:: sim_type .. py:method:: prepare(mca=True, ode=True, **kwargs) Model preparation for different analysis types. The preparation is done before the compiling step to be able to curate the model in between :param mca: :param ode: :return: .. py:method:: compile_jacobian(type=NUMERICAL, sim_type=QSSA, ncpu=1) .. py:method:: compile_ode(sim_type=QSSA, ncpu=1) .. py:method:: solve_ode(time_out, solver_type='cvode', **kwargs) The solver types are from ::scikits.odes::, and can be found at `_. :param time_out: The times at which the solution is evaluated :type time_out: list(float) or similar :param solver_type: must be among ['cvode','ida','dopri5','dop853'] :param kwargs: :return: .. py:method:: compile_mca(parameter_list=[], mca_type=NET, sim_type=QSSA, ncpu=1) Compile MCA expressions: elasticities, jacobian and control coeffcients .. py:function:: check_is_symbol(s_in) .. py:class:: KineticMechanism(name, reactants, parameters=None, inhibitors=None, enzyme=None) Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: parameter_reactant_links .. py:attribute:: name .. py:attribute:: reactants .. py:attribute:: inhibitors :value: None .. py:attribute:: _parameters :value: None .. py:attribute:: enzyme :value: None .. py:method:: __reduce__() .. py:method:: link_parameters_and_reactants() .. py:property:: parameters .. py:property:: Reactants :abstractmethod: Class to define metabolites and their roles in the reaction :return: .. py:property:: Parameters :abstractmethod: Class to define parameters and their roles in the reaction :return: .. py:method:: get_qssa_rate_expression() :abstractmethod: .. py:method:: update_qssa_rate_expression() :abstractmethod: .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:method:: get_parameters_from_expression(expr) .. py:function:: make_parameter_set(mechanism, param_declaration) .. py:function:: make_reactant_set(mechanism, reactant_declaration) .. py:class:: ExpressionModifier(name, reaction=None, modifier=None) Bases: :py:obj:`object` This class describes a modifier to an expression, like a boundary condition or constraint. For example, changing a rate to a constant (boundary condition), or linking it to another variable of the model (constraint). It accepts as an argument a modifier. A modifier is a function which will look at all your expressions, and apply its transformation to them. As a result, its arguments have to be a TabDict of expressions, such as KinModel.ODEFun.expressions .. py:attribute:: prefix :value: 'MOD' .. py:attribute:: _name .. py:attribute:: _reaction :value: None .. py:method:: __call__(expressions) .. py:property:: modifier .. py:method:: link(model) Link the modifier to a model, to gain awareness of the inner/outer variables :param model: :return: .. py:property:: name .. py:class:: BoundaryCondition(name, modifier=None, reaction=None) Bases: :py:obj:`ExpressionModifier` We differentiate boundary conditions as modifiers that define the boundaries of the observed system. .. py:attribute:: prefix :value: 'BC' .. py:class:: ConstantConcentration(reactant, name=None, reaction=None) Bases: :py:obj:`BoundaryCondition` .. py:attribute:: prefix :value: 'CC' .. py:attribute:: reactant .. py:method:: modifier(expressions) Set the rate to 0 :param expressions: :return: .. py:method:: __del__() .. py:class:: AdditiveConcentrationRate(reactant, flux_value, name=None, reaction=None) Bases: :py:obj:`ExpressionModifier` Add a concentration rate term to your rate expression .. py:attribute:: prefix :value: 'ADDCR' .. py:attribute:: reactant .. py:attribute:: flux_value .. py:method:: modifier(expressions) Add to the rate expression :param expressions: :return: .. py:class:: BoundaryFlux(reactant, flux_value, reaction=None) Bases: :py:obj:`BoundaryCondition`, :py:obj:`AdditiveConcentrationRate` We differentiate boundary conditions as modifiers that define the boundaries of the observed system. .. py:attribute:: prefix :value: 'BF' .. py:method:: check_dependency(expression) .. py:class:: FirstOrderSmallMoleculeModifier(small_molecule, mechanism_stoichiometry, name=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'HSM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: DisplacementSmallMoleculeModifier(small_molecule, mechanism_stoichiometry, name=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'DSM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: ActivationModifier(activator, name=None, k_activation=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'AM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:attribute:: reactant_stoichiometry .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: InhibitionModifier(inhibitor, name=None, k_inhibition=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'IM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:attribute:: reactant_stoichiometry .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: HillActivationModifier(activator, name=None, k_activation=None, a_max=None, hill_coefficient=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'HAM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:attribute:: reactant_stoichiometry .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: SimpleHillActivationModifier(activator, name=None, k_activation=None, a_max=None, hill_coefficient=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'SHAM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:attribute:: reactant_stoichiometry .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:class:: HillInhibitionModifier(inhibitor, name=None, k_inhibition=None, hill_coefficient=None, reaction=None) Bases: :py:obj:`skimpy.mechanisms.mechanism.KineticMechanism`, :py:obj:`ExpressionModifier` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: prefix :value: 'HIM' .. py:attribute:: Reactants Class to define metabolites and their roles in the reaction :return: .. py:attribute:: Parameters Class to define parameters and their roles in the reaction :return: .. py:attribute:: parameter_reactant_links .. py:attribute:: reactant_stoichiometry .. py:method:: modifier(expressions) change the flux reaction rate expressions :param expression: {vnet, vfwd, vbwd} :return: .. py:method:: get_qssa_rate_expression() .. py:method:: update_qssa_rate_expression() .. py:method:: get_full_rate_expression() :abstractmethod: .. py:method:: calculate_rate_constants() :abstractmethod: .. py:data:: QSSA :value: 'qssa' .. py:data:: TQSSA :value: 'tqssa' .. py:data:: MCA :value: 'mca' .. py:data:: ODE :value: 'ode' .. py:data:: ELEMENTARY :value: 'elementary' Jacobian Types .. py:data:: NUMERICAL :value: 'numerical' .. py:data:: SYMBOLIC :value: 'symbolic' MCA Types .. py:data:: NET :value: 'net' .. py:data:: SPLIT :value: 'split' Item types .. py:data:: PARAMETER :value: 'parameter' .. py:data:: VARIABLE :value: 'variable' Units .. py:data:: KCAL :value: 'kcal' .. py:data:: KJ :value: 'kJ' .. py:data:: JOULE :value: 'JOULE' OTHER .. py:data:: WATER_FORMULA :value: 'H2O' .. py:class:: Reaction(name, reactants, mechanism, parameters=None, inhibitors=None, enzyme=None) Bases: :py:obj:`object` Global reaction class .. py:attribute:: name .. py:attribute:: enzyme :value: None .. py:attribute:: modifiers .. py:property:: reactants .. py:property:: reactant_stoichiometry .. py:property:: parameters .. py:property:: rates .. py:method:: __str__() .. py:method:: parametrize(params) .. py:class:: TabDict Bases: :py:obj:`collections.OrderedDict` Really just an ordered dict with tab completion in interactive terminals .. py:method:: __dir__() Default dir() implementation. .. py:method:: __getattr__(attr) .. py:method:: iloc(ix) .. py:class:: Item(name, value=None, model=None, suffix='') Bases: :py:obj:`object` .. py:attribute:: name .. py:attribute:: model :value: None .. py:attribute:: value :value: None .. py:attribute:: _suffix :value: '' .. py:attribute:: _symbol :value: None .. py:attribute:: hook :value: None .. py:attribute:: type :value: None .. py:attribute:: _lower_bound :value: None .. py:attribute:: _upper_bound :value: None .. py:method:: _generate_symbol() .. py:property:: symbol .. py:property:: suffix .. py:property:: bounds .. py:method:: __str__() .. py:method:: __repr__() .. py:class:: ItemSet(mechanism) Bases: :py:obj:`abc.ABC`, :py:obj:`skimpy.utils.tabdict.TabDict` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: mechanism .. py:method:: __reduce__() Helper for pickle. .. py:class:: Parameter(name, required_for=None, value=None, model=None, suffix='') Bases: :py:obj:`Item` .. py:attribute:: type :value: 'parameter' .. py:class:: ParameterSet(mechanism, param_declaration, param_values, suffix='') Bases: :py:obj:`ItemSet` Helper class that provides a standard way to create an ABC using inheritance. .. py:property:: required_for .. py:function:: make_parameter_set(mechanism, param_declaration) .. py:class:: Reactant(name, value=None, model=None, suffix='') Bases: :py:obj:`Item` .. py:attribute:: type :value: 'variable' .. py:attribute:: compartment :value: None .. py:class:: ReactantSet(mechanism, reactant_declaration, reactant_values) Bases: :py:obj:`ItemSet` Helper class that provides a standard way to create an ABC using inheritance. .. py:function:: make_reactant_set(mechanism, reactant_declaration) .. py:data:: QSSA :value: 'qssa' .. py:data:: TQSSA :value: 'tqssa' .. py:data:: MCA :value: 'mca' .. py:data:: ODE :value: 'ode' .. py:data:: ELEMENTARY :value: 'elementary' Jacobian Types .. py:data:: NUMERICAL :value: 'numerical' .. py:data:: SYMBOLIC :value: 'symbolic' MCA Types .. py:data:: NET :value: 'net' .. py:data:: SPLIT :value: 'split' Item types .. py:data:: PARAMETER :value: 'parameter' .. py:data:: VARIABLE :value: 'variable' Units .. py:data:: KCAL :value: 'kcal' .. py:data:: KJ :value: 'kJ' .. py:data:: JOULE :value: 'JOULE' OTHER .. py:data:: WATER_FORMULA :value: 'H2O' .. py:class:: TabDict Bases: :py:obj:`collections.OrderedDict` Really just an ordered dict with tab completion in interactive terminals .. py:method:: __dir__() Default dir() implementation. .. py:method:: __getattr__(attr) .. py:method:: iloc(ix) .. py:class:: ParameterValues(parameter_values, kmodel=None) Bases: :py:obj:`object` Parameters set for kinetic models wich can be indexed with symbols or .. py:attribute:: _parameter_values .. py:attribute:: _sym_to_str .. py:method:: __getitem__(item) .. py:method:: __setitem__(item, value) .. py:method:: items() .. py:method:: keys() .. py:method:: values() .. py:class:: ParameterValuePopulation(data, kmodel=None, index=None) Bases: :py:obj:`object` .. py:attribute:: kmodel :value: None .. py:method:: __getitem__(index) .. py:method:: __len__() .. py:method:: __iter__() .. py:method:: __next__() .. py:method:: _dataframe(dropna=True) .. py:method:: mean() :return Computes the mean parameter values for the population: .. py:method:: var() :return Computes the variance parameter values for the population: .. py:method:: cov() :return Computes the covaraince parameter values for the population: .. py:method:: log_mean() :return Computes the logarithmic mean parameter values for the population: .. py:method:: log_var() :return Computes the logarithmic variance parameter values for the population: .. py:method:: log_cov() :return Computes the logarithmic covaraince parameter values for the population: .. py:method:: save(filename) Saves the parameter population as hdf5 file :param filename: string XXX.h5 / XXX.hdf5 :return: .. py:function:: load_parameter_population(filename, lower_index=None, upper_index=None) .. py:function:: concat_populations(values, kmodel=None, index=None)