[CHNOSZ-commits] r884 - in pkg/CHNOSZ: . R demo inst man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 23 13:17:59 CEST 2025


Author: jedick
Date: 2025-04-23 13:17:59 +0200 (Wed, 23 Apr 2025)
New Revision: 884

Added:
   pkg/CHNOSZ/demo/MgATP.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/vignettes/anintro.Rmd
Log:
Add demo/MgATP.R (speciation of ATP with H+ and Mg+2)


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/DESCRIPTION	2025-04-23 11:17:59 UTC (rev 884)
@@ -1,6 +1,6 @@
 Date: 2025-04-23
 Package: CHNOSZ
-Version: 2.1.0-55
+Version: 2.1.0-56
 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/examples.R
===================================================================
--- pkg/CHNOSZ/R/examples.R	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/R/examples.R	2025-04-23 11:17:59 UTC (rev 884)
@@ -34,7 +34,8 @@
   "ORP", "ionize", "buffer", "protbuff", "glycinate",
   "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "minsol",
   "Shh", "saturation", "adenine", "DEW", "lambda", "potassium", "TCA", "aluminum",
-  "AD", "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity", "uranyl", "sum_S"),
+  "AD", "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity", "uranyl",
+  "sum_S", "MgATP"),
   save.png = FALSE) {
   # Run one or more demos from CHNOSZ with ask = FALSE, and return the value of the last one
   out <- NULL

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/demo/00Index	2025-04-23 11:17:59 UTC (rev 884)
@@ -34,3 +34,4 @@
 rank.affinity   Affinity ranking for proteins in yeast nutrient limitation
 yttrium         logK.to.OBIGT fits at 800 and 1000 bar and Y speciation in NaCl solution at varying pH
 uranyl          Total (carbonate|sulfate)-pH diagrams for uranyl species
+MgATP           Speciation of ATP with H+ and Mg+2

Added: pkg/CHNOSZ/demo/MgATP.R
===================================================================
--- pkg/CHNOSZ/demo/MgATP.R	                        (rev 0)
+++ pkg/CHNOSZ/demo/MgATP.R	2025-04-23 11:17:59 UTC (rev 884)
@@ -0,0 +1,106 @@
+# CHNOSZ/demo/MgATP.R
+# Speciation of ATP with H+ and Mg+2
+# 20250423 Moved from anintro.Rmd
+
+# Speciation plots, similar to Figures 1.2-1.5 in Alberty (2003).
+# These figures show the distribution of differently charged species of
+# adenosine triphosphate (ATP) as a function of pH,
+# and the average number of H+ and Mg+2 bound to ATP in solution as a function of pH or pMg.
+
+par(mfrow = c(2, 2), mar = c(3.1, 3.6, 2.1, 1.6), mgp = c(1.8, 0.5, 0))
+
+# For the following calculations, we change the nonideality method to Alberty.
+# This is a simpler formulation than the default,
+# with parameters that are suitable for biochemical species at relatively low temperatures.
+
+oldnon <- nonideal("Alberty")
+
+# Use the following commands to set the basis species,
+# add the variously protonated ATP species,
+# calculate the affinities of the formation reactions,
+# equilibrate the system, and make a degree of formation (alpha) or mole fraction diagram.
+# This is similar to Figure 1.3 of Alberty (2003), but is calculated for I = 0 M and T = 100 degrees C.
+
+basis("MgCHNOPS+")
+species(c("ATP-4", "HATP-3", "H2ATP-2", "H3ATP-", "H4ATP"))
+T <- 100
+a <- affinity(pH = c(3, 9), T = T)
+e <- equilibrate(a)
+d <- diagram(e, alpha = TRUE, tplot = FALSE)
+title(main = describe.property("T", T))
+
+# Note that we have saved the numeric results of diagram(), i.e. the degrees of formation of the species (alpha).
+# With that, we can calculate and plot the average number of protons bound per ATP molecule.
+# To do so, we use R's rbind() and do.call() to turn alpha into a matrix,
+# then multiply by the number of protons bound to each species,
+# and sum the columns to get the total (i.e. average proton number, N_H+).
+
+alphas <- do.call(rbind, d$plotvals)
+nH <- alphas * 0:4
+Hlab <- substitute(italic(N)[H^`+`])
+plot(a$vals[[1]], colSums(nH), type = "l", xlab = "pH", ylab=Hlab, lty=2, col=2)
+
+# Adding the IS argument to affinity(), we can now plot N_H+ at the given ionic strength.
+# Here we set plot.it = FALSE diagram() because we use the computed alpha to make our own plot.
+# This is similar to Figure 1.3 of Alberty (2003), but at higher temperature.
+
+a <- affinity(pH = c(3, 9), IS = 0.25, T = T)
+e <- equilibrate(a)
+d <- diagram(e, alpha = TRUE, plot.it = FALSE)
+alphas <- do.call(rbind, d$plotvals)
+nH <- alphas * 0:4
+lines(a$vals[[1]], colSums(nH))
+legend("topright", legend = c("I = 0 M", "I = 0.25 M"), lty = 2:1, col = 2:1, cex = 0.8)
+ATP.H <- substitute("ATP and H"^`+`)
+title(main = ATP.H)
+
+# Next, we add the Mg+2-complexed ATP species:
+
+species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP"), add = TRUE)
+
+# Here is a function to calculate and plot N_H+ for a given pMg:
+
+Hplot <- function(pMg, IS = 0.25) {
+  basis("Mg+2", -pMg)
+  a <- affinity(pH = c(3, 9), IS = IS, T = T)
+  e <- equilibrate(a)
+  d <- diagram(e, alpha = TRUE, plot.it = FALSE)
+  alphas <- do.call(rbind, d$plotvals)
+  NH <- alphas * c(0:4, 0, 1, 2, 0)
+  lines(a$vals[[1]], colSums(NH), lty = 7 - pMg, col = 7 - pMg)
+}
+
+# With that function in hand, we plot the lines corresponding to pMg = 2 to 6.
+# This is similar to Figure 1.4 of Alberty (2003):
+
+plot(c(3, 9), c(0, 2), type = "n", xlab = "pH", ylab = Hlab)
+lapply(2:6, Hplot)
+legend("topright", legend = paste("pMg = ", 2:6), lty = 5:1, col = 5:1, cex = 0.8)
+ATP.H.Mg <- substitute("ATP and H"^`+`~"and Mg"^`+2`)
+title(main = ATP.H.Mg)
+
+# The next function calculates and plots the average number of Mg+2 bound to ATP (N_Mg+2) for a given pH.
+# Here we multiply alpha by the number of Mg+2 in each species, and negate loga_Mg+2 (the variable used in affinity()) to get pMg.
+
+Mgplot <- function(pH, IS = 0.25) {
+  basis("pH", pH)
+  a <- affinity(`Mg+2` = c(-2, -7), IS = IS, T = T)
+  e <- equilibrate(a)
+  d <- diagram(e, alpha = TRUE, plot.it = FALSE)
+  alphas <- do.call(rbind, d$plotvals)
+  NMg <- alphas * species()$`Mg+`
+  lines(-a$vals[[1]], colSums(NMg), lty = 10 - pH, col = 10 - pH)
+}
+
+# Using that function, we plot the lines corresponding to pH = 3 to 9.
+# This is similar to Figure 1.5 of Alberty (2003):
+
+Mglab <- substitute(italic(N)[Mg^`+2`])
+plot(c(2, 7), c(0, 1.2), type = "n", xlab = "pMg", ylab = Mglab)
+lapply(3:9, Mgplot)
+legend("topright", legend = paste("pH = ", 3:9), lty = 7:1, col = 7:1, cex = 0.8)
+title(main = ATP.H.Mg)
+
+# Now that we're finished, we can reset the nonideality method to the default.
+
+nonideal(oldnon)

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2025-04-23 11:17:59 UTC (rev 884)
@@ -15,7 +15,7 @@
 \newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
 \newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{Δ<I>G</I>°}}{ΔG°}}}
 
-\section{Changes in CHNOSZ version 2.1.0-53 (2025-04-21)}{
+\section{Changes in CHNOSZ version 2.1.0-56 (2025-04-23)}{
 
   \subsection{OBIGT DEFAULT DATA}{
     \itemize{
@@ -87,7 +87,8 @@
   \subsection{DOCUMENTATION}{
     \itemize{
 
-      \item Revise and shorten \file{anintro.Rmd} with AI assistance.
+      \item Revise \file{anintro.Rmd}. Text before \dQuote{Building Up} was
+      revised and shortened with AI assistance.
 
       \item Add FAQ question: Why are mineral stability boundaries curved on
       mosaic diagrams?
@@ -102,6 +103,11 @@
       \item Revise \file{demo/sum_S.R} for log \emph{f}O\s{2} - log \emph{m} ΣS
       diagram and add solubility contours for Fe and Au.
 
+      \item Add \file{demo/MgATP.R}: speciation of ATP with H\S{+} and
+      Mg\S{+2}, based on
+      \href{https://search.worldcat.org/title/51242181}{Alberty (2003)}
+      (example moved here from \file{anintro.Rmd}).
+
       \item Update \file{demo/contour.R} to use conditions taken from
       \href{https://doi.org/10.1016/j.oregeorev.2022.105231}{Ding et al.
         (2023)} and optional data for Au species from IGEM RAS, including

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/man/examples.Rd	2025-04-23 11:17:59 UTC (rev 884)
@@ -19,7 +19,7 @@
     "contour", "sphalerite", "minsol", "Shh", "saturation",
     "adenine", "DEW", "lambda", "potassium", "TCA", "aluminum", "AD",
     "comproportionation", "Pourbaix", "E_coli", "yttrium", "rank.affinity",
-    "uranyl", "sum_S"),
+    "uranyl", "sum_S", "MgATP"),
     save.png = FALSE)
 }
 
@@ -68,6 +68,7 @@
     \item{yttrium}{\code{\link{logK.to.OBIGT}} fits at 800 and 1000 bar and Y speciation in \code{\link{NaCl}} solution at varying pH (Guan et al., 2020)}
     \item{uranyl}{Total (carbonate|sulfate)-pH diagrams for uranyl species (Migdisov et al., 2024)}
     \item{sum_S}{Summed molality of S species and solubility contours for iron and gold (Skirrow and Walshe, 2002)}
+    \item{MgATP}{Speciation of ATP with H+ and Mg+2 (Alberty, 2003)}
   }
 
 For either function, if \code{save.png} is TRUE, the plots are saved in \code{\link{png}} files whose names begin with the names of the help topics or demos.
@@ -99,6 +100,8 @@
 
 Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57.
 
+Alberty, R. A. (2003) \emph{Thermodynamics of Biochemical Reactions}, John Wiley & Sons, Hoboken, New Jersey, 397 p. \url{https://www.worldcat.org/oclc/51242181}
+
 Amend, J. P. and Shock, E. L. (1998) Energetics of amino acid synthesis in hydrothermal ecosystems. \emph{Science} \bold{281}, 1659--1662. \doi{10.1126/science.281.5383.1659}
 
 Amend, J. P. and Shock, E. L. (2001) Energetics of overall metabolic reactions of thermophilic and hyperthermophilic Archaea and Bacteria. \emph{FEMS Microbiol. Rev.} \bold{25}, 175--243. \doi{10.1016/S0168-6445(00)00062-0}

Modified: pkg/CHNOSZ/vignettes/anintro.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/anintro.Rmd	2025-04-23 09:21:23 UTC (rev 883)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2025-04-23 11:17:59 UTC (rev 884)
@@ -806,6 +806,11 @@
   - `TCA`: Citric acid cycle energetics
   - `comproportionation`: Using a color scale (image map)
 
+*Calculations using the output of `diagram()`*
+
+  - `buffer`: Place labels next to lines
+  - `MgATP`: Calculate number of protons bound per ATP molecule
+
 *Activity buffers*
 
   - `buffer`: Plotting buffers as a function of temperature



More information about the CHNOSZ-commits mailing list