示例#1
0
    def dG0_prime(self, pH, pMg, I):
        """
            Get a detla-deltaG estimate for this group of species.
            I.e., this is the difference between the dG0 and the dG'0, which
            only depends on the pKa of the pseudoisomers, but not on their
            formation energies.

            Args:
                pH  - the pH to estimate at.
                pMg - the pMg to estimate at.
                I   - the ionic strength to estimate at.

            Returns:
                The estimated delta G in the given conditions or None.
        """
        # Compute per-species transforms, scaled down by R*T.
        dG0_prime_vec = array(
            list(map(lambda s: s.dG0_prime(pH, pMg, I), self.species_list)))

        # Numerical issues: taking a sum of exp(v) for |v| quite large.
        # Use the fact that we take a log later to offset all values by a
        # constant (the minimum value).
        if len(dG0_prime_vec) > 0:
            dG0_f_prime = -settings.RT * logaddexp.reduce(
                (-1.0 / settings.RT) * dG0_prime_vec)
        else:
            raise Exception('compound contains no species')

        logging.info('KEGG_ID = %s, dG\'0_f = %.1f' %
                     (self.kegg_id, dG0_f_prime))
        return dG0_f_prime
    def dG0_prime(self, pH, pMg, I):
        """
            Get a detla-deltaG estimate for this group of species.
            I.e., this is the difference between the dG0 and the dG'0, which
            only depends on the pKa of the pseudoisomers, but not on their
            formation energies.

            Args:
                pH  - the pH to estimate at.
                pMg - the pMg to estimate at.
                I   - the ionic strength to estimate at.

            Returns:
                The estimated delta G in the given conditions or None.
        """
        if self.phase == DEFAULT_PHASE:
            # Compute per-species transforms, scaled down by R*T.
            dG0_prime_vec = array(map(lambda s: s.dG0_prime(pH, pMg, I),
                                      self.species_list))
            
            # Numerical issues: taking a sum of exp(v) for |v| quite large.
            # Use the fact that we take a log later to offset all values by a
            # constant (the minimum value).
            dG0_f_prime = -RT * logaddexp.reduce((-1.0 / RT) * dG0_prime_vec)
        else:
            dG0_f_prime = self.species_list[0].dG0_prime(pH, pMg, I)
        
        logging.info('KEGG_ID = %s, dG\'0_f = %.1f' % (self.kegg_id, dG0_f_prime))
        return dG0_f_prime
示例#3
0
def log_integrate_log_trap(log_func, log_support):
    """
    Trapezoidal integration of given log(func)
    Returns log of the integral
    """

    log_func_sum = logaddexp(log_func[:-1], log_func[1:]) - log(2)
    log_dxs = logsubexp(log_support[:-1], log_support[1:])

    return logaddexp.reduce(log_func_sum + log_dxs)
示例#4
0
def log_integrate_log_trap(log_func,log_support):
    """
    Trapezoidal integration of given log(func)
    Returns log of the integral
    """

    log_func_sum = logaddexp(log_func[:-1], log_func[1:]) - log(2)
    log_dxs = logsubexp(log_support[:-1], log_support[1:])

    return logaddexp.reduce(log_func_sum + log_dxs)