RandomReactionNetwork – Reference Guide

This guide is for versions 1.0.0rc.8+ (Release Candidate)

Source code

Class RandomReactionNetwork

    Generate and manage random networks of reactions that are thermodynamically possible,
    and biologically plausible
    
nameargumentsreturns
__init__n_species :int, n_rxns :int, relative_rxn_prob=None, seed=None, temp=298.15, thermodynamic_ruggedness = 2.0, verbose=False
        :param n_species:           Integer >=3, with the desired number of chemicals species
        :param n_rxns:              Number of desired reactions (ok to use 0 for testing)
        :param relative_rxn_prob:   [OPTIONAL] A 3-element list with the relative probability
                                        of each of the 3 reaction choices that are currently available:
                                        [ReactionUnimolecular, ReactionSynthesis, ReactionDecomposition]
                                        Probabilities must add up to 1;
                                        if not specified, a uniform distribution is used.
                                        EXAMPLE:  [0.2, 0.5, 0.3]
        :param seed:                [OPTIONAL] A (large) integer, to guarantee consistent random runs
        :param temp:                [OPTIONAL] Temperature in Kelvins.  By default, 298.15 K
        :param thermodynamic_ruggedness: [OPTIONAL] It affects the magnitudes of the random reactions delta Gibbs energy values,
                                            by means of picking the standard deviation of the normal distribution
                                            used to generate the random values for the SPECIES enthalpy.
                                            Very rough guidelines:
                                                ruggedness  sigma(H)           behavior
                                                    0.5	      10	        metabolism-like
                                                    1	      20	        moderate
                                                    1.5	      30	        broad chemistry
                                                    2	      40	        rugged chemistry
                                            A value of 40.4145 for sigma has the effect of
                                            making the derived SD for the REACTION delta_H value to be sqrt(3) * sigma = 70 kJ/mol
                                            For more details, see random_species_enthalpy()

        :param verbose:             [OPTIONAL] Some extra printout if True
        
nameargumentsreturns
setup_random_reactionsrxn_types :list[str], verbose=FalseNone
        Create a network of randon reactions

        :param rxn_types:   List of names of reaction classes.
                                EXAMPLE: ["ReactionSynthesis", "ReactionDecomposition", "ReactionDecomposition"]
        :param verbose:
        :return:            None
        
nameargumentsreturns
get_reaction_data
        Extract and return all the reactions

        :return:    Object of type "ReactionRegistry"
        
nameargumentsreturns
random_species_enthalpysigma=None, n=Nonenp.ndarray | float
        Generate a random "standard enthalpy" value to assign to each of our chemical species.
        Essentially, a species standard enthalpy is a generalized, randomized version
        of enthalpy of formation, for the n chemical species.

        The values are generated from a normal distribution all centered at zero,
        and with the given value for the standard deviation sigma.

        EXAMPLE: a value of 40.4145 for sigma has the effect of making the derived SD
        of the sum of 3 random values to be about
        sqrt(3) * sigma = 70 kJ/mol
        For example, the sum of 3 random values comes up in determining
        the reaction enthalpy changes in reactions such as  A + B <-> C ,
        as computed by random_reaction_enthalpy()
        [But in the case of reactions such as 2 A <-> C, the reaction enthalpy change
        would be sqrt(2**2 + 1) * sigma = sqrt(5) * sigma = 90.4 kJ/mol]

        :param sigma:   [OPTIONAL] The standard deviation of the (zero-centered)
                            normal distribution used to generate all the values.
                            Default: 40.4145 kJ/mol
        :param n:       [OPTIONAL] The number of desired values.
                            If None (default) a single value is generated
        :return:        If n isn't None, return a Numpy Array with n numbers;
                            otherwise, return a single float.
                            All values are kJ/mol
        
nameargumentsreturns
get_species_enthalpylabel :strfloat
        Look up the standard enthalpy value to assign to the given chemical;
        if not found, assign and store a new random one

        :param label:   To identify a chemical species
        :return:        A standard enthalpy value already assigned, or just assigned,
                            to the given chemical
        
nameargumentsreturns
random_reaction_enthalpyreactants :[str], products :[str]float
        Attempt to provide a plausible regime for non-enzymatic small-molecule aqueous reactions,
        and thermodynamically consistent with all the previous random reactions added so far.

        It aims to randomly generate reaction ΔH values that are normally-distributed, with a mean of zero,
        and a standard deviation of roughly 70-90 kJ/mol

        With σ ≈ 70 kJ/mol for ΔH:
            ~68% of reactions fall within ±70 kJ/mol    (one standard deviation from the mean)
            ~95% within ±140 kJ/mol                     (2 standard deviations from the mean)

        That is the plausible range for non-enzymatic small-molecule chemistry.

        So, statistically:
            - You'll get many moderate reactions
            - Some strongly exothermic/endothermic ones

        For a given elementary reaction, specified by its reactants and products,
        compute the Sum_i[v_i * H0_i] ,
        where i ranges over all the species in the reaction,
        H0_i is the standard enthalpy of that species,
        and v_i is the stoichiometric coefficient (negative for reactants,
        and positive for products)

        :param reactants:   A list of the labels of the reactants
        :param products:    A list of the labels of the reaction products
        :return:            A random value for the change in enthalpy of the given reaction, in kJ/mol,
                                normally-distributed with mean 0 and sigma ≈ 70 kJ/mol,
                                thermodynamically consistent with all the previous random reactions added so far
        
nameargumentsreturns
random_reaction_entropyreaction_type :strfloat
        Attempt to provide plausible random entropy values for non-enzymatic small-molecule aqueous reactions.

        Current starting point (to further verify):

        For decomposition reactions:
            ΔS ~ Normal with mean=40 and σ=20 ,  J/(mol·K)
            Note that 95% of the values will fall between 0 and 80 (i.e within 2σ of the mean)
            Further clipped to within the range [0, 100]

        For synthesis reactions:
            ΔS ~ Normal with mean=-40 and σ=20 ,  J/(mol·K)
            Note that 95% of the values will fall between -80 and 0 (i.e within 2σ of the mean)
            Further clipped to within the range [-100, 0]

        At biological temperature T ≈ 300K, our distribution centers of 40 J/mol·K will correspond to entropy values of:
            300 * 40 J/mol = 12 kJ/mol

        :param reaction_type:One of the following reaction types:
                                "ReactionSynthesis", "ReactionDecomposition"
        :return:            A random value for the change in entropy of the given reaction,
                                in J/(mol·K)
        
nameargumentsreturns
forward_activation_gibbs_energy_normaldelta_G :float, mean=70., sigma=15.float
        Draw values for the forward activation free energy  ΔGf‡ from a normal distribution.

        We also enforce :  ΔGf‡ >= 0   and  ΔGf‡ >= ΔG

        Tentatively (to be further verified and validated), 
        we use the following default parameter values:
 
            mean=70. kJ/mol
            sigma=15. kJ/mol

        This is a coarse way to generate random forward activation free energies,
        because no consideration is given to the reaction free energy ΔG, other than
        enforcing ΔGf‡ >= ΔG.

        For a more sophisticated approach, see forward_activation_free_energy_BEP()

        :param delta_G: The reaction free energy Delta_G, in kJ/mol
        :param mean:    The standard deviation, in kJ/mol, of the Gaussian values
        :param sigma:   The standard deviation, in kJ/mol, of the Gaussian values

        :return:        An estimate, based on a Normal distribution,
                            of a plausible forward activation free energy, in kJ/mol,
                            for a random reaction
        
nameargumentsreturns
forward_activation_gibbs_energy_BEPdelta_G :float, alpha=0.5, beta=70., sigma=12.float
        Using the Brønsted-Evans-Polanyi relation (BEP),
        the forward activation Gibbs free energy ΔGf‡ is modeled by:
            ΔGf‡ = α ΔG + β + ε
        where
            ΔG reaction free energy
            α and β are two parameters
            ε is noise (because real reactions are not perfectly correlated)

        We also enforce :  ΔGf‡ >= 0   and  ΔGf‡ >= ΔG

        Tentatively (to be further verified and validated),
        we use the following default parameter values:

            α=0.5
            β=70 kJ/mol
            ε modeled with a Normal distribution N(0, 12^2) , i.e. σ=12 kJ/mol

        See: "Molecular Driving Forces - Statistical Thermodynamics", by Dill & Bromberg (2nd edn, 2011)

        :param delta_G: The reaction free energy ΔG, in kJ/mol
        :param alpha:   The multiplicative parameter of the Brønsted-Evans-Polanyi relation (BEP) model
        :param beta:    The multiplicative parameter of the BEP model, in 70 kJ/mol
        :param sigma:   The standard deviation, in kJ/mol, of the Gaussian noise to add to the estimates

        :return:        An estimate, based on the Brønsted-Evans-Polanyi relation (BEP),
                            of a plausible forward activation free energy, in kJ/mol,
                            for the given reaction free energy ΔG
        
nameargumentsreturns
rate_constant_from_activation_gibbs_energyactivation_delta_G :float, temp :floatfloat
        Using the Eyring equation from transition state theory,
        estimate the kinetic rate constant from the activation free energy.

        We are working under the assumption that the transmission coefficient κ = 1
        (the fraction of the flux through the transition state that proceeds to the product
        without recrossing the transition state)

        For more info: https://en.wikipedia.org/wiki/Eyring_equation

        Note that, at T=300 K, every additional 5.7434 kJ/mol (R T ln10) of activation free energy
        leads to a x10 decrease in the rate constant

        :param activation_delta_G:  Activation free energy (forward or reverse), in kJ/mol
        :param temp:                System's temperature, in degree Kelvins
        :return:                    The kinetic rate constant, in 1/sec, for either the forward or reverse reaction,
                                        depending on the type of activation_delta_G