[CHNOSZ-commits] r733 - in pkg/CHNOSZ: . R inst inst/tinytest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 21 11:34:13 CEST 2022
Author: jedick
Date: 2022-06-21 11:34:12 +0200 (Tue, 21 Jun 2022)
New Revision: 733
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/util.affinity.R
pkg/CHNOSZ/inst/NEWS.Rd
pkg/CHNOSZ/inst/tinytest/test-ionize.aa.R
Log:
affinity(): output message for protein ionization
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2022-06-21 00:10:00 UTC (rev 732)
+++ pkg/CHNOSZ/DESCRIPTION 2022-06-21 09:34:12 UTC (rev 733)
@@ -1,6 +1,6 @@
Date: 2022-06-21
Package: CHNOSZ
-Version: 1.9.9-25
+Version: 1.9.9-26
Title: Thermodynamic Calculations and Diagrams for Geochemistry
Authors at R: c(
person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),
Modified: pkg/CHNOSZ/R/util.affinity.R
===================================================================
--- pkg/CHNOSZ/R/util.affinity.R 2022-06-21 00:10:00 UTC (rev 732)
+++ pkg/CHNOSZ/R/util.affinity.R 2022-06-21 09:34:12 UTC (rev 733)
@@ -202,21 +202,24 @@
# A/2.303RT
A <- function() {
out <- mapply(`-`, X.fun("logK"), logQ(), SIMPLIFY = FALSE)
- # deal with affinities of protein ionization here 20120527
- if("H+" %in% rownames(mybasis) & get("thermo", CHNOSZ)$opt$ionize.aa) {
- # which species are proteins
+ # Deal with affinities of protein ionization here 20120527
+ if("H+" %in% rownames(mybasis)) {
+ # Which species are proteins
isprotein <- grepl("_", myspecies$name)
if(any(isprotein)) {
- # the rownumbers in thermo()$protein
- ip <- pinfo(myspecies$name[isprotein])
- # get the affinity of ionization
- iHplus <- match("H+", rownames(mybasis))
- # as.numeric is needed in case the logact column is character mode
- # due to buffer definition (that means we can't do pH buffers)
- pH <- -as.numeric(mybasis$logact[iHplus])
- A.ionization <- A.ionization(ip, vars, vals, T=T, P=P, pH=pH, transect=transect)
- # add it to the affinities of formation reactions of the non-ionized proteins
- out[isprotein] <- lsum(out[isprotein], A.ionization)
+ if(get("thermo", CHNOSZ)$opt$ionize.aa) {
+ message("affinity: ionizing proteins ...")
+ # The rownumbers in thermo()$protein
+ ip <- pinfo(myspecies$name[isprotein])
+ # Get the affinity of ionization
+ iHplus <- match("H+", rownames(mybasis))
+ # as.numeric is needed in case the logact column is character mode
+ # due to buffer definition (that means we can't do pH buffers)
+ pH <- -as.numeric(mybasis$logact[iHplus])
+ A.ionization <- A.ionization(ip, vars, vals, T = T, P = P, pH = pH, transect = transect)
+ # Add it to the affinities of formation reactions of the non-ionized proteins
+ out[isprotein] <- lsum(out[isprotein], A.ionization)
+ } else message("affinity: NOT ionizing proteins because thermo()$opt$ionize.aa is FALSE")
}
}
return(out)
Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd 2022-06-21 00:10:00 UTC (rev 732)
+++ pkg/CHNOSZ/inst/NEWS.Rd 2022-06-21 09:34:12 UTC (rev 733)
@@ -10,7 +10,7 @@
\newcommand{\s}{\ifelse{latex}{\eqn{_{#1}}}{\ifelse{html}{\out{<sub>#1</sub>}}{#1}}}
\newcommand{\S}{\ifelse{latex}{\eqn{^{#1}}}{\ifelse{html}{\out{<sup>#1</sup>}}{^#1}}}
-\section{Changes in CHNOSZ version 1.9.9-25 (2022-06-21)}{
+\section{Changes in CHNOSZ version 1.9.9-26 (2022-06-21)}{
\subsection{MAJOR CHANGE}{
\itemize{
@@ -89,6 +89,9 @@
\item Add a check to \code{add.protein()} that all new protein IDs
(protein name + organism name) are unique.
+ \item In \code{affinity()}, print a message to indicate whether
+ ionization calculations for proteins are being done.
+
}
}
Modified: pkg/CHNOSZ/inst/tinytest/test-ionize.aa.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-ionize.aa.R 2022-06-21 00:10:00 UTC (rev 732)
+++ pkg/CHNOSZ/inst/tinytest/test-ionize.aa.R 2022-06-21 09:34:12 UTC (rev 733)
@@ -5,12 +5,12 @@
expect_message(expect_error(ionize.aa(T = c(25, 25, 100, 100, 100), P = c(100, 1000, 1000, 1000, 1000))),
"18 species at 3 values of T \\(\u00BAC\\) and P \\(bar\\) \\(wet\\)", info = info)
expect_message(ia.25x10 <- ionize.aa(T = rep(25,10), ret.val = "pK"), "18 species at 25 \u00BAC and 1 bar \\(wet\\)", info = info)
-# we have ten rows of the same values
+# We have ten rows of the same values
expect_identical(ia.25x10[1, ], apply(ia.25x10, 2, unique), info = info)
# also ten rows of the same values for same pH
ia.7x10 <- ionize.aa(pH = rep(7, 10), ret.val = "pK")
expect_identical(ia.7x10[1, ], apply(ia.7x10, 2, unique), info = info)
-# same behaviour with alpha and aavals
+# Same behaviour with alpha and aavals
ia.7x10 <- ionize.aa(pH = rep(7, 10), ret.val = "alpha")
expect_identical(ia.7x10[1, ], apply(ia.7x10, 2, unique), info = info)
ia.7x10 <- ionize.aa(pH = rep(7, 10), ret.val = "aavals")
@@ -17,10 +17,10 @@
expect_identical(ia.7x10[1, ], apply(ia.7x10, 2, unique), info = info)
info <- "Charge summations for aa compositions are internally consistent"
-# one pH value should give the same results as two of the same value
+# One pH value should give the same results as two of the same value
expect_equal(ionize.aa(thermo()$protein[1:10,], pH = 7),
ionize.aa(thermo()$protein[1:10,], pH = c(7,7))[1, , drop = FALSE], check.attributes = FALSE, info = info)
-# at pH extremes we should be fully ionized
+# At pH extremes we should be fully ionized
iplus <- match(c("His", "Lys", "Arg", "chains"), colnames(thermo()$protein))
iminus <- match(c("Cys", "Asp", "Glu", "Tyr", "chains"), colnames(thermo()$protein))
ia520 <- ionize.aa(thermo()$protein[1:10,], pH = c(-5, 20))
@@ -28,7 +28,7 @@
expect_equal(ia520[2, ], -rowSums(thermo()$protein[1:10, iminus]), info = info)
info <- "Charge summations for aa compositions are consistent with literature"
-# comparison with values for LYSC_CHICK digitized from Fig. 10 of Dick et al., 2006
+# Comparison with values for LYSC_CHICK digitized from Fig. 10 of Dick et al., 2006
# charge at 25, 100, 150 degrees and at 25 degrees with cysteine suppressed (oxidized)
# at pH 4, 6, 8, 10, 12, 14
Z.LYSC_CHICK.25 <- c(13.3, 8.5, 5.1, -6.2, -14, -20.6)
@@ -37,7 +37,7 @@
Z.LYSC_CHICK.25_oxid <- c(13.5, 8.7, 7.6, 1.6, -6.2, -12.9)
aa <- pinfo(pinfo("LYSC_CHICK"))
pH <- c(4, 6, 8, 10, 12, 14)
-# the literature values are significantly different at this tolerance (the following is not TRUE)
+# The literature values are significantly different at this tolerance (the following is not TRUE)
# expect_equal(Z.LYSC_CHICK.25, Z.LYSC_CHICK.100, 1e-1, info = info)
expect_equal(ionize.aa(aa, pH = pH, T = 25)[, 1], Z.LYSC_CHICK.25, tolerance = 1e-1, check.attributes = FALSE, info = info)
expect_equal(ionize.aa(aa, pH = pH, T = 100)[, 1], Z.LYSC_CHICK.100, tolerance = 1e-1, check.attributes = FALSE, info = info)
@@ -45,7 +45,7 @@
expect_equal(ionize.aa(aa, pH = pH, T = 25, suppress.Cys = TRUE)[, 1], Z.LYSC_CHICK.25_oxid, tolerance = 1e-2, check.attributes = FALSE, info = info)
info <- "Heat capacity of ionization is consistent with literature"
-# heat capacity (kcal mol-1 K-1) of AMYA_PYRFU at 60, 80, 100, 120, 140 degrees
+# Heat capacity (kcal mol-1 K-1) of AMYA_PYRFU at 60, 80, 100, 120, 140 degrees
# for nonionzed protein and ionized protein at pH 6 and 12
# digitized from Fig. 11 of Dick et al., 2006
Cp.AMYA_PYRFU.nonion <- convert(c(41.26, 42.22, 42.85, 43.33, 43.74), "J")
@@ -54,7 +54,7 @@
aa <- pinfo(pinfo("AMYA_PYRFU"))
Cp.ionization.pH6 <- ionize.aa(aa, "Cp", T = c(60, 80, 100, 120, 140), pH = 6)
Cp.ionization.pH12 <- ionize.aa(aa, "Cp", T = c(60, 80, 100, 120, 140), pH = 12)
-# the literature values are significantly different at this tolerance (the following is not TRUE)
+# The literature values are significantly different at this tolerance (the following is not TRUE)
# expect_equal(Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion, Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion, 1e-2, info = info)
expect_equal(Cp.ionization.pH6[,1], (Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion)*1000, tolerance = 1e-2, check.attributes = FALSE, info = info)
expect_equal(Cp.ionization.pH12[,1], (Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion)*1000, tolerance = 1e-2, check.attributes = FALSE, info = info)
@@ -64,7 +64,7 @@
# digitized from Fig. 12 of Dick et al., 2006
G.AMY_BACSU.25 <- convert(c(-24.9, -24.9, -24.7, -24.5, -24.4, -23.9, -23.5, -23.2), "J")
G.AMY_BACSU.100 <- convert(c(-26.7, -26.7, -26.4, -26.1, -25.7, -25.1, -24.9, -24.9), "J")
-# to reproduce the calculations in the paper, use superseded properties of [Met], [Gly], and [UPBB]
+# To reproduce the calculations in the paper, use superseded properties of [Met], [Gly], and [UPBB]
mod.OBIGT("[Met]", G = -35245, H = -59310, S = 40.38, E_units = "cal")
mod.OBIGT("[Gly]", G = -6075, H = -5570, S = 17.31, E_units = "cal")
mod.OBIGT("[UPBB]", G = -21436, H = -45220, S = 1.62, E_units = "cal")
@@ -76,28 +76,28 @@
expect_equal(G.nonionized[2] + G.ionization.100, G.AMY_BACSU.100 * 1e6, tolerance = 1e-3, check.attributes = FALSE, info = info)
info <- "Affinity of ionization is consistent with manual calculations"
-# the equilibrium constant of ionization of [Cys] at 25 and 100 degres C
+# Equilibrium constant of ionization of [Cys] at 25 and 100 degres C
logK.Cys <- subcrt(c("[Cys]", "[Cys-]", "H+"), c(-1, 1, 1), T = c(25, 100))$out$logK
-# the affinity (A/2.303RT) of ionization of [Cys] at pH 7
+# Affinity (A/2.303RT) of ionization of [Cys] at pH 7
A.2303RT.Cys.pH7 <- logK.Cys + 7
-# the equilibrium constant of ionization of [His] at 25 degrees C
+# Equilibrium constant of ionization of [His] at 25 degrees C
logK.His <- subcrt(c("[His]", "H+", "[His+]"), c(-1, -1, 1), T = 25)$out$logK
-# the affinity (A/2.303RT) of ionization of [His] at pH 7 and 14
+# Affinity (A/2.303RT) of ionization of [His] at pH 7 and 14
A.2303RT.His.pH7_14 <- logK.His - c(7, 14)
-# calculate the affinities at pH 7 at 25 and 100 degrees C using ionize()
+# Calculate the affinities at pH 7 at 25 and 100 degrees C using ionize()
A.ionization.pH7 <- ionize.aa(property = "A", T = c(25, 100), ret.val = "aavals")
iCys <- match("[Cys-]", colnames(A.ionization.pH7))
expect_equal(A.2303RT.Cys.pH7, A.ionization.pH7[, iCys], check.attributes = FALSE, info = info)
-# calculate the affinities at pH 7 and 14 at 25 degrees C using ionize()
+# Calculate the affinities at pH 7 and 14 at 25 degrees C using ionize()
A.ionization.pH7_14 <- ionize.aa(property = "A", pH = c(7, 14), ret.val = "aavals")
iHis <- match("[His+]", colnames(A.ionization.pH7_14))
expect_equal(A.2303RT.His.pH7_14, A.ionization.pH7_14[, iHis], check.attributes = FALSE, info = info)
-# test whether the additive value for a protein is internally consistent
+# Test whether the additive value for a protein is internally consistent
alpha <- ionize.aa(ret.val = "alpha")
affinity <- ionize.aa(property = "A", ret.val = "aavals")
aa <- pinfo(pinfo("LYSC_CHICK"))
iionize <- match(c("Cys", "Asp", "Glu", "His", "Lys", "Arg", "Tyr", "chains", "chains"), colnames(aa))
-# the sum of the affinities of ionization of each ionizable group mutiplied by
+# Sum of the affinities of ionization of each ionizable group mutiplied by
# their degree of formation and by their frequency in the protein
A.protein <- sum(alpha * affinity * aa[, iionize])
expect_equal(ionize.aa(aa, property = "A")[1, ], A.protein, check.attributes = FALSE, info = info)
@@ -111,8 +111,15 @@
a2 <- affinity(iprotein = 1)
expect_equal(a1$values, a2$values, info = info)
-# references
+# Test added 20220621
+info <- "Message indicates status of ionization calculations"
+basis("CHNOS+")
+expect_message(a <- affinity(iprotein = 1), "affinity: ionizing proteins ...")
+thermo("opt$ionize.aa" = FALSE)
+expect_message(a <- affinity(iprotein = 1), "affinity: NOT ionizing proteins because thermo()$opt$ionize.aa is FALSE", fixed = TRUE)
+# References
+
# Dick, J. M., LaRowe, D. E. and Helgeson, H. C. (2006)
# Temperature, pressure, and electrochemical constraints on protein speciation:
# Group additivity calculation of the standard molal thermodynamic properties of ionized unfolded proteins.
More information about the CHNOSZ-commits
mailing list