From noreply at r-forge.r-project.org Thu Feb 2 18:17:23 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 2 Feb 2017 18:17:23 +0100 (CET) Subject: [CHNOSZ-commits] r125 - in pkg/CHNOSZ: . R inst tests/testthat vignettes Message-ID: <20170202171723.2A96A180FCD@r-forge.r-project.org> Author: jedick Date: 2017-02-02 18:17:22 +0100 (Thu, 02 Feb 2017) New Revision: 125 Added: pkg/CHNOSZ/vignettes/CHNOSZ.png pkg/CHNOSZ/vignettes/newintro.Rmd Removed: pkg/CHNOSZ/vignettes/EOSregress.bib Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/util.units.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/tests/testthat/test-info.R pkg/CHNOSZ/vignettes/EOSregress.Rmd pkg/CHNOSZ/vignettes/vig.bib pkg/CHNOSZ/vignettes/vig.css Log: begin writing newintro.Rmd Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-02 17:17:22 UTC (rev 125) @@ -1,6 +1,6 @@ -Date: 2017-01-29 +Date: 2017-02-02 Package: CHNOSZ -Version: 1.0.8-14 +Version: 1.0.8-15 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/R/info.R 2017-02-02 17:17:22 UTC (rev 125) @@ -160,7 +160,7 @@ if(length(approx.species)==1) { message("info.approx: '", species, "' is similar to ", info.text(approx.species)) } else { - napprox.max <- 25 + napprox.max <- 100 exttext <- ":" if(length(approx.species) > napprox.max) exttext <- paste(" (showing first ", napprox.max, ")", sep="") message("info.approx: '", species, "' is ambiguous; has approximate matches to ", Modified: pkg/CHNOSZ/R/util.units.R =================================================================== --- pkg/CHNOSZ/R/util.units.R 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/R/util.units.R 2017-02-02 17:17:22 UTC (rev 125) @@ -11,7 +11,7 @@ # set the units and return them if(units=="bar") with(as.environment("CHNOSZ"), thermo$opt$P.units <- "bar") if(units=="mpa") with(as.environment("CHNOSZ"), thermo$opt$P.units <- "MPa") - return(get("thermo")$opt$P.units) + message("changed pressure units to ", get("thermo")$opt$P.units) } T.units <- function(units=NULL) { @@ -24,7 +24,7 @@ # set the units and return them if(units=="c") with(as.environment("CHNOSZ"), thermo$opt$T.units <- "C") if(units=="k") with(as.environment("CHNOSZ"), thermo$opt$T.units <- "K") - return(get("thermo")$opt$T.units) + message("changed temperature units to ", get("thermo")$opt$T.units) } E.units <- function(units=NULL) { @@ -37,7 +37,7 @@ # set the units and return them if(units=="cal") with(as.environment("CHNOSZ"), thermo$opt$E.units <- "cal") if(units=="j") with(as.environment("CHNOSZ"), thermo$opt$E.units <- "J") - return(get("thermo")$opt$E.units) + message("changed energy units to ", get("thermo")$opt$E.units) } outvert <- function(value,units) { Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/inst/NEWS 2017-02-02 17:17:22 UTC (rev 125) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-14 (2017-01-29) +CHANGES IN CHNOSZ 1.0.8-15 (2017-02-02) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -39,6 +39,8 @@ message() from base R. As a result, the messages don't appear in Sweave vignettes, but can now be turned on or off easily in knitr vignettes. +- Add vignette newintro.Rmd. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/tests/testthat/test-info.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-info.R 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/tests/testthat/test-info.R 2017-02-02 17:17:22 UTC (rev 125) @@ -19,7 +19,6 @@ }) test_that("info.approx() produces expected messages", { - expect_message(info.approx("lact"), "showing first 25") expect_message(info.approx("lactic"), "is similar to lactic acid") expect_message(info.approx("lactic acid"), "is ambiguous") # note though that info("lactic acid") finds a match b/c info.character is used first... Added: pkg/CHNOSZ/vignettes/CHNOSZ.png =================================================================== (Binary files differ) Property changes on: pkg/CHNOSZ/vignettes/CHNOSZ.png ___________________________________________________________________ Added: svn:mime-type + image/png Modified: pkg/CHNOSZ/vignettes/EOSregress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-02-02 17:17:22 UTC (rev 125) @@ -5,7 +5,7 @@ date: "`r Sys.Date()`" output: tufte::tufte_html: - tufte_features: ["background", "italics"] + tufte_features: ["background"] css: "vig.css" tufte::tufte_handout: citation_package: natbib @@ -17,7 +17,7 @@ %\VignetteIndexEntry{Regressing thermodynamic data} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} -bibliography: EOSregress.bib +bibliography: vig.bib link-citations: yes --- Deleted: pkg/CHNOSZ/vignettes/EOSregress.bib =================================================================== --- pkg/CHNOSZ/vignettes/EOSregress.bib 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/vignettes/EOSregress.bib 2017-02-02 17:17:22 UTC (rev 125) @@ -1,108 +0,0 @@ -% Encoding: UTF-8 - - at Article{HKF81, - author = {Helgeson, Harold C. and Kirkham, David H. and Flowers, George C.}, - journal = {American Journal of Science}, - title = {{T}heoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: {IV}. {C}alculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600?{C} and 5 {K}b}, - year = {1981}, - volume = {281}, - number = {10}, - pages = {1249--1516}, - doi = {10.2475/ajs.281.10.1249}, - size = {268 p.}, -} - - at Article{SSW01, - author = {Schulte, Mitchell D. and Shock, Everett L. and Wood, Robert H.}, - journal = {Geochimica et Cosmochimica Acta}, - title = {{T}he temperature dependence of the standard-state thermodynamic properties of aqueous nonelectrolytes}, - year = {2001}, - volume = {65}, - number = {21}, - pages = {3919--3930}, - doi = {10.1016/S0016-7037(01)00717-7}, -} - - at Article{SH90, - author = {Shock, Everett L. and Helgeson, Harold C.}, - journal = {Geochimica et Cosmochimica Acta}, - title = {{C}alculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {S}tandard partial molal properties of organic species}, - year = {1990}, - volume = {54}, - number = {4}, - pages = {915 -- 945}, - doi = {10.1016/0016-7037(90)90429-O}, -} - - at Article{SOJSH92, - author = {Shock, Everett L. and Oelkers, Eric H. and Johnson, James W. and Sverjensky, Dimitri A. and Helgeson, Harold C.}, - journal = {Journal of the Chemical Society, Faraday Transactions}, - title = {{C}alculation of the thermodynamic properties of aqueous species at high pressures and temperatures: {E}ffective electrostatic radii, dissociation constants, and standard partial molal properties to 1000 ?{C} and 5 kbar}, - year = {1992}, - volume = {88}, - number = {6}, - pages = {803 -- 826}, - doi = {10.1039/FT9928800803}, -} - - at Article{TH88, - author = {Tanger, IV, John C. and Helgeson, Harold C.}, - journal = {American Journal of Science}, - title = {{C}alculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {R}evised equations of state for the standard partial molal properties of ions and electrolytes}, - year = {1988}, - volume = {288}, - number = {1}, - pages = {19--98}, - doi = {10.2475/ajs.288.1.19}, -} - - at Article{HW97, - author = {Hn\v{e}dkovsk\'y, Lubom\'ir and Wood, Robert H.}, - journal = {Journal of Chemical Thermodynamics}, - title = {{A}pparent molar heat capacities of aqueous solutions of {CH}4, {CO}2, {H}2{S}, and {NH}3 at temperatures from 304 {K} to 704 {K} at a pressure of 28 {MP}a}, - year = {1997}, - volume = {29}, - number = {7}, - pages = {731--747}, - doi = {10.1006/jcht.1997.0192}, - issn = {0021-9614}, -} - - at Article{MKDW15, - author = {Miron, George D. and Kulik, Dmitrii A. and Dmytrieva, Svitlana V. and Wagner, Thomas}, - journal = {Applied Geochemistry}, - title = {{GEMSFITS}: {C}ode package for optimization of geochemical model parameters and inverse modeling}, - year = {2015}, - volume = {55}, - number = {0}, - pages = {28 - 45}, - note = {Geochemical Speciation Codes and Databases}, - doi = {10.1016/j.apgeochem.2014.10.013}, - issn = {0883-2927}, -} - - at Article{Shv15, - author = {Shvarov, Yuri}, - journal = {Applied Geochemistry}, - title = {{A} suite of programs, {O}ptim{A}, {O}ptim{B}, {O}ptim{C}, and {O}ptim{S} compatible with the {U}nitherm database, for deriving the thermodynamic properties of aqueous species from solubility, potentiometry and spectroscopy measurements}, - year = {2015}, - volume = {55}, - number = {0}, - pages = {17 - 27}, - note = {Geochemical Speciation Codes and Databases}, - doi = {10.1016/j.apgeochem.2014.11.021}, - issn = {0883-2927}, -} - - at Article{HWM96, - author = {Hn\v{e}dkovsk\'y, Lubom\'ir and Wood, Robert H. and Majer, Vladimir}, - journal = {Journal of Chemical Thermodynamics}, - title = {{V}olumes of aqueous solutions of {CH}4, {CO}2, {H}2{S}, and {NH}3 at temperatures from 298.15 {K} to 705 {K} and pressures to 35 {MP}a}, - year = {1996}, - volume = {28}, - number = {2}, - pages = {125 -- 142}, - doi = {10.1006/jcht.1996.0011}, - issn = {0021-9614}, -} - Added: pkg/CHNOSZ/vignettes/newintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/newintro.Rmd (rev 0) +++ pkg/CHNOSZ/vignettes/newintro.Rmd 2017-02-02 17:17:22 UTC (rev 125) @@ -0,0 +1,309 @@ +--- +title: "An Introduction to [CHNOSZ](http://www.chnosz.net)" +author: "Jeffrey M. Dick" +date: "`r Sys.Date()`" +output: + tufte::tufte_html: + tufte_features: ["background"] + css: "vig.css" + toc: true + tufte::tufte_handout: + citation_package: natbib + latex_engine: xelatex + tufte::tufte_book: + citation_package: natbib + latex_engine: xelatex +vignette: > + %\VignetteIndexEntry{An Introduction to CHNOSZ} + %\VignetteEngine{knitr::rmarkdown} + \usepackage[utf8]{inputenc} +bibliography: vig.bib +link-citations: yes +--- + +```{r options, include=FALSE} +options(width = 80) +options(digits = 6) +``` + +```{r setup, include=FALSE} +# invalidate cache when the tufte version changes +knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) +options(htmltools.dir.version = FALSE) +knitr::knit_hooks$set(small.mar = function(before, options, envir) { + if (before) par(mar = c(4, 4, .1, .1)) # smaller margin on top and right +}) +``` + +# About + +This document introduces the basic functionality of CHNOSZ, a package for the [R software environment](http://r-project.org). +For more information on R, see "An Introduction to R" and other documents in [The R Manuals](http://cran.r-project.org/manuals.html). + +Since 2006, CHNOSZ has been developed to support a research project on the thermodynamic properties of proteins. +Over time, the package has grown to calculate thermodynamic properties of reactions and to construct equilibrium chemical activity diagrams for both inorganic and organic systems. +Development since 2009 has focused on the calculation of chemical affinities and metastable equilibrium for large numbers of proteins with applications to -omic (metagenomic and proteomic) data in various environments. +Nevertheless, the database and functions are flexible, allowing one to model the relative stabilities of proteins, minerals or aqueous species using similar commands. + +## Installing and loading CHNOSZ + +If you have just installed R for the first time, and you have an internet connection, installing CHNOSZ should be as simple as selecting the "Install packages from CRAN" or similar menu item in the R GUI or using the following command to start the package installation process:^[Or, install the package from a local package file, which you can download from [CRAN](http://cran.r-project.org) or from the [CHNOSZ website](http://chnosz.net). +][]() +```{r install_CHNOSZ, eval=FALSE} +install.packages("CHNOSZ") +``` + +Then load the CHNOSZ package to make its functions available in your working session. +```{r library_CHNOSZ} +library(CHNOSZ) +``` + +Then load the thermo object, which contains the thermodynamic database and is also where your system settings will be stored. +```{r data_thermo} +data(thermo) +``` + +## Organization of major functions + +CHNOSZ is made up of a set of functions and supporting datasets. +The major components of the package are shown in the figure below, which is an updated version of the flowchart from @Dic08 (boxes ? functions; ellipses ? datasets; bold text ? major user functions). +![CHNOSZ flowchart](CHNOSZ.png) + +Many functions in CHNOSZ have no side effects. +That is, the function only returns a result; to use the result in other functions, it can be assigned to a variable with `<-`. +Major functions without side effects in CHNOSZ are: + +* `info()`: search for species in the thermodynamic database +* `subcrt()`: calculate the thermodynamic properties of species and reactions +* `affinity()`: calculate the affinities of formation reactions using given chemical activities +* `equilibrate()`: calculate the equilibrium chemical activities of the species of interest +* `diagram()`: plot the results + +Some functions in CHNOSZ do have side effects: they modify the `thermo` data object in the current R session. +In the text (not code) of this document, the names of these functions are shown in red. +The major functions with side effects are: + +* `basis()`: set the basis species and their chemical activities +* `species()`: set the species of interest and their (non-equilibrium) chemical activities +* `data(thermo)`: reset the database, restoring all settings to their default values. + +The following pseudocode shows a common sequence of commands. +In actual usage, the ... are replaced by arguments that define the chemical makeup and range of conditions of the system: +```{r, eval=FALSE} +basis(...) +species(...) +a <- affinity(...) +e <- equilibrate(a) ## optional +diagram(e) ## or diagram(a) +data(thermo) ## clear system settings +``` + +Some experimental functions are available: + +* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. + +# Thermodynamic database and chemical formulas + +While an attempt has been made to provide a primary database (`OBIGT.csv`) that is generally internally consistent, all thermodynamic data, calculations, and examples are provided *as is*.^[ +For crucial problems, check not only the accuracy of the database, but also the *suitability of the data* for your problem. +If there is any doubt about the suitability of data, please consult the primary sources (which can be located using `browse.refs()`; see Section XXX). +As with the data, please check the *suitability and accuracy of the available computational techniques*, at least by comparing the construction and output of the examples to the primary sources cited in each help page. +Some examples without references demonstrate the more experimental features of CHNOSZ. +] +Where possible, data with known or suspected inconsistencies have been placed into a secondary database (`OBIGT-2.csv`) that should be regarded as experimental. + +## The `info()` function + +The `info()` function provides an interface to the thermodynamic database packaged with CHNOSZ. +Suppose you are interested in the thermodynamic properties aqueous ethylene. +You can search for the species by name: +```{r info_ethylene} +info("ethylene") +``` + +Multiple entries exist for ethylene; the index of the `aq` (aqueous) species is returned by default. +A second argument can be used to specify a different physical state: +```{r info_ethylene_gas} +info("ethylene", "gas") +``` + +Knowing that aqueous ethylene is species number 88 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: +```{r info_88} +info(88) +``` + +This number can be used as an argument (`ispecies`) for other functions in CHNOSZ to uniquely identify any species; some commonly used functions also accept the species names. +Liquid water is species number 1; it has NA entries in the database because specialized functions are used to compute its properties: +```{r info_info_water} +info(info("water")) +``` + +## Fuzzy searches + +Calling `info()` with a string that does not exactly match the name of any species invokes a fuzzy search of the database: +```{r width180, include=FALSE} +options(width = 180) +``` +```{r info_acid} +info("acid") +``` +```{r width80, include=FALSE} +options(width = 80) +``` + +The message includes e.g. "uracil" and "metacinnabar" because their names have some similarity to the search term. + +As "ribose" is the name of a species in the database, to find species with similar names, add an extra character to the search: +```{r info_ribose} +info(" ribose") +``` + +The messages may be useful for browsing the database, but owing to their ambiguous results, these fuzzy searches return an `NA` value for the species index. + +## Counting elements, chemical formulas, `ZC()` + +Continuing with the example of ethylene, let's look at its chemical formula: +```{r info_88_formula} +info(88)$formula +``` + +We can use the `makeup()` function to count the elements in the formula, followed by `as.chemical.formula()` to return to the formula: +```{r makeup_88} +makeup(88) +as.chemical.formula(makeup(88)) +``` + +For organic species, a simple calculation of the average oxidation state of carbon ($Z_C$) is possible given the species index, chemical formula, or elemental count: +```{r ZC_88} +ZC(88) +ZC(info(88)$formula) +ZC(makeup(88)) +``` + +# Calculating thermodynamic properties + +To calculate the standard molal properties of species and reactions, use `subcrt()`.^[ +The inspiration for this function (as well as its name), and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of H2O, is SUPCRT (Johnson et al. 1992).] [- at JOH92] +If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: +```{r subcrt_water} +subcrt("water") +``` + +That uses the default temperature and pressure settings: equally-spaced temperature grid from 0 to 350 ?C at _P_sat.^[_P_sat is 1 bar below 100 ?C, or the pressure of liquid-vapor coexistence at higher temperatures.] +The columns in the output are^[The corresponding units are ?C (`T`), bar (`P`), g cm-3 (`rho`), cal mol-1 (`G` and `H`), cal K-1 mol-1 (`S`), cm3 mol-1 (`V`), and cal K-1 mol-1 (`Cp`).] temperature, pressure, density of water, logarithm of the equilibrium constant (only meaningful for reactions; see below), standard molal Gibbs energy and enthalpy of formation from the elements, standard molal entropy, volume, and heat capacity. + +A custom temperature-pressure grid can be specified. +Here, we calculate the properties of H2O on a _T_,_P_ grid in the supercritical region, with conditions grouped by pressure: +```{r subcrt_water_grid} +subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water +``` + +```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE} +H2O <- subcrt("water", T=seq(0, 1000, 100), P=c(NA, seq(1, 500, 1)), grid="T") +H2O <- H2O$out$water +plot(H2O$P, H2O$rho, type="l") +``` +The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. `write.table()` or `plot()` for further processing: +```{r subcrt_water_plot, eval=FALSE} +``` + +## Changing units + +The default units of temperature, pressure, and energy are ?C, bar, and calories. +The functions `T.units()`, `P.units()`, and `E.units()` can be used to change the units used by various functions in CHNOSZ. +What is the Gibbs energy (J/mol) of aqueous methane at 298.15 K and 0.1 MPa? +```{r methane_units, message=FALSE} +T.units("K") +P.units("MPa") +E.units("J") +subcrt("methane", T=298.15, P=0.1)$out$methane$G +data(thermo) ## restore default settings +``` + +A related function, `convert()`, can be used to convert given values between units. +Let's convert the standard Gibbs energy of aqueous methane listed in the database from cal/mol to J/mol: +```{r methane_G, message=FALSE} +convert(info(info("methane"))$G, "J") +``` + +As expected, we get the same result from both operations. + +# Properties of reactions + +## Reaction definitions + +To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to `subcrt()`. +Here we calculate properties for the dissolution of CO2: +```{r CO2_dissolution} +subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1)) +``` + +

+In order to make a plot like that shown by Manning et al. [- at MSS13, Figure 18], let's run more calculations and store the results. +In addition to the reaction definition, we specify a greater number of temperature points than the default: +```{r dissolution, echo=FALSE, message=FALSE} +T <- seq(0, 350, 10) +CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +CO <- subcrt(c("CO", "CO"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +logK <- data.frame(T, CO2, CO, CH4) +``` +```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE} +matplot(logK[, 1], logK[, -1], type="l", + xlab=axis.label("T"), ylab=axis.label("logK")) +``` +```{r dissolution, eval=FALSE} +``` + +Now we can make the plot. +Here, the `axis.label()` function of CHNOSZ is used to create formatted axis labels: +```{r dissolution_plot, eval=FALSE} +``` + +## Unbalanced reactions + +## Setting the basis species + +## Auto-balancing reactions + +# Basic diagrams + +## Setting the species of interest + +## Thermodynamic potential: `affinity()` + +## Predominance: the `diagram()` function + +## Labels, colors, etc. + +# Equilibration + +## Getting from affinity to equilibrium + +## Setting the constraints + +# Other things you can do with affinity + +## Buffers + +## T-, P-, activity-transect + +# Other things you can do with equilibrate + +## Choosing different balancing constraints + +# Other things you can do with diagrams + +## Mosaic diagrams + +## Groups of species + +# Proteins + +## Group additivity + +## Sources of amino acid data + +## Ionization + +## Normalizing for different lengths Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-02 17:17:22 UTC (rev 125) @@ -299,6 +299,18 @@ url = {http://www.worldcat.org/oclc/583263} } + at Article{HKF81, + author = {Helgeson, Harold C. and Kirkham, David H. and Flowers, George C.}, + journal = {American Journal of Science}, + title = {{T}heoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: {IV}. {C}alculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600?{C} and 5 {K}b}, + year = {1981}, + volume = {281}, + number = {10}, + pages = {1249--1516}, + doi = {10.2475/ajs.281.10.1249}, + size = {268 p.}, +} + @Article{HFG+03, author = {Huh, Won-Ki and Falvo, James V. and Gerke, Luke C. and Carroll, Adam S. and Howson, Russell W. and Weissman, Jonathan S. and O'Shea, Erin K.}, journal = {Nature}, @@ -324,7 +336,7 @@ @Article{JOH92, author = {Johnson, James W. and Oelkers, Eric H. and Helgeson, Harold C.}, journal = {Computers \& Geosciences}, - title = {{SUPCRT}92: {A} software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000$^\circ${C}}, + title = {SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000?C}, year = {1992}, volume = {18}, number = {7}, @@ -342,6 +354,17 @@ doi = {10.1016/j.gca.2011.11.041}, } + at Article{MSS13, + author = {Manning, Craig E. and Shock, Everett L. and Sverjensky, Dimitri A.}, + journal = {Reviews in Mineralogy and Geochemistry}, + title = {The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints}, + year = {2013}, + volume = {75}, + number = {1}, + pages = {109-148}, + doi = {10.2138/rmg.2013.75.5}, +} + @Article{MIS+08, author = {Markowitz, Victor M. and Ivanova, Natalia N. and Szeto, Ernest and Palaniappan, Krishna and Chu, Ken and Dalevi, Daniel and Chen, I-Min A. and Grechkin, Yuri and Dubchak, Inna and Anderson, Iain and Lykidis, Athanasios and Mavromatis, Konstantinos and Hugenholtz, Philip and Kyrpides, Nikos C.}, journal = {Nucleic Acids Research}, @@ -469,6 +492,17 @@ doi = {10.1007/BF01581580}, } + at Article{SSW01, + author = {Schulte, Mitchell D. and Shock, Everett L. and Wood, Robert H.}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{T}he temperature dependence of the standard-state thermodynamic properties of aqueous nonelectrolytes}, + year = {2001}, + volume = {65}, + number = {21}, + pages = {3919--3930}, + doi = {10.1016/S0016-7037(01)00717-7}, +} + @Article{See96, author = {Seewald, Jeffrey S.}, journal = {Materials Research Society Symposium Proceedings}, @@ -504,6 +538,17 @@ doi = {10.1016/0016-7037(90)90429-O}, } + at Article{SOJSH92, + author = {Shock, Everett L. and Oelkers, Eric H. and Johnson, James W. and Sverjensky, Dimitri A. and Helgeson, Harold C.}, + journal = {Journal of the Chemical Society, Faraday Transactions}, + title = {{C}alculation of the thermodynamic properties of aqueous species at high pressures and temperatures: {E}ffective electrostatic radii, dissociation constants, and standard partial molal properties to 1000 ?{C} and 5 kbar}, + year = {1992}, + volume = {88}, + number = {6}, + pages = {803 -- 826}, + doi = {10.1039/FT9928800803}, +} + @Article{SWM+05, author = {Spear, John R. and Walker, Jeffrey J. and McCollom, Thomas M. and Pace, Norman R.}, journal = {Proceedings of the National Academy of Sciences of the United States of America}, @@ -536,6 +581,17 @@ doi = {10.1016/S0016-7037(01)00705-0}, } + at Article{TH88, + author = {Tanger, IV, John C. and Helgeson, Harold C.}, + journal = {American Journal of Science}, + title = {{C}alculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: {R}evised equations of state for the standard partial molal properties of ions and electrolytes}, + year = {1988}, + volume = {288}, + number = {1}, + pages = {19--98}, + doi = {10.2475/ajs.288.1.19}, +} + @Article{WJD58, author = {White, W. B. and Johnson, S. M. and Dantzig, G. B.}, journal = {Journal of Chemical Physics}, @@ -573,3 +629,53 @@ issn = {1474-760X}, } + at Article{HW97, + author = {Hn\v{e}dkovsk\'y, Lubom\'ir and Wood, Robert H.}, + journal = {Journal of Chemical Thermodynamics}, + title = {{A}pparent molar heat capacities of aqueous solutions of {CH}4, {CO}2, {H}2{S}, and {NH}3 at temperatures from 304 {K} to 704 {K} at a pressure of 28 {MP}a}, + year = {1997}, + volume = {29}, + number = {7}, + pages = {731--747}, + doi = {10.1006/jcht.1997.0192}, + issn = {0021-9614}, +} + + at Article{MKDW15, + author = {Miron, George D. and Kulik, Dmitrii A. and Dmytrieva, Svitlana V. and Wagner, Thomas}, + journal = {Applied Geochemistry}, + title = {{GEMSFITS}: {C}ode package for optimization of geochemical model parameters and inverse modeling}, + year = {2015}, + volume = {55}, + number = {0}, + pages = {28 - 45}, + note = {Geochemical Speciation Codes and Databases}, + doi = {10.1016/j.apgeochem.2014.10.013}, + issn = {0883-2927}, +} + + at Article{Shv15, + author = {Shvarov, Yuri}, + journal = {Applied Geochemistry}, + title = {{A} suite of programs, {O}ptim{A}, {O}ptim{B}, {O}ptim{C}, and {O}ptim{S} compatible with the {U}nitherm database, for deriving the thermodynamic properties of aqueous species from solubility, potentiometry and spectroscopy measurements}, + year = {2015}, + volume = {55}, + number = {0}, + pages = {17 - 27}, + note = {Geochemical Speciation Codes and Databases}, + doi = {10.1016/j.apgeochem.2014.11.021}, + issn = {0883-2927}, +} + + at Article{HWM96, + author = {Hn\v{e}dkovsk\'y, Lubom\'ir and Wood, Robert H. and Majer, Vladimir}, + journal = {Journal of Chemical Thermodynamics}, + title = {{V}olumes of aqueous solutions of {CH}4, {CO}2, {H}2{S}, and {NH}3 at temperatures from 298.15 {K} to 705 {K} and pressures to 35 {MP}a}, + year = {1996}, + volume = {28}, + number = {2}, + pages = {125 -- 142}, + doi = {10.1006/jcht.1996.0011}, + issn = {0021-9614}, +} + Modified: pkg/CHNOSZ/vignettes/vig.css =================================================================== --- pkg/CHNOSZ/vignettes/vig.css 2017-01-31 15:07:36 UTC (rev 124) +++ pkg/CHNOSZ/vignettes/vig.css 2017-02-02 17:17:22 UTC (rev 125) @@ -1,5 +1,26 @@ -html { font-size: 14px; } +html { + font-size: 14px; +} -body { font-family: ?Times New Roman?, Times, serif; } +body { + font-family: ?Times New Roman?, Times, serif; +} -li { padding: 0.25rem 0; } +li { + padding: 0.25rem 0; +} + +/* zero margin around pre blocks (looks more like R console output) */ +pre { + margin-top: 0; + margin-bottom: 0; +} + +/* for CHNOSZ links */ +h1 a:link { + color: red; +} + +h3 a:link { + color: red; +} From noreply at r-forge.r-project.org Sat Feb 4 03:51:28 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 4 Feb 2017 03:51:28 +0100 (CET) Subject: [CHNOSZ-commits] r126 - in pkg/CHNOSZ: . R inst vignettes Message-ID: <20170204025128.AD069187DA4@r-forge.r-project.org> Author: jedick Date: 2017-02-04 03:51:27 +0100 (Sat, 04 Feb 2017) New Revision: 126 Added: pkg/CHNOSZ/vignettes/elementa.csl Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/EOSregress.Rmd pkg/CHNOSZ/vignettes/anintro.Rnw pkg/CHNOSZ/vignettes/anintro.lyx pkg/CHNOSZ/vignettes/newintro.Rmd pkg/CHNOSZ/vignettes/vig.bib pkg/CHNOSZ/vignettes/wjd.Rnw pkg/CHNOSZ/vignettes/wjd.lyx Log: work on newintro.Rmd; add elementa.csl Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-04 02:51:27 UTC (rev 126) @@ -1,6 +1,6 @@ -Date: 2017-02-02 +Date: 2017-02-04 Package: CHNOSZ -Version: 1.0.8-15 +Version: 1.0.8-16 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/R/basis.R 2017-02-04 02:51:27 UTC (rev 126) @@ -27,7 +27,7 @@ if( nrow(comp) < ncol(comp) ) stop("underdetermined system; square stoichiometric matrix needed") # the second test: matrix is invertible if(class(try(solve(comp), silent=TRUE))=='try-error') - stop("singular stoichiometric matrix; invertible one needed") + stop("singular stoichiometric matrix") # store the basis definition in thermo$basis, including # both numeric and character data, so we need to use a data frame comp <- cbind(as.data.frame(comp), ispecies, logact, state, stringsAsFactors=FALSE) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/inst/NEWS 2017-02-04 02:51:27 UTC (rev 126) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-15 (2017-02-02) +CHANGES IN CHNOSZ 1.0.8-16 (2017-02-04) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, Modified: pkg/CHNOSZ/vignettes/EOSregress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-02-04 02:51:27 UTC (rev 126) @@ -19,6 +19,7 @@ \usepackage[utf8]{inputenc} bibliography: vig.bib link-citations: yes +csl: elementa.csl --- ```{r setup, include=FALSE} Modified: pkg/CHNOSZ/vignettes/anintro.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rnw 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/vignettes/anintro.Rnw 2017-02-04 02:51:27 UTC (rev 126) @@ -1,8 +1,9 @@ -%% LyX 2.1.3 created this file. For more info, see http://www.lyx.org/. +%% LyX 2.2.2 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are doing. \documentclass[english,noae,round]{article} \usepackage{mathpazo} \usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} \usepackage[letterpaper]{geometry} \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} \usepackage{color} @@ -48,7 +49,6 @@ \title{An introduction to CHNOSZ} - \author{Jeffrey M. Dick} \maketitle @@ -81,13 +81,12 @@ species using very similar commands. Examples below are intended to demonstrate basic usage to new users. - \subsection{Outline of workflow} CHNOSZ is made up of a set of functions and supporting datasets. The major components of the package are shown in the figure below, which is an updated version of the flowchart from \citet{Dic08} (boxes --- functions; ellipses -- datasets; bold text -- major user functions). +? functions; ellipses ? datasets; bold text ? major user functions). \includegraphics[bb=0bp 440bp 612bp 792bp,clip,width=0.75\columnwidth]{flowchart} @@ -119,7 +118,6 @@ results. The results can then be reproduced on demand by yourself or others with whom you might share your scripts. - \subsection{Installing and loading CHNOSZ} If you have just installed R, and you are online, installing the CHNOSZ @@ -150,7 +148,6 @@ The rest of this document assumes that the CHNOSZ package and data are loaded. - \section{Thermodynamic database} @@ -168,7 +165,7 @@ experimental. If there is any doubt about the accuracy or suitability of data for a particular problem, please \emph{consult the primary sources} (which can be located using \texttt{browse.refs()}; see Section -\ref{sub:thermo_refs}). Do not assume that by adding any species +\ref{subsec:thermo_refs}). Do not assume that by adding any species to your calculation (or to any of the examples), you will necessarily obtain a reasonable answer. Do not assume that the examples are correct, or that they can be applied to your problem. As with the data, please @@ -219,7 +216,7 @@ @ -\subsection{\texttt{\label{sub:thermo_refs}thermo\$refs}} +\subsection{\texttt{\label{subsec:thermo_refs}thermo\$refs}} The thermodynamic data and other parameters used by the functions, as well as system definitions provided by the user in an interactive @@ -329,7 +326,6 @@ the first call to\texttt{ info()} just above had a side effect of adding the computed properties and parameters to \texttt{thermo\$obigt}. - \section{Reaction properties} @@ -362,7 +358,6 @@ package uses a Fortran subroutine taken from SUPCRT for these calculations. See \texttt{help(water)} for more information. - \subsection{A reaction} To calculate the properties of a reaction, enter the stoichiometric @@ -404,7 +399,6 @@ an unbalanced reaction). In the next section we'll see how to use another feature of CHNOSZ to automatically balance reactions. - \section{Basis species} @@ -425,6 +419,7 @@ <>= basis(c("CO2","H2O","NH3","H2S","H+")) @ + \begin{lyxcode} Error~in~put.basis(basis,~mystates)~:~ @@ -450,7 +445,6 @@ name. These represent the elements in the commonly-occurring amino acids, together with charge, denoted by ``Z''. - \subsection{Auto-balancing a reaction} Now that the basis species are defined, try the unbalanced reaction @@ -503,7 +497,6 @@ coming up with a useful basis definition is in relating the species to observable quantities. - \subsection{It works for proteins too!} Let's set the basis definition again, this time using a keyword that @@ -588,7 +581,6 @@ directory where CHNOSZ is installed) to change the calculation from calcite to $\mathrm{CO_{2}}$. - \subsection{Stability diagram for proteins} Suppose that we are asked to calculate the relative stabilities of @@ -622,8 +614,8 @@ formation reactions. The chemical affinity is the negative of the Gibbs energy change of a reaction per unit of reaction progress; it is calculated in CHNOSZ using $\boldsymbol{A}=2.303RT\log(K/Q)$ ($R$ --- gas constant, $T$ -- temperature, $K$ -- equilibrium constant, -$Q$ -- activity product). +? gas constant, $T$ ? temperature, $K$ ? equilibrium constant, $Q$ +? activity product). \texttt{affinity()} can accept arguments describing the range of chemical conditions we're interested in. The names of the arguments can refer @@ -654,7 +646,6 @@ Notably, the protein from the organism found at the highest temperatures is relatively stable at more reduced conditions. - \subsection{More proteins, more dimensions} Now let's add some bacterial surface-layer proteins. They are in some @@ -720,7 +711,7 @@ \setkeys{Gin}{width=1.0\textwidth} The 999's in the assignment of logarithms of activities of basis species -could be any number -- these settings do not affect the outcome of +could be any number ? these settings do not affect the outcome of the calculation. This is so because 1) $\mathrm{HCl}$, $\mathrm{CO_{2}}$ and $\mathrm{O_{2}}$ have zero stoichiometric coefficients in the species, 2) the activities of $\mathrm{Ca}^{+2}$ and $\mathrm{Mg}^{+2}$ @@ -743,7 +734,6 @@ diagrams for organic and inorganic species. Try it for your favorite system! - \section{Where to go from here} You can explore the package documentation through R's help system; @@ -765,7 +755,7 @@ Or you can use the following to run \emph{all} of the examples provided in the documentation for the package. You will see a lot of text fly by on the screen, as well as a variety of plots. The examples will -take about 5--10 minutes to run, depending on your machine. +take about 5?10 minutes to run, depending on your machine. <>= examples() @@ -787,7 +777,6 @@ Have fun! - \section{More activity diagrams} The following pages contain activity diagrams created with more complex @@ -815,7 +804,7 @@ of difference. Toward the end of the script, points are added for Eh-pH values from -soils \citep{BKM60} and hot springs in Yellowstone ($+$) \citep{SWM+05} +soils \citep{BKM60} and hot springs in Yellowstone ($+$) \citep{SWM_05} and Iceland ($\blacktriangle$) \citep{SA02}. The symbols identifying the latter two sources were swapped in the figure caption of \citet{DLH06}. Finally legends are drawn to identify the lines and symbols. The \texttt{describe.property()} @@ -851,7 +840,7 @@ \subsection{Subcellular proteins} -Localizations and abundances of proteins from YeastGFP \citep{HFG+03,GHB+03} +Localizations and abundances of proteins from YeastGFP \citep{HFG_03,GHB_03} are used here to calculate an abundance-weighted average of amino acid compositions of proteins in different subcellular compartments of yeast. The relative stabilities of these 23 model proteins are @@ -907,7 +896,7 @@ both $\mathrm{S_{2}}$ and $\mathrm{O_{2}}$ by pyrite-pyrrhotite-magnetite, and the buffers have effects on equilibrium activity diagrams) while the latter is more convenient (no need to set up the buffer in \texttt{thermo\$buffer} --- the buffers come from the species of interest). The plot below, +? the buffers come from the species of interest). The plot below, based on Fig. 6 of \citet{SS95}, shows values of $\log f_{\mathrm{H_{2}}_{\left(g\right)}}$ buffered by minerals and in equilibrium with different activities of organic species that are calculated using these two methods. @@ -1065,7 +1054,6 @@ it remains a matter of discussion what the optimized chemical activities of the basis species and the amino acids signify. - \section{Document information} Revision history: Modified: pkg/CHNOSZ/vignettes/anintro.lyx =================================================================== --- pkg/CHNOSZ/vignettes/anintro.lyx 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/vignettes/anintro.lyx 2017-02-04 02:51:27 UTC (rev 126) @@ -1,7 +1,9 @@ -#LyX 2.1 created this file. For more info see http://www.lyx.org/ -\lyxformat 474 +#LyX 2.2 created this file. For more info see http://www.lyx.org/ +\lyxformat 508 \begin_document \begin_header +\save_transient_properties true +\origin unavailable \textclass article \begin_preamble %\VignetteIndexEntry{An introduction to CHNOSZ} @@ -17,18 +19,18 @@ \maintain_unincluded_children false \language english \language_package default -\inputencoding default +\inputencoding utf8 \fontencoding global -\font_roman palatino -\font_sans default -\font_typewriter default -\font_math auto +\font_roman "palatino" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false -\font_sf_scale 100 -\font_tt_scale 100 +\font_sf_scale 100 100 +\font_tt_scale 100 100 \graphics default \default_output_format default \output_sync 0 @@ -211,7 +213,7 @@ \end_inset - (boxes -- functions; ellipses -- datasets; bold text -- major user functions). + (boxes ? functions; ellipses ? datasets; bold text ? major user functions). \end_layout \begin_layout Standard @@ -509,7 +511,7 @@ ; see Section \begin_inset CommandInset ref LatexCommand ref -reference "sub:thermo_refs" +reference "subsec:thermo_refs" \end_inset @@ -738,7 +740,7 @@ \family typewriter \begin_inset CommandInset label LatexCommand label -name "sub:thermo_refs" +name "subsec:thermo_refs" \end_inset @@ -2196,7 +2198,7 @@ \begin_layout Standard \begin_inset Branch stuff -status collapsed +status open \begin_layout Standard \begin_inset ERT @@ -2501,19 +2503,19 @@ \begin_inset Formula $R$ \end_inset - -- gas constant, + ? gas constant, \begin_inset Formula $T$ \end_inset - -- temperature, + ? temperature, \begin_inset Formula $K$ \end_inset - -- equilibrium constant, + ? equilibrium constant, \begin_inset Formula $Q$ \end_inset - -- activity product). + ? activity product). \end_layout \begin_layout Standard @@ -2970,8 +2972,8 @@ \begin_layout Standard The 999's in the assignment of logarithms of activities of basis species - could be any number -- these settings do not affect the outcome of the - calculation. + could be any number ? these settings do not affect the outcome of the calculati +on. This is so because 1) \begin_inset Formula $\mathrm{HCl}$ \end_inset @@ -3137,7 +3139,7 @@ of the examples provided in the documentation for the package. You will see a lot of text fly by on the screen, as well as a variety of plots. - The examples will take about 5--10 minutes to run, depending on your machine. + The examples will take about 5?10 minutes to run, depending on your machine. \end_layout @@ -3398,7 +3400,7 @@ ) \begin_inset CommandInset citation LatexCommand citep -key "SWM+05" +key "SWM_05" \end_inset @@ -3617,7 +3619,7 @@ Localizations and abundances of proteins from YeastGFP \begin_inset CommandInset citation LatexCommand citep -key "HFG+03,GHB+03" +key "HFG_03,GHB_03" \end_inset @@ -3870,7 +3872,7 @@ \family typewriter thermo$buffer \family default - -- the buffers come from the species of interest). + ? the buffers come from the species of interest). The plot below, based on Fig. 6 of \begin_inset CommandInset citation Added: pkg/CHNOSZ/vignettes/elementa.csl =================================================================== --- pkg/CHNOSZ/vignettes/elementa.csl (rev 0) +++ pkg/CHNOSZ/vignettes/elementa.csl 2017-02-04 02:51:27 UTC (rev 126) @@ -0,0 +1,453 @@ + + Modified: pkg/CHNOSZ/vignettes/newintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/newintro.Rmd 2017-02-02 17:17:22 UTC (rev 125) +++ pkg/CHNOSZ/vignettes/newintro.Rmd 2017-02-04 02:51:27 UTC (rev 126) @@ -19,6 +19,7 @@ \usepackage[utf8]{inputenc} bibliography: vig.bib link-citations: yes +csl: elementa.csl --- ```{r options, include=FALSE} @@ -31,8 +32,11 @@ knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) options(htmltools.dir.version = FALSE) knitr::knit_hooks$set(small.mar = function(before, options, envir) { - if (before) par(mar = c(4, 4, .1, .1)) # smaller margin on top and right + if (before) par(mar = c(4.2, 4.2, .1, .1)) # smaller margin on top and right }) +knitr::knit_hooks$set(tiny.mar = function(before, options, envir) { + if (before) par(mar = c(.1, .1, .1, .1)) # tiny margin all around +}) ``` # About @@ -47,7 +51,7 @@ ## Installing and loading CHNOSZ -If you have just installed R for the first time, and you have an internet connection, installing CHNOSZ should be as simple as selecting the "Install packages from CRAN" or similar menu item in the R GUI or using the following command to start the package installation process:^[Or, install the package from a local package file, which you can download from [CRAN](http://cran.r-project.org) or from the [CHNOSZ website](http://chnosz.net). +If you have just installed R for the first time, and you have an Internet connection, installing CHNOSZ should be as simple as selecting the "Install packages from CRAN" or similar menu item in the R GUI or using the following command to start the package installation process:^[Or, install the package from a local package file, which you can download from [CRAN](http://cran.r-project.org) or from the [CHNOSZ website](http://chnosz.net). ][]() ```{r install_CHNOSZ, eval=FALSE} install.packages("CHNOSZ") @@ -239,7 +243,7 @@ ```

-In order to make a plot like that shown by Manning et al. [- at MSS13, Figure 18], let's run more calculations and store the results. +In order to make a plot like Figure 18 of @MSS13, let's run more calculations and store the results. In addition to the reaction definition, we specify a greater number of temperature points than the default: ```{r dissolution, echo=FALSE, message=FALSE} T <- seq(0, 350, 10) @@ -262,15 +266,149 @@ ## Unbalanced reactions +A balanced chemical reaction conserves mass. +`subcrt()` won't stop you from running an unbalanced reaction, but it will give you a warning: +```{r subcrt_unbalanced, results="hide"} +subcrt(c("CO2", "CH4"), c(-1, 1)) +``` + +In other words, to balance the reaction, we should add exactly 4 H to the left and 2 O to the right. +That could be done manually be redefining the reaction with the appropriate species. +There is another option: balancing the reaction automatically using basis species. + ## Setting the basis species +_Basis species_ are a minimal number of chemical species that represent the compositional variation in a system. +The basis species are similar to thermodynamic components, but can include charged species. +You might want to use basis species to automatically balance reactions. +A basis setting is also required for making chemical activity diagrams. + +Let's start with an example that **doesn't** work: +```{r basis_singular, error=TRUE} +basis(c("CO2", "H2", "H2CO2")) +``` + +That set of species has a singular (non-invertible) stoichiometric matrix. +An error would also result from either an underdetermined or overdetermined system. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 126 From noreply at r-forge.r-project.org Sat Feb 4 13:55:30 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 4 Feb 2017 13:55:30 +0100 (CET) Subject: [CHNOSZ-commits] r127 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170204125530.E05D518845D@r-forge.r-project.org> Author: jedick Date: 2017-02-04 13:55:30 +0100 (Sat, 04 Feb 2017) New Revision: 127 Added: pkg/CHNOSZ/vignettes/CHNOSZ.dia pkg/CHNOSZ/vignettes/anintro.Rmd Removed: pkg/CHNOSZ/vignettes/anintro.Rnw pkg/CHNOSZ/vignettes/anintro.lyx pkg/CHNOSZ/vignettes/flowchart.dia pkg/CHNOSZ/vignettes/flowchart.pdf pkg/CHNOSZ/vignettes/newintro.Rmd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/vignettes/vig.bib Log: replace anintro.Rnw with updated anintro.Rmd Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-04 12:55:30 UTC (rev 127) @@ -1,6 +1,6 @@ Date: 2017-02-04 Package: CHNOSZ -Version: 1.0.8-16 +Version: 1.0.8-17 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/R/basis.R 2017-02-04 12:55:30 UTC (rev 127) @@ -174,15 +174,18 @@ # pH transformation if("pH" %in% species) { logact[species=="pH"] <- -logact[species=="pH"] - species[species=="pH"] <- "H+" + if(!is.null(logact)) species[species=="pH"] <- "H+" } # Eh and pe transformations - if(any(c("pe","Eh") %in% species)) { + if("pe" %in% species) { logact[species=="pe"] <- -logact[species=="pe"] + if(!is.null(logact)) species[species=="pe"] <- "e-" + } + if("Eh" %in% species) { # 20090209 should be careful with this conversion as it's only for 25 deg C - # to be sure, just don"t call species("Eh") - logact[species=="Eh"] <- -convert(logact[species=="Eh"],"pe") - species[species %in% c("pe","Eh")] <- "e-" + # to be sure, just don't call species("Eh") + if(!is.null(logact)) logact[species=="Eh"] <- -convert(logact[species=="Eh"],"pe") + species[species=="Eh"] <- "e-" } ## if all species are in the existing basis definition, ## *and* at least one of state or logact is not NULL Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/R/diagram.R 2017-02-04 12:55:30 UTC (rev 127) @@ -421,7 +421,7 @@ } if(is.null(fill)) fill <- "transparent" else if(isTRUE(fill[1]=="rainbow")) fill <- rainbow(ngroups) - else if(isTRUE(fill[1]=="heat")) fill <- heat.colors(ngroups) + else if(isTRUE(fill[1] %in% c("heat", "terrain", "topo", "cm"))) fill <- get(paste0(fill[1], ".colors"))(ngroups) fill <- rep(fill, length.out=ngroups) # the x and y values xs <- eout$vals[[1]] Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/inst/NEWS 2017-02-04 12:55:30 UTC (rev 127) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-16 (2017-02-04) +CHANGES IN CHNOSZ 1.0.8-17 (2017-02-04) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -39,7 +39,7 @@ message() from base R. As a result, the messages don't appear in Sweave vignettes, but can now be turned on or off easily in knitr vignettes. -- Add vignette newintro.Rmd. +- Replace anintro.Rnw (Sweave) with updated anintro.Rmd (knitr, tufte). CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-04 12:55:30 UTC (rev 127) @@ -85,6 +85,7 @@ On 2-D diagrams, the fields represent the species with the highest equilibrium activity. \code{fill} determines the color of the predominance fields, \code{col} that of the boundary lines. By default, \code{\link{heat.colors}} are used to fill the predominance fields in diagrams on the screen plot device. +\code{fill} can be any color specification, or the word \samp{rainbow}, \samp{heat}, \samp{terrain}, \samp{topo}, or \samp{cm}, indicating a palette from \pkg{grDevices}. As of CHNOSZ 1.0.8-11, a new default line-drawing procedure has been implemented. This uses \code{\link{contour}} to draw smooth-looking diagonal and curved lines, at the expense of not coinciding exactly with the rectangular grid (which is still used for drawing colors). Copied: pkg/CHNOSZ/vignettes/CHNOSZ.dia (from rev 126, pkg/CHNOSZ/vignettes/flowchart.dia) =================================================================== (Binary files differ) Copied: pkg/CHNOSZ/vignettes/anintro.Rmd (from rev 126, pkg/CHNOSZ/vignettes/newintro.Rmd) =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd (rev 0) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-04 12:55:30 UTC (rev 127) @@ -0,0 +1,550 @@ +--- +title: "An Introduction to [CHNOSZ](http://www.chnosz.net)" +author: "Jeffrey M. Dick" +date: "`r Sys.Date()`" +output: + tufte::tufte_html: + tufte_features: ["background"] + css: "vig.css" + toc: true + tufte::tufte_handout: + citation_package: natbib + latex_engine: xelatex + tufte::tufte_book: + citation_package: natbib + latex_engine: xelatex +vignette: > + %\VignetteIndexEntry{An Introduction to CHNOSZ} + %\VignetteEngine{knitr::rmarkdown} + \usepackage[utf8]{inputenc} +bibliography: vig.bib +link-citations: yes +csl: elementa.csl +--- + +```{r options, include=FALSE} +options(width = 80) +options(digits = 6) +``` + +```{r setup, include=FALSE} +# invalidate cache when the tufte version changes +knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) +options(htmltools.dir.version = FALSE) +knitr::knit_hooks$set(small.mar = function(before, options, envir) { + if (before) par(mar = c(4.2, 4.2, .1, .1)) # smaller margin on top and right +}) +knitr::knit_hooks$set(tiny.mar = function(before, options, envir) { + if (before) par(mar = c(.1, .1, .1, .1)) # tiny margin all around +}) +knitr::knit_hooks$set(smallish.mar = function(before, options, envir) { + if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right +}) +``` + +# About + +This document introduces the basic functionality of CHNOSZ, a package for the [R software environment](http://r-project.org). +For more information on R, see "An Introduction to R" and other documents in [The R Manuals](http://cran.r-project.org/manuals.html). + +CHNOSZ has been developed since 2006 to support research projects in geochemistry and biochemistry. +The package provides functions and an extensive thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions among minerals and organic or inorganic aqueous species. +These same functions enable calculations of chemical affinities and metastable equilibrium for systems of proteins. + +## Installing and loading CHNOSZ + +If you have just installed R for the first time, installing CHNOSZ should be as simple as selecting the "Install packages from CRAN" or similar menu item in the R GUI or using the following command to start the package installation process: +```{marginfigure} +Or, install the package from a local package file, which you can download from [CRAN](https://cran.r-project.org/package=CHNOSZ) or from the [CHNOSZ website](http://chnosz.net/download). +``` +```{r install_CHNOSZ, eval=FALSE} +install.packages("CHNOSZ") +``` + +Then load the CHNOSZ package to make its functions available in your R session. +```{r library_CHNOSZ} +library(CHNOSZ) +``` + +Then load the thermo object, which contains the thermodynamic database and system settings for CHNOSZ. +```{r data_thermo} +data(thermo) +``` + +## Getting help + +After CHNOSZ is installed, type `help.start()` to browse the R help documents, then choose "Packages" followed by "CHNOSZ". +That shows an index of the manual (help page) for each function; many of the help pages include examples. +There are also links to the *demos* (longer examples) and *vignettes* (more in-depth documentation). +Suggestions for accessing the documentation are indicated here with blue text. +For example, read `?"CHNOSZ-package"` to get an overview of the package and a list of features. +```{marginfigure} +That page identifies some features as experimental, i.e. not based on published algorithms or extensively compared with published results. +``` + +## Organization of major functions + +CHNOSZ is made up of a set of functions and supporting datasets. +The major components of the package are shown in the figure below, which is an updated version of the flowchart from @Dic08. +Rectangles and ellipses represent functions and datasets; bold text indicates primary functions. + +![CHNOSZ flowchart](CHNOSZ.png) + +Many functions in CHNOSZ have no side effects. +That is, the function only returns a result; to use the result in other functions, it can be assigned to a variable with `<-`. +Major functions without side effects in CHNOSZ are: + +* `info()`: search for species in the thermodynamic database +* `subcrt()`: calculate the thermodynamic properties of species and reactions +* `affinity()`: calculate the affinities of formation reactions using given chemical activities +* `equilibrate()`: calculate the equilibrium chemical activities of the species of interest +* `diagram()`: plot the results + +Some functions in CHNOSZ do have side effects: they modify the `thermo` data object in the current R session. +In the text (not code) of this document, the names of these functions are shown in red text. +The major functions with side effects are: + +* `basis()`: set the basis species and their chemical activities +* `species()`: set the species of interest and their (non-equilibrium) chemical activities +* `data(thermo)`: reset the database, restoring all settings to their default values. + +The following pseudocode shows a common sequence of commands. +In actual usage, the `...` are replaced by arguments that define the chemical makeup and range of conditions of the system: +```{r, eval=FALSE} +basis(...) +species(...) +a <- affinity(...) +e <- equilibrate(a) ## optional +diagram(e) ## or diagram(a) +data(thermo) ## clear system settings +``` + +Some experimental functions are available: + +* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. + +# Thermodynamic database and chemical formulas + +While an attempt has been made to provide a primary database (`OBIGT.csv`) that is generally internally consistent, all thermodynamic data, calculations, and examples are provided *as is*. +```{marginfigure} +For crucial problems, check not only the accuracy of the database, but also the *suitability of the data* for your problem. +If there is any doubt about the suitability of data, please consult the primary sources (see ?`browse.refs`). +``` +Where possible, data with known or suspected inconsistencies have been placed into a secondary database (`OBIGT-2.csv`) that should be regarded as experimental. + +## The `info()` function + +The `info()` function provides an interface to the thermodynamic database packaged with CHNOSZ. +Suppose you are interested in the thermodynamic properties aqueous ethylene. +You can search for the species by name: +```{r info_ethylene} +info("ethylene") +``` + +Multiple entries exist for ethylene; the index of the `aq` (aqueous) species is returned by default. +A second argument can be used to specify a different physical state: +```{r info_ethylene_gas} +info("ethylene", "gas") +``` + +Knowing that aqueous ethylene is species number 88 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: +```{r info_88} +info(88) +``` + +This number can be used as an argument (`ispecies`) for other functions in CHNOSZ to uniquely identify any species; some commonly used functions also accept the species names. +Liquid water is species number 1; it has NA entries in the database because specialized functions are used to compute its properties: +```{r info_info_water} +info(info("water")) +``` + +## Fuzzy searches + +Calling `info()` with a string that does not exactly match the name of any species invokes a fuzzy search of the database: +```{r width180, include=FALSE} +options(width = 180) +``` +```{r info_acid} +info("acid") +``` +```{r width80, include=FALSE} +options(width = 80) +``` + +The message includes e.g. "uracil" and "metacinnabar" because their names have some similarity to the search term. + +As "ribose" is the name of a species in the database, to find species with similar names, add an extra character to the search: +```{r info_ribose} +info(" ribose") +``` + +The messages may be useful for browsing the database, but owing to their ambiguous results, these fuzzy searches return an `NA` value for the species index. + +## Counting elements, chemical formulas, `ZC()` + +Continuing with the example of ethylene, let's look at its chemical formula: +```{r info_88_formula} +info(88)$formula +``` + +We can use the `makeup()` function to count the elements in the formula, followed by `as.chemical.formula()` to return to the formula: +```{r makeup_88} +makeup(88) +as.chemical.formula(makeup(88)) +``` + +For organic species, a simple calculation of the average oxidation state of carbon ($Z_C$) is possible given the species index, chemical formula, or elemental count: +```{r ZC_88} +ZC(88) +ZC(info(88)$formula) +ZC(makeup(88)) +``` + +# Calculating thermodynamic properties + +To calculate the standard molal properties of species and reactions, use `subcrt()`. +```{marginfigure} +The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of H2O, is SUPCRT (Johnson et al., 1992). +``` +[- at JOH92] +If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: +```{r subcrt_water} +subcrt("water") +``` + +That uses the default temperature and pressure settings: equally-spaced temperature grid from 0 to 350 ?C at *P*sat. +```{marginfigure} +*P*sat is 1 bar below 100 ?C, or the pressure of liquid-vapor coexistence at higher temperatures. +``` +The columns in the output are temperature, pressure, density of water, logarithm of the equilibrium constant (only meaningful for reactions; see below), standard molal Gibbs energy and enthalpy of formation from the elements, standard molal entropy, volume, and heat capacity. +```{marginfigure} +The corresponding units are ?C (`T`), bar (`P`), g cm-3 (`rho`), cal mol-1 (`G` and `H`), cal K-1 mol-1 (`S`), cm3 mol-1 (`V`), and cal K-1 mol-1 (`Cp`). +``` + +A custom temperature-pressure grid can be specified. +Here, we calculate the properties of H2O on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure: +```{marginfigure} +See also `demo(density)`. +``` +```{r subcrt_water_grid} +subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water +``` + +```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE} +H2O <- subcrt("water", T=seq(0, 1000, 100), P=c(NA, seq(1, 500, 1)), grid="T") +H2O <- H2O$out$water +plot(H2O$P, H2O$rho, type="l") +``` +The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. `write.table()` or `plot()` for further processing: +```{r subcrt_water_plot, eval=FALSE} +``` + +## Changing units + +The default units of temperature, pressure, and energy are ?C, bar, and calories. +The functions `T.units()`, `P.units()`, and `E.units()` can be used to change the units used by various functions in CHNOSZ. +What is the Gibbs energy (J/mol) of aqueous methane at 298.15 K and 0.1 MPa? +```{r methane_units, message=FALSE} +T.units("K") +P.units("MPa") +E.units("J") +subcrt("methane", T=298.15, P=0.1)$out$methane$G +data(thermo) ## restore default settings +``` + +A related function, `convert()`, can be used to convert given values between units. +Let's convert the standard Gibbs energy of aqueous methane listed in the database from cal/mol to J/mol: +```{r methane_G, message=FALSE} +convert(info(info("methane"))$G, "J") +``` + +As expected, we get the same result from both operations. + +# Properties of reactions + +## Reaction definitions + +To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to `subcrt()`. +Here we calculate properties for the dissolution of CO2: +```{marginfigure} +Because of aqueous speciation, this doesn't give the _solubility_ of CO2. +For an example of a solubility calculation, see `demo(solubility)`, which is based on a figure in Manning et al. (2013). +``` +```{r CO2_dissolution} +subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=seq(0, 250, 50)) +``` + +

+In order to make a plot like Figure 18 of @MSS13, let's run more calculations and store the results. +In addition to the reaction definition, we specify a greater number of temperature points than the default: +```{r dissolution, echo=FALSE, message=FALSE} +T <- seq(0, 350, 10) +CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +CO <- subcrt(c("CO", "CO"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +logK <- data.frame(T, CO2, CO, CH4) +``` +```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE} +matplot(logK[, 1], logK[, -1], type="l", + xlab=axis.label("T"), ylab=axis.label("logK")) +``` +```{r dissolution, eval=FALSE} +``` + +Now we can make the plot. +Here, the `axis.label()` function of CHNOSZ is used to create formatted axis labels: +```{r dissolution_plot, eval=FALSE} +``` + +## Unbalanced reactions + +A balanced chemical reaction conserves mass. +`subcrt()` won't stop you from running an unbalanced reaction, but it will give you a warning: +```{r subcrt_unbalanced, results="hide"} +subcrt(c("CO2", "CH4"), c(-1, 1)) +``` + +In other words, to balance the reaction, we should add 4 H to the left and 2 O to the right. +That could be done manually be redefining the reaction with the appropriate species. +There is another option: balancing the reaction automatically using basis species. + +## Setting the basis species + +_Basis species_ are a minimal number of chemical species that represent the compositional variation in a system. +The basis species are similar to thermodynamic components, but can include charged species. +You might want to use basis species to automatically balance reactions. +A basis setting is also required for making chemical activity diagrams. + +Let's start with an example that doesn't work: +```{r basis_singular, error=TRUE} +basis(c("CO2", "H2", "H2CO2")) +``` + +That set of species has a singular (non-invertible) stoichiometric matrix. +An error would also result from either an underdetermined or overdetermined system. +A valid set of basis species has an invertible stoichiometric matrix and the same number of species as elements: +```{r basis_CHO} +basis(c("CO2", "H2", "H2O")) +``` +The composition of any species made up of C, H, and O can be represented by a single linear combination of these basis species. + +## Auto-balancing reactions + +Methanogenic metabolism in reducing environments may take advantage of acetoclastic or hydrogenotrophic processes. +To consider reactions involving a charged species (acetate), let's define a basis with H+: +```{r basis_CHOZ} +basis(c("CO2", "H2", "H2O", "H+")) +``` + +By identifying species *other than* the basis species, the reactions will be automatically balanced. +This produces the balanced reaction for acetoclastic methanogenesis: +```{r subcrt_acetoclastic, message=FALSE} +subcrt(c("acetate", "methane"), c(-1, 1))$reaction +``` + +We can similarly consider reactions for hydrogenotrophic methanogenesis as well as acetate oxidation (no production of methane): +```{r subcrt_methanogenesis, message=FALSE} +acetate_oxidation <- subcrt("acetate", -1) +hydrogenotrophic <- subcrt("methane", 1) +acetoclastic <- subcrt(c("acetate", "methane"), c(-1, 1)) +``` + +

+Use `describe.reaction()` to write the reactions on a plot: +```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=50, out.width="100%"} +plot(0, 0, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2)) +text(0, 0, "acetoclastic methanogenesis", adj=0) +text(5, 1, describe.reaction(acetoclastic$reaction), adj=1) +text(0, 2, "acetate oxidation", adj=0) +text(5, 3, describe.reaction(acetate_oxidation$reaction), adj=1) +text(0, 4, "hydrogenotrophic methanogenesis", adj=0) +text(5, 5, describe.reaction(hydrogenotrophic$reaction), adj=1) +``` + +## Non-standard state affinities and Gibbs energies + +Usually, `subcrt()` returns only standard state thermodynamic properties. +```{marginfigure} +The standard state adopted for H2O is unit activity of the pure component at any *T* and *P*. +The standard state for aqueous species is unit activity of a hypothetical one molal solution referenced to infinite dilution at any *T* and *P*. +``` +Thermodynamic models often consider a non-standard state (i.e. non-unit activity). +The activities of basis species can be modified with `basis()`, and those of the other species using the `logact` argument in `subcrt()`. + +Let us calculate the chemical affinity of acetoclastic methanogenesis. +```{marginfigure} +The affinity is equal to the negative of the overall (non-standard) Gibbs energy change of the reaction. +``` +We begin by changing the energy units to Joules. +Then, we change the state of H2 and CO2 in the basis from `aq` (aqueous) to `gas`, and set the logarithm of fugacity of gaseous H2 and the pH, using values from @MDS_13. +The activity of acetate and fugacity of methane, as well as temperature and pressure, are set in the call to `subcrt()`: +```{r basis_mayumi, message=FALSE, results="hide"} +E.units("J") +basis(c("CO2", "H2"), "gas") +basis(c("H2", "pH"), c(-3.92, 7.3)) +``` +```{r affinity_acetoclastic, message=FALSE} +subcrt(c("acetate", "methane"), c(-1, 1), + c("aq", "gas"), logact=c(-3.4, -0.18), T=55, P=50)$out +``` + +The new `A` column shows the affinity; the other columns are unaffected and still show the standard-state properties. +Let's repeat the calculation for hydrogenotrophic methanogenesis. +```{r affinity_hydrogenotrophic, message=FALSE} +subcrt("methane", 1, "gas", logact=-0.18, T=55, P=50)$out +``` + +Under the specified conditions, the affinities of hydrogenotrophic and acetoclastic methanogenesis are somewhat greater than and less than 20 kJ, respectively. +This result matches Figure 4b in Mayumi et al. (2013) at unit fugacity of CO2. + +We can go even further and reproduce their plot. +```{marginfigure} +The reproduction is not identical, owing to differences of thermodynamic data and of calculations of the effects of temperature and pressure. +``` +To make the code neater, we write a function that can run any of the reactions: +```{r rxnfun, message=FALSE} +rxnfun <- function(coeffs) { + subcrt(c("acetate", "methane"), coeffs, + c("aq", "gas"), logact=c(-3.4, -0.18), T=55, P=50)$out +} +``` + +

+Now we're ready to calculate and plot the affinities. +Here, we use the `lapply()` function of R to list the results at two values of logarithm of fugacity of CO2. +We insert an empty reaction to get a line at zero affinity. +`do.call(rbind, Adat)` turns the list into a data frame that can be plotted with `matplot()`. +There, we plot the negative affinities, equal to Gibbs energy, as shown in the plot of Mayumi et al. (2013). +```{r methanogenesis_plot, fig.margin=TRUE, fig.width=4.1, fig.height=4.1, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Gibbs energies of acetate oxidation and methanogenesis (after Mayumi et al., 2013).", cache=TRUE} +Adat <- lapply(c(-3, 3), function(logfCO2) { + basis("CO2", logfCO2) + data.frame(logfCO2, + rxnfun(c(0, 0))$A, + rxnfun(c(-1, 0))$A, + rxnfun(c(-1, 1))$A, + rxnfun(c(0, 1))$A + ) +}) +Adat <- do.call(rbind, Adat) +matplot(Adat[, 1], -Adat[, -1]/1000, type="l", lty=1, lwd=2, + xlab=axis.label("CO2"), ylab=axis.label("DG", prefix="k")) +legend("topleft", c("acetate oxidation", "acetoclastic methanogenesis", + "hydrogenotrophic methanogenesis"), lty=1, col=2:4) +``` +```{r methanogenesis_plot, echo=TRUE, eval=FALSE} +``` + +Let't not forget to clear the system settings, which were modified by `basis()` and `E.units()`, before running other calculations: +```{r data_thermo, message=FALSE} +``` + +# Affinity, species of interest, and potential diagrams + +`affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species. + +By *formation reaction* is meant the stoichiometric requirements for formation of one mole of any species from the basis species. +The `species()` function is used to set these *species of interest*. +Let's consider the stoichiometry of some aqueous sulfur-bearing species. +```{r basis_CHNOSZ, results="hide"} +basis("CHNOS+") +``` +```{r sulfur_species} +species(c("SO4-2", "HS-", "H2S", "HSO4-")) +``` + +There we used `basis()` with a keyword to identify a preset basis definition. +Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: +```{marginfigure} +The values returned by `affinity()` are dimensionless, i.e. log10(*A*/*RT*). +``` +```{r affinity} +affinity()$values +``` + +The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. +Let's choose a set of variables commonly used in aqueous speciation diagrams: Eh and pH. +To use Eh as a variable, the electron (`e-`) should be in the basis. +To get the electron in there, we could use a different keyword (`basis("CHNOSe")`), or swap oxygen out of the existing basis: +```{r swap_basis} +swap.basis("O2", "e-") +``` + +The swap.basis() changed the basis species and recalculated their activities, but preserved the species of interest. +```{marginfigure} +That is, running `affinity()$values` again would give the same result. +``` + +

+```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE} +a <- affinity(pH=c(0, 12), Eh=c(-1, 1)) +diagram(a, fill="heat") +``` +Now we can calculate the affinities on an Eh-pH grid: +```{r EhpH_plot, echo=1, eval=FALSE} +``` + +Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram: +```{r EhpH_plot_echo, eval=FALSE} +diagram(a) +``` + +Note that the calculation of affinity implies a non-equilibrium reference state of equal activities of species (see above). +Generally, then, `diagram()` gives a *potential diagram* because it shows regions of maximum affinity. +In systems where equilibrium is attainable, it makes sense to call this a *predominance diagram*, showing regions of maximum activity. + +```{r EhpH_plot_color, fig.margin=TRUE, fig.width=4, fig.height=4, smallish.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE} +diagram(a, fill="terrain", lwd=3, lty=3, + names=c("sulfate", "bisulfide", "hydrogen sulfide", "bisulfate"), + tplot=FALSE, main="sulfur species, 25 ?C", bty="n") +``` +The default colors for diagrams shown on screen are R's "heat colors". +Some arguments in `diagram()` can be used to control the color, labels, and lines, and title (`main`). +The `tplot` argument turns off plot customizations used in CHNOSZ. +Additional arguments can be passed via `...`; here, we use that to remove the box around the plot: +```{r EhpH_plot_color, echo=TRUE, eval=FALSE} +``` + +## Mosaic diagrams + +If sulfur is in the basis species, then we should consider that its speciation is sensitive to Eh and pH, as shown in the preceding diagram. +Mosaic diagrams, which are often shown for metal oxide, sulfide, and carbonate minerals, account for speciation of the basis species. +These diagrams are made by constructing individual diagrams for the possible basis species. +The individual diagrams are then combined, each one contributing to the final diagram only in the range of stability of the corresponding basis species. + +Here, we use the `mosaic()` function in CHNOSZ to make a diagram for aqueous species and minerals in the Cu-S-Cl-H2O system, similar Figure 5a of @CPCC17. +The key argument is `bases`, which identifies the candidate basis species (starting with the one in the current basis set). +The other arguments, like those of `affinity()`, specify the ranges of the variables. + +# Equilibration + +## Getting from affinity to equilibrium + +## Setting the constraints + +# Other things you can do with affinity + +## Buffers + +## T-, P-, activity-transect + +# Other things you can do with equilibrate + +## Choosing different balancing constraints + +# Other things you can do with diagrams + +## Groups of species + +# Proteins + +## Group additivity + +## Sources of amino acid data + +## Ionization + +## Normalizing for different lengths + +# Functions outside of the main workflow + +transfer, wjd, eqdata, RH2obigt, EOSregress Deleted: pkg/CHNOSZ/vignettes/anintro.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rnw 2017-02-04 02:51:27 UTC (rev 126) +++ pkg/CHNOSZ/vignettes/anintro.Rnw 2017-02-04 12:55:30 UTC (rev 127) @@ -1,1077 +0,0 @@ -%% LyX 2.2.2 created this file. For more info, see http://www.lyx.org/. -%% Do not edit unless you really know what you are doing. -\documentclass[english,noae,round]{article} -\usepackage{mathpazo} -\usepackage[T1]{fontenc} -\usepackage[utf8]{inputenc} -\usepackage[letterpaper]{geometry} -\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} -\usepackage{color} -\usepackage{babel} -\usepackage{amsbsy} -\usepackage{amssymb} -\usepackage{graphicx} -\usepackage[authoryear]{natbib} -\usepackage[unicode=true, - bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, - breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=true] - {hyperref} -\hypersetup{pdftitle={An introduction to CHNOSZ}, - pdfauthor={Jeffrey M. Dick}, - citecolor=blue} -\usepackage{breakurl} - -\makeatletter -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. -<>= - if(exists(".orig.enc")) options(encoding = .orig.enc) -@ -\newenvironment{lyxcode} -{\par\begin{list}{}{ -\setlength{\rightmargin}{\leftmargin} -\setlength{\listparindent}{0pt}% needed for AMS classes -\raggedright -\setlength{\itemsep}{0pt} -\setlength{\parsep}{0pt} -\normalfont\ttfamily}% - \item[]} -{\end{list}} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. -%\VignetteIndexEntry{An introduction to CHNOSZ} - -% so DOIs in bibliography show up as hyperlinks -\newcommand*{\doi}[1]{\href{http://dx.doi.org/#1}{doi: #1}} - -\makeatother - -\begin{document} - -\title{An introduction to CHNOSZ} - -\author{Jeffrey M. Dick} - -\maketitle -<>= -options(width=90) -@ - - -\section{About} - -This document will orient you to the basic functionality of CHNOSZ, -a package for the R software environment. R is a powerful language -and also very fun to use. Don't worry if you're new to it; just plow -through the examples below and you'll start to get the hang of it. -If you want a more structured approach to learning the language, there -are some excellent guides in the Manuals section of the \href{http://www.r-project.org}{R Project page}. - -The package was developed since 2006 to support a research project -on the thermodynamic properties of proteins. Since that time, the -functions in the package have expanded to include calculation of the -thermodynamic properties of reactions, and especially the construction -of equilibrium chemical activity diagrams for both inorganic and organic [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 127 From noreply at r-forge.r-project.org Sat Feb 4 15:11:59 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 4 Feb 2017 15:11:59 +0100 (CET) Subject: [CHNOSZ-commits] r128 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170204141159.EC364188327@r-forge.r-project.org> Author: jedick Date: 2017-02-04 15:11:59 +0100 (Sat, 04 Feb 2017) New Revision: 128 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: diagram() applies formatting to chemical formulas Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-04 12:55:30 UTC (rev 127) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-04 14:11:59 UTC (rev 128) @@ -1,6 +1,6 @@ Date: 2017-02-04 Package: CHNOSZ -Version: 1.0.8-17 +Version: 1.0.8-18 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-04 12:55:30 UTC (rev 127) +++ pkg/CHNOSZ/R/diagram.R 2017-02-04 14:11:59 UTC (rev 128) @@ -22,7 +22,7 @@ # colors bg=par("bg"), col=par("col"), col.names=par("col"), fill=NULL, # labels - names=NULL, main=NULL, legend.x="topright", + names=NULL, main=NULL, legend.x="topright", format.names=TRUE, # plotting controls add=FALSE, plot.it=TRUE, tplot=TRUE, ... ) { @@ -198,6 +198,17 @@ } } + ## apply formatting to chemical formulas 20170204 + if(format.names) { + exprnames <- as.expression(names) + for(i in seq_along(exprnames)) { + # can the name be parsed as a chemical formula? + mtry <- suppressWarnings(try(makeup(exprnames[[i]]), TRUE)) + if(!identical(class(mtry), "try-error")) exprnames[[i]] <- expr.species(exprnames[[i]]) + } + names <- exprnames + } + if(nd==0) { ### 0-D diagram - bar graph of properties of species or reactions Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-04 12:55:30 UTC (rev 127) +++ pkg/CHNOSZ/inst/NEWS 2017-02-04 14:11:59 UTC (rev 128) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-17 (2017-02-04) +CHANGES IN CHNOSZ 1.0.8-18 (2017-02-04) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -41,6 +41,9 @@ - Replace anintro.Rnw (Sweave) with updated anintro.Rmd (knitr, tufte). +- diagram() applies formatting (subscripts and superscripts) to names + that parse as chemical formulas; use `format.names` to disable. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-04 12:55:30 UTC (rev 127) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-04 14:11:59 UTC (rev 128) @@ -15,8 +15,8 @@ cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, bg=par("bg"), col=par("col"), col.names=par("col"), fill=NULL, - names=NULL, main=NULL, legend.x="topright", add=FALSE, plot.it=TRUE, - tplot=TRUE, ...) + names=NULL, main=NULL, legend.x="topright", format.names=TRUE, + add=FALSE, plot.it=TRUE, tplot=TRUE, ...) strip(affinity, ispecies = NULL, col = NULL, ns = NULL, xticks = NULL, ymin = -0.2, xpad = 1, cex.names = 0.7) find.tp(x) @@ -52,6 +52,7 @@ \item{names}{character, names of species for activity lines or predominance fields} \item{main}{character, a main \code{\link{title}} for the plot; \code{NULL} means to plot no title} \item{legend.x}{character, description of legend placement passed to \code{\link{legend}}} + \item{format.names}{logical, apply formatting to chemical formulas?} \item{add}{logical, add to current plot?} \item{plot.it}{logical, make a plot?} \item{tplot}{logical, set up plot with \code{\link{thermo.plot.new}}?} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-04 12:55:30 UTC (rev 127) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-04 14:11:59 UTC (rev 128) @@ -449,7 +449,7 @@ basis("CHNOS+") ``` ```{r sulfur_species} -species(c("SO4-2", "HS-", "H2S", "HSO4-")) +species(c("H2S", "HS-", "HSO4-", "SO4-2")) ``` There we used `basis()` with a keyword to identify a preset basis definition. @@ -494,10 +494,10 @@ ```{r EhpH_plot_color, fig.margin=TRUE, fig.width=4, fig.height=4, smallish.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE} diagram(a, fill="terrain", lwd=3, lty=3, - names=c("sulfate", "bisulfide", "hydrogen sulfide", "bisulfate"), + names=c("hydrogen sulfide", "bisulfide", "bisulfate", "sulfate"), tplot=FALSE, main="sulfur species, 25 ?C", bty="n") ``` -The default colors for diagrams shown on screen are R's "heat colors". +The default colors for diagrams shown on the screen are R's "heat colors". Some arguments in `diagram()` can be used to control the color, labels, and lines, and title (`main`). The `tplot` argument turns off plot customizations used in CHNOSZ. Additional arguments can be passed via `...`; here, we use that to remove the box around the plot: @@ -511,7 +511,7 @@ These diagrams are made by constructing individual diagrams for the possible basis species. The individual diagrams are then combined, each one contributing to the final diagram only in the range of stability of the corresponding basis species. -Here, we use the `mosaic()` function in CHNOSZ to make a diagram for aqueous species and minerals in the Cu-S-Cl-H2O system, similar Figure 5a of @CPCC17. +Here, we use the `mosaic()` function in CHNOSZ to make a diagram for aqueous species and minerals in the Cu-S-Cl-H2O system, similar to Figure 5a of @CPCC17. The key argument is `bases`, which identifies the candidate basis species (starting with the one in the current basis set). The other arguments, like those of `affinity()`, specify the ranges of the variables. From noreply at r-forge.r-project.org Sun Feb 5 02:20:14 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 02:20:14 +0100 (CET) Subject: [CHNOSZ-commits] r129 - in pkg/CHNOSZ: . R inst vignettes Message-ID: <20170205012014.6CBA61889E7@r-forge.r-project.org> Author: jedick Date: 2017-02-05 02:20:14 +0100 (Sun, 05 Feb 2017) New Revision: 129 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/swap.basis.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: finish mosaic diagrams section Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-04 14:11:59 UTC (rev 128) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 01:20:14 UTC (rev 129) @@ -1,6 +1,6 @@ -Date: 2017-02-04 +Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-18 +Version: 1.0.8-19 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/swap.basis.R =================================================================== --- pkg/CHNOSZ/R/swap.basis.R 2017-02-04 14:11:59 UTC (rev 128) +++ pkg/CHNOSZ/R/swap.basis.R 2017-02-05 01:20:14 UTC (rev 129) @@ -62,12 +62,9 @@ # swap in one basis species for another swap.basis <- function(species, species2, T = 25) { - # before we do anything, remember the old basis definition + # before we do anything, remember the old basis and species definitions oldbasis <- get("thermo")$basis - # and the species definition ts <- species() - # the delete the species - species(delete=TRUE) if(is.null(oldbasis)) stop("swapping basis species requires an existing basis definition") # both arguments must have length 1 @@ -75,6 +72,11 @@ stop("two species must be identified") if(length(species) > 1 | length(species2) > 2) stop("can only swap one species for one species") + # replace pH with H+ and pe and Eh with e- 20170205 + if(species == "pH") species <- "H+" + if(species %in% c("Eh", "pe")) species <- "e-" + if(species2 == "pH") species2 <- "H+" + if(species2 %in% c("Eh", "pe")) species2 <- "e-" # arguments are good, now find the basis species to swap out ib <- ibasis(species) if(is.na(ib)) stop(paste("basis species '",species,"' is not defined",sep="")) @@ -94,7 +96,8 @@ bl <- basis.logact(emu, newbasis, T=T) # update the basis with these logacts mb <- mod.basis(ispecies, logact=bl) - # restore species if they were defined + # delete, then restore species if they were defined + species(delete=TRUE) if(!is.null(ts)) { suppressMessages(species(ts$ispecies)) suppressMessages(species(1:nrow(get("thermo")$species), ts$logact)) @@ -102,4 +105,3 @@ # all done, return the new basis definition return(mb) } - Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-04 14:11:59 UTC (rev 128) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 01:20:14 UTC (rev 129) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-18 (2017-02-04) +CHANGES IN CHNOSZ 1.0.8-19 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-04 14:11:59 UTC (rev 128) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 01:20:14 UTC (rev 129) @@ -91,7 +91,7 @@ ![CHNOSZ flowchart](CHNOSZ.png) Many functions in CHNOSZ have no side effects. -That is, the function only returns a result; to use the result in other functions, it can be assigned to a variable with `<-`. +That is, the function only returns a result; to use the result elsewhere, it can be assigned to a variable with `<-`. Major functions without side effects in CHNOSZ are: * `info()`: search for species in the thermodynamic database @@ -285,14 +285,17 @@ logK <- data.frame(T, CO2, CO, CH4) ``` ```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE} -matplot(logK[, 1], logK[, -1], type="l", +matplot(logK[, 1], logK[, -1], type="l", col=1, lty=1, xlab=axis.label("T"), ylab=axis.label("logK")) +text(80, -1.7, expr.species("CO2")) +text(270, -2.2, expr.species("CO")) +text(310, -2.4, expr.species("CH4")) ``` ```{r dissolution, eval=FALSE} ``` -Now we can make the plot. -Here, the `axis.label()` function of CHNOSZ is used to create formatted axis labels: +Now we can make the plot, using R's `matplot()`. +Here, the `axis.label()` and `expr.species()` functions of CHNOSZ are used to create formatted axis labels and chemical formulas: ```{r dissolution_plot, eval=FALSE} ``` @@ -500,7 +503,7 @@ The default colors for diagrams shown on the screen are R's "heat colors". Some arguments in `diagram()` can be used to control the color, labels, and lines, and title (`main`). The `tplot` argument turns off plot customizations used in CHNOSZ. -Additional arguments can be passed via `...`; here, we use that to remove the box around the plot: +Additional arguments are passed to R's plotting functions; here, we use `bty` to remove the box around the plot: ```{r EhpH_plot_color, echo=TRUE, eval=FALSE} ``` @@ -511,24 +514,86 @@ These diagrams are made by constructing individual diagrams for the possible basis species. The individual diagrams are then combined, each one contributing to the final diagram only in the range of stability of the corresponding basis species. -Here, we use the `mosaic()` function in CHNOSZ to make a diagram for aqueous species and minerals in the Cu-S-Cl-H2O system, similar to Figure 5a of @CPCC17. -The key argument is `bases`, which identifies the candidate basis species (starting with the one in the current basis set). -The other arguments, like those of `affinity()`, specify the ranges of the variables. +Let's use the `mosaic()` function in CHNOSZ to make a diagram for aqueous species and minerals in the Cu-S-Cl-H2O system, similar to Figure 5a of @CPCC17. +To know what aqueous copper chloride complexes are available in the database, we can use a fuzzy search: +```{r info_CuCl, results="hide"} +info(" CuCl") +``` -# Equilibration +We wish to include chalcocite (Cu2S) in the system. +This mineral undergoes phase transitions; to find out the temperatures of the phase transitions, we can also use `info()`: +```{r info_chalcocite, message=FALSE} +info(info("chalcocite", c("cr1", "cr2", "cr3")))$T +``` -## Getting from affinity to equilibrium +Those are temperatures in Kelvin (regardless of the `T.units()`); at 200 ?C we should use the second phase. -## Setting the constraints +Next we define the basis, and set the activities of the H2S and Cl- basis species. +These represent the total activity of S and Cl in the system, which are distributed among the minerals and aqueous species (i.e., not the basis species). +Three minerals and the aqueous copper chloride species are included: +```{r copper_setup, echo=TRUE, results="hide"} +basis(c("Cu", "H2S", "Cl-", "H2O", "H+", "e-")) +basis("H2S", -6) +basis("Cl-", -0.7) +species(c("copper", "tenorite")) +species("chalcocite", "cr2") +species(c("CuCl", "CuCl2-", "CuCl3-2", "CuCl+", "CuCl2", "CuCl3-", "CuCl4-2")) +``` -# Other things you can do with affinity +

+We use `mosaic()` to generate and combine diagrams for each candidate basis species (H2S, HS-, HSO4-, or SO4-2) as a function of Eh and pH. +The key argument is `bases`, which identifies the candidate basis species (starting with the one in the current basis). +The other arguments, like those of `affinity()`, specify the ranges of the variables; `res` indicates the grid resolution to use for each variable (higher than the default). +The first call to `diagram()` plots the species of interest; the second adds the predominance fields of the basis species. +Finally, `water.lines()` is used to add the stability limits of water at the given temperature. +```{r copper_mosaic, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", message=FALSE, cache=TRUE} +T <- 200 +res <- 300 +bases <- c("H2S", "HS-", "HSO4-", "SO4-2") +m1 <- mosaic(bases, blend=TRUE, pH=c(0, 12, res), Eh=c(-1.2, 0.75, res), T=T) +diagram(m1$A.species, lwd=2) +diagram(m1$A.bases, add=TRUE, col="blue", col.names="blue", lty=2) +water.lines("pH", "Eh", T=convert(T, "K"), col="red", lwd=2, lty=2) +``` +The argument `blend=TRUE` is used to combine the diagrams according to the equilibrium activities of the basis species (see below). +The smooth transitions between basis species cause the appearance of curved lines on the plot. +Without that argument, the diagrams would be combined using the dominant basis species, and all of the line segments would be straight. + +We have seen the effects of speciation of S in the basis species. +However, the choice of other basis species can also affect the diagram. +For instance, we can use H2 or O2 in place of *e*-. +To do that, let's write a function to swap those basis species and make a diagram. +We use `do.call()` to construct the argument list for `mosaic()`; this way, the name of the `newvar` argument to our function indicates the chosen variable. +```{r mosaicfun, fig.fullwidth=TRUE, fig.width=10.5, fig.height=3, small.mar=TRUE, dpi=50, out.width="100%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness."} +mosaicfun <- function(newvar, T=200, res=300) { + swap.basis("e-", names(newvar)) + if(names(newvar) == "O2") basis("O2", "gas") + mosaicargs <- c(list(bases), blend=TRUE, pH=list(c(-2, 12, res)), newvar, T=T) + m1 <- do.call(mosaic, mosaicargs) + diagram(m1$A.species, lwd=2, fill=rev(topo.colors(10))) + diagram(m1$A.bases, add=TRUE, col="blue", col.names="blue", lty=3) + title(main=axis.label(names(newvar))) + swap.basis(names(newvar), "e-") +} +layout(t(matrix(c(1, 1, 2, 2, 3, 3, 0)))) +mosaicfun(list(Eh=c(-1, 1, res))) +mosaicfun(list(H2=c(-15, 5, res))) +mosaicfun(list(O2=c(-70, 0, res))) +``` + ## Buffers ## T-, P-, activity-transect -# Other things you can do with equilibrate + +# Equilibration + +## Getting from affinity to equilibrium + +## Setting the constraints + ## Choosing different balancing constraints # Other things you can do with diagrams From noreply at r-forge.r-project.org Sun Feb 5 04:29:18 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 04:29:18 +0100 (CET) Subject: [CHNOSZ-commits] r130 - in pkg/CHNOSZ: . R demo inst man vignettes Message-ID: <20170205032918.89EE51880DF@r-forge.r-project.org> Author: jedick Date: 2017-02-05 04:29:16 +0100 (Sun, 05 Feb 2017) New Revision: 130 Added: pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/protbuff.R Removed: pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/nucleobase.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add buffers Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 03:29:16 UTC (rev 130) @@ -1,6 +1,6 @@ Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-19 +Version: 1.0.8-20 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/R/examples.R 2017-02-05 03:29:16 UTC (rev 130) @@ -30,8 +30,8 @@ } demos <- function(which=c("sources", "NaCl", "density", - "nucleobase", "ORP", "revisit", "findit", - "ionize", "buffer", "yeastgfp", "mosaic", + "ORP", "revisit", "findit", + "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/demo/00Index 2017-02-05 03:29:16 UTC (rev 130) @@ -1,12 +1,12 @@ sources cross-check the reference list with the thermodynamic database NaCl equilibrium constant for aqueous NaCl dissociation density density of H2O, inverted from IAPWS-95 equations -nucleobase relative stabilities of nucleobases and some amino acids ORP oxidation-reduction potential of redox standards as a function of temperature revisit detailed example of usage of revisit() findit detailed example of usage of findit() ionize ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK -buffer ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) +buffer minerals and aqueous species as buffers of hydrogen fugacity +protbuff ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) yeastgfp logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations mosaic Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species copper another example of mosaic(): complexation of copper with glycine species Deleted: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-05 03:29:16 UTC (rev 130) @@ -1,43 +0,0 @@ -## Buffer + ionization: Metastablilities of -## thiol peroxidases from model bactera -## (ECOLI, BACSU mesophile; AQUAE thermophile, -## THIDA acidophile, BACHD alkaliphile) -basis("CHNOS+") -organisms <- c("ECOLI", "AQUAE", "BACSU", "BACHD", "THIDA") -species("TPX", organisms) -# create a buffer with our proteins in it -mod.buffer("TPX", paste("TPX", organisms, sep="_")) -# set up the buffered activities -basis(c("CO2", "H2O", "NH3", "O2"), "TPX") -a <- affinity(return.buffer=TRUE, T=50) -basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4])) -a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300)) -e <- equilibrate(a, normalize=TRUE) -diagram(e, fill=NULL) -title(main="Thiol peroxidases from bacteria") -legend("topleft", describe.basis(thermo$basis[-6,])) - -## Buffer + ionization: relative stabilities -## of E. coli sigma factors on a T-pH diagram -# (sigma factors 24, 32, 38, 54, 70, i.e. -# RpoE, RpoH, RpoS, RpoN, RpoD) -proteins <- c("RPOE", "RP32", "RPOS", "RP54", "RPOD") -basis("CHNOS+") -basis("pH", 7.4) -# define and set the buffer -mod.buffer("sigma", paste(proteins, "ECOLI", sep="_")) -basis(c("CO2", "NH3", "H2S", "O2"), "sigma") -logact <- affinity(return.buffer=TRUE, T=25) -# Set the activities of the basis species to constants -# corresponding to the buffer, and diagram the relative -# stabilities as a function of T and pH -basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact)) -species(paste(proteins, "ECOLI", sep="_")) -a <- affinity(pH=c(5, 10), T=c(10, 40)) -diagram(a, normalize=FALSE, fill="heat") -title(main="Relative stabilities of sigma factors in E. coli") -ptext <- c(describe.property("T", 25), - describe.basis(ibasis=c(2, 6), oneline=TRUE)) -btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE) -legend("bottomleft", legend=c("preset (input values):", - ptext, "buffered (results):", btext), bty="n") Added: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R (rev 0) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-05 03:29:16 UTC (rev 130) @@ -0,0 +1,32 @@ +# demos/buffer.R +# calculate buffered activities of basis species using two methods +# reproduces Figure 6 of Schulte and Shock, 1995 (doi:10.1007/BF01581580) + +b.species <- c("Fe", "CO2", "H2O", "N2", "H2", "H2S", "SiO2") +b.state <- c("cr1", "gas", "liq", "gas", "gas", "aq", "aq") +b.logact <- c(0, 1, 0, 0, 0, 0, 0) +basis(b.species, b.state, b.logact) +xlim <- c(0, 350) +thermo.plot.new(xlim=xlim, ylim=c(-4, 4), xlab=axis.label("T"), ylab=axis.label("H2")) +# method 1: in affinity(), assign name of buffer to basis species +bufferline <- function(buffer, ixlab) { + basis("H2", buffer) + a <- affinity(T=xlim, P=300, return.buffer=TRUE, exceed.Ttr=TRUE) + lines(a$vals[[1]], a$H2, col="red", lwd=2) + text(a$vals[[1]][ixlab], a$H2[ixlab], buffer) +} +bufferline("FeFeO", 20) +bufferline("QFM", 38) +bufferline("PPM", 102) +bufferline("HM", 51) +# method 2: in diagram(), use the `what` argument +basis("H2", 0) +for(logact in c(-6, -10, -15)) { + species(c("formaldehyde", "HCN"), logact) + a <- affinity(T=xlim, P=300) + d <- diagram(a, what="H2", lty=c(3, 2), add=TRUE) + text(a$vals[[1]][13], mean(sapply(d$plotvals, c)[13, ]), logact) +} +# add legend +legend("topright", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4)), + "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 2, 1, 1), bg="white") Deleted: pkg/CHNOSZ/demo/nucleobase.R =================================================================== --- pkg/CHNOSZ/demo/nucleobase.R 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/demo/nucleobase.R 2017-02-05 03:29:16 UTC (rev 130) @@ -1,22 +0,0 @@ -## Nucleobase - Amino Acid Interaction Eh-H2O -# for this example we try a custom basis set -basis(c("CO2", "H2O", "glutamine", "e-", "H+"), c(-3, 0, -3, 0, -7)) -species(c("uracil", "cytosine", "adenine", "guanine", - "phenylalanine", "proline", "lysine", "glycine"), "aq") -# this loaded four nucleobases and four related amino acids -# (coded for by the homocodon triplets) -# check out the predominance diagrams -a.1 <- affinity(H2O=c(-5, 0, 300), Eh=c(-0.5, 0, 300)) -diagram(a.1, fill=NULL) -# overlay a different temperature -a.2 <- affinity(H2O=c(-5, 0, 300), Eh=c(-0.5, 0, 300), T=100) -diagram(a.2, col="red", add=TRUE, names=NULL) -# add title and legend -title(main="Nucleobases and amino acids; P=Psat") -# includes activities of basis species -tb <- thermo$basis -# exclude those that are on the axes -tb <- tb[!((rownames(tb) %in% c("e-", "H2O"))),] -dp <- describe.property(c("T", "T"), c(25, 100)) -db <- describe.basis(tb) -legend("bottomleft", lty=c(1, 1, NA, NA, NA), col=c("black", "red"), legend=c(dp, db)) Copied: pkg/CHNOSZ/demo/protbuff.R (from rev 129, pkg/CHNOSZ/demo/buffer.R) =================================================================== --- pkg/CHNOSZ/demo/protbuff.R (rev 0) +++ pkg/CHNOSZ/demo/protbuff.R 2017-02-05 03:29:16 UTC (rev 130) @@ -0,0 +1,43 @@ +## Buffer + ionization: Metastablilities of +## thiol peroxidases from model bactera +## (ECOLI, BACSU mesophile; AQUAE thermophile, +## THIDA acidophile, BACHD alkaliphile) +basis("CHNOS+") +organisms <- c("ECOLI", "AQUAE", "BACSU", "BACHD", "THIDA") +species("TPX", organisms) +# create a buffer with our proteins in it +mod.buffer("TPX", paste("TPX", organisms, sep="_")) +# set up the buffered activities +basis(c("CO2", "H2O", "NH3", "O2"), "TPX") +a <- affinity(return.buffer=TRUE, T=50) +basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4])) +a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300)) +e <- equilibrate(a, normalize=TRUE) +diagram(e, fill=NULL) +title(main="Thiol peroxidases from bacteria") +legend("topleft", describe.basis(thermo$basis[-6,])) + +## Buffer + ionization: relative stabilities +## of E. coli sigma factors on a T-pH diagram +# (sigma factors 24, 32, 38, 54, 70, i.e. +# RpoE, RpoH, RpoS, RpoN, RpoD) +proteins <- c("RPOE", "RP32", "RPOS", "RP54", "RPOD") +basis("CHNOS+") +basis("pH", 7.4) +# define and set the buffer +mod.buffer("sigma", paste(proteins, "ECOLI", sep="_")) +basis(c("CO2", "NH3", "H2S", "O2"), "sigma") +logact <- affinity(return.buffer=TRUE, T=25) +# Set the activities of the basis species to constants +# corresponding to the buffer, and diagram the relative +# stabilities as a function of T and pH +basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact)) +species(paste(proteins, "ECOLI", sep="_")) +a <- affinity(pH=c(5, 10), T=c(10, 40)) +diagram(a, normalize=FALSE, fill="heat") +title(main="Relative stabilities of sigma factors in E. coli") +ptext <- c(describe.property("T", 25), + describe.basis(ibasis=c(2, 6), oneline=TRUE)) +btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE) +legend("bottomleft", legend=c("preset (input values):", + ptext, "buffered (results):", btext), bty="n") Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 03:29:16 UTC (rev 130) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-19 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-20 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -22,7 +22,8 @@ (citric acid cycle metabolites; thioester species have been kept) and from Dick et al., 2006 (methionine and [Met]). -- Add demo bugstab.R. +- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R, + remove nucleobase.R. - Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter Canovas. Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/man/examples.Rd 2017-02-05 03:29:16 UTC (rev 130) @@ -15,8 +15,8 @@ \usage{ examples(do.png = FALSE) demos(which = c("sources", "NaCl", "density", - "nucleobase", "ORP", "revisit", "findit", - "ionize", "buffer", "yeastgfp", "mosaic", + "ORP", "revisit", "findit", + "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE) } @@ -35,12 +35,12 @@ \code{sources} \tab cross-check the reference list with the thermodynamic database \cr \code{NaCl} \tab equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr \code{density} \tab density of H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr - \code{nucleobase} \tab relative stabilities of nucleobases and some amino acids \cr \code{ORP} \tab oxidation-reduction potential of redox standards as a function of temperature \cr \code{revisit} \tab detailed example of usage of \code{\link{revisit}} \cr \code{findit} \tab detailed example of usage of \code{\link{findit}} \cr \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr - \code{buffer} \tab ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) \cr + \code{buffer} \tab minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr + \code{protbuff} \tab ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) \cr \code{yeastgfp} \tab logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations (Dick, 2009) \cr \code{mosaic} \tab Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr \code{copper} \tab another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr @@ -63,6 +63,8 @@ Manning, C. E., Shock, E. L. and Sverjensky, D. A. (2013) The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. \emph{Rev. Mineral. Geochem.} \bold{75}, 109--148. \url{http://dx.doi.org/10.2138/rmg.2013.75.5} + Schulte, M. D. and Shock, E. L. (1995) Thermodynamics of Strecker synthesis in hydrothermal systems. \emph{Orig. Life Evol. Biosph.} \bold{25}, 161--173. \url{http://dx.doi.org/10.1007/BF01581580} + Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{http://dx.doi.org/10.1039/FT9928800803} Stumm, W. and Morgan, J. J. (1996) \emph{Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters}, John Wiley & Sons, New York, 1040 p. \url{http://www.worldcat.org/oclc/31754493} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 03:29:16 UTC (rev 130) @@ -582,12 +582,67 @@ mosaicfun(list(O2=c(-70, 0, res))) ``` +## T-, P-, activity-transect + ## Buffers -## T-, P-, activity-transect +There is one final feature of `affinity()` to notice. +Can we go the other direction: calculate the activities of basis species from the activities of the species of interest? +This question relates to the concept of chemical activity buffers. +In CHNOSZ there are two ways to perform buffer calculations: +1. Assign the name of a buffer (listed in `thermo$buffer`) to the basis species +* more versatile (multiple activities can be buffered, e.g. both S2 and O2 by pyrite-pyrrhotite-magnetite) +* the buffers are active in calculations of affinity of other species +* use `mod.buffer()` to change or add buffers in `thermo$buffer` +* `demo(buffer)` uses it for mineral buffers (solid lines) +2. Use the `what` argument of `diagram()` to solve for the activity of the indicated basis species +* more convenient (the buffers come from the currently defined species of interest), but only a single basis species can be buffered, and it's not used in the calculation of affinity +* `demo(buffer)` uses it for aqueous organic species as buffers (dotted and dashed lines) +As an example of method 1, let's look at the pyrite-pyrrhotite-magnetite (PPM) buffer at 300 ?C. +```{marginfigure} +For other examples, see `?buffer` and `demo(protbuff)` (hypothetical buffer made of proteins). +``` +Without the buffer, the basis species have default activities of zero. +Under these conditions, the minerals are not in equilibrium, as shown by their different affinities of formation: +```{r PPM_basis, results="hide", message=FALSE} +basis(c("FeS2", "H2S", "O2", "H2O")) +species(c("pyrite", "magnetite")) +species("pyrrhotite", "cr2") +``` +```{r PPM_affinity, message=FALSE} +unlist(affinity(T=300, P=100)$values) +``` +```{marginfigure} +The affinity of formation of pyrite happens to be zero because it is identical to one of the selected basis species. +``` +We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature. +Then, we set up H2S and O2 to be buffered by PPM, and inspect their buffered activities: +```{r PPM_setup, results="hide"} +mod.buffer("PPM", "pyrrhotite", "cr2") +basis(c("H2S", "O2"), c("PPM", "PPM")) +``` +```{r PPM_activities, message=FALSE} +unlist(affinity(T=300, P=100, return.buffer=TRUE)[1:3]) +``` + +

+Et voil?! We have found log*a*H2S and log*f*O2 that are compatible with the coexistence of the three minerals. +Under these conditions, the affinities of formation reactions of the minerals in the buffer are all equal to zero: +```{r demo_buffer, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", message=FALSE, echo=FALSE, cache=TRUE} +demo(buffer, echo=FALSE) +``` +```{r PPM_affinity, message=FALSE} +``` + +Another example, based on Figure 6 of @SS95, is given in `demo(buffer)`. +Here, values of log*f*H2 buffered by minerals or aqueous species are calculated using the two methods: +```{r demo_buffer, eval=FALSE} +``` + + # Equilibration ## Getting from affinity to equilibrium @@ -604,12 +659,18 @@ ## Group additivity +## Compositional analysis (ZC and nH2O) + ## Sources of amino acid data ## Ionization ## Normalizing for different lengths +# Modifying the database + +mod.obigt, mod.buffer + # Functions outside of the main workflow transfer, wjd, eqdata, RH2obigt, EOSregress Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-05 01:20:14 UTC (rev 129) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-05 03:29:16 UTC (rev 130) @@ -211,6 +211,17 @@ doi = {10.1016/S0891-5849(01)00480-4}, } + at Article{SS95, + author = {Schulte, Mitchell D. and Shock, Everett L.}, + journal = {Origins of Life and Evolution of the Biosphere}, + title = {Thermodynamics of {S}trecker synthesis in hydrothermal systems}, + year = {1995}, + volume = {25}, + number = {1-3}, + pages = {161--173}, + doi = {10.1007/BF01581580}, +} + @Article{SSW01, author = {Schulte, Mitchell D. and Shock, Everett L. and Wood, Robert H.}, journal = {Geochimica et Cosmochimica Acta}, From noreply at r-forge.r-project.org Sun Feb 5 08:30:25 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 08:30:25 +0100 (CET) Subject: [CHNOSZ-commits] r131 - in pkg/CHNOSZ: . R demo inst man vignettes Message-ID: <20170205073025.41677187BB1@r-forge.r-project.org> Author: jedick Date: 2017-02-05 08:30:22 +0100 (Sun, 05 Feb 2017) New Revision: 131 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/buffer.R pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/protbuff.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/affinity.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add transects Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 07:30:22 UTC (rev 131) @@ -1,6 +1,6 @@ Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-20 +Version: 1.0.8-21 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/buffer.R =================================================================== --- pkg/CHNOSZ/R/buffer.R 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/R/buffer.R 2017-02-05 07:30:22 UTC (rev 131) @@ -23,7 +23,7 @@ thermo$buffers <- thermo$buffers[-imod,] assign("thermo", thermo, "CHNOSZ") message(paste('mod.buffer: removed ',c2s(species),' in ', - c2s(unique(name)),' buffer.',sep='')) + c2s(unique(name)),' buffer',sep='')) } else { if(missing(state)) state <- thermo$buffers$state[imod] if(missing(logact)) logact <- thermo$buffers$logact[imod] @@ -36,10 +36,10 @@ assign("thermo", thermo, "CHNOSZ") if(identical(state.old,state) & identical(logact.old,logact)) { message(paste('mod.buffer: nothing changed for ', - c2s(species),' in ',c2s(unique(name)),' buffer.',sep='')) + c2s(species),' in ',c2s(unique(name)),' buffer',sep='')) } else { message(paste('mod.buffer: changed state and/or logact of ', - c2s(species),' in ',c2s(unique(name)),' buffer.',sep='')) + c2s(species),' in ',c2s(unique(name)),' buffer',sep='')) } } } else { @@ -51,7 +51,7 @@ t <- data.frame(name=name,species=species,state=state,logact=logact) thermo$buffers <- rbind(thermo$buffers,t) assign("thermo", thermo, "CHNOSZ") - message(paste('mod.buffer: added ',c2s(unique(name)),'.',sep='')) + message(paste('mod.buffer: added',c2s(unique(name)))) } return(invisible(thermo$buffers[thermo$buffers$name %in% name,])) } Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/R/diagram.R 2017-02-05 07:30:22 UTC (rev 131) @@ -20,7 +20,7 @@ # line styles lty=NULL, lwd=par("lwd"), dotted=NULL, # colors - bg=par("bg"), col=par("col"), col.names=par("col"), fill=NULL, + col=par("col"), col.names=par("col"), fill=NULL, # labels names=NULL, main=NULL, legend.x="topright", format.names=TRUE, # plotting controls @@ -254,7 +254,7 @@ if(xvalues[imax] < xlim[1] + 0.2*diff(xlim)) adj <- 0 text(xvalues[imax], plotvals[[i]][imax], labels=names[i], adj=adj) } - } else legend(x=legend.x, lty=lty, legend=names, col=col, bg=bg, cex=cex.names, lwd=lwd) + } else legend(x=legend.x, lty=lty, legend=names, col=col, cex=cex.names, lwd=lwd, ...) } # add a title if(!is.null(main)) title(main=main) Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/R/util.plot.R 2017-02-05 07:30:22 UTC (rev 131) @@ -3,7 +3,7 @@ thermo.plot.new <- function(xlim,ylim,xlab,ylab,cex=par('cex'),mar=NULL,lwd=par('lwd'),side=c(1,2,3,4), mgp=c(1.5,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE,ticks=NULL, - las=1,xline=NULL) { + las=1,xline=NULL, ...) { # start a new plot with some customized settings thermo <- get("thermo") # 20120523 store the old par in thermo$opar @@ -17,7 +17,7 @@ # 20090324 mar handling: NULL - a default setting; NA - par's setting # 20090413 changed mar of top side from 2 to 2.5 if(is.null(mar)) mar <- c(3,3.5,2.5,1) else if(is.na(mar[1])) mar <- par('mar') - par(mar=mar,mgp=mgp,tcl=0.3,las=las,xaxs=axs,yaxs=axs,cex=cex,lwd=lwd,col=col,fg=col) + par(mar=mar,mgp=mgp,tcl=0.3,las=las,xaxs=axs,yaxs=axs,cex=cex,lwd=lwd,col=col,fg=col, ...) plot.new() plot.window(xlim=xlim,ylim=ylim) if(do.box) box() Modified: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-05 07:30:22 UTC (rev 131) @@ -12,7 +12,7 @@ bufferline <- function(buffer, ixlab) { basis("H2", buffer) a <- affinity(T=xlim, P=300, return.buffer=TRUE, exceed.Ttr=TRUE) - lines(a$vals[[1]], a$H2, col="red", lwd=2) + lines(a$vals[[1]], a$H2, col=3, lwd=2) text(a$vals[[1]][ixlab], a$H2[ixlab], buffer) } bufferline("FeFeO", 20) @@ -29,4 +29,4 @@ } # add legend legend("topright", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4)), - "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 2, 1, 1), bg="white") + "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 3, 1, 1), bg="white") Modified: pkg/CHNOSZ/demo/protbuff.R =================================================================== --- pkg/CHNOSZ/demo/protbuff.R 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/demo/protbuff.R 2017-02-05 07:30:22 UTC (rev 131) @@ -13,7 +13,7 @@ basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4])) a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300)) e <- equilibrate(a, normalize=TRUE) -diagram(e, fill=NULL) +diagram(e, fill=NULL, format.names=FALSE) title(main="Thiol peroxidases from bacteria") legend("topleft", describe.basis(thermo$basis[-6,])) @@ -34,7 +34,7 @@ basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact)) species(paste(proteins, "ECOLI", sep="_")) a <- affinity(pH=c(5, 10), T=c(10, 40)) -diagram(a, normalize=FALSE, fill="heat") +diagram(a, normalize=FALSE, fill="heat", format.names=FALSE) title(main="Relative stabilities of sigma factors in E. coli") ptext <- c(describe.property("T", 25), describe.basis(ibasis=c(2, 6), oneline=TRUE)) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 07:30:22 UTC (rev 131) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-20 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-21 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -45,6 +45,8 @@ - diagram() applies formatting (subscripts and superscripts) to names that parse as chemical formulas; use `format.names` to disable. +- Add '...' argument to thermo.plot.new() (extra arguments for par()). + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/affinity.Rd =================================================================== --- pkg/CHNOSZ/man/affinity.Rd 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/man/affinity.Rd 2017-02-05 07:30:22 UTC (rev 131) @@ -51,8 +51,7 @@ \code{iprotein} contains indices of desired proteins in \code{\link{thermo}$protein}; \code{affinity} adds to the species list the amino acid residues and and terminal H2O group (indicated by \dQuote{RESIDUE} in \code{thermo$protein}) then calculates the properties of the reactions for the residues and terminal group, including ionization effects, and adds them together to get those of the indicated proteins. In CHNOSZ version 0.9, \code{energy} gained a new argument \samp{transect} which is set to TRUE by \code{energy.args} when the length(s) of the variables is(are) greater than three. -In this mode of operation, instead of performing the calculations on an \eqn{n}{n}-dimensional grid, the affinities are calculated on an \eqn{n}{n}-dimensional transect through chemical potential (possibly including T and/or P) space. - +In this mode of operation, instead of performing the calculations on an \eqn{n}{n}-dimensional grid, the affinities are calculated on a transect of changing T, P, and/or chemical activity of basis species. } \value{ @@ -72,25 +71,28 @@ \examples{ \dontshow{data(thermo)}## set up a system and calculate ## chemical affinities of formation reactions -basis(c("SiO2","MgO","H2O","O2"),c(-5,-5,0,999)) +basis(c("SiO2", "MgO", "H2O", "O2"), c(-5, -5, 0, 999)) species(c("quartz","enstatite","forsterite")) # chemical affinities (A/2.303RT) at 25 deg C and 1 bar affinity() # at higher temperature and pressure -affinity(T=500,P=2000) +affinity(T=500, P=2000) # ten different temperatures at one pressure -affinity(T=c(500,1000,10),P=2000) +affinity(T=c(500, 1000, 10), P=2000) # at 25 temperatures and pressures -affinity(T=c(500,1000,5),P=c(1000,5000,5)) +affinity(T=c(500, 1000, 5), P=c(1000, 5000, 5)) # as a function of logarithm of activity of MgO -affinity(MgO=c(-10,-5,10)) -## equilibrium constants of formation reactions +affinity(MgO=c(-10, -5, 10)) +# equilibrium constants of formation reactions affinity(property="logK") -# Standard molal Gibbs energies of species, +# standard molal Gibbs energies of species, # user units (default: cal/mol) affinity(property="G.species") -# Standard molal Gibbs energies of reactions +# standard molal Gibbs energies of reactions affinity(property="G") +# a T,P-transect +# (fluid pressure from Helgeson et al., 2009 Fig. 7) +affinity(T=c(25, 110, 115, 215), P=c(11, 335, 500, 1450)) ## affinities of metabolic reactions ## after Amend and Shock, 2001, Fig. 7 @@ -180,37 +182,6 @@ # reset units and species to run next examples E.units("cal") species(delete=TRUE) - -## calculations along a transect: methanogenesis and biosynthetic -## reactions in hydrothermal systems, after Shock and Canovas, 2010 -# this file has their mixing path results for Rainbow hydrothermal field -file <- system.file("extdata/cpetc/SC10_Rainbow.csv", package="CHNOSZ") -rb <- read.csv(file, check.names=FALSE) -# write all synthesis reactions in terms of these basis species -# it's okay not to set the activities of the basis species now -# because they'll be changing along with temperature -basis(c("CO2", "H2", "NH4+", "H2O", "H2S", "H+")) -# now a selection of the species from SC10, with activities equal to 1e-6 -species(c("CH4", "formaldehyde", "ethylene", "glycolic acid", - "n-nonanoic acid", "leucine", "aspartic acid", "tryptophan", "deoxyribose", - "adenine", "cytosine"), -6) -# the exception is methane; unlike SC10 we use a constant activity 1e-3 -# (accounting for variable activities of the species of interest here -# is possible but would require longer code ....) -species("CH4", -3) -# synchronized change of temperature and five basis activities -a <- affinity(T=rb$T, CO2=rb$CO2, H2=rb$H2, `NH4+`=rb$`NH4+`, H2S=rb$H2S, pH=rb$pH) -# the tricky part: affinity() uses dimensionless values (A/2.303RT) -# but we want to show the values in cal/mol -a$values <- lapply(a$values, function(val) { - -convert(val, "G", T=convert(a$vals[[1]], "K")) }) -# if we didn't have balance=1 here the values would be -# divided by the number of moles of CO2 in the reactions ... -diagram(a, balance=1, ylim=c(-100000, 100000), ylab=axis.label("A"), - col=topo.colors(4), lwd=2) -# add a zero-affinity line and a title -abline(h=0, lty=2, lwd=2) -title(main="Affinities of organic synthesis, after Shock and Canovas, 2010") } \references{ @@ -220,6 +191,8 @@ 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. \emph{Biogeosciences} \bold{3}, 311--336. \url{http://www.biogeosciences.net/3/311/2006/bg-3-311-2006.html} + Helgeson, H. C., Richard, L, McKenzie, W. F., Norton, D. L. and Schmitt, A. (2009) A chemical and thermodynamic model of oil generation in hydrocarbon source rocks. \emph{Geochim. Cosmochim. Acta} \bold{73}, 594--695. \url{http://dx.doi.org/10.1016/j.gca.2008.03.004} + Kondepudi, D. K. and Prigogine, I. (1998) \emph{Modern Thermodynamics: From Heat Engines to Dissipative Structures}, John Wiley & Sons, New York, 486 p. \url{http://www.worldcat.org/oclc/38055900} Shock, E. and Canovas, P. (2010) The potential for abiotic organic synthesis and biosynthesis at seafloor hydrothermal systems. \emph{Geofluids} \bold{10}, 161--192. \url{http://dx.doi.org/10.1111/j.1468-8123.2010.00277.x} Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-05 07:30:22 UTC (rev 131) @@ -14,7 +14,7 @@ ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, - bg=par("bg"), col=par("col"), col.names=par("col"), fill=NULL, + col=par("col"), col.names=par("col"), fill=NULL, names=NULL, main=NULL, legend.x="topright", format.names=TRUE, add=FALSE, plot.it=TRUE, tplot=TRUE, ...) strip(affinity, ispecies = NULL, col = NULL, ns = NULL, @@ -45,7 +45,6 @@ \item{lty}{numeric, line types to be used in plots} \item{lwd}{numeric, line width} \item{dotted}{numeric, how often to skip plotting points on predominance field boundaries (to gain the effect of dotted or dashed boundary lines)} - \item{bg}{character, background color for legend} \item{col}{character, color of activity lines (1D diagram) or predominance field boundaries (2D diagram), or colors of bars in a strip diagram (\code{strip})} \item{col.names}{character, colors for labels of species} \item{fill}{character, colors used to fill predominance fields} Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-02-05 07:30:22 UTC (rev 131) @@ -20,7 +20,7 @@ mar = NULL, lwd = par("lwd"), side = c(1,2,3,4), mgp = c(1.5, 0.3, 0), cex.axis = par("cex"), col = par("col"), yline = NULL, axs = "i", do.box = TRUE, ticks = NULL, las = 1, - xline = NULL) + xline = NULL, ...) thermo.axis(lab = "x-axis", side = 1, line = 1.5, cex = par("cex"), lwd = par("lwd"), T = NULL, col = par("col")) label.plot(x, xfrac = 0.05, yfrac = 0.95, paren = FALSE, @@ -53,6 +53,7 @@ \item{ticks}{numeric, same effect as \code{side} (retained for backwards compatibility)} \item{las}{numeric, style for axis labels} \item{xline}{numeric, margin line on which to plot \eqn{x}{x}-axis name} + \item{...}{further arguments passed to \code{par} or \code{mtext}} \item{lab}{character, description of axis label} \item{line}{numeric, margin line to plot axis label} \item{T}{numeric, temperature (K)} @@ -70,7 +71,6 @@ \item{xpoints}{numeric, points to plot on \eqn{x}{x} axis} \item{O2state}{character, state of O2} \item{main}{character, text for plot title} - \item{...}{further arguments passed to \code{mtext}} \item{residuals}{numeric, named vector of residuals to plot} \item{property}{character, name of property} \item{model}{character, name of model to use in plot title} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 07:30:22 UTC (rev 131) @@ -582,8 +582,63 @@ mosaicfun(list(O2=c(-70, 0, res))) ``` -## T-, P-, activity-transect +## *T*, *P*, activity transects +Above, we used evenly-spaced grids of *T*, *P*, and/or chemical activities of basis species; the ranges of variables were given by two or three values (minimum, maximum, and optionally resolution). +`affinity()` can also perform calculations along a transect, i.e. a particular path along one or more variables. +A transect is calculated when there are four or more values assigned to the variable(s). +Let's use this feature to calculate affinities (negative Gibbs energies) of methanogenesis and biosynthetic reactions in a hydrothermal system. +The results of mixing calculations between seawater and the Rainbow hydrothermal vent fluid, reported by @SC10, are included in a data file in CHNOSZ: +```{r rainbow_data} +file <- system.file("extdata/cpetc/SC10_Rainbow.csv", package="CHNOSZ") +rb <- read.csv(file, check.names=FALSE) +``` + +We take a selection of the species from Shock and Canovas (2010) with activities equal to 10-6; methane is assigned an activity of 10-3. +We will write the synthesis reactions of organic species in terms of these basis species: +```{marginfigure} +The constant activity of methane is a simplification of the calculation reported by Shock and Canovas (2010). +More code could be added here to vary the activity of methane. +``` +```{r rainbow_species, results="hide"} +basis(c("CO2", "H2", "NH4+", "H2O", "H2S", "H+")) +species("CH4", -3) +species(c("adenine", "cytosine", "aspartic acid", "deoxyribose", + "methane", "leucine", "tryptophan", "n-nonanoic acid"), -6) +``` + +Now we can calculate affinity along the transect of changing temperature and activities of five basis species. +Each variable is given as a named argument; the name for `NH4+` must be quoted. +```{marginfigure} +A shorter code would use `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` +``` +```{marginfigure} +The target of the conversion is `G`, or free energy, from `logK`. +That conversion requires temperature in Kelvin, which is obtained by conversion from ?C. +We finish with a negation (affinity is negative Gibbs energy) and scaling from cal to kcal. +``` +Using the `convert()` function in CHNOSZ, we also convert the result from dimensionless values (**_A_**/2.303*RT*) to kcal/mol. +```{r rainbow_affinity, message=FALSE} +a <- affinity(T=rb$T, CO2=rb$CO2, H2=rb$H2, + `NH4+`=rb$`NH4+`, H2S=rb$H2S, pH=rb$pH) +T <- convert(a$vals[[1]], "K") +a$values <- lapply(a$values, convert, "G", T) +a$values <- lapply(a$values, `*`, -0.001) +``` + +```{r rainbow_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, fig.cap="Affinities of organic synthesis in a hydrothermal system, after Shock and Canovas (2010)."} +diagram(a, balance=1, ylim=c(-100, 100), ylab=axis.label("A", prefix="k"), + col=rainbow(8), lwd=2, legend.x=NA, bg="slategray3") +abline(h=0, lty=2, lwd=2) +``` +Finally, we use `diagram()` to plot the results. +Although only temperature is shown on the *x*-axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. +By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). +To override that behavior, we set `balance=1` to plot the affinities of the formation reactions as written (per mole of the species being formed). +Also, `legend.x=NA` is used to suppress making a legend (so the labels are placed next to the lines instead). +```{r rainbow_diagram, eval=FALSE} +``` + ## Buffers There is one final feature of `affinity()` to notice. @@ -611,14 +666,14 @@ species(c("pyrite", "magnetite")) species("pyrrhotite", "cr2") ``` +```{marginfigure} +The affinity of formation of pyrite happens to be zero because it is identical to one of the selected basis species. +``` ```{r PPM_affinity, message=FALSE} unlist(affinity(T=300, P=100)$values) ``` -```{marginfigure} -The affinity of formation of pyrite happens to be zero because it is identical to one of the selected basis species. -``` -We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature. +We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature. Then, we set up H2S and O2 to be buffered by PPM, and inspect their buffered activities: ```{r PPM_setup, results="hide"} mod.buffer("PPM", "pyrrhotite", "cr2") Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-05 03:29:16 UTC (rev 130) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-05 07:30:22 UTC (rev 131) @@ -243,6 +243,20 @@ doi = {10.1557/PROC-432-317}, } + at Article{SC10, + author = {Shock, Everett and Canovas, Peter}, + journal = {Geofluids}, + title = {{T}he potential for abiotic organic synthesis and biosynthesis at seafloor hydrothermal systems}, + year = {2010}, + volume = {10}, + number = {1-2}, + pages = {161--192}, + af = {Shock, E.EOLEOLCanovas, P.}, + doi = {10.1111/j.1468-8123.2010.00277.x}, + si = {Sp. Iss. SI}, + sn = {1468-8115}, +} + @Article{SH90, author = {Shock, Everett L. and Helgeson, Harold C.}, journal = {Geochimica et Cosmochimica Acta}, From noreply at r-forge.r-project.org Sun Feb 5 10:39:34 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 10:39:34 +0100 (CET) Subject: [CHNOSZ-commits] r132 - in pkg/CHNOSZ: . demo inst man vignettes Message-ID: <20170205093934.609F2184306@r-forge.r-project.org> Author: jedick Date: 2017-02-05 10:39:33 +0100 (Sun, 05 Feb 2017) New Revision: 132 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/bugstab.R pkg/CHNOSZ/demo/solubility.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/read.expr.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: add equilibration Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 09:39:33 UTC (rev 132) @@ -1,6 +1,6 @@ Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-21 +Version: 1.0.8-22 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/bugstab.R =================================================================== --- pkg/CHNOSZ/demo/bugstab.R 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/demo/bugstab.R 2017-02-05 09:39:33 UTC (rev 132) @@ -44,7 +44,7 @@ basis(basis) a <- affinity(O2=O2, H2O=H2O, iprotein=ip, T=37) names <- bugs$abbrv[ibug] - d <- CHNOSZ::diagram(a, names=names, fill=col, as.residue=TRUE, tplot=FALSE, xlab=logfO2lab, ylab=logaH2Olab) + d <- diagram(a, names=names, fill=col, as.residue=TRUE, tplot=FALSE, xlab=logfO2lab, ylab=logaH2Olab, format.names=FALSE) if(i==1) title(main="fecal 16S rRNA", cex.main=1) if(i==2) title(main="fecal metagenome (ZTV+14)", cex.main=1) if(i==3) title(main="co-abundance groups", cex.main=1) Modified: pkg/CHNOSZ/demo/solubility.R =================================================================== --- pkg/CHNOSZ/demo/solubility.R 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/demo/solubility.R 2017-02-05 09:39:33 UTC (rev 132) @@ -19,8 +19,8 @@ # (New York: John Wiley & Sons), 3rd edition # set this to CO2 or calcite +what <- "calcite" #what <- "CO2" -what <- "calcite" # function to return the affinity of the metastable equilibrium species Afun <- function(loga.balance=-3, T=25) { Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 09:39:33 UTC (rev 132) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-21 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-22 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, Modified: pkg/CHNOSZ/man/read.expr.Rd =================================================================== --- pkg/CHNOSZ/man/read.expr.Rd 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/man/read.expr.Rd 2017-02-05 09:39:33 UTC (rev 132) @@ -106,7 +106,7 @@ a <- affinity(O2=c(-80, -73), iprotein=ip, loga.protein=logact) # make a speciation diagram e <- equilibrate(a, normalize=TRUE) -diagram(e, ylim=c(-4.9, -2.9)) +diagram(e, ylim=c(-4.9, -2.9), format.names=FALSE) # where we are closest to experimental log activity logfO2 <- rep(-78, length(ip)) abline(v=logfO2[1], lty=3) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 07:30:22 UTC (rev 131) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 09:39:33 UTC (rev 132) @@ -458,7 +458,7 @@ There we used `basis()` with a keyword to identify a preset basis definition. Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: ```{marginfigure} -The values returned by `affinity()` are dimensionless, i.e. log10(*A*/*RT*). +The values returned by `affinity()` are dimensionless, i.e. log10(**_A_**/*RT*). ``` ```{r affinity} affinity()$values @@ -598,7 +598,7 @@ We will write the synthesis reactions of organic species in terms of these basis species: ```{marginfigure} The constant activity of methane is a simplification of the calculation reported by Shock and Canovas (2010). -More code could be added here to vary the activity of methane. +The code could be expanded to vary the activity of methane. ``` ```{r rainbow_species, results="hide"} basis(c("CO2", "H2", "NH4+", "H2O", "H2S", "H+")) @@ -697,13 +697,92 @@ ```{r demo_buffer, eval=FALSE} ``` - # Equilibration +Above we considered this kind of question: for equal (or known) activities of species, what are their affinities? +Turning the question around, we would like to know: for equal affinities of species, what are their activities? +This is the question of equilibration. + +Before presenting some examples, it is helpful to know about the limitations of the tools. +CHNOSZ is limited to treatment of ideal systems and does not take account of all possible reactions in the speciation of a system. +```{marginfigure} +See `?nonideal` and `?wjd` for some functions that address these issues, but are not integrated with the main workflow. +``` +Instead, it assumes that the total activity of species in the system is set by the activity of *one* basis species. +```{marginfigure} +Because activity coefficients are assumed to be zero, activities are additive and we can refer to "total activity". +``` +This balanced basis species must be present (with a positive or negative coefficient) in the formation reactions of all species considered. + +Under this constraint, activities of the species can be found such that the affinities of the formation reactions are all equal. +This is known as metastable equilibrium. +With additional constraints, the affinites of the formation reactions are not only equal to each other, but equal to zero. +This is total equilibrium. +An example of total equilibrium was given above for the PPM buffer. +In contrast, models for systems of organic and biomolecules most often use metastable equilibrium constraints. + ## Getting from affinity to equilibrium -## Setting the constraints +The `equilibrate()` function in CHNOSZ automatically chooses between two methods for calculating equilibrium. +```{marginfigure} +For more information, see the vignette *Equilibrium in CHNOSZ*. +``` +The method based on the Boltzmann equation is fast, but is applicable only to systems where the coefficients on the balanced basis species are all one. +The reaction-matrix method is slower, but can be applied to systems were the balanced basis species has non-unity coefficients. +```{r bjerrum_diagram, fig.margin=TRUE, fig.width=3, fig.height=6, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, results="hide", message=FALSE, cache=TRUE, fig.cap="Three views of carbonate speciation: affinity, metastable equilibrium activity, degree of formation."} +par(mfrow=c(3, 1)) +basis("CHNOS+") +species(c("CO2", "HCO3-", "CO3-2")) +# affinity at 25 ?C and 150 ?C +a25 <- affinity(pH=c(4, 12)) +a150 <- affinity(pH=c(4, 12), T=150) +diagram(a25, legend.x="topleft", bty="n") +diagram(a150, add=TRUE, col="red") +# equilibration +e25 <- equilibrate(a25, loga.balance=-3) +e150 <- equilibrate(a150, loga.balance=-3) +diagram(e25, ylim=c(-6, 0), bty="n") +diagram(e150, add=TRUE, col="red") +# degree of formation +diagram(e25, alpha=TRUE, legend.x="center", bty="n") +diagram(e150, alpha=TRUE, add=TRUE, col="red") +``` +The distribution of aqueous carbonate species is a classic example of an equilibrium calculation. +We can begin by plotting the affinities for equal activities of the species. +Here, CO2 is in the basis, so it has zero affinity, which is greater than the affinities of HCO3- and CO3-2 at low pH: +```{r bjerrum_1, eval=FALSE} +basis("CHNOS+") +species(c("CO2", "HCO3-", "CO3-2")) +a25 <- affinity(pH=c(4, 12)) +a150 <- affinity(pH=c(4, 12), T=150) +diagram(a25, legend.x="topleft", bty="n") +diagram(a150, add=TRUE, col="red") +``` + +Now we use `equilibrate()` to calculate the activities of species. +Our balancing constraint is that the total activity of C is 10-3. +This shows a hypothetical *metastable equilibrium*; we know that for true equilibrium the total activity of C is affected by pH. +```{r bjerrum_2, eval=FALSE} +e25 <- equilibrate(a25, loga.balance=-3) +e150 <- equilibrate(a150, loga.balance=-3) +diagram(e25, ylim=c(-6, 0), bty="n") +diagram(e150, add=TRUE, col="red") +``` + +To display the species distribution, or degree of formation, use the `alpha=TRUE` argument: +```{r bjerrum_3, eval=FALSE} +diagram(e25, alpha=TRUE, legend.x="center", bty="n") +diagram(e150, alpha=TRUE, add=TRUE, col="red") +``` + +The possible reactions between species are all balanced on 1 C. +Therefore, although pH alters the total activity of C, in an ideal system the total activity of C doesn't affect the relative activities of the species. +```{marginfigure} +See `demo(solubility)` for calculations of the total activity of C in this ideal system; uncomment a line in the demo to run calculations for CO2 instead of calcite. +``` +This makes the species distribution diagram useful for this system. + ## Choosing different balancing constraints # Other things you can do with diagrams @@ -728,4 +807,4 @@ # Functions outside of the main workflow -transfer, wjd, eqdata, RH2obigt, EOSregress +transfer, wjd, eqdata, RH2obigt, EOSregress, nonideal From noreply at r-forge.r-project.org Sun Feb 5 10:51:24 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 10:51:24 +0100 (CET) Subject: [CHNOSZ-commits] r133 - in pkg/CHNOSZ: . demo inst Message-ID: <20170205095124.6B3041883D5@r-forge.r-project.org> Author: jedick Date: 2017-02-05 10:51:24 +0100 (Sun, 05 Feb 2017) New Revision: 133 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/ORP.R pkg/CHNOSZ/inst/NEWS Log: fix ORP.R demo Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 09:39:33 UTC (rev 132) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 09:51:24 UTC (rev 133) @@ -1,6 +1,6 @@ Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-22 +Version: 1.0.8-23 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/ORP.R =================================================================== --- pkg/CHNOSZ/demo/ORP.R 2017-02-05 09:39:33 UTC (rev 132) +++ pkg/CHNOSZ/demo/ORP.R 2017-02-05 09:51:24 UTC (rev 133) @@ -2,9 +2,10 @@ # calculate the temperature dependence of # potentials vs. standard hydrogen electrode (SHE) of various electrodes (Ag/AgCl) # and ORP standards (ZoBell, Light's, (tri)iodide) + # CHNOSZ provides functions subcrt() and convert() # used in this example -#require(CHNOSZ) + # Bard et al.'s fit to the potential # (Bard, Parson, Jordan, Standard Potentials In Aqueous Solution, 1985) AgAgCl.Bard <- function(T,high.T=TRUE) { @@ -12,6 +13,7 @@ if(high.T) return(0.23737 - 5.3783e-4 * T - 2.3728e-6 * T^2 - 2.2671e-9 * (T+273)) else return(0.23695 - 4.8564e-4 * T - 3.4205e-6 * T^2 - 5.869e-9 * (T+273)) } + # function to calculate the potential of Ag/AgCl vs. SHE # Ag(s) + Cl- = AgCl(s) + e- # logK = -pe - logaCl @@ -25,13 +27,14 @@ # get the logK for the reaction logK <- subcrt(c("Ag","Cl-","AgCl","e-"),c(-1,-1,1,1),c("cr","aq","cr","aq"),T=T)$out$logK # get the activity coefficient for Cl- - loggamCl <- subcrt("Cl-",T=T,IS=mKCl)$out[[1]]$loggam + loggamCl <- log(10) * subcrt("Cl-",T=T,IS=mKCl)$out[[1]]$loggam # get the pe for the solution pe <- -logK - logmCl - loggamCl # convert that to Eh Eh <- convert(pe,"Eh",T=convert(T,"K")) return(Eh) } + ZoBell <- function(T) { # doesn't work very well because we ignore the # ferricyanide and ferrocyanide complexes @@ -45,14 +48,15 @@ # 7.4555 g KCl -> 0.1 mol Cl- logmFe2 <- logmFe3 <- log10(0.0033333) # get the loggam for the iron species - loggamFe2 <- subcrt("Fe+2",T=T,IS=1)$out[[1]]$loggam - loggamFe3 <- subcrt("Fe+3",T=T,IS=1)$out[[1]]$loggam + loggamFe2 <- log(10) * subcrt("Fe+2",T=T,IS=1)$out[[1]]$loggam + loggamFe3 <- log(10) * subcrt("Fe+3",T=T,IS=1)$out[[1]]$loggam # get the pe for the solution pe <- -logK + logmFe3 + loggamFe3 - logmFe2 - loggamFe2 # convert to Eh Eh <- convert(pe,"Eh",T=convert(T,"K")) return(Eh) } + ZoBell.table <- function(T=NULL,which=NULL) { # oxidation-reduction potential of ZoBell's solution # from Standard Methods for Water and Wastewater or YSI @@ -76,6 +80,7 @@ if(is.null(T)) T <- Eh.T return(data.frame(T=T,Eh=Eh.fun(T))) } + Light <- function(T) { # this is going to look something like # Fe+2 = Fe+3 + e- @@ -87,14 +92,15 @@ # 48.22 g Fe(NH4)(SO4)2(H2O)12 -> 0.1 mol Fe+3 logmFe2 <- logmFe3 <- log10(0.1) # get the loggam for the iron species - loggamFe2 <- subcrt("Fe+2",T=T,IS=0.2)$out[[1]]$loggam - loggamFe3 <- subcrt("Fe+3",T=T,IS=0.2)$out[[1]]$loggam + loggamFe2 <- log(10) * subcrt("Fe+2",T=T,IS=0.2)$out[[1]]$loggam + loggamFe3 <- log(10) * subcrt("Fe+3",T=T,IS=0.2)$out[[1]]$loggam # get the pe for the solution pe <- -logK + logmFe3 + loggamFe3 - logmFe2 - loggamFe2 # convert to Eh Eh <- convert(pe,"Eh",T=convert(T,"K")) return(Eh) } + Iodide.table <- function(T=NULL) { # oxidation-reduction potential of Thermo's iodide solution # from thermo instruction sheet 255218-001 (articlesFile_18739) @@ -104,6 +110,7 @@ if(is.null(T)) T <- T.Iodide return(data.frame(T=T,Eh=Iodide(T))) } + Iodide <- function(T) { # this is going to look something like # 3I- = I3- + 2e- @@ -114,14 +121,15 @@ logmI <- log10(2) logmI3 <- log10(0.01) # get the loggam for the iodine species - loggamI <- subcrt("I-",T=T,IS=0.2)$out[[1]]$loggam - loggamI3 <- subcrt("I3-",T=T,IS=0.2)$out[[1]]$loggam + loggamI <- log(10) * subcrt("I-",T=T,IS=0.2)$out[[1]]$loggam + loggamI3 <- log(10) * subcrt("I3-",T=T,IS=0.2)$out[[1]]$loggam # get the pe for the solution pe <- ( -logK + logmI3 + loggamI3 - 3 * (logmI - loggamI) ) / 2 # convert to Eh Eh <- convert(pe,"Eh",T=convert(T,"K")) return(Eh) } + figure <- function() { # make some figures # the temperatures we're interested in @@ -156,5 +164,6 @@ c("Light","ZoBell","(Tri)Iodide","Ag/AgCl")) title(main="Potentials vs standard hydrogen electrode (SHE)") } + # finally, make the plot figure() Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 09:39:33 UTC (rev 132) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 09:51:24 UTC (rev 133) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-22 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-23 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, From noreply at r-forge.r-project.org Sun Feb 5 12:43:21 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 5 Feb 2017 12:43:21 +0100 (CET) Subject: [CHNOSZ-commits] r134 - in pkg/CHNOSZ: . demo inst inst/extdata/fasta man tests/testthat Message-ID: <20170205114321.55C541804EC@r-forge.r-project.org> Author: jedick Date: 2017-02-05 12:43:21 +0100 (Sun, 05 Feb 2017) New Revision: 134 Removed: pkg/CHNOSZ/inst/extdata/fasta/HTCC1062.faa.xz Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/demo/revisit.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/iprotein.Rd pkg/CHNOSZ/tests/testthat/test-util.program.R Log: remove HTCC1062.faa.xz Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-05 11:43:21 UTC (rev 134) @@ -1,6 +1,6 @@ Date: 2017-02-05 Package: CHNOSZ -Version: 1.0.8-23 +Version: 1.0.8-24 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/demo/revisit.R =================================================================== --- pkg/CHNOSZ/demo/revisit.R 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/demo/revisit.R 2017-02-05 11:43:21 UTC (rev 134) @@ -1,13 +1,14 @@ ## Demo for revisit(): CV of equilibrium activities of proteins in -## Pelagibacter ubique. -## Also shows use of grep.file(), read.fasta(), add.protein() -f <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ") -# what proteins to select (set to "" for all proteins) -w <- "ribosomal" -# locate entries whose names contain w -j <- grep.file(f, w) -# get the amino acid compositions of these proteins -aa <- read.fasta(f, j) +## subcellular compartment of S. cerevisiae + +# get the proteins in the requested location +loc <- "cell.periphery" +y <- yeastgfp(loc) +# get the amino acid compositions of the proteins +aa <- more.aa(y$protein, "Sce") +# don't use those with NA abundance or sequence +ina <- is.na(y$abundance) | is.na(aa$chains) +aa <- aa[!ina, ] # add these proteins to CHNOSZ's inventory ip <- add.protein(aa) # set up a the chemical system @@ -19,21 +20,19 @@ e <- equilibrate(a, loga.balance=0, normalize=TRUE) diagram(e, names=NULL) # make a title -expr <- as.expression(substitute(x~y~"proteins in"~ - italic("P. ubique"), list(x=length(j), y=w))) +expr <- as.expression(substitute(x~loc~"proteins in"~ + italic("S. cerevisiae"), list(x=length(ip), loc=loc))) mtitle(c("Equilibrium activities of", expr)) # show the coefficient of variation revisit(e, "CV") mtitle(c("CV of equilibrium activities of", expr)) # calculate affinities in logfO2-logaH2O space -a <- affinity(O2=c(-85,-65), H2O=c(-10,0), iprotein=ip) +a <- affinity(O2=c(-85, -65), H2O=c(-5, 5), iprotein=ip) # show the predominances -diagram(a, normalize=TRUE, fill="heat") +diagram(a, normalize=TRUE, fill="heat", format.names=FALSE) # calculate the equilibrium activities e <- equilibrate(a, loga.balance=0, normalize=TRUE) # show the coefficient of variation r <- revisit(e, "CV") -stopifnot(r$ix==37) -stopifnot(r$iy==53) mtitle(c("CV of equilibrium activities of", expr)) par(opar) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/inst/NEWS 2017-02-05 11:43:21 UTC (rev 134) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-23 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-24 (2017-02-05) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -47,6 +47,8 @@ - Add '...' argument to thermo.plot.new() (extra arguments for par()). +- Remove HTCC1062.faa.xz. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Deleted: pkg/CHNOSZ/inst/extdata/fasta/HTCC1062.faa.xz =================================================================== (Binary files differ) Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-05 11:43:21 UTC (rev 134) @@ -39,7 +39,6 @@ Files in \code{fasta} contain protein sequences: \itemize{ - \item \code{HTCC1062.faa.xz} is a FASTA file of 1354 protein sequences in the organism \emph{Pelagibacter ubique} HTCC1062 downloaded from the NCBI RefSeq collection on 2009-04-12. The search term was Protein: txid335992[Organism:noexp] AND "refseq"[Filter]. See \code{\link{util.fasta}} and \code{\link{revisit}} for examples that use this file. \item \code{EF-Tu.aln} consists of aligned sequences (394 amino acids) of elongation factor Tu (EF-Tu). The sequences correspond to those taken from UniProtKB for ECOLI (\emph{Escherichia coli}), THETH (\emph{Thermus thermophilus}) and THEMA (\emph{Thermotoga maritima}), and reconstructed ancestral sequences taken from Gaucher et al., 2003 (maximum likelihood bacterial stem and mesophilic bacterial stem, and alternative bacterial stem). See the \sQuote{formation} vignette for an example that uses this file. } Modified: pkg/CHNOSZ/man/iprotein.Rd =================================================================== --- pkg/CHNOSZ/man/iprotein.Rd 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/man/iprotein.Rd 2017-02-05 11:43:21 UTC (rev 134) @@ -87,33 +87,6 @@ stopifnot(as.chemical.formula(protein.formula(ip))=="C41H69N11O18") # we can also calculate a formula without using add.protein as.chemical.formula(protein.formula(seq2aa("pentapeptide_test", "ANLSG"))) - -# read a fasta file, calculate H/C and O/C for all proteins -# and averages by polypeptide chain, residue and mass -ffile <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ") -aa <- read.fasta(ffile) -pf <- as.data.frame(protein.formula(aa)) -plot(pf$H/pf$C, pf$O/pf$C, pch=NA) -points(pf$H/pf$C, pf$O/pf$C, pch=20, cex=0.5, col="grey") -# average composition per polypeptide chain -chainaa <- aasum(aa, average=TRUE) -chainpf <- as.data.frame(protein.formula(chainaa)) -points(chainpf$H/chainpf$C, chainpf$O/chainpf$C, pch=15, col="red") -# average by amino acid residue -pl <- protein.length(aa) -resaa <- aasum(aa, abundance=pl, average=TRUE) -respf <- as.data.frame(protein.formula(resaa)) -points(respf$H/respf$C, respf$O/respf$C, pch=16, col="red") -# average by mass -pm <- mass(pf) -massaa <- aasum(aa, abundance=pm, average=TRUE) -masspf <- as.data.frame(protein.formula(massaa)) -points(masspf$H/masspf$C, masspf$O/masspf$C, pch=17, col="red") -# add a legend and title -legend("topright", pch=c(20, 15, 16, 17), col=c("grey", rep("red", 3)), - legend=c("protein", "chain average", "residue average", "mass average")) -title(main=paste("O/C vs H/C for HTCC1062 proteins\n", - "n =", nrow(aa))) } \seealso{ Modified: pkg/CHNOSZ/tests/testthat/test-util.program.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-util.program.R 2017-02-05 09:51:24 UTC (rev 133) +++ pkg/CHNOSZ/tests/testthat/test-util.program.R 2017-02-05 11:43:21 UTC (rev 134) @@ -14,15 +14,16 @@ test_that("other functions are calling palply() properly", { if(min(getOption("mc.cores"), 2) > 1 & parallel::detectCores() > 1) { - ff <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ") - expect_message(aa <- read.fasta(ff), "read.fasta running 1354 calculations") - # ^^^ also messaged: count.aa running 1354 calculations - ip <- add.protein(aa) + # CHNOSZ no longer has a large FASTA file to test this with 20170205 + #ff <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ") + #expect_message(aa <- read.fasta(ff), "read.fasta running 1354 calculations") + ip <- 1:nrow(thermo$protein) basis("CHNOS") - expect_message(a <- affinity(O2=c(-90, -60, 1000), iprotein=ip), "affinity running 1354 calculations") + expect_message(a <- affinity(iprotein=rep(ip, 3)), "affinity running 1359 calculations") + expect_message(e <- equilibrate(a, normalize=TRUE), "equil.boltzmann running 1359 calculations") + # test reaction method + species(c("CO2", "acetic acid")) + a <- affinity(O2=c(-90, -60, 1000)) expect_message(e <- equilibrate(a), "equil.reaction running 1000 calculations") - expect_message(e <- equilibrate(a, normalize=TRUE), "equil.boltzmann running 1354 calculations") - # ^^^ above message repeated 2x } }) - From noreply at r-forge.r-project.org Mon Feb 6 14:30:11 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 6 Feb 2017 14:30:11 +0100 (CET) Subject: [CHNOSZ-commits] r135 - in pkg/CHNOSZ: . R inst vignettes Message-ID: <20170206133011.26FA61884D0@r-forge.r-project.org> Author: jedick Date: 2017-02-06 14:30:10 +0100 (Mon, 06 Feb 2017) New Revision: 135 Added: pkg/CHNOSZ/vignettes/eos-regress.Rmd Removed: pkg/CHNOSZ/vignettes/EOSregress.Rmd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/equilibrate.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: rename EOSregress.Rmd to eos-regress.Rmd Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-05 11:43:21 UTC (rev 134) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-06 13:30:10 UTC (rev 135) @@ -1,6 +1,6 @@ -Date: 2017-02-05 +Date: 2017-02-06 Package: CHNOSZ -Version: 1.0.8-24 +Version: 1.0.8-25 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/equilibrate.R =================================================================== --- pkg/CHNOSZ/R/equilibrate.R 2017-02-05 11:43:21 UTC (rev 134) +++ pkg/CHNOSZ/R/equilibrate.R 2017-02-06 13:30:10 UTC (rev 135) @@ -250,6 +250,8 @@ # no shared basis species - balance on one mole of species if(length(ibalance) == 0) balance <- 1 } + # change "1" to 1 (numeric) 20170206 + if(identical(balance, "1")) balance <- 1 if(is.numeric(balance[1])) { # a numeric vector n.balance <- rep(balance, length.out=length(aout$values)) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-05 11:43:21 UTC (rev 134) +++ pkg/CHNOSZ/inst/NEWS 2017-02-06 13:30:10 UTC (rev 135) @@ -1,10 +1,10 @@ -CHANGES IN CHNOSZ 1.0.8-24 (2017-02-05) +CHANGES IN CHNOSZ 1.0.8-25 (2017-02-06) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, glutamic acid, glutamine, H2O, oxygen). -- Add EOSregress.Rmd vignette; update related functions. +- Add eos-regress.Rmd vignette; update related functions. - More flexible parsing of chemical formulas for ZC() and other functions; e.g. ZC(colMeans(protein.formula(1:4))) now works. Deleted: pkg/CHNOSZ/vignettes/EOSregress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-02-05 11:43:21 UTC (rev 134) +++ pkg/CHNOSZ/vignettes/EOSregress.Rmd 2017-02-06 13:30:10 UTC (rev 135) @@ -1,307 +0,0 @@ ---- -title: "Regressing Thermodynamic Data" -subtitle: "EOSregress in [CHNOSZ](http://www.chnosz.net)" -author: "Jeffrey M. Dick" -date: "`r Sys.Date()`" -output: - tufte::tufte_html: - tufte_features: ["background"] - css: "vig.css" - tufte::tufte_handout: - citation_package: natbib - latex_engine: xelatex - tufte::tufte_book: - citation_package: natbib - latex_engine: xelatex -vignette: > - %\VignetteIndexEntry{Regressing thermodynamic data} - %\VignetteEngine{knitr::rmarkdown} - \usepackage[utf8]{inputenc} -bibliography: vig.bib -link-citations: yes -csl: elementa.csl ---- - -```{r setup, include=FALSE} -# invalidate cache when the tufte version changes -knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) -options(htmltools.dir.version = FALSE) -``` - - -This vignette demonstrates [`EOSregress`](http://www.chnosz.net/manual/EOSregress.html) and related functions for the regression of heat capacity and volumetric data to obtain "equations of state" coefficients. - -# A note on the equations - -The CHNOSZ thermodynamic database uses the revised Helgeson-Kirkham-Flowers equations of state (EOS) for aqueous species. -Different terms in these equations give the "non-solvation" and "solvation" contributions to the standard molal heat capacity ($C_P^\circ$) and volume ($V^\circ$) as a function of temperature ($T$) and pressure ($P$). - - at HKF81 published the original description of the equations; for $C_P^\circ$ the equation is -$$C_P^\circ = c_1 + \frac{c_2}{(T-\Theta)^2} + {\omega}TX$$ -Here, $c_1$ and $c_2$ are the non-solvation parameters, and $\omega$ is the solvation parameter. -$\Theta$ is equal to 228 K, and $X$ is one of the "Born functions" that relates the solvation process to the dielectric properties of water. -For neutral species, all of the parameters, including the "effective" value of $\omega$, are constant. -However, **for charged species, $\omega$ has derivatives, larger with higher temperature**, that depend on the charge and ionic radius. -Revisions by @TH88 and @SOJSH92 refined the equations to improve their high-$T$ and $P$ behavior. - -# A note on the algorithms - -The regression functions are essentially a wrapper around the [`water`](http://www.chnosz.net/manual/water.html)-related functions in CHNOSZ and [`lm` in R](http://stat.ethz.ch/R-manual/R-patched/library/stats/html/lm.html). -The former provide values of the Born functions. -Accordingly, numerical values for all of the *variables* in the equations (e.g. $\frac{1}{(T-\Theta)^2}$ and $TX$) can be calculated at each experimental $T$ and $P$. - -Applying a linear model (`lm`), the *coefficients* in the model can be obtained. -In this case, they correspond to the HKF parameters, e.g. $c_1$ (the intercept), $c_2$ and $\omega$. -The coefficients are constants, meaning that **the linear model is applicable only to neutral (uncharged) species**, for which the high-temperature derivatives of $\omega$ are 0. -Further below, a procedure is described to iteratively solve the equations for charged species. - -# An example for neutral species - -```{r options, echo=FALSE} -options(width = 90) -``` - -```{r chnosz, message=FALSE} -library(CHNOSZ) -data(thermo) -``` - -This is from the first example from `?EOSregress`. -`r tufte::margin_note("The ? indicates a documentation topic in R. To view it, type ?EOSregress or help(EOSregress) at the R prompt.")` -Here, we regress experimental heat capacities of aqueous methane ($\mathrm{CH_4}$) using the revised HKF equations. - - -First, read the data from @HW97. -We also convert J to cal and MPa to bar. - -```{r Cpdat} -file <- system.file("extdata/cpetc/Cp.CH4.HW97.csv", package="CHNOSZ") -Cpdat <- read.csv(file) -Cpdat$Cp <- convert(Cpdat$Cp, "cal") -Cpdat$P <- convert(Cpdat$P, "bar") -``` - -```{r EOSregress_hide, fig.margin = TRUE, fig.cap = "Heat Capacity of Aqueous Methane", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, dpi=50, out.width=672, out.height=336} -var <- c("invTTheta2", "TXBorn") -Cplm <- EOSregress(Cpdat, var, T.max=600) -EOSplot(Cpdat, coefficients=round(Cplm$coefficients, 1)) -EOSplot(Cpdat, add=TRUE, lty=3) -``` - -Next, we specify the terms in the HKF equations and perform the regression, using data below 600 K. -The terms in `Cplm` correspond to $c_1$, $c_2$ and $\omega$ in the HKF equations. -We use `EOSplot` to plot the data and fitted line and show the coefficients in the legend. - -```{r EOSregress, eval=FALSE} -var <- c("invTTheta2", "TXBorn") -Cplm <- EOSregress(Cpdat, var, T.max=600) -EOSplot(Cpdat, coefficients=round(Cplm$coefficients, 1)) -EOSplot(Cpdat, add=TRUE, lty=3) -``` - -`r tufte::margin_note("Be aware that the lines shown by EOSplot are calculated for a single pressure only, despite the temperature- and pressure-dependence of the data and regressions.")` - -Note the second call to `EOSplot`, where the coefficients are not provided. -This causes the data to be re-regressed, this time without the $T$ < 600 K limitation. -Although the overall fit, represented by the dotted line, is better, the fit to the low-temperature data is considerably worse. -For nonelectroyltes, consider excluding extreme near-critical values from the regression (or modify the procedure to give them lower weight) in order to obtain more generally useful results. - -`EOScoeffs` is a small function to retrieve the HKF parameters from the database in CHNOSZ. -The `stopifnot` expression tests that the regressed values are within 10% of the database values of $c_1$, $c_2$ and $\omega$ for $\mathrm{CH_4}$. - -```{r Cpcoeffs} -Cpcoeffs_database <- EOScoeffs("CH4", "Cp") -diff_coeffs <- Cplm$coefficients - Cpcoeffs_database -stopifnot(all(abs(diff_coeffs/Cpcoeffs_database) < 0.1)) -Cpcoeffs_database -``` - -Compare the database values [from @SH90] with the regressed values in the legend of figure above. -Some differences are expected as the values in the database are derived from earlier experimental data. - -## Setting the value of omega - -Given both high-temperature volumetric and calorimetric data for neutral species, the effective value of $\omega$ is most reliably regressed from the latter [@SSW01]. -Let's regress volumetric data using a value of omega taken from the heat capacity regression. -First, read the data from @HWM96. - -```{r Vdat} -file <- system.file("extdata/cpetc/V.CH4.HWM96.csv", package="CHNOSZ") -Vdat <- read.csv(file) -Vdat$P <- convert(Vdat$P, "bar") -``` - -Compressibilities of species (measured or estimated) are implied by the full set of HKF volumetric parameters ($a_1$, $a_2$, $a_3$, $a_4$). -In this example we model volumes at nearly constant $P$. -Therefore, we can use a simpler equation for $V^\circ$ written in terms of the "isobaric fit parameters" (Tanger and Helgeson 1988, p. 35) $\sigma$ and $\xi$, together with the solvation contribution that depends on the $Q$ Born function: -$$V^\circ = \sigma + \frac{\xi}{T-\Theta} - {\omega}Q$$ - -`r tufte::margin_note("EOSvar actually returns the negative of $Q$, so the omega symbol here carries no negative sign.")` - -Now we calculate the $Q$ Born function using `EOSvar` and multiply by $\omega$ (from the heat capacity regression) to get the solvation volume at each experimental temperature and pressure. -Subtract the solvation volume from the experimental volumes and create a new data frame holding the calculated "non-solvation" volume. - -`r tufte::margin_note("Because we are dealing with volumes, the units of $?$ are converted according to 1 cal = 41.84 cm$^3$?bar.")` - -```{r Vdat_non} -QBorn <- EOSvar("QBorn", T=Vdat$T, P=Vdat$P) -Vomega <- convert(Cplm$coefficients[["TXBorn"]], "cm3bar") -V_sol <- Vomega * QBorn -V_non <- Vdat$V - V_sol -Vdat_non <- data.frame(T=Vdat$T, P=Vdat$P, V=V_non) -``` - -Next, regress the non-solvation volume using the non-solvation terms in the HKF model. -As with $C_P^\circ$, also get the values of the parameters from the database for comparison with the regression results. - - -```{r Vdat_non_regress} -var <- "invTTheta" -Vnonlm <- EOSregress(Vdat_non, var, T.max=450) -Vcoeffs <- round(c(Vnonlm$coefficients, QBorn=Vomega), 1) -Vcoeffs_database <- EOScoeffs("CH4", "V") -``` - -```{r Vplot_hide, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of Aqueous Methane", dpi=50, out.width=672, out.height=672} -par(mfrow=c(2, 1)) -# plot 1 -EOSplot(Vdat, coefficients=Vcoeffs) -EOSplot(Vdat, coefficients=Vcoeffs_database, add=TRUE, lty=2) -# plot 2 -EOSplot(Vdat, coefficients=Vcoeffs_database, T.plot=600, lty=2) -EOSplot(Vdat, coefficients=Vcoeffs, add=TRUE) -``` - -Finally, plot the data and regressions. -The first plot shows all the data, and the second the low-temperature subset ($T$ < 600 K). -The solid line is the two-term fit for $\sigma$ and $\xi$ (using $\omega$ from the heat capacity regression), and the dashed line shows the volumes calculated using the parameters in the database. -The plot legends give the parameters from the two-term fit (first plot), or from the database (second plot). - -```{r Vplot, eval=FALSE} -par(mfrow=c(2, 1)) -# plot 1 -EOSplot(Vdat, coefficients=Vcoeffs) -EOSplot(Vdat, coefficients=Vcoeffs_database, add=TRUE, lty=2) -# plot 2 -EOSplot(Vdat, coefficients=Vcoeffs_database, T.plot=600, lty=2) -EOSplot(Vdat, coefficients=Vcoeffs, add=TRUE) -``` - -The equation for $V^\circ$ provides a reasonable approximation of the trend of lowest-temperature data ($T$ < 450 K). -However, the equation does not closely reproduce the trend of higher-temperature $V^\circ$ data ($T$ < 600 K), nor behavior in the critical region. -Because of these issues, some researchers are exploring alternatives to the HKF model for aqueous nonelectrolytes. -(See also an example in `?EOSregress`.) - - -# An example for charged species - -For this example, let's generate synthetic data for Na$^+$ using its parameters in the database. -In the call to `subcrt` below, `convert=FALSE` means to take $T$ in units of K. - -```{r Nadat} -T <- convert(seq(0, 600, 50), "K") -P <- 1000 -prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] -Nadat <- prop.PT[, c("T", "P", "Cp")] -``` - -As noted above, $\omega$ for electrolytes is not a constant. -What happens if we apply the linear model anyway, knowing it's not applicable (especially at high temperature)? - -```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Inapplicable: Constant $?$)", dpi=50, out.width=672, out.height=336} -var <- c("invTTheta2", "TXBorn") -Nalm <- EOSregress(Nadat, var, T.max=600) -EOSplot(Nadat, coefficients=Nalm$coefficients, fun.legend=NULL) -EOSplot(Nadat, add=TRUE, lty=3) -``` - -As before, the solid line is a fit to relatively low-temperature ($T$ < 600 K) data, and the dotted line a fit to the entire temperature range of the data. -The fits using constant $\omega$ are clearly not acceptable. - -There is, however, a way out. -A different variable, `Cp_s_var`, can be used to specify the calculation of the "solvation" heat capacity in the HKF equations **using the temperature- and pressure-dependent corrections for charged species**. -To use this variable, the values of $\omega_{P_r,T_r}$ (omega at the reference temperature and pressure) and $Z$ (charge) must be given, in addition to $T$ and $P$. -Of course, right now we **don't know** the value of $\omega_{P_r,T_r}$ -- it is the purpose of the regression to find it! -But we can make a first guess using the value of $\omega$ found above. - -```{r Navars1} -var1 <- c("invTTheta2", "Cp_s_var") -omega.guess <- coef(Nalm)[3] -``` - -Then, we can use an iterative procedure that refines successive guesses of $\omega_{P_r,T_r}$. -The convergence criterion is measured by the difference in sequential regressed values of $\omega$. - -```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Variable $?$)", dpi=50, out.width=672, out.height=336} -diff.omega <- 999 -while(abs(diff.omega) > 1) { - Nalm1 <- EOSregress(Nadat, var1, omega.PrTr=tail(omega.guess, 1), Z=1) - omega.guess <- c(omega.guess, coef(Nalm1)[3]) - diff.omega <- tail(diff(omega.guess), 1) -} -EOSplot(Nadat, coefficients=signif(coef(Nalm1), 6), - omega.PrTr=tail(omega.guess, 1), Z=1) -EOScoeffs("Na+", "Cp") -``` - -Alrighty! We managed to obtain EOS parameters from synthetic data for Na$^+$. -The regressed values of the EOS parameters (shown in the plot legend) are very close to the database values (printed by the call to `EOScoeffs`) used to generate the synthetic data. - -## Doing it for volume - -Just like above, but using synthetic $V^\circ$ data. -Note that the regressed value of $\omega$ has volumetric units (cm$^3$?bar/mol), while `omega.PrTr` is in caloric units (cal/mol). -Compared to $C_P^\circ$, the regression of $V^\circ$ is very finicky. -Given a starting guess of $\omega_{P_r,T_r}$ of 1400000 cm$^3$?bar/mol, the iteration converges on 1394890 instead of the "true" database value of 1383230 (represented by dashed line in the plot). - -```{r NaVolume_hide, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na$^+$ (Variable $?$)", results="hide", message=FALSE, echo=FALSE, dpi=50, out.width=672, out.height=336} -T <- convert(seq(0, 600, 25), "K") -P <- 1000 -prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] -NaVdat <- prop.PT[, c("T", "P", "V")] -var1 <- c("invTTheta", "V_s_var") -omega.guess <- 1400000 -diff.omega <- 999 -while(abs(diff.omega) > 1) { - NaVlm1 <- EOSregress(NaVdat, var1, - omega.PrTr=tail(convert(omega.guess, "calories"), 1), Z=1) - omega.guess <- c(omega.guess, coef(NaVlm1)[3]) - diff.omega <- tail(diff(omega.guess), 1) -} -EOSplot(NaVdat, coefficients=signif(coef(NaVlm1), 6), - omega.PrTr=tail(convert(omega.guess, "calories"), 1), Z=1, - fun.legend="bottomleft") -coefficients <- EOScoeffs("Na+", "V", P=1000) -names(coefficients)[3] <- "V_s_var" -EOSplot(NaVdat, coefficients=coefficients, Z=1, add=TRUE, lty=2, - omega.PrTr=convert(coefficients["V_s_var"], "calories")) -``` - -```{r NaVolume, eval=FALSE} -T <- convert(seq(0, 600, 25), "K") -P <- 1000 -prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] -NaVdat <- prop.PT[, c("T", "P", "V")] -var1 <- c("invTTheta", "V_s_var") -omega.guess <- 1400000 -diff.omega <- 999 -while(abs(diff.omega) > 1) { - NaVlm1 <- EOSregress(NaVdat, var1, - omega.PrTr=tail(convert(omega.guess, "calories"), 1), Z=1) - omega.guess <- c(omega.guess, coef(NaVlm1)[3]) - diff.omega <- tail(diff(omega.guess), 1) -} -EOSplot(NaVdat, coefficients=signif(coef(NaVlm1), 6), - omega.PrTr=tail(convert(omega.guess, "calories"), 1), Z=1, - fun.legend="bottomleft") -coefficients <- EOScoeffs("Na+", "V", P=1000) -names(coefficients)[3] <- "V_s_var" -EOSplot(NaVdat, coefficients=coefficients, Z=1, add=TRUE, lty=2, - omega.PrTr=convert(coefficients["V_s_var"], "calories")) -``` - -# Other possibilities - -These functions are limited to treatment of calorimetric and volumetric data. -Other software tools have been described recently for deriving HKF parameters and other thermodynamic properties from different types of experimental data [@MKDW15; @Shv15]. - Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-05 11:43:21 UTC (rev 134) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-06 13:30:10 UTC (rev 135) @@ -331,7 +331,7 @@ ``` The composition of any species made up of C, H, and O can be represented by a single linear combination of these basis species. -## Auto-balancing reactions +## Automatically balancing reactions Methanogenic metabolism in reducing environments may take advantage of acetoclastic or hydrogenotrophic processes. To consider reactions involving a charged species (acetate), let's define a basis with H+: @@ -610,7 +610,7 @@ Now we can calculate affinity along the transect of changing temperature and activities of five basis species. Each variable is given as a named argument; the name for `NH4+` must be quoted. ```{marginfigure} -A shorter code would use `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` +A shorter expression would use `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` ``` ```{marginfigure} The target of the conversion is `G`, or free energy, from `logK`. @@ -783,24 +783,28 @@ ``` This makes the species distribution diagram useful for this system. +## Groups of species + +[SMS98] + ## Choosing different balancing constraints -# Other things you can do with diagrams +amino acids: [Sho90b] -## Groups of species - # Proteins -## Group additivity - -## Compositional analysis (ZC and nH2O) - ## Sources of amino acid data -## Ionization +## Group additivity and Ionization ## Normalizing for different lengths +[Dic08] + +## Compositional analysis (ZC) + +[Dic14] + # Modifying the database mod.obigt, mod.buffer @@ -808,3 +812,5 @@ # Functions outside of the main workflow transfer, wjd, eqdata, RH2obigt, EOSregress, nonideal + +Gibbs energy minimization with amino acids: [Cob13]? Copied: pkg/CHNOSZ/vignettes/eos-regress.Rmd (from rev 134, pkg/CHNOSZ/vignettes/EOSregress.Rmd) =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd (rev 0) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-06 13:30:10 UTC (rev 135) @@ -0,0 +1,307 @@ +--- +title: "Regressing Thermodynamic Data" +subtitle: "EOSregress in [CHNOSZ](http://www.chnosz.net)" +author: "Jeffrey M. Dick" +date: "`r Sys.Date()`" +output: + tufte::tufte_html: + tufte_features: ["background"] + css: "vig.css" + tufte::tufte_handout: + citation_package: natbib + latex_engine: xelatex + tufte::tufte_book: + citation_package: natbib + latex_engine: xelatex +vignette: > + %\VignetteIndexEntry{Regressing thermodynamic data} + %\VignetteEngine{knitr::rmarkdown} + \usepackage[utf8]{inputenc} +bibliography: vig.bib +link-citations: yes +csl: elementa.csl +--- + +```{r setup, include=FALSE} +# invalidate cache when the tufte version changes +knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) +options(htmltools.dir.version = FALSE) +``` + + +This vignette demonstrates [`EOSregress`](http://www.chnosz.net/manual/EOSregress.html) and related functions for the regression of heat capacity and volumetric data to obtain "equations of state" coefficients. + +# A note on the equations + +The CHNOSZ thermodynamic database uses the revised Helgeson-Kirkham-Flowers equations of state (EOS) for aqueous species. +Different terms in these equations give the "non-solvation" and "solvation" contributions to the standard molal heat capacity ($C_P^\circ$) and volume ($V^\circ$) as a function of temperature ($T$) and pressure ($P$). + + at HKF81 published the original description of the equations; for $C_P^\circ$ the equation is +$$C_P^\circ = c_1 + \frac{c_2}{(T-\Theta)^2} + {\omega}TX$$ +Here, $c_1$ and $c_2$ are the non-solvation parameters, and $\omega$ is the solvation parameter. +$\Theta$ is equal to 228 K, and $X$ is one of the "Born functions" that relates the solvation process to the dielectric properties of water. +For neutral species, all of the parameters, including the "effective" value of $\omega$, are constant. +However, **for charged species, $\omega$ has derivatives, larger with higher temperature**, that depend on the charge and ionic radius. +Revisions by @TH88 and @SOJSH92 refined the equations to improve their high-$T$ and $P$ behavior. + +# A note on the algorithms + +The regression functions are essentially a wrapper around the [`water`](http://www.chnosz.net/manual/water.html)-related functions in CHNOSZ and [`lm` in R](http://stat.ethz.ch/R-manual/R-patched/library/stats/html/lm.html). +The former provide values of the Born functions. +Accordingly, numerical values for all of the *variables* in the equations (e.g. $\frac{1}{(T-\Theta)^2}$ and $TX$) can be calculated at each experimental $T$ and $P$. + +Applying a linear model (`lm`), the *coefficients* in the model can be obtained. +In this case, they correspond to the HKF parameters, e.g. $c_1$ (the intercept), $c_2$ and $\omega$. +The coefficients are constants, meaning that **the linear model is applicable only to neutral (uncharged) species**, for which the high-temperature derivatives of $\omega$ are 0. +Further below, a procedure is described to iteratively solve the equations for charged species. + +# An example for neutral species + +```{r options, echo=FALSE} +options(width = 90) +``` + +```{r chnosz, message=FALSE} +library(CHNOSZ) +data(thermo) +``` + +This is from the first example from `?EOSregress`. +`r tufte::margin_note("The ? indicates a documentation topic in R. To view it, type ?EOSregress or help(EOSregress) at the R prompt.")` +Here, we regress experimental heat capacities of aqueous methane ($\mathrm{CH_4}$) using the revised HKF equations. + + +First, read the data from @HW97. +We also convert J to cal and MPa to bar. + +```{r Cpdat} +file <- system.file("extdata/cpetc/Cp.CH4.HW97.csv", package="CHNOSZ") +Cpdat <- read.csv(file) +Cpdat$Cp <- convert(Cpdat$Cp, "cal") +Cpdat$P <- convert(Cpdat$P, "bar") +``` + +```{r EOSregress_hide, fig.margin = TRUE, fig.cap = "Heat Capacity of Aqueous Methane", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, dpi=50, out.width=672, out.height=336} +var <- c("invTTheta2", "TXBorn") +Cplm <- EOSregress(Cpdat, var, T.max=600) +EOSplot(Cpdat, coefficients=round(Cplm$coefficients, 1)) +EOSplot(Cpdat, add=TRUE, lty=3) +``` + +Next, we specify the terms in the HKF equations and perform the regression, using data below 600 K. +The terms in `Cplm` correspond to $c_1$, $c_2$ and $\omega$ in the HKF equations. +We use `EOSplot` to plot the data and fitted line and show the coefficients in the legend. + +```{r EOSregress, eval=FALSE} +var <- c("invTTheta2", "TXBorn") +Cplm <- EOSregress(Cpdat, var, T.max=600) +EOSplot(Cpdat, coefficients=round(Cplm$coefficients, 1)) +EOSplot(Cpdat, add=TRUE, lty=3) +``` + +`r tufte::margin_note("Be aware that the lines shown by EOSplot are calculated for a single pressure only, despite the temperature- and pressure-dependence of the data and regressions.")` + +Note the second call to `EOSplot`, where the coefficients are not provided. +This causes the data to be re-regressed, this time without the $T$ < 600 K limitation. +Although the overall fit, represented by the dotted line, is better, the fit to the low-temperature data is considerably worse. +For nonelectroyltes, consider excluding extreme near-critical values from the regression (or modify the procedure to give them lower weight) in order to obtain more generally useful results. + +`EOScoeffs` is a small function to retrieve the HKF parameters from the database in CHNOSZ. +The `stopifnot` expression tests that the regressed values are within 10% of the database values of $c_1$, $c_2$ and $\omega$ for $\mathrm{CH_4}$. + +```{r Cpcoeffs} +Cpcoeffs_database <- EOScoeffs("CH4", "Cp") +diff_coeffs <- Cplm$coefficients - Cpcoeffs_database +stopifnot(all(abs(diff_coeffs/Cpcoeffs_database) < 0.1)) +Cpcoeffs_database +``` + +Compare the database values [from @SH90] with the regressed values in the legend of figure above. +Some differences are expected as the values in the database are derived from earlier experimental data. + +## Setting the value of omega + +Given both high-temperature volumetric and calorimetric data for neutral species, the effective value of $\omega$ is most reliably regressed from the latter [@SSW01]. +Let's regress volumetric data using a value of omega taken from the heat capacity regression. +First, read the data from @HWM96. + +```{r Vdat} +file <- system.file("extdata/cpetc/V.CH4.HWM96.csv", package="CHNOSZ") +Vdat <- read.csv(file) +Vdat$P <- convert(Vdat$P, "bar") +``` + +Compressibilities of species (measured or estimated) are implied by the full set of HKF volumetric parameters ($a_1$, $a_2$, $a_3$, $a_4$). +In this example we model volumes at nearly constant $P$. +Therefore, we can use a simpler equation for $V^\circ$ written in terms of the "isobaric fit parameters" (Tanger and Helgeson 1988, p. 35) $\sigma$ and $\xi$, together with the solvation contribution that depends on the $Q$ Born function: +$$V^\circ = \sigma + \frac{\xi}{T-\Theta} - {\omega}Q$$ + +`r tufte::margin_note("EOSvar actually returns the negative of $Q$, so the omega symbol here carries no negative sign.")` + +Now we calculate the $Q$ Born function using `EOSvar` and multiply by $\omega$ (from the heat capacity regression) to get the solvation volume at each experimental temperature and pressure. +Subtract the solvation volume from the experimental volumes and create a new data frame holding the calculated "non-solvation" volume. + +`r tufte::margin_note("Because we are dealing with volumes, the units of $?$ are converted according to 1 cal = 41.84 cm$^3$?bar.")` + +```{r Vdat_non} +QBorn <- EOSvar("QBorn", T=Vdat$T, P=Vdat$P) +Vomega <- convert(Cplm$coefficients[["TXBorn"]], "cm3bar") +V_sol <- Vomega * QBorn +V_non <- Vdat$V - V_sol +Vdat_non <- data.frame(T=Vdat$T, P=Vdat$P, V=V_non) +``` + +Next, regress the non-solvation volume using the non-solvation terms in the HKF model. +As with $C_P^\circ$, also get the values of the parameters from the database for comparison with the regression results. + + +```{r Vdat_non_regress} +var <- "invTTheta" +Vnonlm <- EOSregress(Vdat_non, var, T.max=450) +Vcoeffs <- round(c(Vnonlm$coefficients, QBorn=Vomega), 1) +Vcoeffs_database <- EOScoeffs("CH4", "V") +``` + +```{r Vplot_hide, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of Aqueous Methane", dpi=50, out.width=672, out.height=672} +par(mfrow=c(2, 1)) +# plot 1 +EOSplot(Vdat, coefficients=Vcoeffs) +EOSplot(Vdat, coefficients=Vcoeffs_database, add=TRUE, lty=2) +# plot 2 +EOSplot(Vdat, coefficients=Vcoeffs_database, T.plot=600, lty=2) +EOSplot(Vdat, coefficients=Vcoeffs, add=TRUE) +``` + +Finally, plot the data and regressions. +The first plot shows all the data, and the second the low-temperature subset ($T$ < 600 K). +The solid line is the two-term fit for $\sigma$ and $\xi$ (using $\omega$ from the heat capacity regression), and the dashed line shows the volumes calculated using the parameters in the database. +The plot legends give the parameters from the two-term fit (first plot), or from the database (second plot). + +```{r Vplot, eval=FALSE} +par(mfrow=c(2, 1)) +# plot 1 +EOSplot(Vdat, coefficients=Vcoeffs) +EOSplot(Vdat, coefficients=Vcoeffs_database, add=TRUE, lty=2) +# plot 2 +EOSplot(Vdat, coefficients=Vcoeffs_database, T.plot=600, lty=2) +EOSplot(Vdat, coefficients=Vcoeffs, add=TRUE) +``` + +The equation for $V^\circ$ provides a reasonable approximation of the trend of lowest-temperature data ($T$ < 450 K). +However, the equation does not closely reproduce the trend of higher-temperature $V^\circ$ data ($T$ < 600 K), nor behavior in the critical region. +Because of these issues, some researchers are exploring alternatives to the HKF model for aqueous nonelectrolytes. +(See also an example in `?EOSregress`.) + + +# An example for charged species + +For this example, let's generate synthetic data for Na$^+$ using its parameters in the database. +In the call to `subcrt` below, `convert=FALSE` means to take $T$ in units of K. + +```{r Nadat} +T <- convert(seq(0, 600, 50), "K") +P <- 1000 +prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] +Nadat <- prop.PT[, c("T", "P", "Cp")] +``` + +As noted above, $\omega$ for electrolytes is not a constant. +What happens if we apply the linear model anyway, knowing it's not applicable (especially at high temperature)? + +```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Inapplicable: Constant $?$)", dpi=50, out.width=672, out.height=336} +var <- c("invTTheta2", "TXBorn") +Nalm <- EOSregress(Nadat, var, T.max=600) +EOSplot(Nadat, coefficients=Nalm$coefficients, fun.legend=NULL) +EOSplot(Nadat, add=TRUE, lty=3) +``` + +As before, the solid line is a fit to relatively low-temperature ($T$ < 600 K) data, and the dotted line a fit to the entire temperature range of the data. +The fits using constant $\omega$ are clearly not acceptable. + +There is, however, a way out. +A different variable, `Cp_s_var`, can be used to specify the calculation of the "solvation" heat capacity in the HKF equations **using the temperature- and pressure-dependent corrections for charged species**. +To use this variable, the values of $\omega_{P_r,T_r}$ (omega at the reference temperature and pressure) and $Z$ (charge) must be given, in addition to $T$ and $P$. +Of course, right now we **don't know** the value of $\omega_{P_r,T_r}$ -- it is the purpose of the regression to find it! +But we can make a first guess using the value of $\omega$ found above. + +```{r Navars1} +var1 <- c("invTTheta2", "Cp_s_var") +omega.guess <- coef(Nalm)[3] +``` + +Then, we can use an iterative procedure that refines successive guesses of $\omega_{P_r,T_r}$. +The convergence criterion is measured by the difference in sequential regressed values of $\omega$. + +```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Variable $?$)", dpi=50, out.width=672, out.height=336} +diff.omega <- 999 +while(abs(diff.omega) > 1) { + Nalm1 <- EOSregress(Nadat, var1, omega.PrTr=tail(omega.guess, 1), Z=1) + omega.guess <- c(omega.guess, coef(Nalm1)[3]) + diff.omega <- tail(diff(omega.guess), 1) +} +EOSplot(Nadat, coefficients=signif(coef(Nalm1), 6), + omega.PrTr=tail(omega.guess, 1), Z=1) +EOScoeffs("Na+", "Cp") +``` + +Alrighty! We managed to obtain EOS parameters from synthetic data for Na$^+$. +The regressed values of the EOS parameters (shown in the plot legend) are very close to the database values (printed by the call to `EOScoeffs`) used to generate the synthetic data. + +## Doing it for volume + +Just like above, but using synthetic $V^\circ$ data. +Note that the regressed value of $\omega$ has volumetric units (cm$^3$?bar/mol), while `omega.PrTr` is in caloric units (cal/mol). +Compared to $C_P^\circ$, the regression of $V^\circ$ is very finicky. +Given a starting guess of $\omega_{P_r,T_r}$ of 1400000 cm$^3$?bar/mol, the iteration converges on 1394890 instead of the "true" database value of 1383230 (represented by dashed line in the plot). + +```{r NaVolume_hide, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na$^+$ (Variable $?$)", results="hide", message=FALSE, echo=FALSE, dpi=50, out.width=672, out.height=336} +T <- convert(seq(0, 600, 25), "K") +P <- 1000 +prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] +NaVdat <- prop.PT[, c("T", "P", "V")] +var1 <- c("invTTheta", "V_s_var") +omega.guess <- 1400000 +diff.omega <- 999 +while(abs(diff.omega) > 1) { + NaVlm1 <- EOSregress(NaVdat, var1, + omega.PrTr=tail(convert(omega.guess, "calories"), 1), Z=1) + omega.guess <- c(omega.guess, coef(NaVlm1)[3]) + diff.omega <- tail(diff(omega.guess), 1) +} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 135 From noreply at r-forge.r-project.org Mon Feb 6 17:08:42 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 6 Feb 2017 17:08:42 +0100 (CET) Subject: [CHNOSZ-commits] r136 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170206160842.A547F188697@r-forge.r-project.org> Author: jedick Date: 2017-02-06 17:08:42 +0100 (Mon, 06 Feb 2017) New Revision: 136 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add choosing a different balance Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-06 16:08:42 UTC (rev 136) @@ -1,12 +1,12 @@ Date: 2017-02-06 Package: CHNOSZ -Version: 1.0.8-25 +Version: 1.0.8-26 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Depends: R (>= 3.1.0) Suggests: limSolve, testthat, knitr, rmarkdown, tufte -Imports: grDevices, graphics, stats, utils +Imports: grDevices, graphics, stats, utils, colorspace Description: Functions and data sets to support chemical thermodynamic modeling in biochemistry and low-temperature geochemistry. The features include calculation of the standard molal thermodynamic properties and chemical affinities of reactions involving minerals and/or Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/NAMESPACE 2017-02-06 16:08:42 UTC (rev 136) @@ -16,3 +16,7 @@ importFrom("utils", "browseURL", "capture.output", "combn", "demo", "example", "head", "installed.packages", "read.csv", "tail", "write.csv", "write.table") + +# Imports from colorspace +importFrom("colorspace", "diverge_hcl") + Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/R/util.plot.R 2017-02-06 16:08:42 UTC (rev 136) @@ -230,3 +230,14 @@ # add axis label mtext(axis.label(property),1,3) } + +# get colors for range of ZC values 20170206 +ZC.col <- function(z) { + # scale values to [1, 1000] + z <- z * 999/diff(range(z)) + z <- round(z - min(z)) + 1 + # diverging (blue - light grey - red) palette + dcol <- colorspace::diverge_hcl(1000, c = 100, l = c(50, 90), power = 1) + # reverse the palette so red is at lower ZC (more reduced) + rev(dcol)[z] +} Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/inst/NEWS 2017-02-06 16:08:42 UTC (rev 136) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-25 (2017-02-06) +CHANGES IN CHNOSZ 1.0.8-26 (2017-02-06) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -49,6 +49,9 @@ - Remove HTCC1062.faa.xz. +- Add ZC.col() for generating a red-grey-blue color scale from + numeric values. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-02-06 16:08:42 UTC (rev 136) @@ -8,10 +8,11 @@ \alias{water.lines} \alias{mtitle} \alias{residualsplot} +\alias{ZC.col} \title{Functions to Create and Modify Plots} \description{ - Initialize a new plot window using preset parameters, open a postcript file for plotting, add an axis or title to a plot, generate labels for plot axes and for identification of subplots and physical and chemical conditions, add stability lines for water to a diagram. + Initialize a new plot window using preset parameters, open a postcript file for plotting, add an axis or title to a plot, generate labels for plot axes and for identification of subplots and physical and chemical conditions, add stability lines for water to a diagram, get colors for set of values. } @@ -33,6 +34,7 @@ col = par("fg"), xpoints = NULL, O2state="gas") mtitle(main, line=0, ...) residualsplot(residuals, property = "Cp", model = "big") + ZC.col(z) } \arguments{ @@ -74,6 +76,7 @@ \item{residuals}{numeric, named vector of residuals to plot} \item{property}{character, name of property} \item{model}{character, name of model to use in plot title} + \item{z}{numeric, set of values} } \details{ @@ -103,6 +106,10 @@ \code{residualsplot} produces a \code{\link{barchart}} with options useful for plotting residuals of group contribution models for thermodynamic properties. It plots horizontal bars stacked with largest on top. The names of the \code{residuals} argument (i.e., the names of model species) are plotted across from each respective bar. The axis title is taken from the \code{property} (probably \samp{Cp} or \samp{V}), and the plot title includes the \code{model} name. See the \sQuote{xadditivity} vignette for examples of these plots. +\code{ZC.col} returns colors from a diverging palette (red - light grey - blue) corresponding to the values in \code{z}. +Red is associated with lower values of \code{z}. +This function is intended to generate colors for distinguishing average oxidation state of carbon \code{\link{ZC}}, but any numeric values can be supplied. + } \section{Side Effects}{ Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-06 16:08:42 UTC (rev 136) @@ -42,12 +42,12 @@ }) ``` -# About +# First steps This document introduces the basic functionality of CHNOSZ, a package for the [R software environment](http://r-project.org). For more information on R, see "An Introduction to R" and other documents in [The R Manuals](http://cran.r-project.org/manuals.html). -CHNOSZ has been developed since 2006 to support research projects in geochemistry and biochemistry. +CHNOSZ has been developed since 2006 to support research projects in geochemistry and compositional biology. The package provides functions and an extensive thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions among minerals and organic or inorganic aqueous species. These same functions enable calculations of chemical affinities and metastable equilibrium for systems of proteins. @@ -55,7 +55,8 @@ If you have just installed R for the first time, installing CHNOSZ should be as simple as selecting the "Install packages from CRAN" or similar menu item in the R GUI or using the following command to start the package installation process: ```{marginfigure} -Or, install the package from a local package file, which you can download from [CRAN](https://cran.r-project.org/package=CHNOSZ) or from the [CHNOSZ website](http://chnosz.net/download). +Or, install the package from a package file, which you can download from [CRAN](https://cran.r-project.org/package=CHNOSZ) or from the [CHNOSZ website](http://chnosz.net/download). +This vignette depends on some features that are only available in the development version of CHNOSZ, which can be found at [R-Forge](https://r-forge.r-project.org/projects/chnosz/). ``` ```{r install_CHNOSZ, eval=FALSE} install.packages("CHNOSZ") @@ -448,6 +449,11 @@ By *formation reaction* is meant the stoichiometric requirements for formation of one mole of any species from the basis species. The `species()` function is used to set these *species of interest*. Let's consider the stoichiometry of some aqueous sulfur-bearing species. +Here we use `basis()` with a keyword to identify a preset basis definition. +```{marginfigure} +Possible keywords are `CHNOS` (including CO2, H2O, NH3, H2S, and O2), `CHNOS+` (also including H+), `CHNOSe` (including H+, and *e*- instead of O2). +See ?basis for more options. +``` ```{r basis_CHNOSZ, results="hide"} basis("CHNOS+") ``` @@ -455,7 +461,6 @@ species(c("H2S", "HS-", "HSO4-", "SO4-2")) ``` -There we used `basis()` with a keyword to identify a preset basis definition. Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: ```{marginfigure} The values returned by `affinity()` are dimensionless, i.e. log10(**_A_**/*RT*). @@ -710,7 +715,7 @@ ``` Instead, it assumes that the total activity of species in the system is set by the activity of *one* basis species. ```{marginfigure} -Because activity coefficients are assumed to be zero, activities are additive and we can refer to "total activity". +Because activity coefficients are assumed to be zero, activities are equal to concentration and we can refer to "total activity". ``` This balanced basis species must be present (with a positive or negative coefficient) in the formation reactions of all species considered. @@ -787,10 +792,45 @@ [SMS98] -## Choosing different balancing constraints +## Choosing a different balance -amino acids: [Sho90b] +How about the choice between balancing constraints? +Let's look at some amino acids in a hypothetical metastable equilibrium. +This calculation is similar to one presented by @Sho90b for five amino acids, but here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. +We use `ZC.col()` to generate colors based on the average oxidation state of carbon of the amino acids (red and blue for relatively reduced and oxidized). +```{r aminoacids_setup, results="hide", message=FALSE} +basis("CHNOS") +basis("CO2", "gas") +swap.basis("NH3", "N2") +species(aminoacids("")) +a <- affinity(O2=c(-50, -25), CO2=c(-10, 15), T=250, P=265) +aa.ZC <- ZC(info(aminoacids(""))) +col <- ZC.col(aa.ZC) +``` +To make plots using different balance constraints, let's write a simple function that sets the `balance` argument of `diagram()` and adds a title to the plot. +The first plot is the most similar to Figure 4 of Shock (1990), except for the absence of alanine (probably due to different thermodynamic data) and the presence of some other amino acids. +There, we set `balance=1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone. +The remaining plots balance on each of the basis species (except for O2), then on volume (in the last plot). +```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=50, out.width="100%", message=FALSE, results="hide", cache=TRUE} +aafun <- function(balance) { + diagram(a, balance=balance, fill=col) + title(main=paste("balanced on", balance)) +} +par(mfrow=c(1, 5)) +lapply(c("1", "CO2", "H2O", "N2", "volume"), aafun) +``` + +There are some broad similarities---increasing log*f*O2 favors more oxidized amino acids---but also substantial differences. +It is interesting that there is more "going on" in the middle part of the digram showing volume conservation. + +Caveat: these plots demonstrate some possibilities in CHNOSZ and are not necessarily realistic portrayals of this system. +It does seem odd to balance on a fugacious component like O2 or H2O. +Unlike different choices of basis species, which are thermodynamically equivalent (see the example above for a mineral system), the choice of balance reflects extra-thermodynamic factors. +For instance, the widespread rule of thumb for balancing mineral reactions on a component is unrealistic for processes where volume is conserved [@MC11]. +Any choice of balancing constraints may oversimplify the physical or biological context for reactions of organic species or biomolecules. +While choosing an inappropriate balance leads to infeasible models, a well-considered overview of the possibilities might offer insight into the conditions affecting the dynamics of some systems. + # Proteins ## Sources of amino acid data @@ -799,15 +839,11 @@ ## Normalizing for different lengths -[Dic08] - ## Compositional analysis (ZC) -[Dic14] - # Modifying the database -mod.obigt, mod.buffer +mod.obigt, mod.buffer, OBIGT-2 # Functions outside of the main workflow Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-06 13:30:10 UTC (rev 135) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-06 16:08:42 UTC (rev 136) @@ -20,21 +20,6 @@ url = {http://www.worldcat.org/oclc/12106344}, } - at Article{DLE64, - author = {Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V.}, - journal = {Science}, - title = {Thermodynamic equilibria in prebiological atmospheres}, - year = {1964}, - volume = {146}, - number = {3650}, - pages = {1461--1464}, - doi = {10.1126/science.146.3650.1461}, - sn = {0036-8075}, - z8 = {0}, - z9 = {60}, - zb = {13}, -} - @TechReport{DLEN67, author = {Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. and Nagarajan, G.}, title = {Thermodynamic equilibrium in prebiological atmospheres of {C}, {H}, {O}, {N}, {P}, {S}, and {C}l}, @@ -165,6 +150,19 @@ doi = {10.2138/rmg.2013.75.5}, } + at Article{MC11, + author = {Merino, Enrique and Canals, ?ngels}, + journal = {American Journal of Science}, + title = {Self-accelerating dolomite-for-calcite replacement: Self-organized dynamics of burial dolomitization and associated mineralization}, + year = {2011}, + volume = {311}, + number = {7}, + pages = {573--607}, + doi = {10.2475/07.2011.01}, + sn = {0002-9599}, + z9 = {0}, +} + @InProceedings{NPW_79, author = {Nordstrom, D. K. and Plummer, L. N. and Wigley, T. M. L. and Wolery, T. J. and Ball, J. W. and Jenne, E. A. and Bassett, R. L. and Crerar, D. A. and Florence, T. M. and Fritz, B. and Hoffman, M. and Holdren, G. R., Jr. and Lafon, G. M. and Mattigod, S. V. and McDuff, R. E. and Morel, F. and Reddy, M. M. and Sposito, G. and Thrailkill, J.}, title = {A comparison of computerized chemical models for equilibrium calculations in aqueous systems}, @@ -257,6 +255,18 @@ sn = {1468-8115}, } + at Article{Sho90b, + author = {Shock, Everett L.}, + journal = {Geochimica et Cosmochimica Acta}, + title = {{D}o amino acids equilibrate in hydrothermal fluids?}, + year = {1990}, + volume = {54}, + number = {4}, + pages = {1185--1189}, + doi = {10.1016/0016-7037(90)90450-Y}, + issn = {0016-7037}, +} + @Article{SH90, author = {Shock, Everett L. and Helgeson, Harold C.}, journal = {Geochimica et Cosmochimica Acta}, From noreply at r-forge.r-project.org Thu Feb 9 13:58:00 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Feb 2017 13:58:00 +0100 (CET) Subject: [CHNOSZ-commits] r137 - in pkg/CHNOSZ: . R demo inst inst/extdata/cpetc man tests/testthat vignettes Message-ID: <20170209125800.F2C071883DA@r-forge.r-project.org> Author: jedick Date: 2017-02-09 13:58:00 +0100 (Thu, 09 Feb 2017) New Revision: 137 Added: pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5a.csv pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5b.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/equilibrate.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/copper.R pkg/CHNOSZ/demo/yeastgfp.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/read.expr.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/tests/testthat/test-diagram.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: ainintro.Rmd: add groups of species Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-09 12:58:00 UTC (rev 137) @@ -1,6 +1,6 @@ -Date: 2017-02-06 +Date: 2017-02-09 Package: CHNOSZ -Version: 1.0.8-26 +Version: 1.0.8-27 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/R/diagram.R 2017-02-09 12:58:00 UTC (rev 137) @@ -89,13 +89,15 @@ else message("diagram: using 'as.residue' in calculation of predominant species") } - ## sum activities of species together in groups 20090524 + ## sum affinities or activities of species together in groups 20090524 # using lapply/Reduce 20120927 if(!missing(groups)) { # loop over the groups plotvals <- lapply(groups, function(ispecies) { # remove the logarithms - act <- lapply(plotvals[ispecies], function(x) 10^x) + if(eout.is.aout) act <- lapply(plotvals[ispecies], function(x) 10^x) + # and, for activity, multiply by n.balance 20170207 + else act <- lapply(seq_along(ispecies), function(i) eout$n.balance[ispecies[i]] * 10^plotvals[[ispecies[i]]]) # sum the activities return(Reduce("+", act)) }) @@ -123,11 +125,11 @@ plotvar <- what } - ## alpha: plot fractional degree of formation instead of logarithms of activities + ## alpha: plot fractional degree of formation ## scale the activities to sum=1 ... 20091017 if(alpha) { # remove the logarithms - act <- lapply(eout$loga.equil, function(x) 10^x) + act <- lapply(plotvals, function(x) 10^x) # sum the activities sumact <- Reduce("+", act) # divide activities by the total @@ -252,7 +254,8 @@ adj <- 0.5 if(xvalues[imax] > xlim[1] + 0.8*diff(xlim)) adj <- 1 if(xvalues[imax] < xlim[1] + 0.2*diff(xlim)) adj <- 0 - text(xvalues[imax], plotvals[[i]][imax], labels=names[i], adj=adj) + # also include y-adjustment (labels bottom-aligned with the line) + text(xvalues[imax], plotvals[[i]][imax], labels=names[i], adj=c(adj, 0)) } } else legend(x=legend.x, lty=lty, legend=names, col=col, cex=cex.names, lwd=lwd, ...) } @@ -462,6 +465,8 @@ pn <- plot.names(zs, xs, ys, names) if(!is.null(dotted)) plot.line(zs, xlim, ylim, dotted, col, lwd, xrange=xrange) else contour.lines(predominant, xlim, ylim, lty=lty, col=col, lwd=lwd) + # re-draw the tick marks and axis lines in case the fill obscured them + if(tplot & !identical(fill, "transparent")) thermo.axis() } # done with the 2D plot! out2D <- list(lx=pn$lx, ly=pn$ly, is=pn$is) } # end if(nd==2) Modified: pkg/CHNOSZ/R/equilibrate.R =================================================================== --- pkg/CHNOSZ/R/equilibrate.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/R/equilibrate.R 2017-02-09 12:58:00 UTC (rev 137) @@ -269,7 +269,7 @@ # is the balance the name of a basis species? if(length(ibalance)==0) { ibalance <- match(balance, rownames(aout$basis)) - if(is.na(ibalance)) stop("basis species (", balance, ") not available to balance transformations") + if(is.na(ibalance)) stop("basis species (", balance, ") not available to balance reactions") } # the name of the basis species (need this if we got ibalance which which.balance, above) balance <- colnames(aout$species)[ibalance[1]] Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/R/util.plot.R 2017-02-09 12:58:00 UTC (rev 137) @@ -2,7 +2,7 @@ # Functions to create and modify plots thermo.plot.new <- function(xlim,ylim,xlab,ylab,cex=par('cex'),mar=NULL,lwd=par('lwd'),side=c(1,2,3,4), - mgp=c(1.5,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE,ticks=NULL, + mgp=c(1.5,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE, las=1,xline=NULL, ...) { # start a new plot with some customized settings thermo <- get("thermo") @@ -11,9 +11,6 @@ thermo$opar <- par(no.readonly=TRUE) assign("thermo", thermo, "CHNOSZ") } - # 20091108 changed argument name from 'ticks' to 'side' but - # keep 'ticks' for backward compatibility - if(!is.null(ticks)) side <- ticks # 20090324 mar handling: NULL - a default setting; NA - par's setting # 20090413 changed mar of top side from 2 to 2.5 if(is.null(mar)) mar <- c(3,3.5,2.5,1) else if(is.na(mar[1])) mar <- par('mar') @@ -33,7 +30,7 @@ if(4 %in% side) thermo.axis(NULL,side=4,lwd=lwd) } -thermo.axis <- function(lab='x-axis',side=1,line=1.5,cex=par('cex'),lwd=par('lwd'),T=NULL,col=par('col')) { +thermo.axis <- function(lab=NULL,side=1:4,line=1.5,cex=par('cex'),lwd=par('lwd'),T=NULL,col=par('col')) { # if T isn't NULL, looks like we want make a second # oxidation scale corresponding to one already plotted. # e.g., Eh-pe, Eh-logfO2, or logfO2-Eh @@ -52,53 +49,56 @@ } if(!is.null(lwd)) { ## plot major tick marks and numeric labels - do.label <- TRUE - if(missing(cex) & side %in% c(3,4) & is.null(T)) do.label <- FALSE - at <- axis(side,labels=do.label,tick=TRUE,lwd=lwd,col=col,col.axis=col) - ## plot minor tick marks - # the distance between major tick marks - da <- abs(diff(at[1:2])) - # distance between minor tick marks - di <- da / 4 - if(da %% 2 | !(da %% 10)) di <- da / 5 - # number of minor tick marks - if(side %in% c(1,3)) { - ii <- c(1,2) - myasp <- par('xaxp') - } else { - ii <- c(3,4) - myasp <- par('yaxp') + for(thisside in side) { + do.label <- TRUE + if(missing(side) | (missing(cex) & thisside %in% c(3,4) & is.null(T))) do.label <- FALSE + at <- axis(thisside,labels=do.label,tick=TRUE,lwd=lwd,col=col,col.axis=col) + ## plot minor tick marks + # the distance between major tick marks + da <- abs(diff(at[1:2])) + # distance between minor tick marks + di <- da / 4 + if(da %% 2 | !(da %% 10)) di <- da / 5 + # number of minor tick marks + if(thisside %in% c(1,3)) { + ii <- c(1,2) + myasp <- par('xaxp') + } else { + ii <- c(3,4) + myasp <- par('yaxp') + } + myusr <- par('usr')[ii] + daxis <- abs(diff(myusr)) + nt <- daxis / di + 1 + ## if nt isn't an integer, it probably + ## means the axis limits don't correspond + ## to major tick marks (expect problems) + ##at <- seq(myusr[1],myusr[2],length.out=nt) + # start from (bottom/left) of axis? + bl <- 1 + #if(myasp[2]==myusr[2]) bl <- 2 + # is forward direction (top/right)? + tr <- 1 + if(xor(myusr[2] < myusr[1] , bl==2)) tr <- -1 + #at <- myusr[bl] + tr * di * seq(0:(nt-1)) + # well all of that doesn't work in a lot of cases, + # where none of the axis limits correspond to + # major tick marks. perhaps the following will work + at <- myusr[1] + tr * di * (0:(nt-1)) + # apply an offset + axt <- axTicks(thisside)[1] + daxt <- (axt - myusr[1])/di + daxt <- (daxt-round(daxt))*di + at <- at + daxt + tcl <- par('tcl') * 0.5 + axis(thisside,labels=FALSE,tick=TRUE,lwd=lwd,col=col,col.axis=col,at=at,tcl=tcl) } - myusr <- par('usr')[ii] - daxis <- abs(diff(myusr)) - nt <- daxis / di + 1 - ## if nt isn't an integer, it probably - ## means the axis limits don't correspond - ## to major tick marks (expect problems) - ##at <- seq(myusr[1],myusr[2],length.out=nt) - # start from (bottom/left) of axis? - bl <- 1 - #if(myasp[2]==myusr[2]) bl <- 2 - # is forward direction (top/right)? - tr <- 1 - if(xor(myusr[2] < myusr[1] , bl==2)) tr <- -1 - #at <- myusr[bl] + tr * di * seq(0:(nt-1)) - # well all of that doesn't work in a lot of cases, - # where none of the axis limits correspond to - # major tick marks. perhaps the following will work - at <- myusr[1] + tr * di * (0:(nt-1)) - # apply an offset - axt <- axTicks(side)[1] - daxt <- (axt - myusr[1])/di - daxt <- (daxt-round(daxt))*di - at <- at + daxt - tcl <- par('tcl') * 0.5 - axis(side,labels=FALSE,tick=TRUE,lwd=lwd,col=col,col.axis=col,at=at,tcl=tcl) } - # rotate labels on side axes - if(side %in% c(2,4)) las <- 0 else las <- 1 - if(!is.null(lab)) mtext(lab,side=side,line=line,cex=cex,las=las) + for(thisside in side) { + if(thisside %in% c(2,4)) las <- 0 else las <- 1 + if(!is.null(lab)) mtext(lab,side=thisside,line=line,cex=cex,las=las) + } # reset limits if we were plotting a second axis if(!is.null(T)) par(opar) } Modified: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-09 12:58:00 UTC (rev 137) @@ -29,4 +29,5 @@ } # add legend legend("topright", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4)), - "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 3, 1, 1), bg="white") + "minerals", "formaldehyde", "HCN"), lty=c(NA, NA, NA, 1, 3, 2), col=c(NA, NA, NA, 3, 1, 1), + bg="white", cex=0.9) Modified: pkg/CHNOSZ/demo/copper.R =================================================================== --- pkg/CHNOSZ/demo/copper.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/demo/copper.R 2017-02-09 12:58:00 UTC (rev 137) @@ -38,7 +38,7 @@ # mosaic diagram with to speciate glycine as a function of pH m <- mosaic(bases=Gly, pH=c(0, 16, 300), Eh=c(-0.6, 1.0, 300)) fill <- c(rep("lightgrey", 3), rep("white", 4), rep("lightblue", 4)) -d <- diagram(m$A.species, fill=fill, names=NULL, tplot=FALSE, xaxs="i", yaxs="i") +d <- diagram(m$A.species, fill=fill, names=NULL, xaxs="i", yaxs="i") # to make the labels look nicer names <- names[sort(unique(as.numeric(d$predominant)))] for(i in 1:length(names)) { @@ -57,10 +57,8 @@ d <- diagram(m$A.bases, add=TRUE, col="darkblue", lty=3, names=NULL) text(d$lx, -0.5, Gly, col="darkblue") -# add water lines and title and re-draw a box around the plot -# because the filling of fields masks it +# add water lines and title water.lines() -box() mtitle(expression("Copper-water-glycine at 25"~degree*"C and 1 bar", "After Aksu and Doyle, 2001 (Fig. 2b)"), line=0.5) Modified: pkg/CHNOSZ/demo/yeastgfp.R =================================================================== --- pkg/CHNOSZ/demo/yeastgfp.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/demo/yeastgfp.R 2017-02-09 12:58:00 UTC (rev 137) @@ -1,8 +1,8 @@ ## Oxygen fugacity - activity of H2O predominance ## diagrams for proteologs for 23 YeastGFP localizations -# use old properties of [Met] to reproduce this example +# use old properties of [Met] (Dick et al., 2006) to reproduce this example data(thermo) -add.obigt() +mod.obigt("[Met]", G=-35245, H=-59310) # arranged by decreasing metastability: # order of this list of locations is based on the # (dis)appearance of species on the current set of diagrams Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/inst/NEWS 2017-02-09 12:58:00 UTC (rev 137) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-26 (2017-02-06) +CHANGES IN CHNOSZ 1.0.8-27 (2017-02-09) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -52,6 +52,12 @@ - Add ZC.col() for generating a red-grey-blue color scale from numeric values. +- For the `groups` argument in diagram(), activities are now multiplied + by the balance coefficients before the summation. + +- With new default arguments, thermo.axis() only plots the axis tick + marks and lines (useful for redrawing the axis on filled diagrams). + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Added: pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5a.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5a.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5a.csv 2017-02-09 12:58:00 UTC (rev 137) @@ -0,0 +1,81 @@ +T,logfO2 +7.37714269416,-79.8759305211 +10.0691176331,-79.1315136476 +13.4332544232,-78.2630272953 +17.4695530647,-77.270471464 +20.8353536218,-76.2779156328 +24.8699884962,-75.4094292804 +28.2324615194,-74.6650124069 +32.9375944782,-73.7965260546 +36.9705655857,-73.0521091811 +41.0035366932,-72.3076923077 +43.6921840982,-71.8114143921 +47.7234914387,-71.1910669975 +51.7547987793,-70.570719603 +55.7827785859,-70.1985111663 +59.1402603082,-69.8263027295 +62.4977420306,-69.4540942928 +67.1995474554,-68.8337468983 +71.8980253463,-68.4615384615 +76.5998307711,-67.841191067 +80.6311381117,-67.2208436725 +86.0067691547,-66.3523573201 +91.3807364308,-65.6079404467 +94.741545687,-64.9875930521 +98.1006911763,-64.4913151365 +101.461500433,-63.8709677419 +104.822309689,-63.2506203474 +108.855280796,-62.5062034739 +112.216090053,-61.8858560794 +116.24906116,-61.141439206 +119.608206649,-60.6451612903 +122.969015906,-60.0248138958 +125.657663311,-59.5285359801 +129.018472567,-58.9081885856 +132.377618056,-58.41191067 +135.066265461,-57.9156327543 +139.097572802,-57.2952853598 +143.80270576,-56.4267990074 +148.506174952,-55.682382134 +151.866984208,-55.0620347395 +156.5704534,-54.317617866 +160.600096974,-53.8213399504 +164.631404314,-53.2009925558 +168.664375422,-52.4565756824 +172.694018995,-51.9602977667 +178.740148123,-51.0918114144 +182.771455463,-50.4714640199 +188.145422739,-49.7270471464 +192.175066313,-49.2307692308 +196.878535505,-48.4863523573 +202.923000865,-47.7419354839 +207.623142523,-47.2456575682 +212.324947948,-46.6253101737 +217.026753373,-46.0049627792 +221.726895031,-45.5086848635 +225.756538604,-45.0124069479 +231.128842113,-44.3920595533 +236.501145622,-43.7717121588 +241.873449132,-43.1513647643 +245.903092705,-42.6550868486 +250.601570596,-42.2828784119 +255.303376021,-41.6625310174 +260.674015763,-41.1662531017 +264.70199557,-40.794044665 +270.072635312,-40.2977667494 +273.430117034,-39.9255583127 +278.128594925,-39.5533498759 +282.828736583,-39.0570719603 +288.199376325,-38.5607940447 +293.570016067,-38.064516129 +298.270157725,-37.5682382134 +305.653955487,-36.9478908189 +311.696757081,-36.3275434243 +317.737894907,-35.8312655087 +323.108534649,-35.3349875931 +329.149672476,-34.8387096774 +335.862972153,-34.2183622829 +340.561450044,-33.8461538462 +345.259927935,-33.4739454094 +348.617409657,-33.1017369727 +350.630567677,-32.9776674938 Added: pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5b.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5b.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/cpetc/SS98_Fig5b.csv 2017-02-09 12:58:00 UTC (rev 137) @@ -0,0 +1,84 @@ +T,pH +5.38461538462,7.00497512438 +8.07692307692,6.99502487562 +10.7692307692,6.97512437811 +14.1346153846,6.9552238806 +18.8461538462,6.93532338308 +22.8846153846,6.91542288557 +27.5961538462,6.8855721393 +32.3076923077,6.84577114428 +37.0192307692,6.81592039801 +42.4038461538,6.77611940299 +45.7692307692,6.75621890547 +49.1346153846,6.74626865672 +53.8461538462,6.74626865672 +57.8846153846,6.74626865672 +62.5961538462,6.75621890547 +66.6346153846,6.74626865672 +70,6.7263681592 +72.6923076923,6.69651741294 +76.0576923077,6.66666666667 +78.75,6.62686567164 +81.4423076923,6.57711442786 +84.1346153846,6.53731343284 +87.5,6.4776119403 +90.1923076923,6.42786069652 +92.8846153846,6.37810945274 +95.5769230769,6.32835820896 +98.9423076923,6.26865671642 +102.307692308,6.20895522388 +105.673076923,6.14925373134 +109.711538462,6.08955223881 +113.75,6.02985074627 +117.788461538,5.96019900498 +120.480769231,5.93034825871 +123.846153846,5.87064676617 +127.884615385,5.82089552239 +133.269230769,5.74129353234 +137.307692308,5.69154228856 +142.692307692,5.62189054726 +147.403846154,5.56218905473 +152.115384615,5.50248756219 +156.826923077,5.44278606965 +161.538461538,5.38308457711 +167.596153846,5.30348258706 +172.980769231,5.24378109453 +178.365384615,5.16417910448 +183.75,5.10447761194 +189.807692308,5.01492537313 +193.846153846,4.9552238806 +197.884615385,4.89552238806 +201.923076923,4.84577114428 +204.615384615,4.81592039801 +207.307692308,4.77611940299 +212.019230769,4.71641791045 +216.057692308,4.66666666667 +219.423076923,4.62686567164 +222.788461538,4.59701492537 +226.153846154,4.5671641791 +229.519230769,4.53731343284 +232.884615385,4.50746268657 +236.923076923,4.4776119403 +241.634615385,4.44776119403 +247.019230769,4.41791044776 +253.75,4.38805970149 +260.480769231,4.35820895522 +266.538461538,4.34825870647 +271.25,4.32835820896 +277.307692308,4.3184079602 +282.692307692,4.3184079602 +286.057692308,4.30845771144 +290.769230769,4.30845771144 +294.807692308,4.30845771144 +299.519230769,4.30845771144 +304.230769231,4.30845771144 +308.269230769,4.30845771144 +312.980769231,4.3184079602 +319.038461538,4.3184079602 +323.75,4.32835820896 +330.480769231,4.33830845771 +335.192307692,4.34825870647 +339.903846154,4.35820895522 +343.269230769,4.36815920398 +346.634615385,4.36815920398 +350,4.36815920398 Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-09 12:58:00 UTC (rev 137) @@ -74,8 +74,8 @@ The allowed variables are any that \code{\link{affinity}} accepts: temperature, pressure, or the chemical activities of the basis species If \code{alpha} is TRUE, the fractional degrees of formation (ratios of activities to total activity) are plotted. -This setting is useful for visualizing the molalities (activities for ideal interactions) of monomer groups in a system of biopolymers (e.g. proteins). -If \code{groups} is supplied, the activities of the species identified in each numeric vector of this list are summed together and subsequently treated as a single species; the names of the new species are taken from the names of this list. +If \code{groups} is supplied, the activities of the species identified in each numeric element of this list are multiplied by the balance coefficients of the species, then summed together. +The names of the list are used to label the lines or fields for the summed activities of the resulting groups. For 1-D diagrams, the default setting for the y-axis is a logarithmic scale (unless \code{alpha} is TRUE) with limits corresponding to the range of logarithms of activities (or 0,1 if \code{alpha} is TRUE); these actions can be overridden by \code{ylog} and \code{ylim}. A \code{\link{legend}} is placed at the location identified by \code{legend.x}, or omitted if \code{legend.x} is \code{FALSE}. Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-09 12:58:00 UTC (rev 137) @@ -26,7 +26,7 @@ } - Files in \code{cpetc} contain heat capacity data and other thermodynamic properties: + Files in \code{cpetc} contain heat capacity and other thermodynamic data and parameters: \itemize{ \item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Names of proteins are in the first column, temperature in \eqn{^{\circ}}{?}C in the second, and heat capacities in J mol\eqn{^{-1}}{^-1} K\eqn{^{-1}}{^-1} in the third. See \code{\link{ionize.aa}} for an example that uses this file. \item \code{RH95.csv} Heat capacity data for iron taken from Robie and Hemingway, 1995. Temperature in Kelvin is in the first column, heat capacity in J K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1} in the second. See \code{\link{subcrt}} for an example that uses this file. @@ -35,6 +35,7 @@ \item \code{Cp.CH4.HW97.csv}, \code{V.CH4.HWM96.csv} Apparent molar heat capacities and volumes of CH4 in dilute aqueous solutions reported by Hnedkovsky and Wood, 1997 and Hnedkovsky et al., 1996. See \code{\link{EOSregress}} for examples that use these files. \item \code{BKM60_Fig7.dat} Eh-pH values for normal, wet and waterlogged soils from Fig. 7 of Baas Becking et al., 1960. See the \sQuote{anintro} vignette for an example that uses this file. \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), pH and logarithms of activity of \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2}}{H2}, \eqn{\mathrm{NH_4^+}}{NH4+}, \eqn{\mathrm{H_2S}}{H2S} and \eqn{\mathrm{CH_4}}{CH4} for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010. + \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{O2} and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998. } Files in \code{fasta} contain protein sequences: @@ -148,9 +149,11 @@ SGD project. \emph{Saccharomyces} Genome Database, \url{http://www.yeastgenome.org} + Shock, E. and Canovas, P. (2010) The potential for abiotic organic synthesis and biosynthesis at seafloor hydrothermal systems. \emph{Geofluids} \bold{10}, 161--192. \url{http://dx.doi.org/10.1111/j.1468-8123.2010.00277.x} + Shock, E. L., Oelkers, E. H., Johnson, J. W., Sverjensky, D. A. and Helgeson, H. C. (1992) Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures: Effective electrostatic radii, dissociation constants and standard partial molal properties to 1000 \eqn{^{\circ}}{?}C and 5 kbar. \emph{J. Chem. Soc. Faraday Trans.} \bold{88}, 803--826. \url{http://dx.doi.org/10.1039/FT9928800803} - Shock, E. and Canovas, P. (2010) The potential for abiotic organic synthesis and biosynthesis at seafloor hydrothermal systems. \emph{Geofluids} \bold{10}, 161--192. \url{http://dx.doi.org/10.1111/j.1468-8123.2010.00277.x} + Shock, E. L. and Schulte, M. D. (1998) Organic synthesis during fluid mixing in hydrothermal systems. \emph{J. Geophys. Res.} \bold{103}, 28513--28527. \url{http://dx.doi.org/10.1029/98JE02142} YeastGFP project. Yeast GFP Fusion Localization Database, http://yeastgfp.ucsf.edu; Current location: \url{http://yeastgfp.yeastgenome.org} Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-09 12:58:00 UTC (rev 137) @@ -55,7 +55,7 @@ ## surface-layer proteins from Methanococcus and others ## as a function of oxygen fugacity, after Dick, 2008, Fig. 5b -# use old properties of [Met] to reproduce this example +# use old properties of [Met] (Dick et al., 2006) to reproduce this example data(thermo) mod.obigt("[Met]", G=-35245, H=-59310) # make our protein list Modified: pkg/CHNOSZ/man/read.expr.Rd =================================================================== --- pkg/CHNOSZ/man/read.expr.Rd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/man/read.expr.Rd 2017-02-09 12:58:00 UTC (rev 137) @@ -88,7 +88,7 @@ ## speciation diagram for ER.to.Golgi proteins (COPII coat ## proteins) as a function of logfO2, after Dick, 2009 -# use old parameters for [Met] sidechain group +# use old parameters for [Met] (Dick et al., 2006) mod.obigt("[Met]", G=-35245, H=-59310) y <- yeastgfp("ER.to.Golgi") # don't use those with NA abundance Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-02-09 12:58:00 UTC (rev 137) @@ -20,9 +20,9 @@ thermo.plot.new(xlim, ylim, xlab, ylab, cex = par("cex"), mar = NULL, lwd = par("lwd"), side = c(1,2,3,4), mgp = c(1.5, 0.3, 0), cex.axis = par("cex"), col = par("col"), - yline = NULL, axs = "i", do.box = TRUE, ticks = NULL, las = 1, + yline = NULL, axs = "i", do.box = TRUE, las = 1, xline = NULL, ...) - thermo.axis(lab = "x-axis", side = 1, line = 1.5, cex = par("cex"), + thermo.axis(lab = NULL, side = 1:4, line = 1.5, cex = par("cex"), lwd = par("lwd"), T = NULL, col = par("col")) label.plot(x, xfrac = 0.05, yfrac = 0.95, paren = FALSE, italic = FALSE, ...) @@ -52,7 +52,6 @@ \item{yline}{numeric, margin line on which to plot \eqn{y}{y}-axis name} \item{axs}{character, setting for axis limit calculation} \item{do.box}{logical, draw a box around the plot?} - \item{ticks}{numeric, same effect as \code{side} (retained for backwards compatibility)} \item{las}{numeric, style for axis labels} \item{xline}{numeric, margin line on which to plot \eqn{x}{x}-axis name} \item{...}{further arguments passed to \code{par} or \code{mtext}} @@ -81,7 +80,7 @@ \details{ - \code{thermo.plot.new} sets parameters for a new plot, creates a new plot using \code{\link{plot.new}}, and adds axes and major and minor ticks to the plot. Plot parameters (see \code{\link{par}}) including \code{cex}, \code{mar}, \code{lwd}, \code{mgp} and \code{axs} can be given, as well as a numeric vector in \code{ticks} identifying which sides of the plot receive tick marks. \code{yline}, if present, denotes the margin line (default \code{\link{par}('mgp')[1]}) where the y-axis name is plotted. The very first time \code{thermo.plot.new} is called, it stores the existing value of \code{par(no.readonly=TRUE)} in \code{thermo$opar} so that the plot device can be reset to the previous state later on. + \code{thermo.plot.new} sets parameters for a new plot, creates a new plot using \code{\link{plot.new}}, and adds axes and major and minor tick marks to the plot. Plot parameters (see \code{\link{par}}) including \code{cex}, \code{mar}, \code{lwd}, \code{mgp} and \code{axs} can be given, as well as a numeric vector in \code{side} identifying which sides of the plot receive tick marks. \code{yline}, if present, denotes the margin line (default \code{\link{par}('mgp')[1]}) where the y-axis name is plotted. The very first time \code{thermo.plot.new} is called, it stores the existing value of \code{par(no.readonly=TRUE)} in \code{thermo$opar} so that the plot device can be reset to the previous state later on. \code{water.lines} plots lines representing the oxidation and reduction stability limits of water on \code{yaxis}-\code{xaxis} diagrams, where \code{yaxis} can be \samp{Eh} or \samp{O2}, and \code{xaxis} can be \samp{pH} or \samp{T}. \code{which} controls which lines are drawn (\samp{oxidation}, \samp{reduction}, or both (the default)). @@ -97,7 +96,9 @@ \code{usrfig} returns the limits of the figure region in \dQuote{user} coordinates (i.e. the limits of the plot region, from \code{\link{par}("usr")}). It is a supporting function for \code{label.figure} but is also useful for other circumstances where information must be added at a particular location in a figure. - \code{thermo.axis} is used to add axes and axis labels to plots, with some default style settings (rotation of numeric labels) and conversions between oxidation-reduction scales (called by \code{thermo.plot.new}). It also adds minor tick marks. +\code{thermo.axis} is used to add axes and axis labels to plots, with some default style settings (rotation of numeric labels) and conversions between oxidation-reduction scales (called by \code{thermo.plot.new}). +It also adds minor tick marks. +With the default arguments (no labels specified), it plots only the axis lines and tick marks; this is useful for overplotting the axis on diagrams filled with colors. \code{mtitle} can be used to add a multi-line title to a plot. It loops over each element of \code{main} and places it on a separate margin line using \code{\link{mtext}}. Modified: pkg/CHNOSZ/tests/testthat/test-diagram.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-diagram.R 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/tests/testthat/test-diagram.R 2017-02-09 12:58:00 UTC (rev 137) @@ -48,9 +48,10 @@ e <- equilibrate(a) # group the species together d <- diagram(e, groups=list(1:2, 3:4), plot.it=FALSE) - # we should find that their activities have been summed - expect_equal(d$plotvals[[1]], log10(10^e$loga.equil[[1]] + 10^e$loga.equil[[2]])) - expect_equal(d$plotvals[[2]], log10(10^e$loga.equil[[3]] + 10^e$loga.equil[[4]])) + # we should find that their activities have been multiplied by the balance coefficients and summed + n.balance <- balance(a) + expect_equal(d$plotvals[[1]], log10(n.balance[1]*10^e$loga.equil[[1]] + n.balance[2]*10^e$loga.equil[[2]])) + expect_equal(d$plotvals[[2]], log10(n.balance[3]*10^e$loga.equil[[3]] + n.balance[4]*10^e$loga.equil[[4]])) # ask for degrees of formation instead of logarithms of activities d <- diagram(e, alpha=TRUE, plot.it=FALSE) # we should find that the sum of alphas is one Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-06 16:08:42 UTC (rev 136) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-09 12:58:00 UTC (rev 137) @@ -7,6 +7,7 @@ tufte_features: ["background"] css: "vig.css" toc: true + mathjax: null tufte::tufte_handout: citation_package: natbib latex_engine: xelatex @@ -40,6 +41,11 @@ knitr::knit_hooks$set(smallish.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) +# use pngquant to optimize PNG images +knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) +pngquant <- "--speed=1 --quality=0-50" +# some frequently used HTML expressions +logfO2 <- "logfO2" ``` # First steps @@ -194,7 +200,7 @@ as.chemical.formula(makeup(88)) ``` -For organic species, a simple calculation of the average oxidation state of carbon ($Z_C$) is possible given the species index, chemical formula, or elemental count: +For organic species, a simple calculation of the average oxidation state of carbon (*Z*C) is possible given the species index, chemical formula, or elemental count: ```{r ZC_88} ZC(88) ZC(info(88)$formula) @@ -231,7 +237,7 @@ subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water ``` -```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE} +```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE, pngquant=pngquant} H2O <- subcrt("water", T=seq(0, 1000, 100), P=c(NA, seq(1, 500, 1)), grid="T") H2O <- H2O$out$water plot(H2O$P, H2O$rho, type="l") @@ -285,7 +291,7 @@ CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK logK <- data.frame(T, CO2, CO, CH4) ``` -```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=50, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE} +```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE, pngquant=pngquant} matplot(logK[, 1], logK[, -1], type="l", col=1, lty=1, xlab=axis.label("T"), ylab=axis.label("logK")) text(80, -1.7, expr.species("CO2")) @@ -355,7 +361,7 @@

Use `describe.reaction()` to write the reactions on a plot: -```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=50, out.width="100%"} +```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=72, out.width="100%", pngquant=pngquant} plot(0, 0, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2)) text(0, 0, "acetoclastic methanogenesis", adj=0) text(5, 1, describe.reaction(acetoclastic$reaction), adj=1) @@ -365,7 +371,7 @@ text(5, 5, describe.reaction(hydrogenotrophic$reaction), adj=1) ``` -## Non-standard state affinities and Gibbs energies +## Affinity: not the standard state Gibbs energy Usually, `subcrt()` returns only standard state thermodynamic properties. ```{marginfigure} @@ -419,7 +425,7 @@ We insert an empty reaction to get a line at zero affinity. `do.call(rbind, Adat)` turns the list into a data frame that can be plotted with `matplot()`. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 137 From noreply at r-forge.r-project.org Thu Feb 9 17:49:55 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Feb 2017 17:49:55 +0100 (CET) Subject: [CHNOSZ-commits] r138 - in pkg/CHNOSZ: . R inst inst/extdata/cpetc man vignettes Message-ID: <20170209164955.506CB188615@r-forge.r-project.org> Author: jedick Date: 2017-02-09 17:49:54 +0100 (Thu, 09 Feb 2017) New Revision: 138 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/cpetc/PM90.csv pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add proteins: group additivity and ionization Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-09 16:49:54 UTC (rev 138) @@ -1,6 +1,6 @@ Date: 2017-02-09 Package: CHNOSZ -Version: 1.0.8-27 +Version: 1.0.8-28 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/R/util.expression.R 2017-02-09 16:49:54 UTC (rev 138) @@ -87,11 +87,9 @@ else if(thischar %in% letters) thisexpr <- substitute(""[italic(a)], list(a=thischar)) else thisexpr <- substitute(a, list(a=thischar)) # D for greek Delta - # A for bold A (affinity) # p for subscript italic P (in Cp) # 0 for degree sign (but not immediately following a number e.g. 2.303) if(thischar=='D') thisexpr <- substitute(Delta) - if(thischar=='A') thisexpr <- substitute(bold(A)) if(thischar=='p') thisexpr <- substitute(a[italic(P)], list(a="")) if(thischar=='0' & !can.be.numeric(prevchar)) thisexpr <- substitute(degree) # put it together Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/inst/NEWS 2017-02-09 16:49:54 UTC (rev 138) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-27 (2017-02-09) +CHANGES IN CHNOSZ 1.0.8-28 (2017-02-09) --------------------------------------- - Add "AA" as a keyword for preset species in basis() (cysteine, @@ -58,6 +58,9 @@ - With new default arguments, thermo.axis() only plots the axis tick marks and lines (useful for redrawing the axis on filled diagrams). +- Remove the bold formatting for "A" in expr.property(); now "A" is + italicized like most other uppercase letters. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/inst/extdata/cpetc/PM90.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/PM90.csv 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/inst/extdata/cpetc/PM90.csv 2017-02-09 16:49:54 UTC (rev 138) @@ -1,25 +1,7 @@ -protein,T,Cp -CYC_BOVIN,5,21400 -CYC_BOVIN,25,23800 -CYC_BOVIN,50,25200 -CYC_BOVIN,75,26000 -CYC_BOVIN,100,26100 -CYC_BOVIN,125,26300 -LYSC_CHICK,5,25200 -LYSC_CHICK,25,27500 -LYSC_CHICK,50,29500 -LYSC_CHICK,75,31100 -LYSC_CHICK,100,31400 -LYSC_CHICK,125,31500 -MYG_PHYCA,5,31900 -MYG_PHYCA,25,34900 -MYG_PHYCA,50,36900 -MYG_PHYCA,75,39200 -MYG_PHYCA,100,39300 -MYG_PHYCA,125,39500 -RNAS1_BOVIN,5,23100 -RNAS1_BOVIN,25,26000 -RNAS1_BOVIN,50,27700 -RNAS1_BOVIN,75,29200 -RNAS1_BOVIN,100,29800 -RNAS1_BOVIN,125,30100 +T,CYC_BOVIN,LYSC_CHICK,MYG_PHYCA,RNAS1_BOVIN +5,21400,25200,31900,23100 +25,23800,27500,34900,26000 +50,25200,29500,36900,27700 +75,26000,31100,39200,29200 +100,26100,31400,39300,29800 +125,26300,31500,39500,30100 Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-09 16:49:54 UTC (rev 138) @@ -28,7 +28,7 @@ Files in \code{cpetc} contain heat capacity and other thermodynamic data and parameters: \itemize{ - \item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Names of proteins are in the first column, temperature in \eqn{^{\circ}}{?}C in the second, and heat capacities in J mol\eqn{^{-1}}{^-1} K\eqn{^{-1}}{^-1} in the third. See \code{\link{ionize.aa}} for an example that uses this file. + \item \code{PM90.csv} Heat capacities of four unfolded aqueous proteins taken from Privalov and Makhatadze, 1990. Temperature in \eqn{^{\circ}}{?}C is in the first column, and heat capacities of the proteins in J mol\eqn{^{-1}}{^-1} K\eqn{^{-1}}{^-1} in the remaining columns. See \code{\link{ionize.aa}} for an example that uses this file. \item \code{RH95.csv} Heat capacity data for iron taken from Robie and Hemingway, 1995. Temperature in Kelvin is in the first column, heat capacity in J K\eqn{^{-1}}{^-1} mol\eqn{^{-1}}{^-1} in the second. See \code{\link{subcrt}} for an example that uses this file. \item \code{RT71.csv} pH titration measurements for unfolded lysozyme (\samp{LYSC_CHICK}) taken from Roxby and Tanford, 1971. pH is in the first column, net charge in the second. See \code{\link{ionize.aa}} for an example that uses this file. \item \code{SOJSH.csv} Experimental equilibrium constants for the reaction NaCl(aq) = Na+ + Cl- as a function of temperature and pressure taken from Fig. 1 of Shock et al., 1992. Data were extracted from the figure using g3data (\url{http://www.frantz.fi/software/g3data.php}). See \code{\link{water}} for an example that uses this file. Modified: pkg/CHNOSZ/man/ionize.aa.Rd =================================================================== --- pkg/CHNOSZ/man/ionize.aa.Rd 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/man/ionize.aa.Rd 2017-02-09 16:49:54 UTC (rev 138) @@ -85,8 +85,7 @@ points(T, convert(MP90.cp("LYSC_CHICK", T), "cal")) # Privalov and Makhatadze's experimental values e <- read.csv(system.file("extdata/cpetc/PM90.csv", package="CHNOSZ")) -e <- e[e$protein=="LYSC_CHICK",] -points(e$T, convert(e$Cp, "cal"), pch=16) +points(e$T, convert(e$LYSC_CHICK, "cal"), pch=16) legend("bottomright", pch=c(16, 1, NA, NA), lty=c(NA, NA, 1, 2), legend=c("PM90 experiment", "MP90 groups", "DLH06 groups no ion", "DLH06 groups ionized")) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-09 16:49:54 UTC (rev 138) @@ -845,7 +845,7 @@ Actually, the total concentration of carbon depends on the mixing ratio, ranging from about 10-2.2 (seawater) to 10-2.6 (vent fluid). The ability to vary the activity of the balanced basis species is not yet implemented in CHNOSZ, so a single value is used here. ``` -```{r groups_affinity, message=FALSE} +```{r groups_affinity, message=FALSE, cache=TRUE} a <- affinity(T=T, O2=O2, pH=pH) e <- equilibrate(a, loga.balance=-2.5) ``` @@ -871,7 +871,7 @@ That makes a diagram that is similar to Figure 6b of Shock and Schulte (1998). ```{marginfigure} -Some differences with the original diagrams may be caused by artifacts introduced by digitization, combined with the sensitivity of the calculations to log*f*O2. +Some differences from the original diagrams may be caused by artifacts introduced by digitization, combined with the sensitivity of the calculations to log*f*O2. ``` It is also possible to plot the distribution of species within individual groups, such as alcohols and ketones. We do this by setting the names and line types for the *other* species to values that prevent them from being plotted: @@ -922,14 +922,102 @@ # Proteins -## Sources of amino acid data +Proteins in CHNOSZ are handled differently from other species. +Amino acid group additivity is used to obtain the thermodynamic properties of proteins. +Therefore, CHNOSZ has a data file with amino acid compositions of selected proteins, as well as functions for importing and downloading amino acid sequence data. +When proteins in CHNOSZ are identified by name, they include an underscore, such as in `LYSC_CHICK` (chicken lysozyme C). -## Group additivity and Ionization +The length and chemical formula of one or more proteins are returned by `protein.length()` and `protein.formula()`. +We can calculate the formula of the protein, and the per-residue formula, and show that both have the same average oxidation state of carbon: +```{r formula_LYSC_CHICK} +pl <- protein.length("LYSC_CHICK") +pf <- protein.formula("LYSC_CHICK") +list(length=pl, protein=pf, residue=pf/pl, + ZC_protein=ZC(pf), ZC_residue=ZC(pf/pl)) +``` -## Normalizing for different lengths +## Group additivity and ionization +The group additivity calculations for proteins are based on equations and data from @AH00, @DLH06, and @LD12. +There are two major options for the calculations: whether to calculate properties for crystalline or aqueous groups, and, for the latter, whether to model the ionization of the sidechain and terminal groups as a function of pH (as well as *T* and *P*). +By default, additivity of aqueous groups is used: +```{r subcrt_LYSC_CHICK, message=FALSE} +subcrt("LYSC_CHICK")$out[[1]][1:6, ] +``` + +

+Let's compare experimental values of heat capacity of four proteins, from @PM90, with those calculated using group additivity. +After dividing Privalov and Makhatadze's experimental values by the lengths of the proteins to get per-residue values, we convert those to calories, then plot them. +The loop calculates the properties of each protein using group additivity, for aqueous and crystalline groups, then plots the per-residue values. +```{r protein_Cp, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap='The heat capacity calculated by group additivity closely approximates experimental values for aqueous proteins. For a related figure showing the effects of ionization in the calculations, see ?ionize.aa.', cache=TRUE, pngquant=pngquant} +PM90 <- read.csv(system.file("extdata/cpetc/PM90.csv", package="CHNOSZ")) +plength <- protein.length(colnames(PM90)[2:5]) +Cp_expt <- t(t(PM90[, 2:5]) / plength) +matplot(PM90[, 1], convert(Cp_expt, "cal"), type="p", pch=19, + xlab=axis.label("T"), ylab=axis.label("Cp0"), ylim=c(28, 65)) +for(i in 1:4) { + pname <- colnames(Cp_expt)[i] + aq <- subcrt(pname, "aq", T=seq(0, 150))$out[[1]] + cr <- subcrt(pname, "cr", T=seq(0, 150))$out[[1]] + lines(aq$T, aq$Cp/plength[i], col=i) + lines(cr$T, cr$Cp/plength[i], col=i, lty=2) +} +legend("right", legend=colnames(Cp_expt), + col=1:4, pch=19, lty=1, bty="n", cex=0.9) +legend("bottomright", legend=c("experimental", "calculated (aq)", + "calculated (cr)"), lty=c(NA, 1, 2), pch=c(19, NA, NA), bty="n") +``` +```{r protein_Cp, eval=FALSE} +``` + +

+Note that `subcrt()` has no provision for protein ionization. +Instead, ionization is handled via `affinity()`, which calls `ionize.aa()` if a charged species is in the basis. +```{marginfigure} +Whether to calculate properties using aqueous or crystalline groups is determined by the value of `thermo\$opt\$state`; if it is changed from its default of `aq` to `cr`, no ionization is possible. +``` +The following plot shows the calculated affinity of reaction between nonionized proteins and their ionized forms as a function of pH. +The affinity is always positive, representing the strong energetic drive for ionization of proteins in aqueous solution. +The degree of ionization of amino and carboxyl groups increase at low and high pH, respectively, accounting for the U-shaped lines. +```{r protein_ionization, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Affinity of ionization of proteins. See demo(ionize) for ionization properties calculated as a function of temperature and pH.', cache=TRUE, pngquant=pngquant} +ip <- iprotein(c("CYC_BOVIN", "LYSC_CHICK", "MYG_PHYCA", "RNAS1_BOVIN")) +basis("CHNOS+") +a_ion <- affinity(pH=c(0, 14), iprotein=ip) +basis("CHNOS") +a_nonion <- affinity(iprotein=ip) +plot(c(0, 14), c(50, 300), xlab="pH", ylab=axis.label("A"), type="n") +for(i in 1:4) { + A_ion <- as.numeric(a_ion$values[[i]]) + A_nonion <- as.numeric(a_nonion$values[[i]]) + lines(a_ion$vals[[1]], A_ion - A_nonion, col=i) +} +legend("topright", legend=a_ion$species$name, + col=1:4, lty=1, bty="n", cex=0.9) +``` +We calculate the affinities for the same four proteins, using both charged and uncharged sets of basis species to activate and suppress the ionization calculations. +The ionized calculation returns a series of values (as a function of pH), but there is only one value of affinity returned by the nonionized calculation, so we need to use `as.numeric()` to avoid subtracting non-conformable arrays: +```{r protein_ionization, eval=FALSE} +``` + +Above, we used the `iprotein` argument of `affinity()` to specify the proteins in the calculation, using their indices as returned by `iprotein()`. +```{marginfigure} +The `iprotein` index refers to the rownumber of `thermo\$protein`; this is distinct from the `ispecies` index, which refers to the rownumber of `thermo\$species`. +``` +That approach utilizes some optimizations that can be realized due group additivity, and is useful for calculations involving many proteins. +An alternative, but slower, approach is to identify the proteins to `species()`; this should produce results that are equivalent to using the `iprotein` argument: +```{r species_protein, message=FALSE} +species(c("CYC_BOVIN", "LYSC_CHICK", "MYG_PHYCA", "RNAS1_BOVIN")) +a_nonion2 <- affinity() +unlist(a_nonion2$values) +unlist(a_nonion$values) +``` + ## Compositional analysis (ZC) +## Normalizing for different lengths + +## Adding amino acid data + # Data options ## Source of data: browse.refs() @@ -954,6 +1042,6 @@ # Functions outside of the main workflow -transfer, wjd, eqdata, RH2obigt, EOSregress +transfer, wjd, eqdata, RH2obigt, EOSregress, anim. Gibbs energy minimization with amino acids: [Cob13]? Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-09 12:58:00 UTC (rev 137) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-09 16:49:54 UTC (rev 138) @@ -11,6 +11,17 @@ doi = {10.1149/1.1344532}, } + at Article{AH00, + author = {Amend, Jan P. and Helgeson, Harold C.}, + journal = {Biophysical Chemistry}, + title = {{C}alculation of the standard molal thermodynamic properties of aqueous biomolecules at elevated temperatures and pressures. {II}. {U}nfolded proteins}, + year = {2000}, + volume = {84}, + number = {2}, + pages = {105--136}, + doi = {10.1016/S0301-4622(00)00116-2}, +} + @Book{BPJ85, author = {Bard, A. J. and Parsons, R. and Jordan, J.}, publisher = {M. Dekker}, @@ -188,14 +199,16 @@ z9 = {41}, } - at Book{Pou49, - author = {Pourbaix, Marcel J. N.}, - publisher = {Edward Arnold \& Co.}, - title = {Thermodynamics of Dilute Aqueous Solutions}, - year = {1949}, - address = {London}, - pages = {136}, - url = {http://www.worldcat.org/oclc/1356445}, + at Article{PM90, + author = {Privalov, P. L. and Makhatadze, G. I.}, + journal = {Journal of Molecular Biology}, + title = {Heat capacity of proteins. {II}. {P}artial molar heat capacity of the unfolded polypeptide chain of proteins: {P}rotein unfolding effects}, + year = {1990}, + volume = {213}, + number = {2}, + pages = {385--391}, + doi = {10.1016/S0022-2836(05)80198-6}, + size = {7 p.}, } @Article{SB01, From noreply at r-forge.r-project.org Fri Feb 10 15:51:45 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 10 Feb 2017 15:51:45 +0100 (CET) Subject: [CHNOSZ-commits] r139 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170210145146.025D4183ECC@r-forge.r-project.org> Author: jedick Date: 2017-02-10 15:51:45 +0100 (Fri, 10 Feb 2017) New Revision: 139 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add proteins: compositional analysis Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-10 14:51:45 UTC (rev 139) @@ -1,6 +1,6 @@ -Date: 2017-02-09 +Date: 2017-02-10 Package: CHNOSZ -Version: 1.0.8-28 +Version: 1.0.8-29 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/R/basis.R 2017-02-10 14:51:45 UTC (rev 139) @@ -94,7 +94,7 @@ # to load a preset basis definition by keyword preset.basis <- function(key=NULL) { # the available keywords - basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "AA") + basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "CEQ") # just list the keywords if none is specified if(is.null(key)) return(basis.key) # delete any previous basis definition Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/inst/NEWS 2017-02-10 14:51:45 UTC (rev 139) @@ -1,64 +1,79 @@ -CHANGES IN CHNOSZ 1.0.8-28 (2017-02-09) +CHANGES IN CHNOSZ 1.0.8-29 (2017-02-10) --------------------------------------- -- Add "AA" as a keyword for preset species in basis() (cysteine, - glutamic acid, glutamine, H2O, oxygen). +DOCUMENTATION: - Add eos-regress.Rmd vignette; update related functions. -- More flexible parsing of chemical formulas for ZC() and other - functions; e.g. ZC(colMeans(protein.formula(1:4))) now works. +- Replace anintro.Rnw (Sweave) with rewritten anintro.Rmd (knitr, Tufte + style). -- subcrt() now returns 'loggam' using the common logarithm; add - test-nonideal.R to check for consistency between loggam and logK - values returned by subcrt(). This also fixes the issue previously - noted for the first example in ?nonideal. Thanks to David T. Wang for - the bug report and test. +- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R, + remove nucleobase.R. +NEW DATA AND FEATURES: + - OBIGT.csv: Add data for citric acid cycle metabolites from Canovas and Shock, 2016. -- Clean up OBIGT-2.csv: remove data from Dalla-Betta and Schulte, 2009 - (citric acid cycle metabolites; thioester species have been kept) and - from Dick et al., 2006 (methionine and [Met]). +- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, + SS98_Fig5b, PM90 (all used by anintro.Rmd). -- Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R, - remove nucleobase.R. +- Add ZC.col() for generating a red-grey-blue color scale from + numeric values. -- Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter - Canovas. +- For the `groups` argument in diagram(), activities are multiplied + by the balance coefficients before the summation. +- Add "CEQ" as a keyword for preset species in basis() (cysteine, + glutamic acid, glutamine, H2O, oxygen). + +- More flexible parsing of chemical formulas for ZC() and other + functions; e.g. `ZC(colMeans(protein.formula(1:4)))` now works. + - read.fasta() extracts information from UniProt FASTA headers (accession, name, organism) into columns of the output data frame (protein, abbrv, organism). -- diagram() draws smoother boundary lines (with contour(); 'lty' is +- diagram() draws smoother boundary lines (with contour(); `lty` is usable), at the expense of not being precisely aligned with the grid - used for plotting colors. For the old behavior, use dotted=0. + used for plotting colors. For the old behavior, use `dotted=0`. -- Remove msgout(), and replace previous calls to that function with - message() from base R. As a result, the messages don't appear in Sweave - vignettes, but can now be turned on or off easily in knitr vignettes. +- diagram() applies formatting (subscripts and superscripts) to names + that parse as chemical formulas; use `format.names=FALSE` to disable. -- Replace anintro.Rnw (Sweave) with updated anintro.Rmd (knitr, tufte). +- Add `...` argument to thermo.plot.new() (additional arguments for + par()). -- diagram() applies formatting (subscripts and superscripts) to names - that parse as chemical formulas; use `format.names` to disable. +- With new default arguments, thermo.axis() only plots the axis tick + marks and lines; this is used in diagram() to redraw the axes on + filled diagrams. -- Add '...' argument to thermo.plot.new() (extra arguments for par()). +CLEANUP AND BUG FIXES: -- Remove HTCC1062.faa.xz. +- subcrt() returns `loggam` using the common logarithm; add + test-nonideal.R to check for consistency between loggam and logK + values returned by subcrt(). This also fixes the issue previously + noted for the first example in ?nonideal. Thanks to David T. Wang for + the bug report and test. -- Add ZC.col() for generating a red-grey-blue color scale from - numeric values. +- OBIGT-2.csv: remove data for citric acid cycle metabolites from + Dalla-Betta and Schulte, 2009; thioester species have been kept. -- For the `groups` argument in diagram(), activities are now multiplied - by the balance coefficients before the summation. +- OBIGT-2.csv: remove data for methionine and [Met] from Dick et al., + 2006. Examples that require the old group additivity parameters + modify the database using: `mod.obigt("[Met]", G=-35245, H=-59310)`. -- With new default arguments, thermo.axis() only plots the axis tick - marks and lines (useful for redrawing the axis on filled diagrams). +- Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter + Canovas. -- Remove the bold formatting for "A" in expr.property(); now "A" is +- Remove msgout(), and replace previous calls to that function with + message() from base R. As a result, the messages don't appear in Sweave + vignettes, but can be turned on or off in knitr vignettes. + +- Remove HTCC1062.faa.xz. + +- Remove the bold formatting for "A" in expr.property(); "A" is italicized like most other uppercase letters. CHANGES IN CHNOSZ 1.0.8 (2016-05-28) Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-10 14:51:45 UTC (rev 139) @@ -92,9 +92,14 @@ } \section{Acknowledgements}{ - This package would not exist without the fearless leadership and encouragement of Professor Harold C. Helgeson. Hal and his associates are in some way responsible for many of the equations and data contained in this package. A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with only cosmetic modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment. The revised Helgeson-Kirkham-Flowers equations of state are used in this package, together with the thermodynamic properties and parameters for many species taken from numerous papers coauthored by Helgeson. + This package would not exist without the leadership and encouragement of Professor Harold C. Helgeson. + Hal and his associates are in some way responsible for many of the equations and data contained in this package. + A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with minor modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment. + The revised Helgeson-Kirkham-Flowers equations of state are used in this package, together with the thermodynamic properties and parameters for many species taken from numerous papers coauthored by Helgeson. - Work on this package at U.C. Berkeley from ~2003--2008 was supported by research grants solicited by HCH from the U.S. National Science Foundation and Department of Energy. In 2009--2011, the major research project stimulating development of this package at Arizona State University was funded by the National Science Foundation under grant EAR-0847616. The files in \code{extdata/bison} are excerpts of results of BLAST calculations made on the Saguaro high performance computer at ASU. + Work on this package at U.C. Berkeley from ~2003--2008 was supported by research grants to HCH from the U.S. National Science Foundation and Department of Energy. + In 2009--2011, development of this package was based upon work supported by the National Science Foundation under grant EAR-0847616. + The files in \code{extdata/bison} are excerpts of results of BLAST calculations made on the Saguaro high performance computer at ASU. } \section{Known Bugs}{ Modified: pkg/CHNOSZ/man/basis.Rd =================================================================== --- pkg/CHNOSZ/man/basis.Rd 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/man/basis.Rd 2017-02-10 14:51:45 UTC (rev 139) @@ -59,7 +59,7 @@ \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2} \cr \code{FeCHNOS+} \tab \eqn{\mathrm{Fe_2O_3}}{Fe2O3}, \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2}, \eqn{\mathrm{H^+}}{H+} \cr - \code{AA} \tab cysteine, glutamic acid, glutamine, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{O_2}}{O2} \cr + \code{CEQ} \tab cysteine, glutamic acid, glutamine, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{O_2}}{O2} \cr } } Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-10 14:51:45 UTC (rev 139) @@ -36,11 +36,13 @@ \item \code{BKM60_Fig7.dat} Eh-pH values for normal, wet and waterlogged soils from Fig. 7 of Baas Becking et al., 1960. See the \sQuote{anintro} vignette for an example that uses this file. \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), pH and logarithms of activity of \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2}}{H2}, \eqn{\mathrm{NH_4^+}}{NH4+}, \eqn{\mathrm{H_2S}}{H2S} and \eqn{\mathrm{CH_4}}{CH4} for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010. \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{O2} and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998. + \item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, and domain and name of organisms, from Dick, 2014. } Files in \code{fasta} contain protein sequences: \itemize{ \item \code{EF-Tu.aln} consists of aligned sequences (394 amino acids) of elongation factor Tu (EF-Tu). The sequences correspond to those taken from UniProtKB for ECOLI (\emph{Escherichia coli}), THETH (\emph{Thermus thermophilus}) and THEMA (\emph{Thermotoga maritima}), and reconstructed ancestral sequences taken from Gaucher et al., 2003 (maximum likelihood bacterial stem and mesophilic bacterial stem, and alternative bacterial stem). See the \sQuote{formation} vignette for an example that uses this file. + \item \code{rubisco.csv} Sequences of Rubisco obtained from UniProt (see Dick, 2014). } Files in \code{protein} contain protein composition data for model organisms. @@ -113,6 +115,8 @@ Dayhoff, M. O. and Lippincott, E. R., Eck, R. V. and Nagarajan (1967) Thermodynamic Equilibrium In Prebiological Atmospheres of C, H, O, N, P, S, and Cl. Report SP-3040, National Aeronautics and Space Administration. \url{http://ntrs.nasa.gov/search.jsp?R=19670017966} + Dick, J. M. (2014) Average oxidation state of carbon in proteins. \emph{J. R. Soc. Interface} \bold{11}, 20131095. \url{http://dx.doi.org/10.1098/rsif.2013.1095} + Dick, J. M. (2016) Proteomic indicators of oxidation and hydration state in colorectal cancer. \emph{PeerJ} \bold{4}:e2238. \url{http://dx.doi.org/10.7717/peerj.2238} Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{http://dx.doi.org/10.1371/journal.pone.0022782} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-09 16:49:54 UTC (rev 138) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-10 14:51:45 UTC (rev 139) @@ -41,11 +41,17 @@ knitr::knit_hooks$set(smallish.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) +# dpi setting +dpi <- 100 # use pngquant to optimize PNG images knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) pngquant <- "--speed=1 --quality=0-50" # some frequently used HTML expressions logfO2 <- "logfO2" +# use lowercase here because these tend to be variable names in the examples +zc <- "ZC" +o2 <- "O2" +h2o <- "H2O" ``` # First steps @@ -99,16 +105,20 @@ Many functions in CHNOSZ have no side effects. That is, the function only returns a result; to use the result elsewhere, it can be assigned to a variable with `<-`. +In this document (but not in the code chunks), the names of these functions are set in green text. +```{marginfigure} +When they are mentioned, names of functions in the base and recommended packages of R are said to belong to R. Example: Use R's `plot()` to plot the points. +``` Major functions without side effects in CHNOSZ are: -* `info()`: search for species in the thermodynamic database -* `subcrt()`: calculate the thermodynamic properties of species and reactions -* `affinity()`: calculate the affinities of formation reactions using given chemical activities -* `equilibrate()`: calculate the equilibrium chemical activities of the species of interest -* `diagram()`: plot the results +* `info()`: search for species in the thermodynamic database +* `subcrt()`: calculate the thermodynamic properties of species and reactions +* `affinity()`: calculate the affinities of formation reactions using given chemical activities +* `equilibrate()`: calculate the equilibrium chemical activities of the species of interest +* `diagram()`: plot the results Some functions in CHNOSZ do have side effects: they modify the `thermo` data object in the current R session. -In the text (not code) of this document, the names of these functions are shown in red text. +In this document, the names of these functions are set in red text. The major functions with side effects are: * `basis()`: set the basis species and their chemical activities @@ -128,7 +138,7 @@ Some experimental functions are available: -* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. +* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. # Thermodynamic database and chemical formulas @@ -139,9 +149,9 @@ ``` Where possible, data with known or suspected inconsistencies have been placed into a secondary database (`OBIGT-2.csv`) that should be regarded as experimental. -## The `info()` function +## The `info()` function -The `info()` function provides an interface to the thermodynamic database packaged with CHNOSZ. +`info()` provides an interface to the thermodynamic database packaged with CHNOSZ. Suppose you are interested in the thermodynamic properties aqueous ethylene. You can search for the species by name: ```{r info_ethylene} @@ -154,7 +164,7 @@ info("ethylene", "gas") ``` -Knowing that aqueous ethylene is species number 88 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: +Knowing that aqueous ethylene is species number 88 in the database, you can again use `info()` to retrieve the set of standard molal thermodynamic properties and equations of state parameters: ```{r info_88} info(88) ``` @@ -167,7 +177,7 @@ ## Fuzzy searches -Calling `info()` with a string that does not exactly match the name of any species invokes a fuzzy search of the database: +Calling `info()` with a string that does not exactly match the name of any species invokes a fuzzy search of the database: ```{r width180, include=FALSE} options(width = 180) ``` @@ -187,20 +197,20 @@ The messages may be useful for browsing the database, but owing to their ambiguous results, these fuzzy searches return an `NA` value for the species index. -## Counting elements, chemical formulas, `ZC()` +## Counting elements, chemical formulas, `ZC()` Continuing with the example of ethylene, let's look at its chemical formula: ```{r info_88_formula} info(88)$formula ``` -We can use the `makeup()` function to count the elements in the formula, followed by `as.chemical.formula()` to return to the formula: +We can use `makeup()` to count the elements in the formula, followed by `as.chemical.formula()` to return to the formula: ```{r makeup_88} makeup(88) as.chemical.formula(makeup(88)) ``` -For organic species, a simple calculation of the average oxidation state of carbon (*Z*C) is possible given the species index, chemical formula, or elemental count: +For organic species, a simple calculation of the average oxidation state of carbon (`r zc`) is possible given the species index, chemical formula, or elemental count: ```{r ZC_88} ZC(88) ZC(info(88)$formula) @@ -209,12 +219,12 @@ # Calculating thermodynamic properties -To calculate the standard molal properties of species and reactions, use `subcrt()`. +To calculate the standard molal properties of species and reactions, use `subcrt()`. ```{marginfigure} -The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of H2O, is SUPCRT (Johnson et al., 1992). +The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of `r h2o`, is SUPCRT (Johnson et al., 1992). ``` [- at JOH92] -If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: +If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: ```{r subcrt_water} subcrt("water") ``` @@ -229,7 +239,7 @@ ``` A custom temperature-pressure grid can be specified. -Here, we calculate the properties of H2O on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure: +Here, we calculate the properties of `r h2o` on a *T*, *P* grid in the supercritical region, with conditions grouped by pressure: ```{marginfigure} See also `demo(density)`. ``` @@ -237,12 +247,12 @@ subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water ``` -```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE, pngquant=pngquant} -H2O <- subcrt("water", T=seq(0, 1000, 100), P=c(NA, seq(1, 500, 1)), grid="T") -H2O <- H2O$out$water -plot(H2O$P, H2O$rho, type="l") +```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE, pngquant=pngquant} +substuff <- subcrt("water", T=seq(0,1000,100), P=c(NA, seq(1,500,1)), grid="T") +water <- substuff$out$water +plot(water$P, water$rho, type="l") ``` -The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. `write.table()` or `plot()` for further processing: +The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. R's `write.table()` or `plot()` for further processing: ```{r subcrt_water_plot, eval=FALSE} ``` @@ -259,7 +269,7 @@ data(thermo) ## restore default settings ``` -A related function, `convert()`, can be used to convert given values between units. +A related function, `convert()`, can be used to convert given values between units. Let's convert the standard Gibbs energy of aqueous methane listed in the database from cal/mol to J/mol: ```{r methane_G, message=FALSE} convert(info(info("methane"))$G, "J") @@ -271,7 +281,7 @@ ## Reaction definitions -To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to `subcrt()`. +To calculate the thermodynamic properties of reactions, give the names of species, the physical states (optional), and reaction coefficients as the arguments to `subcrt()`. Here we calculate properties for the dissolution of CO2: ```{marginfigure} Because of aqueous speciation, this doesn't give the _solubility_ of CO2. @@ -281,9 +291,9 @@ subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=seq(0, 250, 50)) ``` -

In order to make a plot like Figure 18 of @MSS13, let's run more calculations and store the results. In addition to the reaction definition, we specify a greater number of temperature points than the default: + ```{r dissolution, echo=FALSE, message=FALSE} T <- seq(0, 350, 10) CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=T)$out$logK @@ -291,7 +301,7 @@ CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK logK <- data.frame(T, CO2, CO, CH4) ``` -```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE, pngquant=pngquant} +```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE, pngquant=pngquant} matplot(logK[, 1], logK[, -1], type="l", col=1, lty=1, xlab=axis.label("T"), ylab=axis.label("logK")) text(80, -1.7, expr.species("CO2")) @@ -302,14 +312,14 @@ ``` Now we can make the plot, using R's `matplot()`. -Here, the `axis.label()` and `expr.species()` functions of CHNOSZ are used to create formatted axis labels and chemical formulas: +Here, `axis.label()` and `expr.species()` are used to create formatted axis labels and chemical formulas: ```{r dissolution_plot, eval=FALSE} ``` ## Unbalanced reactions A balanced chemical reaction conserves mass. -`subcrt()` won't stop you from running an unbalanced reaction, but it will give you a warning: +`subcrt()` won't stop you from running an unbalanced reaction, but it will give you a warning: ```{r subcrt_unbalanced, results="hide"} subcrt(c("CO2", "CH4"), c(-1, 1)) ``` @@ -359,9 +369,9 @@ acetoclastic <- subcrt(c("acetate", "methane"), c(-1, 1)) ``` -

-Use `describe.reaction()` to write the reactions on a plot: -```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=72, out.width="100%", pngquant=pngquant} +Use `describe.reaction()` to write the reactions on a plot: + +```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=dpi, out.width="100%", pngquant=pngquant} plot(0, 0, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2)) text(0, 0, "acetoclastic methanogenesis", adj=0) text(5, 1, describe.reaction(acetoclastic$reaction), adj=1) @@ -373,21 +383,21 @@ ## Affinity: not the standard state Gibbs energy -Usually, `subcrt()` returns only standard state thermodynamic properties. +Usually, `subcrt()` returns only standard state thermodynamic properties. ```{marginfigure} The standard state adopted for H2O is unit activity of the pure component at any *T* and *P*. The standard state for aqueous species is unit activity of a hypothetical one molal solution referenced to infinite dilution at any *T* and *P*. ``` Thermodynamic models often consider a non-standard state (i.e. non-unit activity). -The activities of basis species can be modified with `basis()`, and those of the other species using the `logact` argument in `subcrt()`. +The activities of basis species can be modified with `basis()`, and those of the other species using the `logact` argument in `subcrt()`. Let us calculate the chemical affinity of acetoclastic methanogenesis. ```{marginfigure} The affinity is equal to the negative of the overall (non-standard) Gibbs energy change of the reaction. ``` We begin by changing the energy units to Joules. -Then, we change the state of H2 and CO2 in the basis from `aq` (aqueous) to `gas`, and set the logarithm of fugacity of gaseous H2 and the pH, using values from @MDS_13. -The activity of acetate and fugacity of methane, as well as temperature and pressure, are set in the call to `subcrt()`: +Then, we change the state of `r h2o` and CO2 in the basis from `aq` (aqueous) to `gas`, and set the logarithm of fugacity of gaseous H2 and the pH, using values from @MDS_13. +The activity of acetate and fugacity of methane, as well as temperature and pressure, are set in the call to `subcrt()`: ```{r basis_mayumi, message=FALSE, results="hide"} E.units("J") basis(c("CO2", "H2"), "gas") @@ -419,13 +429,13 @@ } ``` -

Now we're ready to calculate and plot the affinities. -Here, we use the `lapply()` function of R to list the results at two values of logarithm of fugacity of CO2. +Here, we use R's `lapply()` to list the results at two values of logarithm of fugacity of CO2. We insert an empty reaction to get a line at zero affinity. -`do.call(rbind, Adat)` turns the list into a data frame that can be plotted with `matplot()`. +`do.call(rbind, Adat)` turns the list into a data frame that can be plotted with R's `matplot()`. There, we plot the negative affinities, equal to Gibbs energy, as shown in the plot of Mayumi et al. (2013). -```{r methanogenesis_plot, fig.margin=TRUE, fig.width=4.1, fig.height=4.1, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Gibbs energies of acetate oxidation and methanogenesis (after Mayumi et al., 2013).", cache=TRUE, pngquant=pngquant} + +```{r methanogenesis_plot, fig.margin=TRUE, fig.width=4.1, fig.height=4.1, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Gibbs energies of acetate oxidation and methanogenesis (after Mayumi et al., 2013).", cache=TRUE, pngquant=pngquant} Adat <- lapply(c(-3, 3), function(logfCO2) { basis("CO2", logfCO2) data.frame(logfCO2, @@ -441,7 +451,7 @@ legend("topleft", c("acetate oxidation", "acetoclastic methanogenesis", "hydrogenotrophic methanogenesis"), lty=1, col=2:4) ``` -```{r methanogenesis_plot, echo=TRUE, eval=FALSE} +```{r methanogenesis_plot, eval=FALSE} ``` Let't not forget to clear the system settings, which were modified by `basis()` and `E.units()`, before running other calculations: @@ -450,11 +460,11 @@ ## Activity coefficients -Example using `nonideal()` ... +XXX Example using `nonideal()` ... -# `affinity()`, species of interest, and potential diagrams +# `affinity()`, species of interest, and potential diagrams -`affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species. +`affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species. By *formation reaction* is meant the stoichiometric requirements for formation of one mole of any species from the basis species. The `species()` function is used to set these *species of interest*. @@ -471,15 +481,15 @@ species(c("H2S", "HS-", "HSO4-", "SO4-2")) ``` -Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: +Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: ```{marginfigure} -The values returned by `affinity()` are dimensionless, i.e. log10(**_A_**/*RT*). +The values returned by `affinity()` are dimensionless, i.e. log10(*A*/*RT*). ``` ```{r affinity} affinity()$values ``` -The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. +The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. Let's choose a set of variables commonly used in aqueous speciation diagrams: Eh and pH. To use Eh as a variable, the electron (`e-`) should be in the basis. To get the electron in there, we could use a different keyword (`basis("CHNOSe")`), or swap oxygen out of the existing basis: @@ -489,11 +499,10 @@ The swap.basis() changed the basis species and recalculated their activities, but preserved the species of interest. ```{marginfigure} -That is, running `affinity()$values` again would give the same result. +That is, running `affinity()``$values` again would give the same result. ``` -

-```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=72, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant} +```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant} a <- affinity(pH=c(0, 12), Eh=c(-1, 1)) diagram(a, fill="heat") ``` @@ -501,22 +510,22 @@ ```{r EhpH_plot, echo=1, eval=FALSE} ``` -Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram: +Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram: ```{r EhpH_plot_echo, eval=FALSE} diagram(a) ``` Note that the calculation of affinity implies a non-equilibrium reference state of equal activities of species (see above). -Generally, then, `diagram()` gives a *potential diagram* because it shows regions of maximum affinity. +Generally, then, `diagram()` gives a *potential diagram* because it shows regions of maximum affinity. In systems where equilibrium is attainable, it makes sense to call this a *predominance diagram*, showing regions of maximum activity. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 139 From noreply at r-forge.r-project.org Fri Feb 10 16:39:23 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 10 Feb 2017 16:39:23 +0100 (CET) Subject: [CHNOSZ-commits] r140 - in pkg/CHNOSZ: . inst inst/extdata/cpetc inst/extdata/fasta Message-ID: <20170210153923.3355A188521@r-forge.r-project.org> Author: jedick Date: 2017-02-10 16:39:22 +0100 (Fri, 10 Feb 2017) New Revision: 140 Added: pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv pkg/CHNOSZ/inst/extdata/fasta/rubisco.fasta Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS Log: svn: add new files Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-10 14:51:45 UTC (rev 139) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-10 15:39:22 UTC (rev 140) @@ -1,6 +1,6 @@ Date: 2017-02-10 Package: CHNOSZ -Version: 1.0.8-29 +Version: 1.0.8-30 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-10 14:51:45 UTC (rev 139) +++ pkg/CHNOSZ/inst/NEWS 2017-02-10 15:39:22 UTC (rev 140) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-29 (2017-02-10) +CHANGES IN CHNOSZ 1.0.8-30 (2017-02-10) --------------------------------------- DOCUMENTATION: Added: pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv 2017-02-10 15:39:22 UTC (rev 140) @@ -0,0 +1,28 @@ +ID,T1,T2,domain,species +G9FID8,0,6,E,"Phaeocystis antarctica" +M9R7V1,4,10,B,"Octadecabacter antarcticus 307" +K4MAK9,18,18,A,"Methanolobus psychrophilus" +Q12TQ0,23,23,A,"Methanococcoides burtonii" +Q9ZI34,25,30,B,"Bradyrhizobium japonicum" +P0C916,28,30,B,"Thiobacillus ferrooxidans" +P00874,30,30,E,"Zea mays" +Q0EX22,30,30,B,"Mariprofundus ferrooxydans" +L0RHZ1,35,35,B,"Desulfovibrio hydrothermalis" +Q8THG2,35,40,A,"Methanosarcina acetivorans" +F9ZLP0,45,45,B,"Acidithiobacillus caldus" +P37393,45,45,E,"Cyanidium caldarium" +P72383,45,50,B,"Sulfobacillus acidophilus" +Q51856,52,52,B,"Pseudomonas hydrogenothermophila" +Q2JIP3,50,55,B,"Synechococcus sp. (strain JA-2-3B'a(2-13))" +A0B9K9,55,60,A,"Methanosaeta thermophila" +Q8DIS5,57,57,B,"Thermosynechococcus elongatus" +G8LZL2,60,60,B,"Clostridium clariflavum" +F8IID7,65,65,B,"Bacillus acidocaldarius" +A8F7V4,65,65,B,"Thermotoga lettingae" +B9KXE5,70,70,B,"Thermomicrobium roseum" +O28635,76,76,A,"Archaeoglobus fulgidus" +Q58632,85,85,A,"Methanocaldococcus jannaschii" +A1RZJ5,85,90,A,"Thermofilum pendens" +A3DND9,85,92,A,"Staphylothermus marinus" +O58677,98,98,A,"Pyrococcus horikoshii" +Q8U1P9,100,100,A,"Pyrococcus furiosus" Added: pkg/CHNOSZ/inst/extdata/fasta/rubisco.fasta =================================================================== --- pkg/CHNOSZ/inst/extdata/fasta/rubisco.fasta (rev 0) +++ pkg/CHNOSZ/inst/extdata/fasta/rubisco.fasta 2017-02-10 15:39:22 UTC (rev 140) @@ -0,0 +1,239 @@ +>tr|A0B9K9|A0B9K9_METTP Ribulose-1,5-bisphosphate carboxylase/oxygenase large subunit OS=Methanosaeta thermophila (strain DSM 6194 / PT) GN=Mthe_1616 PE=3 SV=1 +MMQRDVVARYRVETDLPMRKAAEAIAAEQSTGTWTEVRGAESDLAASVLSIDGNTVEIEF +PVELFEPGNIPQYLSVIAGNLFGLEALKKVRLVDVDFPESLVRAHSGPKFGIEEARRIID +AYNRPLVGTIVKPKVGLNPSQTAEVAGAAVRGGLDLVKDDETLTDQKFCPMERRVEEVMA +EFDRVESETGKKAFYAVNVTTGADTILERAERAIDRGANMLMVDVLTAGFSALEALARGV +DLPIHVHRTMHGAMTRDRAHGISMLVIAKLVRMAGGTNLHTGSYVGKMASDIEENDQCRD +ALREDWYGLKRVFPVASGGIHPGKVAGNLDGYGIDCIVQAGGGVHGHPDGTTAGARAMVQ +AVEAWLSGIPVMEYAERHKELKRALERWGV +>tr|A1RZJ5|A1RZJ5_THEPD Ribulose 1,5-bisphosphate carboxylase large subunit OS=Thermofilum pendens (strain Hrk 5) GN=Tpen_1227 PE=3 SV=1 +MPEEFEPYGEFVVKSYLPDPDKDVIVTFRVTPSEGFTIEDAAGGVAAESSVGTWTTLYQW +YDKSRIDRLKGKAYYMESLGDGSYILRVAYPVELFEEGNMPAFLASVAGNIFGMRRVRSL +RVEDIYLPEAFLKHFKGPSQGVEGVRGKLKIWGRPIIGTVPKPKVGYSPEEVEKLAYEIL +VGGMDFVKDDENLAGPSYCRFEERAKAIMKAIDRAEKETGERKAWLANITADVREMERRL +KLVAELGNTHVMVDVVIAGWSSLTYVRDLAADYKLAIHGHRAFHAAFTRNPYHGVSMFTL +AKLYRIIGVDQLHVGTPEVGKLEAKAVDVIRMARLLREQTYKPDIEDGLHMQQPFPGIKP +AFPVSSGGLHPGTLPAVIKAMGVDTVIQVGGGVVGHPDGPRAGAAAARQAVEAYLEGVPL +QEYAKTHRELARALEKWGQVIPV +>tr|A3DND9|A3DND9_STAMF Ribulose bisphosphate carboxylase OS=Staphylothermus marinus (strain ATCC 43588 / DSM 3639 / F1) GN=rbcL PE=3 SV=1 +MPHKFEPYHSYIDKNYVPDLENDIIAVFRIKPAKGFTIEDAAGGVAAESSTGTWTTLYPW +YNTERVRKLSGKAYYFKDLGDGSWIVRIAYPVELFEEANMPGLLASIAGNVFGMKRVEGL +RLEDIYLPKKFLQYFKGPSKGVEGVKKIFRVTDRPIVGTVPKPKVGYSPEEVEKLAYELL +VGGMDYIKDDENLTSPSFCRFSERAKHIMRAIDRAEKETGERKVWFANITSDIREMEKRL +KLVADYDNPYVMVDVVVTGWSTLTYIRDLAEEYGLAIHAHRAMHAAFTRNPYHGISMYVL +AKLYRIIGVDQLHIGTAGVGKLEGGKIDVIRYARILREKHFKPDPDDVFHIEQEMYHIKP +AMPVSSGGLHPGNLPGVIDALGTELVLQIGGGVLGHPDGPRAGAMAVRQSLEAILKGIPL +DEYAKTHRELARALEKWGFAKPI +>tr|A8F7V4|A8F7V4_THELT Ribulose-bisphosphate carboxylase OS=Thermotoga lettingae (strain ATCC BAA-301 / DSM 14385 / TMO) GN=Tlet_1684 PE=3 SV=1 +MIEYETRYHFSQERFRVKYQIFEESKRAKEIAEAICVEQTIEFPIELTGNSIRENVVGKI +EEIQNNHNSTVVTISYPVETVGNEPAQFFNVIMGNCSLFPNLKIIGLQLSPSIENIFPGP +RYGISGLRKLLSIYNRPLLATAIKPMGLSTDQLAQMAYNLALGGVDIIKDDHGLADQPFS +KFKDRVLKVTEAIHKANRETGFHTIYAPNITSNEQTMLKQAEFVKEAGSGALLVSPALSG +FSSFITLRENTDLPILSHPAFLGGYLSIMDFDVLFGTIQRMIGADVVIFPNYGGRFTFSK +EDCRKINHGLKKPFGSFKEIFPSPAGGMNIDSCGDIVSFYNKDVVLLIGGALHKAGADLT +ENVKAFKAQVEKIHVR +>tr|B9KXE5|B9KXE5_THERP Ribulose bisphosphate carboxylase OS=Thermomicrobium roseum (strain ATCC 27502 / DSM 5159 / P-2) GN=trd_0132 PE=3 SV=1 +MSFVRATYYVETPLTLEAAAEALASEQSTGTFIAVPLETAELKARYRARIERIELIETRS +RPTLPGSRPASGSYQCGFVELAFPLENMGCNLPTLMATLAGNLFELSELSAIRLVDLDLP +DEFAQAYTGPRFGIQGTRDIAQVYDRPLIGTIIKPSVGLSPEQTAVVVRELVEAGIDFIK +DDELMANPPHNPLPARARAVMRVIRDYADRTGKYVIYAFNISDRLEDMIRHIEILVEEGA +RCCMVSLNWVGIAAFDYLRRNCPLIIHGHRNGWGMMTRAPGLGMDFRAYQKIWRLAGVDH +LHVNGLANKFWEPDDSVVRSIHDMLQPLFGGYFAMPVISSGQWGGQAPDTYRRCRTIDLL +YLAGGGIFAHPHGVAAGIRAIREAWEAAVAGISLAEYAQTHPDLAAALHHFGTARRGR +>tr|F8IID7|F8IID7_ALIAT Ribulose-bisphosphate carboxylase OS=Alicyclobacillus acidocaldarius (strain Tc-4-1) GN=mtnW PE=3 SV=1 +MVATYRLRDRKDKLEARAEGIAVGLTIGTWTDLPAARKSEVEKHCGRVEGIRVLEERPEG +DVVAEIDIAYPVANLNGTFASLLVTVFGKLSMDGEIRLERLQMPDSLVRQFPGPKFGVEG +VRQRLGAYHRPLVMSIFKACAGLTLDELVEAFGEQAEGGVDLVKDDEIFFTEAYATPEDR +VRAYAAKADEIAQRTGRRTAYAVNLTGPVHSLRERARRLADLGAGALLVNVVAYGYDVVA +DLARDPEVHVPILAHPAVSGALYGSPNYGIAADIVLGQLMRLAGADIGIFPSMYGSVTLG +REATDRLLQHLRAEGVHKPVLPAPSAGIYPGLVPRLYQDFGVDLVLNAGGGIHGHPGGAR +MGGRAFFDAIWAVEHGVPLEEAAKDRPALRQALEKWGMPS +>tr|F9ZLP0|F9ZLP0_ACICS Ribulose bisphosphate carboxylase large chain OS=Acidithiobacillus caldus (strain SM-1) GN=cbbL PE=3 SV=1 +MAGKYEAGVKEYRHTYWAPDYVPLDSDILACFKIVPQPGVDREEAAAAVAAESSTGTWTT +VWTDLLTDMDYYKGRAYRIEDVPGDDTAFYAFIAYPIDLFEEGSVVNVFTSLVGNVFGFK +AVRSLRLEDVRFPLHYVMTCNGPAHGIQVERDKMDKYGRPLLGCTIKPKLGLSAKNYGRA +VYEALRGGLDFTKDDENVNSQPFMRWRDRFLFVADAIRNAEAQTGERKGHYLNVTAPSPE +EMYERAEFAKELGMPIIMHDFLTGGFCANTGLARWCRKNGVLLHIHRAMHAVIDRNPHHG +IHFRVLTKALRLSGGDHLHTGTVVGKLEGDRASTLGWIDLLRESYIPEDRSRGIFFDQDW +GSMPGAFAVASGGIHVWHMPALVNIFGDDSVLQFGGGTLGHPWGNAAGAAANRVALEACV +EARNRGVEIEKEGKEVLMNAARHSPELKIALETWKEIKFEFDTVDKLDVQNR +>tr|G8LZL2|G8LZL2_CLOCD Ribulose 1,5-bisphosphate carboxylase, large subunit OS=Clostridium clariflavum (strain DSM 19732 / NBRC 101661 / EBR45) GN=Clocl_1256 PE=3 SV=1 +MFFSEYKEPKLSGERFSVIYKLSGNEKEAYEKAKDLCLEQTVEFPGELLPDGAIRDSIVG +RIESFKKHDSMHYMATVSYAVETSSNELTQLLNVVFGNSSIKPGIRVEKLLLSDVILKNF +KGPRFGRDGLREYLGIKNRPLLFTALKPMGLSSEALADLAYKFALGGIDLIKDDHGLSNQ +SFSPFEERVELCVNAINKANRETGGKSVYVPNITAPFSEMVDRARKAKELGAGGLLISPG +LAGFDAMREISEDENINLPVFSHPAFLGTFVMSNETGISHGALLGQIMRLAGADATIYPN +FGGRFSFSREECESIAVCTSEKMGNLKPIFPCPAGGMSLGSIPESLKVYGKDVIFLVGGG +LFRHGPNLIENCAYFRKLIENIDLKEIF +>tr|G9FID8|G9FID8_9EUKA Ribulose bisphosphate carboxylase large chain OS=Phaeocystis antarctica GN=rbcL PE=3 SV=1 +MSQAVESRTRIKSERYESGVIPYAKMGYWDPDYAIKETDILALFRCTPQPGVDPVEAGAA +LAGESSTATWTVVWTDLLTACDLYRAKAYRVDPVPSTPDTYFVYVAYDLDLFEEGSLANL +TASIIGNIFGFKAVKALRLEDMRMPVALLKTYQGPACGLIVERERMDKFGRPLLGATVKP +KLGLSGKNYGRVVFEGLKGGLDFLKDDENINSQPFMRYRERFLYSMEGVNHAAATSGEIK +GHYLNSTAATMEDMYERAEFAVELGSVIVMIDLVIGYTAIQSMAKWCRKVDCILHLHRAG +NSTYSRQKNHGMNFRVICKWMRMAGVDHIHAGTVVGKLEGDPLMIKGFYNTLLDFKSDIN +LPCGMFFAQDWASLRKCVPVASGGIHCGQMHQLIDYLGDDVILQFGGGTIGHPDGIQAGA +TANRVALECMVLARNEGRDYVAEGPQILRDAAKTCGPLQTALDLWKDITFNYASTDTADF +VETATANR +>tr|K4MAK9|K4MAK9_9EURY Ribulose bisphosphate carboxylase OS=Methanolobus psychrophilus R15 GN=Mpsy_0328 PE=3 SV=1 +MSLTEEQLVQSLNPKQQGYVDLKLADPRNGEYLLGVFHLVPEGRLNMLQTAAEVAAESST +GTNFKVNTETPFSKVMNALVYQLDLERDLVWIAYPWRLFDRGGNVQNILTYIVGNILGMK +EVKALKLMDVWFPPSMLEQYDGPSYTVDDMRKYLGVYNRPILGTIVKPKMGLTSAEYAEV +CYDFWVGGGDFVKNDEPQANQDFCPYDKMVKHVKEAMDKAVKETGKKKVHSFNVSAADFD +TMIKRCEMIVNAGFEPGSYAFLIDGITAGWMAVQTLRRRYPGVFIHFHRAGHGAFTRPEN +PLGFSVLVLSKFARLAGASGIHTGTAGVGKMKGTPQEDVVAANGILYLRSKGHFFDQSWS +KIPDLDKDVIALVNEDTAHHAILEDDSWRAMKKCCPIVSGGLNPIRLKPFIDVMGNVDFI +TTMGSGVHAHPGGTQGGAKALVQACEAYLKNMDIEQYAKDHEELAQAIEYFSKASKDAM +>tr|L0RHZ1|L0RHZ1_9DELT Ribulose bisphosphate carboxylase OS=Desulfovibrio hydrothermalis AM13 = DSM 14728 GN=cbbM PE=3 SV=1 +MSQYDQTSRYANFDLKEDQLIADGNHVLCAYIFKPAEGHGHIEVAAHFAAESSTGTNVEV +CTTDDFTKGVDALVYEVSEAKDGDYLMKIAYPVELFDRNIIDGRAMLASFLTLCIGNNQG +MGDVAYAKMYDFYVPRQYLELFDGPAKNIADFWRMLGRPMENGGMIVGTIVKPKLGLRPG +PFADACYKFWLGGDFVKNDEPQGNQVFAPLKETITAVADAMKRAQDETGEAKVFSANITA +DDPMEMIARGEFILDAFGEDASRVAFLVDGYVAGPTSITTARRNFPNQFLHYHRAGHGAV +TSPQAKRGYTAFVLSKMSRLQGASGIHTGTMGFGKMEGEMADKNIAYMIEREEAQGPYFK +QKWYGMKATTPMISGGMNALRLPGFFENLGHSNICQTSGGGAFGHLDGPTAGAISLRQSH +EAWQQGVDLVEYAKAHKELARAFESFPQDADKFYPDWRKQLSL +>tr|M9R7V1|M9R7V1_9RHOB Ribulose bisphosphate carboxylase-like protein OS=Octadecabacter antarcticus 307 GN=OAN307_c00690 PE=4 SV=1 +MTRLTATYEIESPVGVQRAAEVMAGEQSTGTFVRLASETDALRDRSAARLDHVDITGTSE +HPALPCRLSAETYEQGRVTISWPMDNFGPSLPNILATVAGNLFELAELSAIRLVDLGIPD +ALAKGCPGPQFGITGTRKLMGVPSGPMIGTIIKPSVGLSAEQTAALAGDLAQAGIDFIKD +DELQGNGPACPFDGRAKLVMDVLNEAAQKAGRKVMYAFNITDEIDVMRRNIDLLESLGAT +CAMVSLNSIGLAGLRAIRDHSPLPIHAHRNGWGLMSRSPHVGIKYLAMQKLWRLAGSDHL +HVNGLGNKFTEGDTVVTNAARAVQAPLNGATPHAALPVFSSGQTAWQVGPSMELLGNDDF +LFCAGGGIMSHPYGPAVGITSLRQAAAAQKAGEKVEDYAKDHPELAAALTTFKSAVNRS +>sp|O28635|RBL_ARCFU Ribulose bisphosphate carboxylase OS=Archaeoglobus fulgidus (strain ATCC 49558 / VC-16 / DSM 4304 / JCM 9628 / NBRC 100126) GN=rbcL PE=1 SV=1 +MAEFEIYREYVDKSYEPQKDDIVAVFRITPAEGFTIEDAAGAVAAESSTGTWTSLHPWYD +EERVKGLSAKAYDFVDLGDGSSIVRIAYPSELFEPHNMPGLLASIAGNVFGMKRVKGLRL +EDLQLPKSFLKDFKGPSKGKEGVKKIFGVADRPIVGTVPKPKVGYSAEEVEKLAYELLSG +GMDYIKDDENLTSPAYCRFEERAERIMKVIEKVEAETGEKKSWFANITADVREMERRLKL +VAELGNPHVMVDVVITGWGALEYIRDLAEDYDLAIHGHRAMHAAFTRNAKHGISMFVLAK +LYRIIGIDQLHIGTAGAGKLEGQKWDTVQNARIFSEVEYTPDEGDAFHLSQNFHHIKPAM +PVSSGGLHPGNLEPVIDALGKEIVIQVGGGVLGHPMGAKAGAKAVRQALDAIISAIPLEE +HAKQHPELQAALEKWGRVTPI +>sp|O58677|RBL_PYRHO Ribulose bisphosphate carboxylase OS=Pyrococcus horikoshii (strain ATCC 700860 / DSM 12428 / JCM 9974 / NBRC 100139 / OT-3) GN=rbcL PE=1 SV=1 +MMVLRMKVEWYLDFVDLNYEPGRDELIVEYYFEPNGVSPEEAAGRIASESSIGTWTTLWK +LPEMAKRSMAKVFYLEKHGEGYIAKIAYPLTLFEEGSLVQLFSAVAGNVFGMKALKNLRL +LDFHPPYEYLRHFKGPQFGVQGIREFMGVKDRPLTATVPKPKMGWSVEEYAEIAYELWSG +GIDLLKDDENFTSFPFNRFEERVRKLYRVRDRVEAETGETKEYLINITGPVNIMEKRAEM +VANEGGQYVMIDIVVAGWSALQYMREVTEDLGLAIHAHRAMHAAFTRNPRHGITMLALAK +AARMIGVDQIHTGTAVGKMAGNYEEIKRINDFLLSKWEHIRPVFPVASGGLHPGLMPELI +RLFGKDLVIQAGGGVMGHPDGPRAGAKALRDAIDAAIEGVDLDEKAKSSPELKKSLREVG +LSKAKVGVQH +>sp|P00874|RBL_MAIZE Ribulose bisphosphate carboxylase large chain OS=Zea mays GN=rbcL PE=3 SV=2 +MSPQTETKASVGFKAGVKDYKLTYYTPEYETKDTDILAAFRVTPQLGVPPEEAGAAVAAE +SSTGTWTTVWTDGLTSLDRYKGRCYHIEPVPGDPDQYICYVAYPLDLFEEGSVTNMFTSI +VGNVFGFKALRALRLEDLRIPPAYSKTFQGPPHGIQVERDKLNKYGRPLLGCTIKPKLGL +SAKNYGRACYECLRGGLDFTKDDENVNSQPFMRWRDRFVFCAEAIYKAQAETGEIKGHYL +NATAGTCEEMIKRAVFARELGVPIVMHDYLTGGFTANTTLSHYCRDNGLLLHIHRAMHAV +IDRQKNHGMHFRVLAKALRMSGGDHIHSGTVVGKLEGEREITLGFVDLLRDDFIEKDRSR +GIFFTQDWVSMPGVIPVASGGIHVWHMPALTEIFGDDSVLQFGGGTLGHPWGNAPGAAAN +RVALEACVQARNEGRDLAREGNEIIKAACKWSAELAAACEIWKEIKFDGFKAMDTI +>sp|P0C916|RBL1A_THIFE Ribulose bisphosphate carboxylase large chain 1 OS=Thiobacillus ferrooxidans GN=cbbL1 PE=3 SV=1 +MAVKTYEAGVKDYRQTYWAPEYVPLDSDILACFKITPQPGVDREEAAAAVAAESSTGTWT +TVWTDLLTDMDYYKGRAYRIEDVPGDDTCFYAFVAYPIDLFEEGSVVNVFTSLVGNVFGF +KAVRALRLEDVRFPLAYVKTCNGPPHGIQVERDKMNKYGRPMLGCTIKPKLGLSAKNYGR +AVYECLRGGLDFTKDDENVNSQPFIAWRDRFLFVADAIHTAEAETGERKGHYLNVTAPSP +EEMYERAEFAKELNMPIIMHDFLTGGFCANTGLARWCRKNGVLLHIHRAMHAVVDRNPHH +GIHFRVLAKALRLSGGDHLHTGTVVGKLEGDRAATQGWVDLLRESFVPEDAGRGIFFDQD +WGSMPGVFAVASGGIHVWHMPALLAIFGDDAIFQFGGGTLGHPWGNAAGAAANRVALEAC +VEARNEGRDLEREGKDILTNAAKDSPELKIALETWKEIKFEFDTVDKLDVVNR +>sp|P37393|RBL_CYACA Ribulose bisphosphate carboxylase large chain OS=Cyanidium caldarium GN=rbcL PE=3 SV=2 +MAQSVQERTRLKNKRYESGVIPYAKMGYWDPNYVVKDTDILALFRVTPQPGVDPIEASAA +VAGESSTATWTVIWCDLLTACDVYRAKAYRVDQVPNSPDQYFAYIAYDLDLFEEGSIANL +TASIIGNVFGFKALAALRLEDMRIPIGYLKTFQGPATGVVVERERLNMFGKPFLGATVKP +KLGLSSKNYGRVVYEGLKGGLNFLKDDENINSQPFMRWRERFLYVMEGVNRASAATGEIK +GSYLNVTAATMEEMYNRAACAKEVGSIIIMIDLVIGYTAIQSMAIWARENNMILHLHRAG +NSTYARQKNHGINFRVICKWMRMAGVDHIHAGTVVGKLEGDPIIVKGFYNTLLLPKLDVN +LPQGLFFEMDWASLRKTVPVASGGIHAGQMHLLLKYLGDDVVLQFGGGTLGHPDGIQAGA +TANRVALEAIVLARNEGRDYVNEGPQILKEAARTCGPLQTSLDLWKDISFNFTSTDTADF +VETPTANV +>tr|P72383|P72383_9FIRM Ribulose bisphosphate carboxylase large chain OS=Sulfobacillus acidophilus GN=cbbL PE=3 SV=2 +MTTEENKNRWAAGVTPYSKMGYWQPDYQPKDTDILCAFRFVPQEGVDPEEAAAAVAGESS +TATWTVVWTDRLTAHEHYQAKAYRVVPVPGTDQYIAYIAYDLDLFEEGSIANLTASIIGN +VFGFKALKSLRLEDMRIPPHYVKTFQGPAHGIVMEREYLNKYGRPLLGATVKPKLGLSAR +NYARVVYEALRGGLDFTKDDENINSQPFMRWRDRYLFVMEAVNKATADTGEIKGHYLNVT +AATMEDIYERADFAKQIGSPIIMIDLIVGYTAIQSIAKWARKNGVLLHLHRAGHSTYTRQ +KTHGVSFRVIAKWMRLAGVDHIHAGTVLGKLEGDPRTTAGYYQTLRGMKYDADPTIGLYF +EQDWASLPGVMPVASGGIHAGQMHQLIDLLGEDVVLQFGGGTFGHPHGIAAGAAANRIAC +EAIIQARNEGRDYVNEGPEILAEAAKWSPALRAALDTWKDVTFNFESTDTPDVLPTPSF +>tr|Q0EX22|Q0EX22_9PROT Ribulose bisphosphate carboxylase large chain OS=Mariprofundus ferrooxydans PV-1 GN=rbcL PE=3 SV=1 +MAVKTYQAGVKDYRETYWMPEYKLKDTDFLACFKITPQAGVPREEAAAAVAAESSTGTWT +TVWTDLLTDLDYYKGRAYAIEDVPGDDEAFYAFIAYPIDLFEEGSVVNVLTSLVGNVFGF +KAVRALRLEDVRIPLAYVMTCNGPPHGIQVERDKMNKYGRPLLGCTIKPKLGLSAKNYGR +ACYEGLRGGLDFTKDDENVNSQPFMRWRQRFDFVMEAIHKAEAETGERKGHYLNVTAPTP +EEMYKRAEYAKELGAPIIMHDYLTGGFTANTGLAQWCRDNGMLLHIHRAMHAVLDRNPRH +GIHFRVLTKMLRLSGGDHLHSGTVVGKLEGDRDATLGWIDLMRDSFVKEDRSRGIMFDQD +WGSMPGVLPVASGGIHVWHMPALVNIFGDDSVLQFGGGTLGHPWGNAAGAAANRVAVEAC +VEARNQGRALEKEGKDILTTAAESSPELKIAMETWKEIKFEFDTVDKLDVAHK +>tr|Q12TQ0|Q12TQ0_METBU Ribulose-1,5-bisphosphate carboxylase-oxygenase type III OS=Methanococcoides burtonii (strain DSM 6242) GN=Mbur_2322 PE=3 SV=1 +MSLIYEDLVKSLDSKQQAYVDLKLPDPTNGEFLLAVFHMIPGGDLNVLQAAAEIAAESST +GTNIKVSTETAFSRTMNARVYQLDLERELVWIAYPWRLFDRGGNVQNILTYIIGNILGMK +EIQALKLMDIWFPPSMLEQYDGPSYTVDDMRKYLDVYDRPILGTIVKPKMGLTSAEYAEV +CYDFWVGGGDFVKNDEPQANQDFCPYEKMVAHVKEAMDKAVKETGQKKVHSFNVSAADFD +TMIERCEMITNAGFEPGSYAFLIDGITAGWMAVQTLRRRYPDVFLHFHRAAHGAFTRQEN +PIGFSVLVLSKFARLAGASGIHTGTAGIGKMKGTPAEDVVAAHSIQYLKSPGHFFEQTWS +KIMDTDKDVINLVNEDLAHHVILEDDSWRAMKKCCPIVSGGLNPVKLKPFIDVMENVDFI +TTMGSGVHSHPGGTQSGAKALVQACDAYLQGMDIEEYAKDHKELAEAIEFYLNR +>sp|Q2JIP3|RBL_SYNJB Ribulose bisphosphate carboxylase large chain OS=Synechococcus sp. (strain JA-2-3B'a(2-13)) GN=cbbL PE=3 SV=1 +MAYSATQSKSGYQAGVKDYRLTYYTPDYTPKDTDVLACFRVTPQPGVPPEEAGAAVAAES +STGTWTTVWTDLLTDLDRYKGRCYDIEPVPGEDNQYFCFVAYPLDLFEEGSVTNMLTSIV +GNVFGFKALKALRLEDVRIPVAYLKTFQGPPHGIQVERDKLNKYGRPLLGCTIKPKLGLS +AKNYGRAVYEALRGGLDFTKDDENINSQPFQRWRDRYLFVMEAVHKAQAETGEIKGHYLN +VTAPTCEEMFKRAEFAKELGAPIIMHDYLTAGFTANTSLAKWCRDNGILLHIHRAMHAVI +DRQKNHGIHFRVLAKCLRMSGGDHLHSGTVVGKLEGDRAITMGFVDLMRENYVEADRSRG +IFFTQDWASMPGVMPVASGGIHVWHMPALVEIFGDDSVLQFGGGTLGHPWGNAPGATANR +VALEACIQARNEGRDLAREGNDIIREAAKWSPELAAACELWKEIKFEFKAVDTL +>sp|Q51856|RBL_PSEHY Ribulose bisphosphate carboxylase large chain OS=Pseudomonas hydrogenothermophila GN=cbbL PE=3 SV=1 +MSQPKRYEAGVKEYRETYWEPTYVPKDSDFLAVFKIVPQPGVPREESAAAVAAESSTATW +TTVWTDLLTDLYYYKGRAYAIEDVPGDDEAFYAFIAYPMGLFEEGSVVNVFTSLVGNVFG +FKAVRSLRLEDVRIPLWFVTTCPGPPHGIYVERDKLNKYGRPLLGCTIKPKLGLSAKNYG +RAVYECLRGGLDFTKDDENVNSQPFMRWRDRFLFCQEAIEKAQAETGERKGHYMNVTGPT +MEEIYKRAEFAKEIGTPIIMIDYLTVGWAATQSLSKWCRDNGMLLHVHRAMHAVIDRNPK +HGINFRVLAKIMRLIGGDHLHSGTVVGKLEGDRAATLGWIDLMRDRYVKADRSRGIFFDQ +DWGQMPGMFPVASGGIHVWHMPALVSIFGDDSVLQFGGGTIGHPWGNAAGACANRVALEA +CVKARNEGLPIEKMGREILTEAAKSCPELKVAMETWKEVKFDFDTVDKLDVQHR +>sp|Q58632|RBL_METJA Ribulose bisphosphate carboxylase OS=Methanocaldococcus jannaschii (strain ATCC 43067 / DSM 2661 / JAL-1 / JCM 10045 / NBRC 100440) GN=rbcL PE=1 SV=2 +MDYINLNYRPNEGDLLSCMVIKGENLEKLANEIAGESSIGTWTKVQTMKSDIYEKLRPKV +YEIKEIGEENGYKVGLIKIAYPLYDFEINNMPGVLAGIAGNIFGMKIAKGLRILDFRFPA +EFVKAYKGPRFGIEGVRETLKIKERPLLGTIVKPKVGLKTEEHAKVAYEAWVGGVDLVKD +DENLTSQEFNKFEDRIYKTLEMRDKAEEETGERKAYMPNITAPYREMIRRAEIAEDAGSE +YVMIDVVVCGFSAVQSFREEDFKFIIHAHRAMHAAMTRSRDFGISMLALAKIYRLLGVDQ +LHIGTVVGKMEGGEKEVKAIRDEIVYDKVEADNENKFFNQDWFDIKPVFPVSSGGVHPRL +VPKIVEILGRDLIIQAGGGVHGHPDGTRAGAKAMRAAIEAIIEGKSLEEKAEEVAELKKA +LEYWK +>sp|Q8DIS5|RBL_THEEB Ribulose bisphosphate carboxylase large chain OS=Thermosynechococcus elongatus (strain BP-1) GN=cbbL PE=1 SV=1 +MAYTQSKSQKVGYQAGVKDYRLTYYTPDYTPKDTDILAAFRVTPQPGVPFEEAAAAVAAE +SSTGTWTTVWTDLLTDLDRYKGCCYDIEPLPGEDNQFIAYIAYPLDLFEEGSVTNMLTSI +VGNVFGFKALKALRLEDLRIPVAYLKTFQGPPHGIQVERDKLNKYGRPLLGCTIKPKLGL +SAKNYGRAVYECLRGGLDFTKDDENINSQPFQRWRDRFLFVADAIHKAQAETGEIKGHYL +NVTAPTCEEMLKRAEFAKELEMPIIMHDFLTAGFTANTTLSKWCRDNGMLLHIHRAMHAV +MDRQKNHGIHFRVLAKCLRMSGGDHIHTGTVVGKLEGDKAVTLGFVDLLRENYIEQDRSR +GIYFTQDWASMPGVMAVASGGIHVWHMPALVDIFGDDAVLQFGGGTLGHPWGNAPGATAN +RVALEACIQARNEGRDLMREGGDIIREAARWSPELAAACELWKEIKFEFEAQDTI +>sp|Q8THG2|RBL_METAC Ribulose bisphosphate carboxylase OS=Methanosarcina acetivorans (strain ATCC 35395 / DSM 2834 / JCM 12185 / C2A) GN=rbcL PE=1 SV=1 +MRRDYVDPGYSPKDTDLICEFHIEPAAGISFEEASTHMAGESSIDSWTEISTLSPELAAR +LKPHVFYLDADTQTVRVAYSEDLFELGSVPQVLSAVAGNIFSMKIVDNLRLQDITFPKSM +LREFEGPNFGLPGVRDIVGVKDRPLVGTIVKPKVGLTSEMHAEVAYNAFAGGCDLVKDDE +NLTDQKFNGFEKRAELTLKIAEKAEAETGERKMYLCNITAPTCEEMIRRLHVLKDLGASY +AMIDIVPTGWTALQTLREAAADEGLALHAHRCMHSAFTRNPRHGVSMLLVAKLCRLIGLD +QLHIGTVVGKMHGDKDEVLSIRDECVLDTVPADPEQHVLAQDWGGLKPMFPVASGGLAPT +MIPDLYSIFGKEVIMQFGGGIHAHPMGTAAGAAACRQALEASLEGISLQDYAKDHKELEA +ALGKWLEK +>sp|Q8U1P9|RBL_PYRFU Ribulose bisphosphate carboxylase OS=Pyrococcus furiosus (strain ATCC 43587 / DSM 3638 / JCM 8422 / Vc1) GN=rbcL PE=3 SV=1 +MKVEWYLDFVDLDYTPGRDELIVEYYFEPNGVSPEEAAGRIASESSIGTWTTLWKMPEMA +KRSMAKVFYLEKSGEGYIAKIAYPLTLFEEGSIVQLLSAIAGNIFGMKALKNLRLLDFHP +PYEYLRHFKGPQYGVKGIREFMGVKERPLTATVPKPKMGWSVDEYAEIAYELWSGGIDLL +KDDENFTSFPFNRFEERVKKLYRIRDIVEAETEERKEYLINITGSVDVMEKRAELVANEG +GQYVMIDIIVTGWSALQYMREVTEDLGLAIHAHRAMHAAFTRNPKHGITMYAIAKLARMI +GVDQIHTGTAVGKMAGDYEEVKRINDFLLSKWEHIREVFPVASGGLHPGLMPELIRLFGK +DLVIQAGGGVMGHPDGPRAGAKALRDAIDAALEGVDLEEKAKSSPELKKALDKWGYLKPK +>sp|Q9ZI34|RBL_BRAJA Ribulose bisphosphate carboxylase large chain OS=Bradyrhizobium japonicum (strain USDA 110) GN=cbbL PE=1 SV=1 +MNAHTGTVRGKERYRSGVMEYKRMGYWEPDYTPKDTDVIALFRVTPQEGVDPIEASAAVA +GESSTATWTVVWTDRLTAAEKYRAKCHRVDPVPGTPGSYFAYIAYDLDLFEPGSIANLSA +SIIGNVFGFKPLKALRLEDMRFPVAYVKTFQGPATGIVVERERLDKFGRPLLGATVKPKL +GLSGRNYGRVVYEALKGGLDFTKDDENINSQPFMHWRDRFLYCIEAVNRAQAASGEVKGT +YLNITAGTMEDMYERAEFAKELGSCIVMIDLVIGYTAIQSMAKWARRNDMILHLHRAGHS +TYTRQKSHGVSFRVIAKWMRLAGVDHIHAGTVVGKLEGDPNTTRGYYDVCREDFNPTKLE +HGLFFDQSWASLNKMMPVASGGIHAGQMHQLLDLLGEDVVLQFGGGTIGHPMGIAAGAIA +NRVALEAMILARNEGRDYVHEGPEILAKAAQTCTPLKSALEVWKDVTFNYQSTDTPDFVP +TALETV From noreply at r-forge.r-project.org Sat Feb 11 05:34:20 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 11 Feb 2017 05:34:20 +0100 (CET) Subject: [CHNOSZ-commits] r141 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes Message-ID: <20170211043421.295611887F8@r-forge.r-project.org> Author: jedick Date: 2017-02-11 05:34:19 +0100 (Sat, 11 Feb 2017) New Revision: 141 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/iprotein.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/R/util.fasta.R pkg/CHNOSZ/demo/bugstab.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/iprotein.Rd pkg/CHNOSZ/man/util.fasta.Rd pkg/CHNOSZ/tests/testthat/test-iprotein.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/hotspring.Rnw pkg/CHNOSZ/vignettes/hotspring.lyx Log: anintro.Rmd: add proteins: adding proteins Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-11 04:34:19 UTC (rev 141) @@ -1,6 +1,6 @@ -Date: 2017-02-10 +Date: 2017-02-11 Package: CHNOSZ -Version: 1.0.8-30 +Version: 1.0.8-31 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/R/basis.R 2017-02-11 04:34:19 UTC (rev 141) @@ -94,7 +94,7 @@ # to load a preset basis definition by keyword preset.basis <- function(key=NULL) { # the available keywords - basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "CEQ") + basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "QEC") # just list the keywords if none is specified if(is.null(key)) return(basis.key) # delete any previous basis definition @@ -109,7 +109,7 @@ else if(ibase==5) species <- c("Mg+2", "CO2", "H2O", "NH3", "H3PO4", "H2S", "e-", "H+") else if(ibase==6) species <- c("Fe2O3", "CO2", "H2O", "NH3", "H2S", "oxygen") else if(ibase==7) species <- c("Fe2O3", "CO2", "H2O", "NH3", "H2S", "oxygen", "H+") - else if(ibase==8) species <- c("cysteine", "glutamic acid", "glutamine", "H2O", "oxygen") + else if(ibase==8) species <- c("glutamine", "glutamic acid", "cysteine", "H2O", "oxygen") # get the preset logact logact <- preset.logact(species) # load the species and return the result Modified: pkg/CHNOSZ/R/iprotein.R =================================================================== --- pkg/CHNOSZ/R/iprotein.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/R/iprotein.R 2017-02-11 04:34:19 UTC (rev 141) @@ -104,6 +104,8 @@ } seq2aa <- function(protein, sequence) { + # remove newlines and whitespace + sequence <- gsub("\\s", "", gsub("[\r\n]", "", sequence)) # make a data frame from counting the amino acids in the sequence caa <- count.aa(sequence) colnames(caa) <- aminoacids(3) @@ -112,7 +114,7 @@ ip <- suppressMessages(iprotein(protein)) # now make the data frame po <- strsplit(protein, "_")[[1]] - aa <- data.frame(protein=po[1], organism=po[2], ref=NA, abbrv=NA) + aa <- data.frame(protein=po[1], organism=po[2], ref=NA, abbrv=NA, stringsAsFactors=FALSE) aa <- cbind(aa, chains=1, caa) return(aa) } @@ -149,10 +151,10 @@ return(out) } -read.aa <- function(file="protein.csv") { +read.aa <- function(file="protein.csv", ...) { # 20090428 added colClasses here # 20140128 added as.is=TRUE (in case numeric values are stored in ref or abbrv column) - aa <- read.csv(file, colClasses=c(rep("character", 2), NA, NA, rep("numeric", 21)), as.is=TRUE) + aa <- read.csv(file, colClasses=c(rep("character", 2), NA, NA, rep("numeric", 21)), as.is=TRUE, ...) if(!identical(colnames(aa), colnames(get("thermo")$protein))) stop(paste("format of", file, "is incompatible with thermo$protein")) return(aa) Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/R/util.expression.R 2017-02-11 04:34:19 UTC (rev 141) @@ -74,7 +74,7 @@ if(property=="pH") return("pH") if(property=="pe") return("pe") if(property=="IS") return("IS") - if(property=="ZC") return(quote(bar(italic(Z))[C])) + if(property=="ZC") return(quote(italic(Z)[C])) # process each character in the property abbreviation prevchar <- character() for(i in 1:length(propchar)) { Modified: pkg/CHNOSZ/R/util.fasta.R =================================================================== --- pkg/CHNOSZ/R/util.fasta.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/R/util.fasta.R 2017-02-11 04:34:19 UTC (rev 141) @@ -44,12 +44,12 @@ return(as.numeric(out)) } -read.fasta <- function(file, i=NULL, ret="count", lines=NULL, ihead=NULL, +read.fasta <- function(file, iseq=NULL, ret="count", lines=NULL, ihead=NULL, start=NULL, stop=NULL, type="protein", id=NULL) { # read sequences from a fasta file # some of the following code was adapted from # read.fasta in package seqinR - # value of 'i' is what sequences to read + # value of 'iseq' is what sequences to read (default is all) # value of 'ret' determines format of return value: # count: amino acid composition (same columns as thermo$protein, can be used by add.protein) # or nucleic acid base composition (A-C-G-T) @@ -80,28 +80,20 @@ linefun <- function(i1,i2) lines[i1:i2] } # identify the lines that begin and end each sequence - if(is.null(i)) { - i <- ihead - begin <- i + 1 - end <- i - 1 - end <- c(end[-1], nlines) - } else { - begin <- i + 1 - iend <- match(i,ihead) - # we have to be careful about the last record - iend[iend==ihead[length(ihead)]] <- NA - end <- ihead[iend+1] - 1 - end[is.na(end)] <- nlines - } + begin <- ihead + 1 + end <- ihead - 1 + end <- c(end[-1], nlines) + # use all or selected sequences + if(is.null(iseq)) iseq <- seq_along(begin) # just return the lines from the file if(ret=="fas") { iline <- numeric() - for(i in 1:length(begin)) iline <- c(iline,(begin[i]-1):end[i]) + for(i in iseq) iline <- c(iline,(begin[i]-1):end[i]) return(lines[iline]) } # get each sequence from the begin to end lines seqfun <- function(i) paste(linefun(begin[i],end[i]),collapse="") - sequences <- lapply(1:length(i), seqfun) + sequences <- lapply(iseq, seqfun) # organism name is from file name # (basename minus extension) bnf <- strsplit(basename(file),split=".",fixed=TRUE)[[1]][1] @@ -109,9 +101,9 @@ # protein/gene name is from header line for entry # (strip the ">" and go to the first space) missid <- missing(id) - if(is.null(id)) id <- as.character(palply("", 1:length(i), function(j) { + if(is.null(id)) id <- as.character(palply("", iseq, function(j) { # get the text of the line - f1 <- linefun(i[j],i[j]) + f1 <- linefun(ihead[j],ihead[j]) # stop if the first character is not ">" # or the first two charaters are "> " if(substr(f1,1,1)!=">" | length(grep("^> ",f1)>0)) Modified: pkg/CHNOSZ/demo/bugstab.R =================================================================== --- pkg/CHNOSZ/demo/bugstab.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/demo/bugstab.R 2017-02-11 04:34:19 UTC (rev 141) @@ -4,8 +4,8 @@ # resolution for plots res <- 500 -# basis can be "AA" or "CHNOS" -basis <- "AA" +# basis can be "QEC" or "CHNOS" +basis <- "QEC" layout(cbind(matrix(sapply(list(c(1, 2), c(3, 4)), function(x) rep(rep(x, each=3), 3)), nrow=6, byrow=TRUE), matrix(rep(c(0, 5, 5, 5, 5, 0), each=4), nrow=6, byrow=TRUE))) par(mar=c(3.3, 3.3, 1.5, 1.5), mgp=c(2.1, 0.7, 0), xaxs="i", yaxs="i", las=1, cex=0.9) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/inst/NEWS 2017-02-11 04:34:19 UTC (rev 141) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-30 (2017-02-10) +CHANGES IN CHNOSZ 1.0.8-31 (2017-02-11) --------------------------------------- DOCUMENTATION: @@ -25,8 +25,8 @@ - For the `groups` argument in diagram(), activities are multiplied by the balance coefficients before the summation. -- Add "CEQ" as a keyword for preset species in basis() (cysteine, - glutamic acid, glutamine, H2O, oxygen). +- Add "QEC" as a keyword for preset species in basis() (glutamine, + glutamic acid, cysteine, H2O, oxygen). - More flexible parsing of chemical formulas for ZC() and other functions; e.g. `ZC(colMeans(protein.formula(1:4)))` now works. @@ -49,6 +49,15 @@ marks and lines; this is used in diagram() to redraw the axes on filled diagrams. +- Add `...` argument to read.aaa() (additional arguments for + read.csv()). + +- seq2aa() removes newlines and whitespace before counting the + letters in the sequence. + +- read.fasta(): change argument `i` to `iseq`; this is used to select + particular sequences to read from the file. + CLEANUP AND BUG FIXES: - subcrt() returns `loggam` using the common logarithm; add Modified: pkg/CHNOSZ/man/iprotein.Rd =================================================================== --- pkg/CHNOSZ/man/iprotein.Rd 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/man/iprotein.Rd 2017-02-11 04:34:19 UTC (rev 141) @@ -17,7 +17,7 @@ aa2eos(aa, state=get("thermo")$opt$state) seq2aa(protein, sequence) aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) - read.aa(file = "protein.csv") + read.aa(file = "protein.csv", ...) add.protein(aa) } @@ -31,6 +31,7 @@ \item{abundance}{numeric, abundances of proteins} \item{average}{logical, return the weighted average of amino acid counts?} \item{file}{character, path to file with amino acid compositions} + \item{...}{additional arguments passed to \code{\link{read.csv}}} } \details{ Modified: pkg/CHNOSZ/man/util.fasta.Rd =================================================================== --- pkg/CHNOSZ/man/util.fasta.Rd 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/man/util.fasta.Rd 2017-02-11 04:34:19 UTC (rev 141) @@ -13,7 +13,7 @@ \usage{ grep.file(file, pattern = "", y = NULL, ignore.case = TRUE, startswith = ">", lines = NULL, grep = "grep") - read.fasta(file, i = NULL, ret = "count", lines = NULL, + read.fasta(file, iseq = NULL, ret = "count", lines = NULL, ihead = NULL, start=NULL, stop=NULL, type="protein", id = NULL) count.aa(seq, start=NULL, stop=NULL, type="protein") uniprot.aa(protein, start=NULL, stop=NULL) @@ -27,7 +27,7 @@ \item{startswith}{character, only lines starting with this expression are matched} \item{lines}{list of character, supply the lines here instead of reading them from file} \item{grep}{character, name of system \samp{grep} command} - \item{i}{numeric, line numbers of sequence headers to read} + \item{iseq}{numeric, which sequences to read from the file} \item{ret}{character, specification for type of return (count, sequence, or FASTA format)} \item{ihead}{numeric, which lines are headers} \item{start}{numeric, position in sequence to start counting} @@ -48,7 +48,7 @@ If the lines from the file were obtained in a preceding operation, they can be supplied to this function in the \code{lines} argument. \code{read.fasta} is used to retrieve entries from a FASTA file. -To read only selected sequences pass the line numbers of the header lines to the function in \code{i} (they can be identified using e.g. \code{grep.file}). +Use \code{iseq} to select the sequences to read (the default is all sequences). The function returns various formats depending on the value of \code{ret}. The default \samp{count} returns a data frame of amino acid counts (the data frame can be given to \code{\link{add.protein}} in order to add the proteins to \code{\link{thermo}$protein}), \samp{seq} returns a list of sequences, and \samp{fas} returns a list of lines extracted from the FASTA file, including the headers (this can be used e.g. to generate a new FASTA file with only the selected sequences). Similarly to \code{grep.file}, this function utilizes the OS's \samp{grep} on supported operating systems in order to identify the header lines as well as \samp{cat} to read the file, otherwise \code{\link{readLines}} and \R's \code{\link{substr}} are used to read the file and locate the header lines. Modified: pkg/CHNOSZ/tests/testthat/test-iprotein.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-iprotein.R 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/tests/testthat/test-iprotein.R 2017-02-11 04:34:19 UTC (rev 141) @@ -39,9 +39,12 @@ expect_equal(formula, lprop$formula) }) -test_that("amino acid counts taken from a fasta file can be added",{ +test_that("read.fasta() identifies sequences correctly and gives amino acid compositions in the correct format",{ ffile <- system.file("extdata/fasta/EF-Tu.aln", package="CHNOSZ") aa <- read.fasta(ffile) + expect_equal(aa[1, ], read.fasta(ffile, 1)) + # use unlist here so that different row names are not compared + expect_equal(unlist(aa[8, ]), unlist(read.fasta(ffile, 8))) expect_message(ip1 <- add.protein(aa), "added 8 new protein\\(s\\)") expect_message(ip2 <- add.protein(aa), "replaced 8 existing protein\\(s\\)") # add.protein should return the correct indices for existing proteins Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-10 15:39:22 UTC (rev 140) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 04:34:19 UTC (rev 141) @@ -42,7 +42,7 @@ if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) # dpi setting -dpi <- 100 +dpi <- 72 # use pngquant to optimize PNG images knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) pngquant <- "--speed=1 --quality=0-50" @@ -472,7 +472,7 @@ Here we use `basis()` with a keyword to identify a preset basis definition. ```{marginfigure} Possible keywords are `CHNOS` (including CO2, H2O, NH3, H2S, and O2), `CHNOS+` (also including H+), `CHNOSe` (including H+, and *e*- instead of O2). -See ?basis for more options. +See `?basis` for more options. ``` ```{r basis_CHNOSZ, results="hide"} basis("CHNOS+") @@ -492,12 +492,12 @@ The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. Let's choose a set of variables commonly used in aqueous speciation diagrams: Eh and pH. To use Eh as a variable, the electron (`e-`) should be in the basis. -To get the electron in there, we could use a different keyword (`basis("CHNOSe")`), or swap oxygen out of the existing basis: +To put the electron in there, we could use a different keyword (`basis("CHNOSe")`), or swap oxygen out of the existing basis: ```{r swap_basis} swap.basis("O2", "e-") ``` -The swap.basis() changed the basis species and recalculated their activities, but preserved the species of interest. +The `swap.basis()` changed the basis species and recalculated their activities, but preserved the species of interest. ```{marginfigure} That is, running `affinity()``$values` again would give the same result. ``` @@ -609,7 +609,7 @@ ## *T*, *P*, activity transects Above, we used evenly-spaced grids of *T*, *P*, and/or chemical activities of basis species; the ranges of variables were given by two or three values (minimum, maximum, and optionally resolution). -`affinity()` can also perform calculations along a transect, i.e. a particular path along one or more variables. +`affinity()` can also perform calculations along a transect, i.e. a particular path along one or more variables. A transect is calculated when there are four or more values assigned to the variable(s). Let's use this feature to calculate affinities (negative Gibbs energies) of methanogenesis and biosynthetic reactions in a hydrothermal system. Some results of mixing calculations for seawater and vent fluid from the Rainbow hydrothermal field, reported by @SC10, are included in a data file in CHNOSZ: @@ -634,14 +634,14 @@ Now we can calculate affinity along the transect of changing temperature and activities of five basis species. Each variable is given as a named argument; the name for `NH4+` must be quoted. ```{marginfigure} -A shorter expression would use `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` +A shorter expression would use R's `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` ``` ```{marginfigure} The target of the conversion is `G`, or free energy, from `logK`. That conversion requires temperature in Kelvin, which is obtained by conversion from ?C. We finish with a negation (affinity is negative Gibbs energy) and scaling from cal to kcal. ``` -Using the `convert()` function in CHNOSZ, we also convert the result from dimensionless values (*A*/2.303*RT*) to kcal/mol. +Using `convert()`, we also convert the result from dimensionless values (*A*/2.303*RT*) to kcal/mol. ```{r rainbow_affinity, message=FALSE} a <- affinity(T=rb$T, CO2=rb$CO2, H2=rb$H2, `NH4+`=rb$`NH4+`, H2S=rb$H2S, pH=rb$pH) @@ -655,9 +655,9 @@ col=rainbow(8), lwd=2, legend.x=NA, bg="slategray3") abline(h=0, lty=2, lwd=2) ``` -Finally, we use `diagram()` to plot the results. +Finally, we use `diagram()` to plot the results. Although only temperature is shown on the *x*-axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. -By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). +By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). To override that behavior, we set `balance=1` to plot the affinities of the formation reactions as written (per mole of the species being formed). Also, `legend.x=NA` is used to suppress making a legend (so the labels are placed next to the lines instead). ```{r rainbow_diagram, eval=FALSE} @@ -665,7 +665,7 @@ ## Buffers -There is one final feature of `affinity()` to notice. +There is one other feature of `affinity()` to mention here. Can we go the other direction: calculate the activities of basis species from the activities of the species of interest? This question relates to the concept of chemical activity buffers. In CHNOSZ there are two ways to perform buffer calculations: @@ -675,7 +675,7 @@ * the buffers are active in calculations of affinity of other species * use `mod.buffer()` to change or add buffers in `thermo$buffer` * `demo(buffer)` uses it for mineral buffers (solid lines) -2. Use the `what` argument of `diagram()` to solve for the activity of the indicated basis species +2. Use the `what` argument of `diagram()` to solve for the activity of the indicated basis species * more convenient (the buffers come from the currently defined species of interest), but only a single basis species can be buffered, and it's not used in the calculation of affinity * `demo(buffer)` uses it for aqueous organic species as buffers (dotted and dashed lines) @@ -746,7 +746,7 @@ ## Getting from affinity to equilibrium -The `equilibrate()` function in CHNOSZ automatically chooses between two methods for calculating equilibrium. +The `equilibrate()` function in CHNOSZ automatically chooses between two methods for calculating equilibrium. ```{marginfigure} For more information, see the vignette *Equilibrium in CHNOSZ*. ``` @@ -783,7 +783,7 @@ diagram(a150, add=TRUE, col="red") ``` -Now we use `equilibrate()` to calculate the activities of species. +Now we use `equilibrate()` to calculate the activities of species. Our balancing constraint is that the total activity of C is 10-3. This shows a hypothetical *metastable equilibrium*; we know that for true equilibrium the total activity of C is affected by pH. ```{r bjerrum_2, eval=FALSE} @@ -809,18 +809,18 @@ ## Groups of species Sometimes it is helpful to look at the total concentration (i.e. activity) of groups in species distribution diagrams. -The `groups` argument of `diagram()` can be used to sum together the activities of species. +The `groups` argument of `diagram()` can be used to sum together the activities of species. To demonstrate this feature, let's consider the distribution of carbon among organic and inorganic species in the hydrothermal mixing scenario described by @SS98. First we define the basis and add two inorganic species. -The `index.return=FALSE` argument tells `info()` to return the index (number) of the species in the current species definition; these indices are saved for use below: +The `index.return=FALSE` argument tells `info()` to return the index (number) of the species in the current species definition; these indices are saved for use below: ```{r groups_basis, results="hide", message=FALSE} basis("CHNOS+") ii <- species(c("CO2", "HCO3-"), index.return=TRUE) ``` Next, we add each group of organic species: C1--C8 alcohols, C3--C8 ketones, C2--C12 carboxylic acids and their corresponding anions, and C2--C8 alkenes. -We provide `info()` with a set of `ispecies` values to select these species. +We provide `info()` with a set of `ispecies` values to select these species. The species in each group are ordered by carbon number in the database, so the set is made from the starting and ending indices using R's `seq()` function, wrapped by `seq2()` to make the code shorter. ```{r groups_species, message=FALSE} seq2 <- function(x) seq(x[1], x[2]) @@ -836,7 +836,7 @@ The specific values are for calculations with vent fluids initially set by the fayalite-magnetite-quartz buffer minus 1/2 log*f*O2 (FMQ - 1/2). ``` These values were calculated using a speciation and mixing model that is not available in CHNOSZ; however, we can use these intermediate values as input to the "downstream" calculations that are available in CHNOSZ. -Because of the noise introduced by digitization of the figure, we smooth the data using R's `smooth.spline()` function; the lower *T* limit reflects the absence of data below this temperature in the figure for log*f*O2. +Because of the noise introduced by digitization of the figure, we smooth the data using R's `smooth.spline()`; the lower *T* limit reflects the absence of data below this temperature in the figure for log*f*O2. ```{r groups_data} O2dat <- read.csv(system.file( "extdata/cpetc/SS98_Fig5a.csv", package="CHNOSZ")) @@ -848,8 +848,8 @@ ``` We are ready to calculate affinities and equilibrium activities of the species. -This calculation utilizes the transect mode of `affinity()`. -The call to `equilibrate()` runs with the default balance (in this case, CO2), with a log activity set to -2.5. +This calculation utilizes the transect mode of `affinity()`. +The call to `equilibrate()` runs with the default balance (in this case, CO2), with a log activity set to -2.5. ```{marginfigure} Actually, the total concentration of carbon depends on the mixing ratio, ranging from about 10-2.2 (seawater) to 10-2.6 (vent fluid). The ability to vary the activity of the balanced basis species is not yet implemented in CHNOSZ, so a single value is used here. @@ -892,10 +892,10 @@ ## Choosing a different balance How about the choice between balancing constraints? -Be default, `equilibrate()` and `diagram()` balance reactions on the first basis species that is present in each of the species of interest. +Be default, `equilibrate()` and `diagram()` balance reactions on the first basis species that is present in each of the species of interest. Let's look at some amino acids in a hypothetical metastable equilibrium. This calculation is based on one described by @Sho90b for five amino acids, but here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. -We use `ZC.col()` to generate colors based on the average oxidation state of carbon of the amino acids (red and blue for relatively reduced and oxidized). +We use `ZC.col()` to generate colors based on the average oxidation state of carbon of the amino acids (red and blue for relatively reduced and oxidized). ```{r aminoacids_setup, results="hide", message=FALSE} basis("CHNOS") basis("CO2", "gas") @@ -906,7 +906,7 @@ col <- ZC.col(aa.ZC) ``` -To make plots using different balance constraints, let's write a simple function that sets the `balance` argument of `diagram()` and adds a title to the plot. +To make plots using different balance constraints, let's write a simple function that sets the `balance` argument of `diagram()` and adds a title to the plot. The first plot is the most similar to Figure 4 of Shock (1990), except for the absence of alanine (probably due to different thermodynamic data) and the presence of some other amino acids. There, we set `balance=1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone. The remaining plots balance on each of the basis species (except for O2), then on volume (in the last plot). @@ -931,12 +931,12 @@ # Proteins -Proteins in CHNOSZ are handled differently from other species. +Proteins in CHNOSZ are handled a little bit differently from other species. Amino acid group additivity is used to obtain the thermodynamic properties of proteins. Therefore, CHNOSZ has a data file with amino acid compositions of selected proteins, as well as functions for importing and downloading amino acid sequence data. When proteins in CHNOSZ are identified by name, they include an underscore, such as in `LYSC_CHICK` (chicken lysozyme C). -The length and chemical formula of one or more proteins are returned by `protein.length()` and `protein.formula()`. +The length and chemical formula of one or more proteins are returned by `protein.length()` and `protein.formula()`. We can calculate the formula of the protein, and the per-residue formula, and show that both have the same average oxidation state of carbon: ```{r formula_LYSC_CHICK} pl <- protein.length("LYSC_CHICK") @@ -979,8 +979,8 @@ ```{r protein_Cp, eval=FALSE} ``` -Note that `subcrt()` has no provision for protein ionization. -Instead, ionization is handled via `affinity()`, which calls `ionize.aa()` if a charged species is in the basis. +Note that `subcrt()` has no provision for protein ionization. +Instead, ionization is handled via `affinity()`, which calls `ionize.aa()` if a charged species is in the basis. ```{marginfigure} Whether to calculate properties using aqueous or crystalline groups is determined by the value of `thermo\$opt\$state`; if it is changed from its default of `aq` to `cr`, no ionization is possible. ``` @@ -1004,16 +1004,16 @@ col=1:4, lty=1, bty="n", cex=0.9) ``` We calculate the affinities for the same four proteins, using both charged and uncharged sets of basis species to activate and suppress the ionization calculations. -The ionized calculation returns a series of values (as a function of pH), but there is only one value of affinity returned by the nonionized calculation, so we need to use `as.numeric()` to avoid subtracting non-conformable arrays: +The ionized calculation returns a series of values (as a function of pH), but there is only one value of affinity returned by the nonionized calculation, so we need to use R's `as.numeric()` to avoid subtracting non-conformable arrays: ```{r protein_ionization, eval=FALSE} ``` -Above, we used the `iprotein` argument of `affinity()` to specify the proteins in the calculation, using their indices as returned by `iprotein()`. +Above, we used the `iprotein` argument of `affinity()` to specify the proteins in the calculation, using their indices returned by `iprotein()`. ```{marginfigure} The `iprotein` index refers to the rownumber of `thermo\$protein`; this is distinct from the `ispecies` index, which refers to the rownumber of `thermo\$species`. ``` That approach utilizes some optimizations that can be realized due group additivity, and is useful for calculations involving many proteins. -An alternative, but slower, approach is to identify the proteins to `species()`; this produces results that are equivalent to using the `iprotein` argument: +An alternative, but slower, approach is to identify the proteins to `species()`; this produces results that are equivalent to using the `iprotein` argument: ```{r basis_CHNOS, echo=FALSE, results="hide"} basis("CHNOS") @@ -1032,10 +1032,10 @@ Let's compare the `r zc` of Rubisco with optimal growth temperature of organisms, as shown in Figure 6a of @Dic14. First we read a CSV file with the protein ID's and optimal growth temperature (*T*opt); the midpoint of the range of *T*opt is used for plotting. -Then we use `read.fasta()` to read a FASTA file holding the amino acid sequences of the proteins; the function returns a data frame with the amino acid counts. +Then we use `read.fasta()` to read a FASTA file holding the amino acid sequences of the proteins; the function returns a data frame with the amino acid counts. To put the proteins in the right order, the IDs in the CSV file are matched to the names of the proteins in the FASTA file. Then, in one line, we calculate the formula of the protein, followed by `r zc`. -Next, point symbols are assigned according to domain (Eukaryota, Bacteria, Archaea); numerals inside the symbols reflect the ordering by *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). +Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numerals inside the symbols reflect the ordering by *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). ```{r rubisco_ZC, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms.", cache=TRUE, pngquant=pngquant} datfile <- system.file("extdata/cpetc/rubisco.csv", package="CHNOSZ") @@ -1059,22 +1059,22 @@ ```{r rubisco_ZC, eval=FALSE} ``` -`protein.basis()` returns the stoichiometry of the basis species the formation reaction of the proteins. -Dividing by `protein.length()` gives the per-residue reaction coefficients. -Using the set of basis species we have seen before (CO2, NH3, H2S, `r h2o`, `r o2`) there is a correlation between `r zc` and *n*`r o2`/residue, as well as a correlation of the latter with *n*`r h2o`/residue (left column). +`protein.basis()` returns the stoichiometry of the basis species the formation reaction of the proteins. +Dividing by `protein.length()` gives the per-residue reaction coefficients (*n*̅). +Using the set of basis species we have seen before (CO2, NH3, H2S, `r h2o`, `r o2`) there is a correlation between `r zc` and *n*̅`r o2`, as well as a correlation of the latter with *n*̅`r h2o` (left column). ```{marginfigure} -The calculation of *Z*C, which is a sum of elemental ratios, is not affected by the choice of basis species. +The calculation of *Z*C, which sums elemental ratios, is not affected by the choice of basis species. ``` -The "CEQ" keyword to basis() loads basis species with a particular combination of three amino acids (cysteine, glutamic acid, glutamine, `r h2o`, `r o2`) that strengthens the relationship between `r zc` and *n*`r o2`/residue, but weakens that between *n*`r o2`/residue and *n*`r h2o`/residue (right column). [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 141 From noreply at r-forge.r-project.org Sat Feb 11 13:23:32 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 11 Feb 2017 13:23:32 +0100 (CET) Subject: [CHNOSZ-commits] r142 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170211122332.81FC0187CBD@r-forge.r-project.org> Author: jedick Date: 2017-02-11 13:23:32 +0100 (Sat, 11 Feb 2017) New Revision: 142 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/revisit.R pkg/CHNOSZ/R/util.misc.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/read.expr.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add proteins: normalization to residues Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-11 12:23:32 UTC (rev 142) @@ -1,6 +1,6 @@ Date: 2017-02-11 Package: CHNOSZ -Version: 1.0.8-31 +Version: 1.0.8-32 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/revisit.R =================================================================== --- pkg/CHNOSZ/R/revisit.R 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/R/revisit.R 2017-02-11 12:23:32 UTC (rev 142) @@ -195,8 +195,9 @@ if(plot.it) { if(is.null(ylim)) ylim <- extendrange(H, f=0.075) if(is.null(xlim)) xlim <- xrange - # format the objective name if it's DGtr + # format the objective name if it's DGtr or DGinf if(objective=="DGtr") ylab <- expr.property("DGtr/2.303RT") + if(objective=="DGinf") ylab <- expr.property("DGinf/2.303RT") else ylab <- objective if(!add) thermo.plot.new(xlim=xlim, ylim=ylim, xlab=axis.label(xname), ylab=ylab, yline=yline, cex=cex, lwd=lwd, mar=mar, side=side) Modified: pkg/CHNOSZ/R/util.misc.R =================================================================== --- pkg/CHNOSZ/R/util.misc.R 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/R/util.misc.R 2017-02-11 12:23:32 UTC (rev 142) @@ -77,7 +77,7 @@ # apply the factor act <- act * act.fact # take the logarithms - logact <- log10(act) + log10(act) # done! } Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/inst/NEWS 2017-02-11 12:23:32 UTC (rev 142) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-31 (2017-02-11) +CHANGES IN CHNOSZ 1.0.8-32 (2017-02-11) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-11 12:23:32 UTC (rev 142) @@ -151,6 +151,14 @@ \examples{ \dontshow{data(thermo)} +## calculate the equilibrium logarithm of activity of a +## basis species in different reactions +basis("CHNOS") +species(c("ethanol", "lactic acid", "deoxyribose", "ribose")) +a <- affinity(T=c(0, 150)) +diagram(a, what="O2", legend.x="topleft", col=rev(rainbow(4)), lwd=2) +title(main="equilibrium logfO2 for 1e-3 mol/kg of CO2 and ... ") + ### 1-D diagrams: logarithms of activities ## Aqueous sulfur species (after Seewald, 1997 and 2001) @@ -204,6 +212,28 @@ title(main=paste("Fe-S-O, 200 degrees C, 1 bar", "After Helgeson, 1970", sep="\n")) +## Mineral equilibrium activity diagram +## After Bowers et al., 1984, p. 246 +# Consider the system denoted by BJH84 as +# HCl-H2O-CaO-CO2-MgO-(SiO2) at 300 deg C and 1000 bar +# HCl, CO2, O2 have zero stoichiometric coeffs in the species +# Ca+2, Mg+2 are going to be on the diagram +# SiO2 will be conserved (the immobile component) +# (try changing any of the 999's, the diagram will be unaffected) +basis(c("HCl","H2O","Ca+2","CO2","Mg+2","SiO2","O2","H+"), + c(999,0,999,999,999,999,999,-7)) +# we have to tell CHNOSZ which species to include; there are +# others that could be in this system +species(c("quartz","talc","forsterite","tremolite","diopside", + "wollastonite","monticellite","merwinite")) +# calculate the chemical affinities of formation reactions +a <- affinity("Mg+2"=c(-12,-4),"Ca+2"=c(-8,0),T=300,P=1000) +diagram(a) +title(main=paste("HCl-H2O-CaO-CO2-MgO-(SiO2) at 300 degrees C,", + "1000 bar and pH=7. After Bowers et al., 1984", sep="\n")) +# note: Bowers et al. use different variables (e.g. (a_Ca+2)/(a_H+)^2), +# so the plot here is not an exact reproduction + ## pe-pH diagram for hydrated iron sulfides, ## goethite and pyrite, after Majzlan et al., 2006 # add some of these species to the database @@ -263,20 +293,14 @@ stopifnot(species()$name[d$predominant[1, 1]]=="andalusite") stopifnot(species()$name[d$predominant[1, 101]]=="kyanite") stopifnot(species()$name[d$predominant[99, 101]]=="sillimanite") - -## calculate the equilibrium logarithm of activity of a -## basis species in different reactions -basis("CHNOS") -species(c("ethanol", "lactic acid", "deoxyribose", "ribose")) -a <- affinity(T=c(0, 150)) -diagram(a, what="O2", legend.x="topleft", col=rev(rainbow(4)), lwd=2) -title(main="equilibrium logfO2 for 1e-3 mol/kg of CO2 and ... ") } \references{ Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57. \url{http://dx.doi.org/10.1149/1.1344532} + Bowers, T. S., Jackson, K. J. and Helgeson, H. C., 1984. \emph{Equilibrium Activity Diagrams for Coexisting Minerals and Aqueous Solutions at Pressures and Temperatures to 5 kb and 600} \eqn{^{\circ}}{degrees }\emph{C}. Springer-Verlag, Heidelberg, 397 p. \url{http://www.worldcat.org/oclc/224591948} + Helgeson, H. C. (1970) A chemical and thermodynamic model of ore deposition in hydrothermal systems. \emph{Mineral. Soc. Amer. Spec. Pap.} \bold{3}, 155--186. \url{http://www.worldcat.org/oclc/583263} Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862} Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-11 12:23:32 UTC (rev 142) @@ -32,23 +32,10 @@ ## Standard molal entropy of a protein reaction basis("CHNOS") # here we provide the reaction coefficients of the -# proteins (per protein backbone); 'subcrt' function calculates +# proteins (per protein backbone); subcrt() calculates # the coefficients of the basis species in the reaction -s <- subcrt(c("CSG_METTL","CSG_METJA"), c(-1/530,1/530), +s <- subcrt(c("CSG_METTL", "CSG_METJA"), c(-1/530, 1/530), T=seq(0, 350, length.out=50)) -thermo.plot.new(xlim=range(s$out$T), ylim=range(s$out$S), - xlab=axis.label("T"), ylab=axis.label("DS0r")) -lines(s$out$T, s$out$S) -# do it at high pressure as well -s <- subcrt(c("CSG_METTL","CSG_METJA"), c(-1/530,1/530), - T=seq(0,350,length.out=50), P=3000) -lines(s$out$T, s$out$S, lty=2) -# label the plot -title(main=paste("Standard molal entropy\n", - "P = Psat (solid), P = 3000 bar (dashed)")) -s$reaction$coeff <- round(s$reaction$coeff, 3) -dsr <- describe.reaction(s$reaction, iname=c(1,2)) -text(170, -3, dsr, cex=0.8) ### Equilibrium activity diagrams Modified: pkg/CHNOSZ/man/read.expr.Rd =================================================================== --- pkg/CHNOSZ/man/read.expr.Rd 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/man/read.expr.Rd 2017-02-11 12:23:32 UTC (rev 142) @@ -86,41 +86,31 @@ # look for proteins described as "Complement" read.expr(file, "name", "log10(pg/ml)", list(description="Complement")) -## speciation diagram for ER.to.Golgi proteins (COPII coat -## proteins) as a function of logfO2, after Dick, 2009 -# use old parameters for [Met] (Dick et al., 2006) -mod.obigt("[Met]", G=-35245, H=-59310) -y <- yeastgfp("ER.to.Golgi") -# don't use those with NA abundance -ina <- is.na(y$abundance) -# get the amino acid compositions of the proteins -aa <- more.aa(y$protein[!ina], "Sce") -# add proteins to thermo$protein -ip <- add.protein(aa) -# use logarithms of activities of proteins such -# that total activity of residues is unity -pl <- protein.length(ip) -logact <- unitize(rep(1, length(ip)), pl) -# load the proteins +## Localizations and abundances of proteins from YeastGFP are used here +## to calculate an abundance-weighted average of amino acid compositions of proteins +## in different subcellular compartments of yeast. +## This figure is similar to Fig. 3 of Dick (2009). +locations <- yeastgfp() +gfp <- yeastgfp(locations) +aa <- more.aa(gfp$protein, "Sce") +for(i in 1:length(locations)) { + avgaa <- aasum(aa[[i]], gfp$abundance[[i]], average=TRUE, protein=locations[i]) + add.protein(avgaa) +} basis("CHNOS+") -a <- affinity(O2=c(-80, -73), iprotein=ip, loga.protein=logact) -# make a speciation diagram -e <- equilibrate(a, normalize=TRUE) -diagram(e, ylim=c(-4.9, -2.9), format.names=FALSE) -# where we are closest to experimental log activity -logfO2 <- rep(-78, length(ip)) -abline(v=logfO2[1], lty=3) -# scale experimental abundances such that -# total activity of residues is unity -logact.expt <- unitize(log10(y$abundance[!ina]), pl) -# plot experimental log activity -points(logfO2, logact.expt, pch=16) -text(logfO2+0.5, logact.expt, y$protein[!ina]) -# add title -title(main=paste("ER.to.Golgi; points - relative abundances", - "from YeastGFP. Figure after Dick, 2009",sep="\n")) -# restore default thermodynamic database -data(thermo) +species(locations, "Sce") +a <- affinity(O2=c(-82, -65)) +e <- equilibrate(a, loga.balance=0, normalize=TRUE) +mycolor <- topo.colors(length(locations)) +diagram(e, names=locations, ylim=c(-5, -3), legend.x=NA, col=mycolor, lwd=2) +dp <- describe.property(c("T", "P"), c(25, 1)) +db <- describe.basis(ibasis=(1:6)[-5]) +legend("topright", legend=c(dp, db), bty="n") +## Notable features include: proteins in the early Golgi, endoplasmic reticulum (ER) +## and vacuole are chemically the most stable relative to those in other locations in the cell; +## proteins in the vacuole are very oxidized; the stability of proteins decreases going from +## early Golgi to Golgi to late Golgi; the least stable proteins (or most energetic) +## are found in the microtubules and bud neck. ############################# ## examples using stress() ## Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 12:23:32 UTC (rev 142) @@ -381,7 +381,7 @@ text(5, 5, describe.reaction(hydrogenotrophic$reaction), adj=1) ``` -## Affinity: not the standard state Gibbs energy +## Chemical affinity Usually, `subcrt()` returns only standard state thermodynamic properties. ```{marginfigure} @@ -460,7 +460,7 @@ ## Activity coefficients -XXX Example using `nonideal()` ... +XXX Example using `nonideal()` ... Alberty, 2003, Fig. 1.4-1.5 (p. 9-10, 235-236) # `affinity()`, species of interest, and potential diagrams @@ -566,7 +566,7 @@ We use `mosaic()` to generate and combine diagrams for each candidate basis species (H2S, HS-, HSO4-, or SO4-2) as a function of Eh and pH. The key argument is `bases`, which identifies the candidate basis species (starting with the one in the current basis). -The other arguments, like those of `affinity()`, specify the ranges of the variables; `res` indicates the grid resolution to use for each variable (higher than the default). +The other arguments, like those of `affinity()`, specify the ranges of the variables; `res` indicates the grid resolution to use for each variable (higher than the default of 128). The first call to `diagram()` plots the species of interest; the second adds the predominance fields of the basis species. Finally, `water.lines()` is used to add the stability limits of water at the given temperature. @@ -589,7 +589,7 @@ For instance, we can use H2 or `r o2` in place of *e*-. To do that, let's write a function to swap those basis species and make a diagram. We use R's `do.call()` to construct the argument list for `mosaic()`; this way, the name of the `newvar` argument to our function indicates the chosen variable. -```{r mosaicfun, fig.fullwidth=TRUE, fig.width=10.5, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant} +```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant} mosaicfun <- function(newvar, T=200, res=300) { swap.basis("e-", names(newvar)) if(names(newvar) == "O2") basis("O2", "gas") @@ -597,10 +597,9 @@ m1 <- do.call(mosaic, mosaicargs) diagram(m1$A.species, lwd=2, fill=rev(topo.colors(10))) diagram(m1$A.bases, add=TRUE, col="blue", col.names="blue", lty=3) - title(main=expr.species(names(newvar))) swap.basis(names(newvar), "e-") } -layout(t(matrix(c(1, 1, 2, 2, 3, 3, 0)))) +par(mfrow=c(1, 3)) mosaicfun(list(Eh=c(-1, 1, res))) mosaicfun(list(H2=c(-15, 5, res))) mosaicfun(list(O2=c(-70, 0, res))) @@ -863,8 +862,8 @@ The groups are identified by the current species numbers in a list, where the list elements are given names that will appear on the diagram. When summing the activities of species in the groups, each activity is multiplied first by the balance coefficient on that species. Therefore, the total activity is that of a basis species (or of an element that only in that basis species, like carbon in this example). -```{r groups_diagram, echo=2:4, eval=FALSE} -layout(t(matrix(c(1, 1, 2, 2, 3, 3, 0)))) +```{r groups_diagram, echo=1:4, eval=FALSE} +par(mfrow=c(1, 3)) groups <- list(inorganic=ii, alcohols=ia, ketones=ik, `carboxylic acids`=c(ic, ica), alkenes=ie) diagram(e, alpha=TRUE, groups=groups, legend.x=NA) @@ -886,7 +885,7 @@ We do this by setting the names and line types for the *other* species to values that prevent them from being plotted: ```{r groups_diagram, echo=-(1:4), eval=FALSE} ``` -```{r groups_diagram, fig.fullwidth=TRUE, fig.width=10.5, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, pngquant=pngquant} +```{r groups_diagram, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, pngquant=pngquant} ``` ## Choosing a different balance @@ -901,7 +900,7 @@ basis("CO2", "gas") swap.basis("NH3", "N2") species(aminoacids("")) -a <- affinity(O2=c(-50, -25), CO2=c(-10, 15), T=250, P=265) +a <- affinity(O2=c(-50, -25, 300), CO2=c(-10, 15, 300), T=250, P=265) aa.ZC <- ZC(info(aminoacids(""))) col <- ZC.col(aa.ZC) ``` @@ -1090,8 +1089,84 @@ By projecting the compositions of proteins into the "QEC" set of basis species, *n*̅`r o2` emerges as a strong indicator of oxidation state, while *n*̅`r h2o` is a relatively non-correlated (i.e. independent) compositional variable. These independent variables make it easier to distinguish the effects of oxidation and hydration state in proteomic experiments [@Dic17]. -## Normalizing for different lengths +## Normalization to residues +As with other systems, a balance must be chosen for calculations of the metastable equilibrium distribution for proteins. +Balancing on the number of backbone units (the length of the proteins) seems a reasonable choice given the polymeric structure of proteins. +```{marginfigure} +Balancing on one of the basis species remains a possibility, using the `balance` argument in `equilibrate()` or `diagram()`. +``` +However, there is an additional consideration: owing to the large size of proteins compared to the basis species, the distribution of *proteins* in metastable equilibrium has many orders of magnitude separation between the activities of the dominant and less-dominant proteins. +The metastable coexistence of the *residues* (i.e. per-residue formulas, or residue equivalents) of the same proteins spans a much smaller range of chemical activities. +In CHNOSZ, the calculation of metastable equilibrium activities of the residue equivalents is referred to as *normalization*. +```{marginfigure} +See the vignette *Equilibrium in CHNOSZ* for other examples using normalization. +``` + +To take an example, let's look at the metastable equilibrium distribution of selected proteins in the ER-to-Golgi compartment of *S. cerevisiae* (yeast). +This example brings in a few other functions we haven't seen yet: `yeastgfp()`, `unitize()`, and `revisit()`. +`yeastgfp()` queries a data file in CHNOSZ for the names and relative abundances of proteins taken from the YeastGFP study of @GHB_03. +There are six proteins identified in the ER-to-Golgi compartment; one has NA abundance, so it is excluded from the comparisons. +```{r yeastgfp} +y <- yeastgfp("ER.to.Golgi") +ina <- is.na(y$abundance) +``` + +Next, we get the amino acid compositions of the proteins and add them to thermo$protein. +```{r add_protein_yeast, message=FALSE} +aa <- more.aa(y$protein[!ina], "Sce") +ip <- add.protein(aa) +``` + +The YeastGFP study reported absolute abundances of molecules, but the thermodynamic calculations give relative chemical activities of the proteins. +In order to make a comparison between them, we use `unitize()` to scale the abundances or activities of proteins (in logarithmic units) such that the total abundance or activity of residue equivalents is unity. +To do that, we must have the lengths of the proteins. +The first call to `unitize()` generates equal logarithms of activities of proteins for unit total activity of residues; this is used as the reference state for `affinity()`. +The second call to `unitize()` scales the logarithms of experimental abundances for unit total activity of residues; this is used for plotting a comparison with the theoretical results. +```{r unitize} +pl <- protein.length(ip) +logact <- unitize(numeric(5), pl) +logabundance <- unitize(log10(y$abundance[!ina]), pl) +``` + +Now we can load the proteins and calculate their activities in metastable equilibrium as a function of `r logfO2`. +```{marginfigure} +The commented line uses `mod.obigt()` to revert the parameters of the methionine sidechain group to those present in older versions of CHNOSZ (Dick et al., 2006). +The current database, with parameters instantiated by `data(thermo)` and used here, contains updated group additivity parameters for methionine (LaRowe and Dick, 2012). +``` +```{r yeastplot, eval=FALSE, echo=1:6} +par(mfrow=c(1, 3)) +basis("CHNOS+") +#mod.obigt("[Met]", G=-35245, H=-59310) +a <- affinity(O2=c(-80, -73), iprotein=ip, loga.protein=logact) +e <- equilibrate(a) +diagram(e, ylim=c(-5, -2), format.names=FALSE, legend.x=NA, col=1:5, lwd=2) +e <- equilibrate(a, normalize=TRUE) +diagram(e, ylim=c(-5, -2.5), format.names=FALSE, legend.x=NA, col=1:5, lwd=2) +abline(h=logabundance, lty=1:5, col=1:5) +revisit(e, "DGinf", logabundance) +``` + +Oh! The proteins look very non-coexistent in metastable equilibrium. +We can get a different view by using per-residue rather than per-protein reactions via the `normalize` argument for `equilibrate()`: +```{marginfigure} +The normalization step is followed by conversion of activities of residues to activities of proteins; that conversion can be skipped using the `as.residue` argument in `equilibrate()`. +``` +```{r yeastplot, eval=FALSE, echo=7:9} +``` + +The experimental relative abundances are plotted as thin horizontal lines with the same style and color as the thicker curved lines calculated for metastable equilibrium. +With the exception of YNL049C, the overlap between the calculations and experiments looks to be greatest near the middle-left part of the figure. +The `revisit()` function offers some statistical and thermodynamic measures that can quantify this comparison. +Here, we plot the free energy associated with the information-theoretic "relative entropy" or Kullback-Leibler divergence: +```{r yeastplot, eval=FALSE, echo=10} +``` +```{r yeastplot, fig.fullwidth=TRUE, fig.width=7.5, fig.height=2.5, small.mar=TRUE, dpi=100, out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, fig.cap="ER-to-Golgi proteins: calculations without and with normalization, and free energy difference between experimental and normalization-calculated abundances.", pngquant=pngquant} +``` + +The minimum free energy difference occurs near `r logfO2` = -78. +This agrees with the assessment shown in Figure 4 of @Dic09 (note that the old methionine sidechain group was used in that study). + ## Adding proteins In the Rubisco example above, we saw the use of `read.fasta()` to read amino acid sequences from a FASTA file. @@ -1221,7 +1296,7 @@ We read a data file of amino acid compositions produced in that study, taking those labelled "transferase". Then we add the proteins and get their indices using `add.protein()`, set the basis, calculate the affinities, and make a potential diagram with temperature and activity of dissolved hydrogen as variables: -```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferase proteins in the outflow channel of Bison Pool hot spring. See also the vignette *Hot-spring proteins in CHNOSZ*.', cache=TRUE, pngquant=pngquant} +```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferases in the outflow channel of Bison Pool hot spring. See also the vignette *Hot-spring proteins in CHNOSZ*.', cache=TRUE, pngquant=pngquant} aa <- read.aa(system.file("extdata/protein/DS11.csv", package="CHNOSZ")) aa <- aa[grep("transferase", aa$protein), ] ip <- add.protein(aa) @@ -1229,7 +1304,8 @@ basis(c("HCO3-", "H2O", "NH3", "HS-", "H2", "H+")) basis(c("HCO3-", "NH3", "HS-", "H+"), c(-3, -4, -7, -7.933)) T <- c(50, 100) -a <- affinity(T = T, H2 = c(-7, -4), iprotein = ip) +res <- 300 +a <- affinity(T = c(T, res), H2 = c(-7, -4, res), iprotein = ip) fill <- ZC.col(ZC(protein.formula(ip))) diagram(a, normalize = TRUE, fill = fill, names = 1:5, format.names=FALSE) logaH2 <- function(T) -11 + T * 3/40 @@ -1262,10 +1338,18 @@ ## Messages from functions -(Look at messages in calculation above: groups?) +(Look at messages in calculation above: groups, ER-to-Golgi?) # Functions outside of the main workflow -transfer, wjd, eqdata, RH2obigt, EOSregress, anim. +transfer, wjd, eqdata, RH2obigt, EOSregress, anim, taxonomy Gibbs energy minimization with amino acids: [Cob13]? + +# Document history + +* 2010-09-30 Initial version. +* 2011-08-15 Add browse.refs(); modifying database hint changed to help(thermo). +* 2012-06-16 Add ?More activity diagrams?. +* 2015-05-14 Add warning about internal consistency of thermodynamic data. +* 2017-02-15 Complete rewrite; switch from Sweave to knitr (Tufte style). Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-11 04:34:19 UTC (rev 141) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-11 12:23:32 UTC (rev 142) @@ -55,7 +55,7 @@ @Article{Dic09, author = {Dick, Jeffrey M.}, journal = {BMC Systems Biology}, - title = {Calculation of the relative metastabilities of proteins in subcellular compartments of \emph{Saccharomyces cerevisiae}}, + title = {Calculation of the relative metastabilities of proteins in subcellular compartments of \emph{{S}accharomyces cerevisiae}}, year = {2009}, volume = {3}, pages = {75}, @@ -114,6 +114,17 @@ url = {http://www.worldcat.org/oclc/517586}, } + at Article{GHB_03, + author = {Ghaemmaghami, Sina and Huh, Won-Ki and Bower, Kiowa and Howson, Russell W. and Belle, Archana and Dephoure, Noah and O'Shea, Erin K. and Weissman, Jonathan S.}, + journal = {Nature}, + title = {Global analysis of protein expression in yeast}, + year = {2003}, + volume = {425}, + number = {6959}, + pages = {737--741}, + doi = {10.1038/nature02046}, +} + @Incollection{Hel70c, author = {Helgeson, Harold C.}, booktitle = {Fiftieth Anniversary Symposia}, From noreply at r-forge.r-project.org Sat Feb 11 19:37:23 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 11 Feb 2017 19:37:23 +0100 (CET) Subject: [CHNOSZ-commits] r143 - in pkg/CHNOSZ: . inst inst/extdata/cpetc man vignettes Message-ID: <20170211183724.0FF6818869C@r-forge.r-project.org> Author: jedick Date: 2017-02-11 19:37:23 +0100 (Sat, 11 Feb 2017) New Revision: 143 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: use RSVGTipsDevice for Rubisco plot Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-11 12:23:32 UTC (rev 142) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-11 18:37:23 UTC (rev 143) @@ -1,11 +1,11 @@ Date: 2017-02-11 Package: CHNOSZ -Version: 1.0.8-32 +Version: 1.0.8-33 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Depends: R (>= 3.1.0) -Suggests: limSolve, testthat, knitr, rmarkdown, tufte +Suggests: limSolve, testthat, knitr, rmarkdown, tufte, RSVGTipsDevice Imports: grDevices, graphics, stats, utils, colorspace Description: Functions and data sets to support chemical thermodynamic modeling in biochemistry and low-temperature geochemistry. The features include calculation of the standard molal Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-11 12:23:32 UTC (rev 142) +++ pkg/CHNOSZ/inst/NEWS 2017-02-11 18:37:23 UTC (rev 143) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-32 (2017-02-11) +CHANGES IN CHNOSZ 1.0.8-33 (2017-02-11) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv 2017-02-11 12:23:32 UTC (rev 142) +++ pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv 2017-02-11 18:37:23 UTC (rev 143) @@ -1,28 +1,28 @@ -ID,T1,T2,domain,species -G9FID8,0,6,E,"Phaeocystis antarctica" -M9R7V1,4,10,B,"Octadecabacter antarcticus 307" -K4MAK9,18,18,A,"Methanolobus psychrophilus" -Q12TQ0,23,23,A,"Methanococcoides burtonii" -Q9ZI34,25,30,B,"Bradyrhizobium japonicum" -P0C916,28,30,B,"Thiobacillus ferrooxidans" -P00874,30,30,E,"Zea mays" -Q0EX22,30,30,B,"Mariprofundus ferrooxydans" -L0RHZ1,35,35,B,"Desulfovibrio hydrothermalis" -Q8THG2,35,40,A,"Methanosarcina acetivorans" -F9ZLP0,45,45,B,"Acidithiobacillus caldus" -P37393,45,45,E,"Cyanidium caldarium" -P72383,45,50,B,"Sulfobacillus acidophilus" -Q51856,52,52,B,"Pseudomonas hydrogenothermophila" -Q2JIP3,50,55,B,"Synechococcus sp. (strain JA-2-3B'a(2-13))" -A0B9K9,55,60,A,"Methanosaeta thermophila" -Q8DIS5,57,57,B,"Thermosynechococcus elongatus" -G8LZL2,60,60,B,"Clostridium clariflavum" -F8IID7,65,65,B,"Bacillus acidocaldarius" -A8F7V4,65,65,B,"Thermotoga lettingae" -B9KXE5,70,70,B,"Thermomicrobium roseum" -O28635,76,76,A,"Archaeoglobus fulgidus" -Q58632,85,85,A,"Methanocaldococcus jannaschii" -A1RZJ5,85,90,A,"Thermofilum pendens" -A3DND9,85,92,A,"Staphylothermus marinus" -O58677,98,98,A,"Pyrococcus horikoshii" -Q8U1P9,100,100,A,"Pyrococcus furiosus" +ID,T1,T2,domain,species,URL +G9FID8,0,6,E,"Phaeocystis antarctica",http://dx.doi.org/10.3354/ab00256 +M9R7V1,4,10,B,"Octadecabacter antarcticus 307",http://dx.doi.org/10.1016/S0723-2020(97)80003-3 +K4MAK9,18,18,A,"Methanolobus psychrophilus",http://dx.doi.org/10.1128/AEM.01146-08 +Q12TQ0,23,23,A,"Methanococcoides burtonii",http://dx.doi.org/10.1016/S0723-2020(11)80117-7 +Q9ZI34,25,30,B,"Bradyrhizobium japonicum",http://dx.doi.org/10.1099/00207713-32-1-136 +P0C916,28,30,B,"Thiobacillus ferrooxidans",http://dx.doi.org/10.1080/01490459209377920 +P00874,30,30,E,"Zea mays",http://dx.doi.org/10.1016/S0065-2113(08)60322-3 +Q0EX22,30,30,B,"Mariprofundus ferrooxydans",http://dx.doi.org/10.1371/journal.pone.0000667 +L0RHZ1,35,35,B,"Desulfovibrio hydrothermalis",http://dx.doi.org/10.1099/ijs.0.02323-0 +Q8THG2,35,40,A,"Methanosarcina acetivorans",http://aem.asm.org/content/47/5/971 +F9ZLP0,45,45,B,"Acidithiobacillus caldus",http://dx.doi.org/10.1099/13500872-140-12-3451 +P37393,45,45,E,"Cyanidium caldarium",http://dx.doi.org/10.1007/BF00409031 +P72383,45,50,B,"Sulfobacillus acidophilus",http://dx.doi.org/10.1099/00221287-142-4-775 +Q51856,52,52,B,"Pseudomonas hydrogenothermophila",http://dx.doi.org/10.1271/bbb1961.41.685 +Q2JIP3,50,55,B,"Synechococcus sp. (strain JA-2-3B'a(2-13))",http://dx.doi.org/10.1128/AEM.72.1.544-550.2006 +A0B9K9,55,60,A,"Methanosaeta thermophila",http://dx.doi.org/10.1099/00207713-42-3-463 +Q8DIS5,57,57,B,"Thermosynechococcus elongatus",http://dx.doi.org/10.1093/oxfordjournals.pcp.a075684 +G8LZL2,60,60,B,"Clostridium clariflavum",http://dx.doi.org/10.1099/ijs.0.003483-0 +F8IID7,65,65,B,"Bacillus acidocaldarius",http://dx.doi.org/10.1099/00221287-67-1-9 +A8F7V4,65,65,B,"Thermotoga lettingae",http://dx.doi.org/10.1099/ijs.0.02165-0 +B9KXE5,70,70,B,"Thermomicrobium roseum",http://dx.doi.org/10.1371/journal.pone.0004207 +O28635,76,76,A,"Archaeoglobus fulgidus",http://aem.asm.org/content/60/4/1227 +Q58632,85,85,A,"Methanocaldococcus jannaschii",http://dx.doi.org/10.1007/BF00425213 +A1RZJ5,85,90,A,"Thermofilum pendens",http://dx.doi.org/10.1016/S0723-2020(83)80035-6 +A3DND9,85,92,A,"Staphylothermus marinus",http://dx.doi.org/10.1016/S0723-2020(86)80157-6 +O58677,98,98,A,"Pyrococcus horikoshii",http://dx.doi.org/10.1007/s007920050051 +Q8U1P9,100,100,A,"Pyrococcus furiosus",http://dx.doi.org/10.1007/BF00413027 Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-11 12:23:32 UTC (rev 142) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-11 18:37:23 UTC (rev 143) @@ -36,7 +36,7 @@ \item \code{BKM60_Fig7.dat} Eh-pH values for normal, wet and waterlogged soils from Fig. 7 of Baas Becking et al., 1960. See the \sQuote{anintro} vignette for an example that uses this file. \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), pH and logarithms of activity of \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2}}{H2}, \eqn{\mathrm{NH_4^+}}{NH4+}, \eqn{\mathrm{H_2S}}{H2S} and \eqn{\mathrm{CH_4}}{CH4} for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010. \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{O2} and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998. - \item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, and domain and name of organisms, from Dick, 2014. + \item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, domain and name of organisms, and URL of reference for growth temperature, from Dick, 2014. } Files in \code{fasta} contain protein sequences: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 12:23:32 UTC (rev 142) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 18:37:23 UTC (rev 143) @@ -29,22 +29,23 @@ ``` ```{r setup, include=FALSE} +library(knitr) # invalidate cache when the tufte version changes -knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) +opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) options(htmltools.dir.version = FALSE) -knitr::knit_hooks$set(small.mar = function(before, options, envir) { +knit_hooks$set(small.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, .1, .1)) # smaller margin on top and right }) -knitr::knit_hooks$set(tiny.mar = function(before, options, envir) { +knit_hooks$set(tiny.mar = function(before, options, envir) { if (before) par(mar = c(.1, .1, .1, .1)) # tiny margin all around }) -knitr::knit_hooks$set(smallish.mar = function(before, options, envir) { +knit_hooks$set(smallish.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) # dpi setting dpi <- 72 # use pngquant to optimize PNG images -knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) +knit_hooks$set(pngquant = hook_pngquant) pngquant <- "--speed=1 --quality=0-50" # some frequently used HTML expressions logfO2 <- "logfO2" @@ -52,6 +53,16 @@ zc <- "ZC" o2 <- "O2" h2o <- "H2O" +# http://stackoverflow.com/questions/23852753/knitr-with-gridsvg +# Set up a chunk hook for manually saved plots. +knit_hooks$set(custom.plot = hook_plot_custom) +# hook to change to - required for interactive SVG +hook_plot <- knit_hooks$get("plot") +knit_hooks$set(plot = function(x, options) { + x <- hook_plot(x, options) + if (!is.null(options$embed.tag) && options$embed.tag) x <- gsub("`demo(density)`. ``` ```{r subcrt_water_grid} -subcrt("water", T=c(400, 500, 600), P=c(200, 400, 600), grid="P")$out$water +subcrt("water", T = c(400, 500, 600), P = c(200, 400, 600), grid = "P")$out$water ``` ```{r subcrt_water_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Isothermal contours of density (g cm-3) and pressure (bar) of H2O.", cache=TRUE, pngquant=pngquant} substuff <- subcrt("water", T=seq(0,1000,100), P=c(NA, seq(1,500,1)), grid="T") water <- substuff$out$water -plot(water$P, water$rho, type="l") +plot(water$P, water$rho, type = "l") ``` The additional operations (`$out$water`) are used to extract a specific part of the results; this can be used with e.g. R's `write.table()` or `plot()` for further processing: ```{r subcrt_water_plot, eval=FALSE} @@ -265,7 +276,7 @@ T.units("K") P.units("MPa") E.units("J") -subcrt("methane", T=298.15, P=0.1)$out$methane$G +subcrt("methane", T = 298.15, P = 0.1)$out$methane$G data(thermo) ## restore default settings ``` @@ -288,7 +299,7 @@ For an example of a solubility calculation, see `demo(solubility)`, which is based on a figure in Manning et al. (2013). ``` ```{r CO2_dissolution} -subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=seq(0, 250, 50)) +subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T = seq(0, 250, 50)) ``` In order to make a plot like Figure 18 of @MSS13, let's run more calculations and store the results. @@ -296,14 +307,14 @@ ```{r dissolution, echo=FALSE, message=FALSE} T <- seq(0, 350, 10) -CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T=T)$out$logK -CO <- subcrt(c("CO", "CO"), c("gas", "aq"), c(-1, 1), T=T)$out$logK -CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T=T)$out$logK +CO2 <- subcrt(c("CO2", "CO2"), c("gas", "aq"), c(-1, 1), T = T)$out$logK +CO <- subcrt(c("CO", "CO"), c("gas", "aq"), c(-1, 1), T = T)$out$logK +CH4 <- subcrt(c("CH4", "CH4"), c("gas", "aq"), c(-1, 1), T = T)$out$logK logK <- data.frame(T, CO2, CO, CH4) ``` ```{r dissolution_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Equilibrium constants calculated for dissolution of CO2, CO, and CH4.", cache=TRUE, pngquant=pngquant} -matplot(logK[, 1], logK[, -1], type="l", col=1, lty=1, - xlab=axis.label("T"), ylab=axis.label("logK")) +matplot(logK[, 1], logK[, -1], type = "l", col = 1, lty = 1, + xlab = axis.label("T"), ylab = axis.label("logK")) text(80, -1.7, expr.species("CO2")) text(270, -2.2, expr.species("CO")) text(310, -2.4, expr.species("CH4")) @@ -372,13 +383,13 @@ Use `describe.reaction()` to write the reactions on a plot: ```{r describe_reaction_plot, fig.margin=TRUE, fig.width=3.5, fig.height=1.8, tiny.mar=TRUE, dpi=dpi, out.width="100%", pngquant=pngquant} -plot(0, 0, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2)) -text(0, 0, "acetoclastic methanogenesis", adj=0) -text(5, 1, describe.reaction(acetoclastic$reaction), adj=1) -text(0, 2, "acetate oxidation", adj=0) -text(5, 3, describe.reaction(acetate_oxidation$reaction), adj=1) -text(0, 4, "hydrogenotrophic methanogenesis", adj=0) -text(5, 5, describe.reaction(hydrogenotrophic$reaction), adj=1) +plot(0, 0, type = "n", axes = FALSE, ann=FALSE, xlim=c(0, 5), ylim=c(5.2, -0.2)) +text(0, 0, "acetoclastic methanogenesis", adj = 0) +text(5, 1, describe.reaction(acetoclastic$reaction), adj = 1) +text(0, 2, "acetate oxidation", adj = 0) +text(5, 3, describe.reaction(acetate_oxidation$reaction), adj = 1) +text(0, 4, "hydrogenotrophic methanogenesis", adj = 0) +text(5, 5, describe.reaction(hydrogenotrophic$reaction), adj = 1) ``` ## Chemical affinity @@ -405,13 +416,13 @@ ``` ```{r affinity_acetoclastic, message=FALSE} subcrt(c("acetate", "methane"), c(-1, 1), - c("aq", "gas"), logact=c(-3.4, -0.18), T=55, P=50)$out + c("aq", "gas"), logact = c(-3.4, -0.18), T = 55, P = 50)$out ``` The new `A` column shows the affinity; the other columns are unaffected and still show the standard-state properties. Let's repeat the calculation for hydrogenotrophic methanogenesis. ```{r affinity_hydrogenotrophic, message=FALSE} -subcrt("methane", 1, "gas", logact=-0.18, T=55, P=50)$out +subcrt("methane", 1, "gas", logact = -0.18, T = 55, P = 50)$out ``` Under the specified conditions, the affinities of hydrogenotrophic and acetoclastic methanogenesis are somewhat greater than and less than 20 kJ, respectively. @@ -425,7 +436,7 @@ ```{r rxnfun, message=FALSE} rxnfun <- function(coeffs) { subcrt(c("acetate", "methane"), coeffs, - c("aq", "gas"), logact=c(-3.4, -0.18), T=55, P=50)$out + c("aq", "gas"), logact = c(-3.4, -0.18), T = 55, P = 50)$out } ``` @@ -446,10 +457,10 @@ ) }) Adat <- do.call(rbind, Adat) -matplot(Adat[, 1], -Adat[, -1]/1000, type="l", lty=1, lwd=2, - xlab=axis.label("CO2"), ylab=axis.label("DG", prefix="k")) +matplot(Adat[, 1], -Adat[, -1]/1000, type = "l", lty = 1, lwd = 2, + xlab = axis.label("CO2"), ylab = axis.label("DG", prefix = "k")) legend("topleft", c("acetate oxidation", "acetoclastic methanogenesis", - "hydrogenotrophic methanogenesis"), lty=1, col=2:4) + "hydrogenotrophic methanogenesis"), lty = 1, col = 2:4) ``` ```{r methanogenesis_plot, eval=FALSE} ``` @@ -491,7 +502,7 @@ The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. Let's choose a set of variables commonly used in aqueous speciation diagrams: Eh and pH. -To use Eh as a variable, the electron (`e-`) should be in the basis. +To use Eh as a variable, the electron (*e*-) should be in the basis. To put the electron in there, we could use a different keyword (`basis("CHNOSe")`), or swap oxygen out of the existing basis: ```{r swap_basis} swap.basis("O2", "e-") @@ -503,14 +514,14 @@ ``` ```{r EhpH_plot, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant} -a <- affinity(pH=c(0, 12), Eh=c(-1, 1)) -diagram(a, fill="heat") +a <- affinity(pH = c(0, 12), Eh = c(-1, 1)) +diagram(a, fill = "heat") ``` Now we can calculate the affinities on an Eh-pH grid: ```{r EhpH_plot, echo=1, eval=FALSE} ``` -Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram: +Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram (i.e. a Pourbaix diagram): ```{r EhpH_plot_echo, eval=FALSE} diagram(a) ``` @@ -520,9 +531,9 @@ In systems where equilibrium is attainable, it makes sense to call this a *predominance diagram*, showing regions of maximum activity. ```{r EhpH_plot_color, fig.margin=TRUE, fig.width=4, fig.height=4, smallish.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, pngquant=pngquant} -diagram(a, fill="terrain", lwd=3, lty=3, - names=c("hydrogen sulfide", "bisulfide", "bisulfate", "sulfate"), - tplot=FALSE, main="sulfur species, 25 ?C", bty="n") +diagram(a, fill = "terrain", lwd = 3, lty = 3, + names = c("hydrogen sulfide", "bisulfide", "bisulfate", "sulfate"), + tplot = FALSE, main = "sulfur species, 25 ?C", bty = "n") ``` The default colors for diagrams shown on the screen uses R's `heat.colors()` palette. Some arguments in `diagram()` can be used to control the color, labels, and lines, and title (`main`). @@ -574,10 +585,10 @@ T <- 200 res <- 300 bases <- c("H2S", "HS-", "HSO4-", "SO4-2") -m1 <- mosaic(bases, blend=TRUE, pH=c(0, 12, res), Eh=c(-1.2, 0.75, res), T=T) -diagram(m1$A.species, lwd=2) -diagram(m1$A.bases, add=TRUE, col="blue", col.names="blue", lty=2) -water.lines("pH", "Eh", T=convert(T, "K"), col="red", lwd=2, lty=2) +m1 <- mosaic(bases, blend = TRUE, pH = c(0, 12, res), Eh=c(-1.2, 0.75, res), T=T) +diagram(m1$A.species, lwd = 2) +diagram(m1$A.bases, add = TRUE, col = "blue", col.names = "blue", lty = 2) +water.lines("pH", "Eh", T = convert(T, "K"), col = "red", lwd = 2, lty = 2) ``` The argument `blend=TRUE` is used to combine the diagrams according to the equilibrium activities of the basis species (see below). @@ -590,19 +601,19 @@ To do that, let's write a function to swap those basis species and make a diagram. We use R's `do.call()` to construct the argument list for `mosaic()`; this way, the name of the `newvar` argument to our function indicates the chosen variable. ```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant} -mosaicfun <- function(newvar, T=200, res=300) { +mosaicfun <- function(newvar, T = 200, res = 300) { swap.basis("e-", names(newvar)) if(names(newvar) == "O2") basis("O2", "gas") mosaicargs <- c(list(bases), blend=TRUE, pH=list(c(-2, 12, res)), newvar, T=T) m1 <- do.call(mosaic, mosaicargs) - diagram(m1$A.species, lwd=2, fill=rev(topo.colors(10))) - diagram(m1$A.bases, add=TRUE, col="blue", col.names="blue", lty=3) + diagram(m1$A.species, lwd = 2, fill = rev(topo.colors(10))) + diagram(m1$A.bases, add = TRUE, col = "blue", col.names = "blue", lty = 3) swap.basis(names(newvar), "e-") } -par(mfrow=c(1, 3)) -mosaicfun(list(Eh=c(-1, 1, res))) -mosaicfun(list(H2=c(-15, 5, res))) -mosaicfun(list(O2=c(-70, 0, res))) +par(mfrow = c(1, 3)) +mosaicfun(list(Eh = c(-1, 1, res))) +mosaicfun(list(H2 = c(-15, 5, res))) +mosaicfun(list(O2 = c(-70, 0, res))) ``` ## *T*, *P*, activity transects @@ -613,8 +624,8 @@ Let's use this feature to calculate affinities (negative Gibbs energies) of methanogenesis and biosynthetic reactions in a hydrothermal system. Some results of mixing calculations for seawater and vent fluid from the Rainbow hydrothermal field, reported by @SC10, are included in a data file in CHNOSZ: ```{r rainbow_data} -file <- system.file("extdata/cpetc/SC10_Rainbow.csv", package="CHNOSZ") -rb <- read.csv(file, check.names=FALSE) +file <- system.file("extdata/cpetc/SC10_Rainbow.csv", package = "CHNOSZ") +rb <- read.csv(file, check.names = FALSE) ``` We take a selection of the species from Shock and Canovas (2010) with activities equal to 10-6; methane is assigned an activity of 10-3. @@ -642,22 +653,22 @@ ``` Using `convert()`, we also convert the result from dimensionless values (*A*/2.303*RT*) to kcal/mol. ```{r rainbow_affinity, message=FALSE} -a <- affinity(T=rb$T, CO2=rb$CO2, H2=rb$H2, - `NH4+`=rb$`NH4+`, H2S=rb$H2S, pH=rb$pH) +a <- affinity(T = rb$T, CO2 = rb$CO2, H2 = rb$H2, + `NH4+` = rb$`NH4+`, H2S = rb$H2S, pH = rb$pH) T <- convert(a$vals[[1]], "K") a$values <- lapply(a$values, convert, "G", T) a$values <- lapply(a$values, `*`, -0.001) ``` ```{r rainbow_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, fig.cap="Affinities of organic synthesis in a hydrothermal system, after Shock and Canovas (2010).", pngquant=pngquant} -diagram(a, balance=1, ylim=c(-100, 100), ylab=axis.label("A", prefix="k"), - col=rainbow(8), lwd=2, legend.x=NA, bg="slategray3") -abline(h=0, lty=2, lwd=2) +diagram(a, balance = 1, ylim = c(-100, 100), ylab = axis.label("A", prefix="k"), + col = rainbow(8), lwd = 2, legend.x = NA, bg = "slategray3") +abline(h = 0, lty = 2, lwd = 2) ``` Finally, we use `diagram()` to plot the results. Although only temperature is shown on the *x*-axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). -To override that behavior, we set `balance=1` to plot the affinities of the formation reactions as written (per mole of the species being formed). +To override that behavior, we set `balance = 1` to plot the affinities of the formation reactions as written (per mole of the species being formed). Also, `legend.x=NA` is used to suppress making a legend (so the labels are placed next to the lines instead). ```{r rainbow_diagram, eval=FALSE} ``` @@ -693,7 +704,7 @@ The affinity of formation of pyrite happens to be zero because it is identical to one of the selected basis species. ``` ```{r PPM_affinity, message=FALSE} -unlist(affinity(T=300, P=100)$values) +unlist(affinity(T = 300, P = 100)$values) ``` We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature. @@ -703,11 +714,11 @@ basis(c("H2S", "O2"), c("PPM", "PPM")) ``` ```{r PPM_activities, message=FALSE} -unlist(affinity(T=300, P=100, return.buffer=TRUE)[1:3]) +unlist(affinity(T = 300, P = 100, return.buffer = TRUE)[1:3]) ``` ```{r demo_buffer, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, echo=FALSE, cache=TRUE, pngquant=pngquant} -demo(buffer, echo=FALSE) +demo(buffer, echo = FALSE) ``` Et voil?! We have found log*a*H2S and `r logfO2` that are compatible with the coexistence of the three minerals. Under these conditions, the affinities of formation reactions of the minerals in the buffer are all equal to zero: @@ -753,49 +764,35 @@ The reaction-matrix method is slower, but can be applied to systems were the balanced basis species has non-unity coefficients. ```{r bjerrum_diagram, fig.margin=TRUE, fig.width=3, fig.height=6, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, cache=TRUE, fig.cap="Three views of carbonate speciation: affinity, metastable equilibrium activity, degree of formation.", pngquant=pngquant} -par(mfrow=c(3, 1)) +par(mfrow = c(3, 1)) basis("CHNOS+") species(c("CO2", "HCO3-", "CO3-2")) -# affinity at 25 ?C and 150 ?C -a25 <- affinity(pH=c(4, 12)) -a150 <- affinity(pH=c(4, 12), T=150) -diagram(a25, legend.x="topleft", bty="n") -diagram(a150, add=TRUE, col="red") -# equilibration -e25 <- equilibrate(a25, loga.balance=-3) -e150 <- equilibrate(a150, loga.balance=-3) -diagram(e25, ylim=c(-6, 0), bty="n") -diagram(e150, add=TRUE, col="red") -# degree of formation -diagram(e25, alpha=TRUE, legend.x="center", bty="n") -diagram(e150, alpha=TRUE, add=TRUE, col="red") +a25 <- affinity(pH = c(4, 12)) +a150 <- affinity(pH = c(4, 12), T = 150) +diagram(a25, legend.x = "topleft", bty = "n") +diagram(a150, add = TRUE, col = "red") +e25 <- equilibrate(a25, loga.balance = -3) +e150 <- equilibrate(a150, loga.balance = -3) +diagram(e25, ylim = c(-6, 0), bty = "n") +diagram(e150, add = TRUE, col = "red") +diagram(e25, alpha = TRUE, legend.x = "center", bty = "n") +diagram(e150, alpha = TRUE, add = TRUE, col = "red") ``` -The distribution of aqueous carbonate species is a classic example of an equilibrium calculation. -We can begin by plotting the affinities for equal activities of the species. + +The distribution of aqueous carbonate species as a function of pH (Bjerrum plot) is a classic example of an equilibrium calculation. +We can begin by plotting the affinities calculated at 25 ?C and 150 ?C with equal activities of the species. Here, CO2 is in the basis, so it has zero affinity, which is greater than the affinities of HCO3- and CO3-2 at low pH: -```{r bjerrum_1, eval=FALSE} -basis("CHNOS+") -species(c("CO2", "HCO3-", "CO3-2")) -a25 <- affinity(pH=c(4, 12)) -a150 <- affinity(pH=c(4, 12), T=150) -diagram(a25, legend.x="topleft", bty="n") -diagram(a150, add=TRUE, col="red") +```{r bjerrum_diagram, echo=1:7, eval=FALSE} ``` Now we use `equilibrate()` to calculate the activities of species. Our balancing constraint is that the total activity of C is 10-3. This shows a hypothetical *metastable equilibrium*; we know that for true equilibrium the total activity of C is affected by pH. -```{r bjerrum_2, eval=FALSE} -e25 <- equilibrate(a25, loga.balance=-3) -e150 <- equilibrate(a150, loga.balance=-3) -diagram(e25, ylim=c(-6, 0), bty="n") -diagram(e150, add=TRUE, col="red") +```{r bjerrum_diagram, echo=8:11, eval=FALSE} ``` To display the species distribution, or degree of formation, use the `alpha=TRUE` argument: -```{r bjerrum_3, eval=FALSE} -diagram(e25, alpha=TRUE, legend.x="center", bty="n") -diagram(e150, alpha=TRUE, add=TRUE, col="red") +```{r bjerrum_diagram, echo=12:13, eval=FALSE} ``` The possible reactions between species are all balanced on 1 C. @@ -812,22 +809,22 @@ To demonstrate this feature, let's consider the distribution of carbon among organic and inorganic species in the hydrothermal mixing scenario described by @SS98. First we define the basis and add two inorganic species. -The `index.return=FALSE` argument tells `info()` to return the index (number) of the species in the current species definition; these indices are saved for use below: +The `index.return = TRUE` argument tells `info()` to return the index (number) of the species in the current species definition; these indices are saved for use below: ```{r groups_basis, results="hide", message=FALSE} basis("CHNOS+") -ii <- species(c("CO2", "HCO3-"), index.return=TRUE) +ii <- species(c("CO2", "HCO3-"), index.return = TRUE) ``` Next, we add each group of organic species: C1--C8 alcohols, C3--C8 ketones, C2--C12 carboxylic acids and their corresponding anions, and C2--C8 alkenes. We provide `info()` with a set of `ispecies` values to select these species. -The species in each group are ordered by carbon number in the database, so the set is made from the starting and ending indices using R's `seq()` function, wrapped by `seq2()` to make the code shorter. +The species in each group are ordered by carbon number in the database, so the set is made from the starting and ending indices using R's `seq()` function, wrapped by a `seq2()` we write to make the code shorter. ```{r groups_species, message=FALSE} seq2 <- function(x) seq(x[1], x[2]) -ia <- species(seq2(info(c("methanol", "octanol"))), index.return=TRUE) -ik <- species(seq2(info(c("acetone", "2-octanone"))), index.return=TRUE) +ia <- species(seq2(info(c("methanol", "octanol"))), index.return = TRUE) +ik <- species(seq2(info(c("acetone", "2-octanone"))), index.return = TRUE) ic <- species(seq2(info(c("acetic acid","n-dodecanoic acid"))),index.return=TRUE) -ica <- species(seq2(info(c("acetate", "n-dodecanoate"))), index.return=TRUE) -ie <- species(seq2(info(c("ethylene", "octene"))), index.return=TRUE) +ica <- species(seq2(info(c("acetate", "n-dodecanoate"))), index.return = TRUE) +ie <- species(seq2(info(c("ethylene", "octene"))), index.return = TRUE) ``` Now we read two data files that contain values of `r logfO2` and pH as a function of temperature, digitized from Figure 5 of Schulte and Shock (1998). @@ -838,9 +835,9 @@ Because of the noise introduced by digitization of the figure, we smooth the data using R's `smooth.spline()`; the lower *T* limit reflects the absence of data below this temperature in the figure for log*f*O2. ```{r groups_data} O2dat <- read.csv(system.file( - "extdata/cpetc/SS98_Fig5a.csv", package="CHNOSZ")) + "extdata/cpetc/SS98_Fig5a.csv", package = "CHNOSZ")) pHdat <- read.csv(system.file( - "extdata/cpetc/SS98_Fig5b.csv", package="CHNOSZ")) + "extdata/cpetc/SS98_Fig5b.csv", package = "CHNOSZ")) T <- seq(8, 350) O2 <- predict(smooth.spline(O2dat$T, O2dat$logfO2), T)$y pH <- predict(smooth.spline(pHdat$T, pHdat$pH), T)$y @@ -854,8 +851,8 @@ The ability to vary the activity of the balanced basis species is not yet implemented in CHNOSZ, so a single value is used here. ``` ```{r groups_affinity, message=FALSE, cache=TRUE} -a <- affinity(T=T, O2=O2, pH=pH) -e <- equilibrate(a, loga.balance=-2.5) +a <- affinity(T = T, O2 = O2, pH = pH) +e <- equilibrate(a, loga.balance = -2.5) ``` At last we come to the diagram. @@ -863,18 +860,18 @@ When summing the activities of species in the groups, each activity is multiplied first by the balance coefficient on that species. Therefore, the total activity is that of a basis species (or of an element that only in that basis species, like carbon in this example). ```{r groups_diagram, echo=1:4, eval=FALSE} -par(mfrow=c(1, 3)) -groups <- list(inorganic=ii, alcohols=ia, ketones=ik, - `carboxylic acids`=c(ic, ica), alkenes=ie) -diagram(e, alpha=TRUE, groups=groups, legend.x=NA) +par(mfrow = c(1, 3)) +groups <- list(inorganic = ii, alcohols = ia, ketones = ik, + `carboxylic acids` = c(ic, ica), alkenes = ie) +diagram(e, alpha = TRUE, groups = groups, legend.x = NA) # plot only alcohols names <- within(species(), name[-ia] <- "")$name -lty <- ifelse(names=="", 0, 1) -diagram(e, alpha=TRUE, ylim=c(0, 0.5), lty=lty, names=names) +lty <- ifelse(names == "", 0, 1) +diagram(e, alpha = TRUE, ylim = c(0, 0.5), lty = lty, names = names) # plot only ketones names <- within(species(), name[-ik] <- "")$name -lty <- ifelse(names=="", 0, 1) -diagram(e, alpha=TRUE, ylim=c(0, 0.13), lty=lty, names=names) +lty <- ifelse(names == "", 0, 1) +diagram(e, alpha = TRUE, ylim = c(0, 0.13), lty = lty, names = names) ``` That makes a diagram that is similar to Figure 6b of Shock and Schulte (1998). @@ -893,28 +890,28 @@ How about the choice between balancing constraints? Be default, `equilibrate()` and `diagram()` balance reactions on the first basis species that is present in each of the species of interest. Let's look at some amino acids in a hypothetical metastable equilibrium. -This calculation is based on one described by @Sho90b for five amino acids, but here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. +This calculation is based on one described by @Sho90b for five amino acids, but here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. We use `ZC.col()` to generate colors based on the average oxidation state of carbon of the amino acids (red and blue for relatively reduced and oxidized). ```{r aminoacids_setup, results="hide", message=FALSE} basis("CHNOS") basis("CO2", "gas") swap.basis("NH3", "N2") species(aminoacids("")) -a <- affinity(O2=c(-50, -25, 300), CO2=c(-10, 15, 300), T=250, P=265) +a <- affinity(O2 = c(-50, -25, 300), CO2 = c(-10, 15, 300), T = 250, P = 265) aa.ZC <- ZC(info(aminoacids(""))) col <- ZC.col(aa.ZC) ``` To make plots using different balance constraints, let's write a simple function that sets the `balance` argument of `diagram()` and adds a title to the plot. The first plot is the most similar to Figure 4 of Shock (1990), except for the absence of alanine (probably due to different thermodynamic data) and the presence of some other amino acids. -There, we set `balance=1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone. +There, we set `balance = 1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone. The remaining plots balance on each of the basis species (except for O2), then on volume (in the last plot). ```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", cache=TRUE, pngquant=pngquant} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 143 From noreply at r-forge.r-project.org Sun Feb 12 03:14:49 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 12 Feb 2017 03:14:49 +0100 (CET) Subject: [CHNOSZ-commits] r144 - in pkg/CHNOSZ: . R inst vignettes Message-ID: <20170212021449.DDC9918868D@r-forge.r-project.org> Author: jedick Date: 2017-02-12 03:14:49 +0100 (Sun, 12 Feb 2017) New Revision: 144 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/revisit.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: comment "csl: elementa.csl" for building on R-Forge Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-12 02:14:49 UTC (rev 144) @@ -1,6 +1,6 @@ -Date: 2017-02-11 +Date: 2017-02-12 Package: CHNOSZ -Version: 1.0.8-33 +Version: 1.0.8-34 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/revisit.R =================================================================== --- pkg/CHNOSZ/R/revisit.R 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/R/revisit.R 2017-02-12 02:14:49 UTC (rev 144) @@ -172,7 +172,7 @@ xlab <- "loga2" if(is.null(xlim)) xlim <- extendrange(loga2) if(is.null(ylim)) ylim <- extendrange(loga1) - plot(loga2, loga1, xlab=xlab, ylab=ylab, pch=pch, col=col, xlim=xlim, ylim=ylim) + plot(loga2, loga1, xlab=xlab, ylab=ylab, pch=pch, col=col, xlim=xlim, ylim=ylim, cex=cex) # add a 1:1 line lines(range(loga2), range(loga2), col="grey") # add a lowess line Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/inst/NEWS 2017-02-12 02:14:49 UTC (rev 144) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-33 (2017-02-11) +CHANGES IN CHNOSZ 1.0.8-34 (2017-02-12) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-12 02:14:49 UTC (rev 144) @@ -20,7 +20,9 @@ \usepackage[utf8]{inputenc} bibliography: vig.bib link-citations: yes -csl: elementa.csl +# The custom CSL file gives a build error on R-Forge (2017-02-12): +# pandoc-citeproc: error while parsing the XML string +#csl: elementa.csl --- ```{r options, include=FALSE} @@ -46,7 +48,8 @@ dpi <- 72 # use pngquant to optimize PNG images knit_hooks$set(pngquant = hook_pngquant) -pngquant <- "--speed=1 --quality=0-50" +# pngquant isn't available on R-Forge ... +if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL else pngquant <- "--speed=1 --quality=0-50" # some frequently used HTML expressions logfO2 <- "logfO2" # use lowercase here because these tend to be variable names in the examples @@ -56,7 +59,7 @@ # http://stackoverflow.com/questions/23852753/knitr-with-gridsvg # Set up a chunk hook for manually saved plots. knit_hooks$set(custom.plot = hook_plot_custom) -# hook to change to - required for interactive SVG +# hook to change to -- required for interactive SVG hook_plot <- knit_hooks$get("plot") knit_hooks$set(plot = function(x, options) { x <- hook_plot(x, options) @@ -921,7 +924,7 @@ Caveat: these plots demonstrate some possibilities in CHNOSZ and are not necessarily realistic portrayals of this system. It does seem odd to balance on a fugacious component like `r o2` or `r h2o`. Unlike different choices of basis species, which are thermodynamically equivalent (see the example above for a mineral system), the choice of balance reflects extra-thermodynamic factors. -For instance, the widespread rule of thumb for balancing mineral reactions on a component is unrealistic for processes where volume is conserved [@MC11]. +For instance, the widespread rule of thumb for balancing mineral reactions on a component is unrealistic for processes where volume is conserved [@MD98]. Any choice of balancing constraints may oversimplify the physical or biological context for reactions of organic species or biomolecules. While choosing an inappropriate balance leads to infeasible models, consideration of the possibilities might give insight into the conditions affecting the dynamics of some systems. Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-12 02:14:49 UTC (rev 144) @@ -19,7 +19,7 @@ \usepackage[utf8]{inputenc} bibliography: vig.bib link-citations: yes -csl: elementa.csl +#csl: elementa.csl --- ```{r setup, include=FALSE} @@ -28,7 +28,8 @@ options(htmltools.dir.version = FALSE) # use pngquant to optimize PNG images knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) -pngquant <- "--speed=1 --quality=0-50" +# pngquant isn't available on R-Forge ... +if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL else pngquant <- "--speed=1 --quality=0-50" ``` Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-11 18:37:23 UTC (rev 143) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-12 02:14:49 UTC (rev 144) @@ -115,14 +115,14 @@ } @Article{GHB_03, - author = {Ghaemmaghami, Sina and Huh, Won-Ki and Bower, Kiowa and Howson, Russell W. and Belle, Archana and Dephoure, Noah and O'Shea, Erin K. and Weissman, Jonathan S.}, - journal = {Nature}, - title = {Global analysis of protein expression in yeast}, - year = {2003}, - volume = {425}, - number = {6959}, - pages = {737--741}, - doi = {10.1038/nature02046}, + author = {Ghaemmaghami, Sina and Huh, Won-Ki and Bower, Kiowa and Howson, Russell W. and Belle, Archana and Dephoure, Noah and O'Shea, Erin K. and Weissman, Jonathan S.}, + journal = {Nature}, + title = {Global analysis of protein expression in yeast}, + year = {2003}, + volume = {425}, + number = {6959}, + pages = {737--741}, + doi = {10.1038/nature02046}, } @Incollection{Hel70c, @@ -182,19 +182,6 @@ doi = {10.2138/rmg.2013.75.5}, } - at Article{MC11, - author = {Merino, Enrique and Canals, ?ngels}, - journal = {American Journal of Science}, - title = {Self-accelerating dolomite-for-calcite replacement: Self-organized dynamics of burial dolomitization and associated mineralization}, - year = {2011}, - volume = {311}, - number = {7}, - pages = {573--607}, - doi = {10.2475/07.2011.01}, - sn = {0002-9599}, - z9 = {0}, -} - @InProceedings{NPW_79, author = {Nordstrom, D. K. and Plummer, L. N. and Wigley, T. M. L. and Wolery, T. J. and Ball, J. W. and Jenne, E. A. and Bassett, R. L. and Crerar, D. A. and Florence, T. M. and Fritz, B. and Hoffman, M. and Holdren, G. R., Jr. and Lafon, G. M. and Mattigod, S. V. and McDuff, R. E. and Morel, F. and Reddy, M. M. and Sposito, G. and Thrailkill, J.}, title = {A comparison of computerized chemical models for equilibrium calculations in aqueous systems}, @@ -458,3 +445,15 @@ doi = {10.1038/ncomms2998}, } + at Article{MD98, + author = {Merino, Enrique and Dewers, Thomas}, + journal = {Journal of Hydrology}, + title = {Implications of replacement for reaction?transport modeling}, + year = {1998}, + volume = {209}, + number = {1?4}, + pages = {137--146}, + doi = {10.1016/S0022-1694(98)00150-4}, + issn = {0022-1694}, +} + From noreply at r-forge.r-project.org Sun Feb 12 10:43:41 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 12 Feb 2017 10:43:41 +0100 (CET) Subject: [CHNOSZ-commits] r145 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20170212094341.E0167187E6E@r-forge.r-project.org> Author: jedick Date: 2017-02-12 10:43:41 +0100 (Sun, 12 Feb 2017) New Revision: 145 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/revisit.R pkg/CHNOSZ/inst/CHECKLIST pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/objective.Rd pkg/CHNOSZ/man/revisit.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add optimization of chemical activities Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-12 09:43:41 UTC (rev 145) @@ -1,6 +1,6 @@ Date: 2017-02-12 Package: CHNOSZ -Version: 1.0.8-34 +Version: 1.0.8-35 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/revisit.R =================================================================== --- pkg/CHNOSZ/R/revisit.R 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/R/revisit.R 2017-02-12 09:43:41 UTC (rev 145) @@ -51,7 +51,7 @@ col = par("fg"), yline = 2, ylim = NULL, cex = par("cex"), lwd = par("lwd"), mar = NULL, side = 1:4, xlim = NULL, labcex = 0.6, pch = 1, main = NULL, plot.it = NULL, add = FALSE, plot.optval = TRUE, - style.2D = "contour") { + style.2D = "contour", bg = par("bg")) { # given a list of logarithms of activities of species # (as vectors or matrices or higher dimensional arrays) # calculate a diversity index or thermodynamic property @@ -158,6 +158,11 @@ xrange <- range(xs) } else xs <- NA + # format the objective name if it's DGtr or DGinf + if(objective=="DGtr") objexpr <- expr.property("DGtr/2.303RT") + if(objective=="DGinf") objexpr <- expr.property("DGinf/2.303RT") + else objexpr <- objective + # make plots and assemble return values if(nd==0) { # a 0-D plot @@ -168,21 +173,24 @@ qqline(loga1) } else if(any(grepl("a2", objargs))) { # plot the points for a referenced objective - ylab <- "loga1" - xlab <- "loga2" + xlab <- substitute(log~italic(a)[expt]) + ylab <- substitute(log~italic(a)[calc]) if(is.null(xlim)) xlim <- extendrange(loga2) if(is.null(ylim)) ylim <- extendrange(loga1) - plot(loga2, loga1, xlab=xlab, ylab=ylab, pch=pch, col=col, xlim=xlim, ylim=ylim, cex=cex) + # just initialize the plot here; add points below so that appear above lines + plot(loga2, loga1, xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim, type="n") # add a 1:1 line lines(range(loga2), range(loga2), col="grey") - # add a lowess line + # add a loess line if(!is.null(lwd)) { ls <- loess.smooth(loga2, loga1, family="gaussian") lines(ls$x, ls$y, col="red", lwd=lwd) } + # add points + points(loga2, loga1, pch=pch, col=col, cex=cex, bg=bg) } else plot.it <- FALSE # add a title - if(missing(main)) main <- paste(objective, "=", round(H,3)) + if(missing(main)) main <- substitute(obj==H, list(obj=objexpr, H=round(H,3))) if(plot.it) title(main=main) } } else if(nd==1) { @@ -195,12 +203,8 @@ if(plot.it) { if(is.null(ylim)) ylim <- extendrange(H, f=0.075) if(is.null(xlim)) xlim <- xrange - # format the objective name if it's DGtr or DGinf - if(objective=="DGtr") ylab <- expr.property("DGtr/2.303RT") - if(objective=="DGinf") ylab <- expr.property("DGinf/2.303RT") - else ylab <- objective if(!add) thermo.plot.new(xlim=xlim, ylim=ylim, xlab=axis.label(xname), - ylab=ylab, yline=yline, cex=cex, lwd=lwd, mar=mar, side=side) + ylab=objexpr, yline=yline, cex=cex, lwd=lwd, mar=mar, side=side) # plot the values lines(xs, c(H), col=col) # indicate the optimal value Modified: pkg/CHNOSZ/inst/CHECKLIST =================================================================== --- pkg/CHNOSZ/inst/CHECKLIST 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/inst/CHECKLIST 2017-02-12 09:43:41 UTC (rev 145) @@ -2,11 +2,14 @@ release checklist for CHNOSZ **************************** -- run examples() to make sure that all examples can be run +- uncomment CSL line in Rmd files (commented for building on R-Forge) + csl: elementa.csl + +- compile vignettes with release version number and date. + +- run examples() and demos() to make sure they can be run (that includes \donttest ones that aren't run by R CMD check) -- run demos() to run all demos - - check output of demo("sources") to make sure all data sources are cited - check output of R CMD Rd2pdf: fix lines truncated by page margins @@ -24,8 +27,6 @@ - update list of documentation topics in examples() with any new ones -- run test_package("CHNOSZ") to run all tests - - recreate extdata/thermo/obigt_check.csv after all data updates: co <- check.obigt() write.csv(co, "obigt_check.csv", row.names=FALSE, na="") Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/inst/NEWS 2017-02-12 09:43:41 UTC (rev 145) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-34 (2017-02-12) +CHANGES IN CHNOSZ 1.0.8-35 (2017-02-12) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/man/objective.Rd =================================================================== --- pkg/CHNOSZ/man/objective.Rd 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/man/objective.Rd 2017-02-12 09:43:41 UTC (rev 145) @@ -71,7 +71,7 @@ \code{DGtr} calculates the change in Gibbs energy/2.303RT of a system in which species with initial logarithms of activitiy (\code{loga1}) are transformed to the same species with different final logarithms of activity (\code{loga2}) at constant temperature, pressure and chemical potentials of basis species. It is calculated as the sum over species of (G2-G1) where G1/RT = -a1*Astar + a1*loga1 - a1 + a constant (where a1 is 10^loga1), likewise for G2, and where \code{Astar} is the starved affinity, that is the affinity of the reaction to form one mole of the species at unit activity from the basis species in their defined activities. -The equation used arises from integrating dG = -A/dxi = -A/dn where xi is the reaction progress variable, dn/dxi = 1 is the reaction coefficient on the species, and A = Astar - 2.303RTloga is the chemical affinity. +The equation used arises from integrating dG = -A/dxi = -A/dn where xi is the reaction progress variable, dn/dxi = 1 is the reaction coefficient on the species, and A = Astar - 2.303RTloga is the chemical affinity (Dick and Shock, 2013). Each objective function has an attribute (see \code{\link{attributes}} and \code{\link{structure}}) named \samp{optimum} that takes the value of \samp{minimal} (\code{SD}, \code{CV}, \code{RMSD}, \code{CVRMSD}, \code{DGmix}, \code{DDGmix}, \code{DGtr}) or \samp{maximal} (\code{logact}, \code{shannon}, \code{qqr}, \code{spearman}, \code{pearson}). This attribute is used in \code{\link{optimal.index}} and \code{\link{extremes}} to identify the conditions having optimal values of the objective functions. @@ -139,9 +139,10 @@ Anderson, G. M. (2005) \emph{Thermodynamics of Natural Systems}, 2nd ed., Cambridge University Press, 648 p. \url{http://www.worldcat.org/oclc/474880901} + Dick, J. M. and Shock, E. L. (2013) A metastable equilibrium model for the relative abundance of microbial phyla in a hot spring. \emph{PLoS ONE} \bold{8}, e72395. \url{http://dx.doi.org/10.1371/journal.pone.0072395} + Ludovisi, A. and Taticchi, M. I. (2006) Investigating beta diversity by Kullback-Leibler information measures. \emph{Ecological Modelling} \bold{192}, 299--313. \url{http://dx.doi.org/10.1016/j.ecolmodel.2005.05.022} - } \concept{Secondary thermodynamic modeling} Modified: pkg/CHNOSZ/man/revisit.Rd =================================================================== --- pkg/CHNOSZ/man/revisit.Rd 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/man/revisit.Rd 2017-02-12 09:43:41 UTC (rev 145) @@ -14,7 +14,7 @@ ispecies = NULL, col = par("fg"), yline = 2, ylim = NULL, cex = par("cex"), lwd = par("lwd"), mar = NULL, side = 1:4, xlim = NULL, labcex = 0.6, pch = 1, main = NULL, plot.it = NULL, - add = FALSE, plot.optval = TRUE, style.2D = "contour") + add = FALSE, plot.optval = TRUE, style.2D = "contour", bg = par("bg")) optimal.index(z, objective) extremes(z, objective) } @@ -41,6 +41,7 @@ \item{plot.optval}{logical, show the location of the optimal value(s)?} \item{style.2D}{character, type of 2-D plot} \item{z}{numeric, matrix of values (\samp{H} element of output from \code{revisit})} + \item{bg}{character, background for \code{\link{points}}} } \details{ Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-12 09:43:41 UTC (rev 145) @@ -44,12 +44,17 @@ knit_hooks$set(smallish.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) -# dpi setting -dpi <- 72 # use pngquant to optimize PNG images knit_hooks$set(pngquant = hook_pngquant) # pngquant isn't available on R-Forge ... -if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL else pngquant <- "--speed=1 --quality=0-50" +if (!nzchar(Sys.which("pngquant"))) { + pngquant <- NULL + # save space by using a lower resolution + dpi <- 50 +} else { + pngquant <- "--speed=1 --quality=0-50" + dpi <- 72 +} # some frequently used HTML expressions logfO2 <- "logfO2" # use lowercase here because these tend to be variable names in the examples @@ -152,7 +157,7 @@ Some experimental functions are available: -* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. +* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. # Thermodynamic database and chemical formulas @@ -235,7 +240,7 @@ To calculate the standard molal properties of species and reactions, use `subcrt()`. ```{marginfigure} -The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of `r h2o`, is SUPCRT (Johnson et al., 1992). +The inspiration for the name `subcrt()`, and the source of the FORTRAN subroutine used to calculate the thermodynamic properties of H2O, is SUPCRT (Johnson et al., 1992). ``` [- at JOH92] If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: @@ -472,10 +477,6 @@ ```{r data_thermo, message=FALSE} ``` -## Activity coefficients - -XXX Example using `nonideal()` ... Alberty, 2003, Fig. 1.4-1.5 (p. 9-10, 235-236) - # `affinity()`, species of interest, and potential diagrams `affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species. @@ -497,7 +498,7 @@ Now, we can use `affinity()` to calculate the affinities of the formation reactions of each of the species: ```{marginfigure} -The values returned by `affinity()` are dimensionless, i.e. log10(*A*/*RT*). +The values returned by `affinity()` are dimensionless, i.e. *A*/2.303*RT*. ``` ```{r affinity} affinity()$values @@ -606,7 +607,7 @@ ```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant} mosaicfun <- function(newvar, T = 200, res = 300) { swap.basis("e-", names(newvar)) - if(names(newvar) == "O2") basis("O2", "gas") + if (names(newvar) == "O2") basis("O2", "gas") mosaicargs <- c(list(bases), blend=TRUE, pH=list(c(-2, 12, res)), newvar, T=T) m1 <- do.call(mosaic, mosaicargs) diagram(m1$A.species, lwd = 2, fill = rev(topo.colors(10))) @@ -669,7 +670,7 @@ abline(h = 0, lty = 2, lwd = 2) ``` Finally, we use `diagram()` to plot the results. -Although only temperature is shown on the *x*-axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. +Although only temperature is shown on the *x* axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). To override that behavior, we set `balance = 1` to plot the affinities of the formation reactions as written (per mole of the species being formed). Also, `legend.x=NA` is used to suppress making a legend (so the labels are placed next to the lines instead). @@ -1196,10 +1197,10 @@ The experimental relative abundances are plotted as thin horizontal lines with the same style and color as the thicker curved lines calculated for metastable equilibrium. With the exception of YNL049C, the overlap between the calculations and experiments looks to be greatest near the middle-left part of the figure. The `revisit()` function offers some statistical and thermodynamic measures that can quantify this comparison. -Here, we plot the free energy associated with the information-theoretic "relative entropy" or Kullback-Leibler divergence: +Here, we plot the information-theoretic free energy ?*Ginf* (relative entropy or Kullback-Leibler divergence): ```{r yeastplot, eval=FALSE, echo=10} ``` -```{r yeastplot, fig.fullwidth=TRUE, fig.width=7.5, fig.height=2.5, small.mar=TRUE, dpi=100, out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, fig.cap="ER-to-Golgi proteins: calculations without and with normalization, and free energy difference between experimental and normalization-calculated abundances.", pngquant=pngquant} +```{r yeastplot, fig.fullwidth=TRUE, fig.width=7.5, fig.height=2.5, small.mar=TRUE, dpi=ifelse(dpi==50, 50, 100), out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, fig.cap="ER-to-Golgi proteins: calculations without and with normalization, and free energy difference between experimental and normalization-calculated abundances.", pngquant=pngquant} ``` The minimum free energy difference occurs near `r logfO2` = -78. @@ -1227,7 +1228,7 @@ aa_Ef <- read.fasta(system.file("extdata/fasta/EF-Tu.aln", package = "CHNOSZ"), iseq = 1:2) ``` -`seq2aa()` counts the amino acids in a user-supplied sequence and generates a data frame of the amino acid compoisition: +`seq2aa()` counts the amino acids in a user-supplied sequence and generates a data frame of the amino acid composition: ```{marginfigure} See also `?count.aa`, which can process both protein and nucleic acid sequences. ``` @@ -1357,6 +1358,133 @@ ```{r bison_transferase, eval=FALSE, echo=12:15} ``` +# Experimental features + +## Activity coefficients + +XXX Example using `nonideal()` ... Alberty, 2003, Fig. 1.4-1.5 (p. 9-10, 235-236) + +## Optimization of chemical activities + +What are the conditions that minimize the standard deviation of calculated activities of species? +What are the conditions that minimize the energetic difference between measured and calculated abundances? +These are questions about optimization of chemical activities. +`revisit()` provides calculations and plots of an objective function in 1 or 2 dimensions of activity of basis species, *T*, or *P*. +```{marginfigure} +See `?objective` for more information. +``` +`findit()` provides a calculation of an objective function on a higher-dimensional grid. + +Amino acids may be produced by high-temperature processes in hydrothermal vents (smokers). +To what extent do their relative abundances tend toward metastable equilibrium? +Let's suppose that the major variables are oxygen fugacity and activity of water (`r h2o`) and ammonia (NH3). +Here are the variables and the (very large) range of logarithms of chemical activity of the basis species that we will explore. +```{r smoker_vars} +vars <- list(O2 = c(-50, -25), NH3 = c(-15, 10), H2O = c(-15, 10)) +``` + +Consider the amino acid abundances reported by @FMM_14. +We identify the amino acids here with their one-letter abbreviations. +Then, `aminoacids()` is used to produce the full names, which in turn are used to search `thermo$obigt` for their formulas. +`makeup()` is used to count the elements in the formulas. +```{r smoker_aa, message=FALSE} +aa <- c("D", "T", "S", "E", "G", "A", "K", "H") +AA <- aminoacids("", aa) +AA.formula <- do.call(rbind, makeup(info(AA))) +AA +``` + +Let's use the reported concentrations (?M) of amino acids in sample D1441 CW-2. +```{marginfigure} +Three amino acids (Val, Phe, Arg) with concentrations below the detection limit of 0.01 ?M are not included here. +``` +The concentrations are converted to logarithmic values (`loga2`). +We then calculate the total C concentration in the measurements; this uses the amino acid formulas calculated above. +```{r smoker_uM} +uM <- c(1.10, 0.70, 3.73, 0.39, 3.04, 1.83, 0.27, 0.21) +loga2 <- log10(uM * 1e-6) +nC <- AA.formula[, "C"] +Ctot <- sum(nC * uM * 1e-6) +``` + +Next, set the basis, load the species, and assign the temperature and resolution to be used in `affinity()`. +Also, we assign the objective function to be the root mean square deviation (RMSD) between experimental and calculated logarithms. +```{r smoker_basis, results="hide"} +basis("CHNOS") +species(AA) +T <- 270 +res <- 80 +objective <- "RMSD" +``` + +Then, we set up the figure, calculate chemical affinities in one dimension, and run `equilibrate()` with the given total carbon activity. +`revisit()` is used to plot RMSD and to identify the `r logfO2` where it is minimized: +```{r smoker_plot, eval=FALSE, echo=1:6} +layout(matrix(1:6, nrow = 2)) +a <- affinity(O2 = c(vars[[1]], res), T = T) +e <- equilibrate(a, loga.balance = log10(Ctot)) +r <- revisit(e, objective, loga2) +d.basis <- describe.basis(ibasis = 1:4) +legend("topleft", d.basis) +ourfun <- function(ibasis = 1:5, x="bottomright") { + a <- affinity(T = T) + e <- equilibrate(a, loga.balance = log10(Ctot)) + revisit(e, objective, loga2, cex = 2.7, pch = 21) + text(loga2, unlist(e$loga.equil), aa) + d.basis <- describe.basis(ibasis = ibasis) + legend(x, d.basis) +} +basis("O2", r$xopt) +ourfun(5) +a <- affinity(O2 = c(vars[[1]], res), NH3 = c(vars[[2]], res), T = T) +e <- equilibrate(a, loga.balance = log10(Ctot)) +r <- revisit(e, objective, loga2) +basis("O2", r$xopt) +basis("NH3", r$yopt) +ourfun(c(3, 5)) +findit(vars[1:3], objective, loga2=loga2, loga.balance=log10(Ctot), + T=T, res=10, niter=8, rat=0.8) +ourfun(c(2, 3, 5), "right") +``` + +Now, we write a function that calculates the affinities and metasable equilibrium activities at a single condition and uses `revisit()` to make a scatter plot. +The plot includes a 1:1 line (grey) and a trend line calculated using R's `loess.smooth()` (red), and the minimum value of RMSD in the title. +The function also adds a legend summarizing the optimal conditions. +```{r smoker_plot, eval=FALSE, echo=7:14} +``` + +We set activity of `r logfO2` in the basis (where RMSD was minimized the first call to `revisit()`), then use our function to make a scatter plot. +```{r smoker_plot, eval=FALSE, echo=15:16} +``` + +In the next pair of plots, let's use two variables: `r logfO2` and log*a*NH3. +This time, `revisit()` makes a contour diagram of the objective function, highlighting the location of the minimum (star) as well as the minimum trough following the *x* or *y* axis (dotted blue and green lines). +After that, we set the activities of both of the basis species and then use `ourfun()` to make a scatter plot. +The legend here shows the two variables that have been optimized; these give RMSD that is lower than in the first calculation: +```{r smoker_plot, eval=FALSE, echo=17:22} +``` + +Finally, we use `findit()` to optimize three variables. +The affinity and equilibrium calculations are integrated into `findit()`, so the function call requires the `loga.balance` and `T` arguments. +Other arguments indicate the grid resolution, factor (ratio) by which variable ranges are reduced in each step, and the number of iterations. +The result is a series of 2D contour plots of decreasing size, each one constructed for the optimal value of log*a*`r h2o` from the previous step. +```{marginfigure} +More dimensions require a lower resolution due to limited computational resources. +``` +While running, `findit()` sets the activities of basis species, so we can immediately call `ourfun()` to make make a scatter plot. +```{marginfigure} +The text for `findit()` is red because it has side effects (changing the activities of basis species). +``` +```{r smoker_plot, eval=FALSE, echo=23:25} +``` + +```{r smoker_plot, fig.fullwidth=TRUE, fig.width=9, fig.height=5, small.mar=TRUE, dpi=100, out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, fig.cap="Optimization of a thermodynamic model for relative abundances of amino acids in a 270 ?C black smoker fluid using 1, 2, or 3 variables (left to right).", pngquant=pngquant} +``` + +The calculation using `findit()`, in which the added variable log*a*`r h2o` optimizes to ca. -2.2, shows that measured concentrations of 6 amino acids fall within 1--2 log units of the relative abundances in metastable equilibrium. +According these calculations, two amino acids, serine and threonine, are very far from metastable equilibrium with the others. +There is a danger of using too many, or unrepresentative variables, but in some systems, calculations of this type may provide insight on processes affecting reactions of organic compounds. + # Thermodynamic data options ## Source of data: `browse.refs()` @@ -1375,6 +1503,8 @@ ## Tests; errors +e.g. "variables define a transect but their lengths are not all equal" + ## Messages from functions (Look at messages in calculation above: groups, ER-to-Golgi?) @@ -1388,7 +1518,7 @@ # Document history * 2010-09-30 Initial version. -* 2011-08-15 Add browse.refs(); modifying database hint changed to help(thermo). +* 2011-08-15 Add `browse.refs()`; modifying database hint changed to `help(thermo)`. * 2012-06-16 Add ?More activity diagrams?. * 2015-05-14 Add warning about internal consistency of thermodynamic data. * 2017-02-15 Complete rewrite; switch from Sweave to knitr (Tufte style). Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-12 09:43:41 UTC (rev 145) @@ -29,7 +29,14 @@ # use pngquant to optimize PNG images knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) # pngquant isn't available on R-Forge ... -if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL else pngquant <- "--speed=1 --quality=0-50" +if (!nzchar(Sys.which("pngquant"))) { + pngquant <- NULL + # save space by using a lower resolution + dpi <- 50 +} else { + pngquant <- "--speed=1 --quality=0-50" + dpi <- 72 +} ``` @@ -85,7 +92,7 @@ Cpdat$P <- convert(Cpdat$P, "bar") ``` -```{r EOSregress_hide, fig.margin = TRUE, fig.cap = "Heat Capacity of Aqueous Methane", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, dpi=72, out.width=672, out.height=336, pngquant=pngquant} +```{r EOSregress_hide, fig.margin = TRUE, fig.cap = "Heat Capacity of Aqueous Methane", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, dpi=dpi, out.width=672, out.height=336, pngquant=pngquant} var <- c("invTTheta2", "TXBorn") Cplm <- EOSregress(Cpdat, var, T.max=600) EOSplot(Cpdat, coefficients=round(Cplm$coefficients, 1)) @@ -166,7 +173,7 @@ Vcoeffs_database <- EOScoeffs("CH4", "V") ``` -```{r Vplot_hide, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of Aqueous Methane", dpi=72, out.width=672, out.height=672, pngquant=pngquant} +```{r Vplot_hide, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of Aqueous Methane", dpi=dpi, out.width=672, out.height=672, pngquant=pngquant} par(mfrow=c(2, 1)) # plot 1 EOSplot(Vdat, coefficients=Vcoeffs) @@ -212,7 +219,7 @@ As noted above, $\omega$ for electrolytes is not a constant. What happens if we apply the linear model anyway, knowing it's not applicable (especially at high temperature)? -```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Inapplicable: Constant $?$)", dpi=72, out.width=672, out.height=336, pngquant=pngquant} +```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Inapplicable: Constant $?$)", dpi=dpi, out.width=672, out.height=336, pngquant=pngquant} var <- c("invTTheta2", "TXBorn") Nalm <- EOSregress(Nadat, var, T.max=600) EOSplot(Nadat, coefficients=Nalm$coefficients, fun.legend=NULL) @@ -236,7 +243,7 @@ Then, we can use an iterative procedure that refines successive guesses of $\omega_{P_r,T_r}$. The convergence criterion is measured by the difference in sequential regressed values of $\omega$. -```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Variable $?$)", dpi=72, out.width=672, out.height=336, pngquant=pngquant} +```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat Capacity of Na$^+$ (Variable $?$)", dpi=dpi, out.width=672, out.height=336, pngquant=pngquant} diff.omega <- 999 while(abs(diff.omega) > 1) { Nalm1 <- EOSregress(Nadat, var1, omega.PrTr=tail(omega.guess, 1), Z=1) @@ -258,7 +265,7 @@ Compared to $C_P^\circ$, the regression of $V^\circ$ is very finicky. Given a starting guess of $\omega_{P_r,T_r}$ of 1400000 cm$^3$?bar/mol, the iteration converges on 1394890 instead of the "true" database value of 1383230 (represented by dashed line in the plot). -```{r NaVolume_hide, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na$^+$ (Variable $?$)", results="hide", message=FALSE, echo=FALSE, dpi=72, out.width=672, out.height=336, pngquant=pngquant} +```{r NaVolume_hide, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na$^+$ (Variable $?$)", results="hide", message=FALSE, echo=FALSE, dpi=dpi, out.width=672, out.height=336, pngquant=pngquant} T <- convert(seq(0, 600, 25), "K") P <- 1000 prop.PT <- subcrt("Na+", T=T, P=P, grid="T", convert=FALSE)$out[[1]] Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-12 02:14:49 UTC (rev 144) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-12 09:43:41 UTC (rev 145) @@ -445,6 +445,17 @@ doi = {10.1038/ncomms2998}, } + at Article{FMM_14, + author = {Fuchida, Shigeshi and Mizuno, Yuki and Masuda, Harue and Toki, Tomohiro and Makita, Hiroko}, + journal = {Organic Geochemistry}, + title = {Concentrations and distributions of amino acids in black and white smoker fluids at temperatures over 200 ?C}, + year = {2014}, + volume = {66}, + pages = {98--106}, + doi = {10.1016/j.orggeochem.2013.11.008}, + issn = {0146-6380}, +} + @Article{MD98, author = {Merino, Enrique and Dewers, Thomas}, journal = {Journal of Hydrology}, From noreply at r-forge.r-project.org Mon Feb 13 04:26:38 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 13 Feb 2017 04:26:38 +0100 (CET) Subject: [CHNOSZ-commits] r146 - in pkg/CHNOSZ: . R data inst man vignettes Message-ID: <20170213032638.6F204180493@r-forge.r-project.org> Author: jedick Date: 2017-02-13 04:26:37 +0100 (Mon, 13 Feb 2017) New Revision: 146 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/util.data.R pkg/CHNOSZ/data/OBIGT.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/man/util.water.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add thermodynamic data Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-13 03:26:37 UTC (rev 146) @@ -1,6 +1,6 @@ -Date: 2017-02-12 +Date: 2017-02-13 Package: CHNOSZ -Version: 1.0.8-35 +Version: 1.0.8-36 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/util.data.R =================================================================== --- pkg/CHNOSZ/R/util.data.R 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/R/util.data.R 2017-02-13 03:26:37 UTC (rev 146) @@ -165,12 +165,13 @@ return(invisible(inew)) } -browse.refs <- function(key=NULL) { - ## browse to web page associated with a given source - ## of thermodynamic data. first version: 20110615 +thermo.refs <- function(key=NULL) { + ## return references for thermodynamic data. + ## 20110615 browse.refs() first version + ## 20170212 thermo.refs() remove browsing (except for table of all sources) # 'key' can be # NULL: show a table of all sources in a browser - # character: open a web page for each listed source + # character: return data for each listed source key # numeric: open one or two web pages for each listed species # list: the output of subcrt() ## first retrieve the sources table @@ -252,36 +253,26 @@ ### end adaptation from print.findFn # show table in browser browseURL(File) - cat("browse.refs: table of references is shown in browser\n") + cat("thermo.refs: table of references is shown in browser\n") } else if(is.character(key)) { - # open the URL(s) of the given source(s) - for(i in seq_along(key)) { - ix <- match(key[i],x$key) - if(is.na(ix)) { - cat(paste("browse.refs: reference key",key[i],"not found\n")) - next - } - URL <- x$URL[ix] - if(URL=="" | is.na(URL)) { - cat(paste("browse.refs: no URL available for reference key",key[i],"\n")) - next - } - cat(paste("browse.refs: opening URL for ",key[i]," (",x$author[ix],", ",x$year[ix],")\n",sep="")) - browseURL(x$URL[ix]) - } - return(invisible(URL)) + # return citation information for the given source(s) + ix <- match(key, x$key) + ina <- is.na(ix) + if(any(is.na(ix))) message(paste("thermo.refs: reference key(s)", + paste(key[ina], collapse = ","), "not found")) + return(x[ix, ]) } else if(is.numeric(key)) { - # open the URL(s) of sources associated with the indicated species + # get the source keys for the indicated species sinfo <- suppressMessages(info(key)) - mysources <- unique(c(sinfo$ref1,sinfo$ref2)) + mysources <- unique(c(sinfo$ref1, sinfo$ref2)) mysources <- mysources[!is.na(mysources)] - return(browse.refs(mysources)) + return(thermo.refs(mysources)) } else if(is.list(key)) { if("species" %in% names(key)) ispecies <- key$species$ispecies else if("reaction" %in% names(key)) ispecies <- key$reaction$ispecies else stop("list does not appear to be a result from subcrt()") if(is.null(ispecies)) stop("list does not appear to be a result from subcrt()") - return(browse.refs(ispecies)) + return(thermo.refs(ispecies)) } } Modified: pkg/CHNOSZ/data/OBIGT.csv =================================================================== --- pkg/CHNOSZ/data/OBIGT.csv 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/data/OBIGT.csv 2017-02-13 03:26:37 UTC (rev 146) @@ -1,5 +1,5 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -water,NA,H2O,liq,WP02,NA,25.Oct.06,-56687.711481,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +water,NA,H2O,liq,NA,NA,25.Oct.06,-56687.711481,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA e-,NA,Z0-1,aq,NA,NA,28.Oct.06,0,0,15.6166,0,0,0,0,0,0,0,0,0,0 H+,H+,H+,aq,SH88,NA,06.Nov.97,0,0,0,0,0,0,0,0,0,0,0,0,0 Li+,Li+,Li+,aq,SH88,NA,06.Nov.97,-69933,-66552,2.7,14.2,-0.87,-0.0237,-0.069,11.58,-2.7761,19.2,-0.24,0.4862,1 Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/inst/NEWS 2017-02-13 03:26:37 UTC (rev 146) @@ -1,13 +1,13 @@ -CHANGES IN CHNOSZ 1.0.8-35 (2017-02-12) +CHANGES IN CHNOSZ 1.0.8-36 (2017-02-13) --------------------------------------- DOCUMENTATION: -- Add eos-regress.Rmd vignette; update related functions. - - Replace anintro.Rnw (Sweave) with rewritten anintro.Rmd (knitr, Tufte style). +- Add eos-regress.Rmd vignette; update related functions. + - Demos: add bugstab.R, rename buffer.R to protbuff.R, add new buffer.R, remove nucleobase.R. @@ -85,6 +85,9 @@ - Remove the bold formatting for "A" in expr.property(); "A" is italicized like most other uppercase letters. +- Rename browse.refs() to thermo.refs(); remove URL browsing (except for + summary table). + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-13 03:26:37 UTC (rev 146) @@ -24,7 +24,7 @@ By combining data taken from different sources, it is possible to build an inconsistent and/or nonsensical calculation. An attempt has been made to provide a primary database (OBIGT.csv) that is internally consistent, but no guarantee can be made. Where possible, data with known or suspected inconsistencies have been placed into a secondary database (OBIGT-2.csv) that should be regarded as experimental. -If there is any doubt about the accuracy or suitability of data for a particular problem, please \emph{consult the primary sources} (see \code{\link{browse.refs}}). +If there is any doubt about the accuracy or suitability of data for a particular problem, please \emph{consult the primary sources} (see \code{\link{thermo.refs}}). Do not assume that by adding any species to your calculation (or to any of the examples), you will necessarily obtain a reasonable answer. Do not assume that the examples are correct, or that they can be applied to your problem. As with the data, please \emph{compare the construction and output of the examples to the primary sources}, cited in the reference list in each help page. Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/man/data.Rd 2017-02-13 03:26:37 UTC (rev 146) @@ -80,7 +80,7 @@ This dataframe is a thermodynamic database of standard molal thermodynamic properties and equations of state parameters of species. \acronym{OBIGT} is an acronym for \samp{OrganoBioGeoTherm}, which refers to a software package produced by Harold C. Helgeson and coworkers at the Laboratory of Theoretical Geochemistry and Biogeochemistry at the University of California, Berkeley. (There may be an additional meaning for the acronym: \dQuote{One BIG Table} of thermodynamic data.) - As of CHNOSZ version 0.7, the data in \code{OBIGT.csv} represent 179 minerals, 16 gases, and 294 aqueous (largely inorganic) species taken from the data file included in the \acronym{SUPCRT92} distribution (Johnson et al., 1992), an additional 14 minerals, 6 gases, and 1049 aqueous organic and inorganic species from the \acronym{slop98.dat} file (Shock et al., 1998), and approximately 50 other minerals, 175 crystalline organic and biochemical species, 220 organic gases, 300 organic liquids, 650 aqueous inorganic, organic, and biochemical species, and 40 organic groups taken from the recent literature. Each entry is referenced to one or two literature sources listed in \code{thermo$refs}. Use \code{\link{browse.refs}} to display the references in a browser window. + As of CHNOSZ version 0.7, the data in \code{OBIGT.csv} represent 179 minerals, 16 gases, and 294 aqueous (largely inorganic) species taken from the data file included in the \acronym{SUPCRT92} distribution (Johnson et al., 1992), an additional 14 minerals, 6 gases, and 1049 aqueous organic and inorganic species from the \acronym{slop98.dat} file (Shock et al., 1998), and approximately 50 other minerals, 175 crystalline organic and biochemical species, 220 organic gases, 300 organic liquids, 650 aqueous inorganic, organic, and biochemical species, and 40 organic groups taken from the recent literature. Each entry is referenced to one or two literature sources listed in \code{thermo$refs}. Use \code{\link{thermo.refs}} to lookup the citation information for the references. Note the following additional modifications: Modified: pkg/CHNOSZ/man/util.data.Rd =================================================================== --- pkg/CHNOSZ/man/util.data.Rd 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/man/util.data.Rd 2017-02-13 03:26:37 UTC (rev 146) @@ -3,7 +3,7 @@ \alias{util.data} \alias{add.obigt} \alias{mod.obigt} -\alias{browse.refs} +\alias{thermo.refs} \alias{checkEOS} \alias{checkGHS} \alias{check.obigt} @@ -20,7 +20,7 @@ package = "CHNOSZ"), force = FALSE, E.units = "cal") mod.obigt(...) today() - browse.refs(key=NULL) + thermo.refs(key=NULL) checkEOS(eos, state, prop, ret.diff = FALSE) checkGHS(ghs, ret.diff = FALSE) check.obigt() @@ -64,7 +64,10 @@ \code{change} is a wrapper function to \code{mod.obigt} and \code{\link{mod.buffer}}. The \code{name} provided in the argument refers to the name or numeric index of the species to update or add using \code{mod.obigt}, unless the \code{name} begins with an underscore character, in which case the remaining part of the name (after the underscore) is passed to \code{mod.buffer}. The arguments in \code{...} are sent without change to the subordinate function. - \code{browse.refs} with default arguments uses \code{\link{browseURL}} to display the sources of thermodynamic data in \code{thermo$refs}, with the URLs in that table showing as hyperlinks in the browser. Otherwise, if \code{key} is character, the URLs of those reference \code{key}s are opened in the browser. If \code{key} is numeric, the values refer to the species in those rows of \code{thermo$obigt}, and the URLs for each listed reference (\code{thermo$obigt$ref1}, \code{thermo$obigt$ref2}) are opened. If \code{key} is a list, it is interpreted as the result of a call to \code{subcrt}, and the reference URLs for each species involved in the calculation are opened. +\code{thermo.refs} with default arguments uses \code{\link{browseURL}} to display the sources of thermodynamic data in \code{thermo$refs}, with the URLs in that table showing as hyperlinks in the browser. +Otherwise, if \code{key} is character, the citation information for those reference \code{key}s (including URLs) are returned. +If \code{key} is numeric, the values refer to the species in those rows of \code{thermo$obigt}, and the citation information for each listed reference (\code{thermo$obigt$ref1}, \code{thermo$obigt$ref2}) is returned. +If \code{key} is a list, it is interpreted as the result of a call to \code{subcrt}, and the citation information for each species involved in the calculation is returned. \code{checkEOS} compares heat capacity and volume calculated from equation-of-state parameters with reference (tabulated) values at 25 \eqn{^{\circ}}{?}C and 1 bar and prints a message and returns the calculated value if tolerance is exceeded. The Helgeson-Kirkham-Flowers equations of state parameters are in \code{eos}, which is a data frame with columns (and column names) in the same format as \code{\link{thermo}$obigt}. The \code{prop}erty can be one of \samp{Cp} or \code{V}. The code only distinguishes between \code{state}s of \samp{aq} and all others. The default tolerances, given in \code{thermo$opt$Cp.tol} and \code{thermo$opt$V.tol}, are 1 cal/K.mol for Cp and 1 cm3/mol for V. If \code{ret.diff} is TRUE, the differences are returned irrespective of their values, and no messages are printed. @@ -104,18 +107,19 @@ info(iCl2O) # add a species with a name that is distinct from the formula mod.obigt("buckminsterfullerene", formula="C60", state="cr") + +# citation information for Helgeson et al., 1998 +thermo.refs("HOK+98") +# two references for alanine +thermo.refs(info("alanine")) +# three references for species in the reaction +s <- subcrt(c("O2","O2"),c("gas","aq"),c(-1,1)) +thermo.refs(s) \dontrun{ -## marked dontrun because they open pages in a browser +## marked dontrun because it opens a browser # show the contents of thermo$refs -browse.refs() -# Internet needed for the following examples: -# open URL for Helgeson et al., 1998 -browse.refs("HOK+98") -# open two URLs for alanine -browse.refs(info("alanine")) -# open three URLs for species in the reaction -s <- subcrt(c("O2","O2"),c("gas","aq"),c(-1,1)) -browse.refs(s) } +thermo.refs() +} ## calculate thermodynamic properties of organic compounds ## using group additivity, after Richard and Helgeson, 1998 Modified: pkg/CHNOSZ/man/util.water.Rd =================================================================== --- pkg/CHNOSZ/man/util.water.Rd 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/man/util.water.Rd 2017-02-13 03:26:37 UTC (rev 146) @@ -73,7 +73,7 @@ \references{ - Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-H?ckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{http://www.nist.gov/data/PDFfiles/jpcrd383.pdf} + Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-H?ckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{https://www.nist.gov/data/PDFfiles/jpcrd383.pdf} Wagner, W. and Pru?, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{http://dx.doi.org/10.1063/1.1461829} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-12 09:43:41 UTC (rev 145) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-13 03:26:37 UTC (rev 146) @@ -111,16 +111,16 @@ Suggestions for accessing the documentation are indicated here with blue text. For example, read `?"CHNOSZ-package"` to get an overview of the package and a list of features. ```{marginfigure} -That page identifies some features as experimental, i.e. not based on published algorithms or extensively compared with published results. +That page identifies some features as experimental, i.e. that implement new algorithms and/or have not been extensively compared with published results. ``` ## Organization of major functions CHNOSZ is made up of a set of functions and supporting datasets. -The major components of the package are shown in the figure below, which is an updated version of the flowchart from @Dic08. +The major components of the package are shown in the figure below, which is an updated version of the diagram in @Dic08. Rectangles and ellipses represent functions and datasets; bold text indicates primary functions. -![CHNOSZ flowchart](CHNOSZ.png) +![Structure of CHNOSZ.](CHNOSZ.png) Many functions in CHNOSZ have no side effects. That is, the function only returns a result; to use the result elsewhere, it can be assigned to a variable with `<-`. @@ -155,16 +155,12 @@ data(thermo) ## clear system settings ``` -Some experimental functions are available: - -* (**experimental**) using `revisit()` to calculate/plot summary statistics of the chemical activities of the species of interest and `findit()` to search for combinations of activities of basis species, temperature and/or pressure that optimize those statistics. - # Thermodynamic database and chemical formulas While an attempt has been made to provide a primary database (`OBIGT.csv`) that is generally internally consistent, all thermodynamic data, calculations, and examples are provided *as is*. ```{marginfigure} For crucial problems, check not only the accuracy of the database, but also the *suitability of the data* for your problem. -If there is any doubt about the suitability of data, please consult the primary sources (see ?`browse.refs`). +If there is any doubt about the suitability of data, please consult the primary sources (see ?`thermo.refs`). ``` Where possible, data with known or suspected inconsistencies have been placed into a secondary database (`OBIGT-2.csv`) that should be regarded as experimental. @@ -369,7 +365,7 @@ ## Automatically balancing reactions -Methanogenic metabolism in reducing environments may take advantage of acetoclastic or hydrogenotrophic processes. +Methanogenic metabolism in reducing environments may proceed by acetoclastic or hydrogenotrophic processes. To consider reactions involving a charged species (acetate), let's define a basis with H+: ```{r basis_CHOZ} basis(c("CO2", "H2", "H2O", "H+")) @@ -477,10 +473,12 @@ ```{r data_thermo, message=FALSE} ``` -# `affinity()`, species of interest, and potential diagrams +# Using affinity `affinity()` offers calculations of chemical affinity of formation reactions over a configurable range of T, P, and activities of basis species. +## Species of interest + By *formation reaction* is meant the stoichiometric requirements for formation of one mole of any species from the basis species. The `species()` function is used to set these *species of interest*. Let's consider the stoichiometry of some aqueous sulfur-bearing species. @@ -501,7 +499,7 @@ The values returned by `affinity()` are dimensionless, i.e. *A*/2.303*RT*. ``` ```{r affinity} -affinity()$values +unlist(affinity()$values) ``` The same result (in energetic units) could be obtained using `subcrt()`, but `affinity()` has the advantage of being able to perform calculations on a grid of *T*, *P*, or activities of basis species. @@ -521,10 +519,13 @@ a <- affinity(pH = c(0, 12), Eh = c(-1, 1)) diagram(a, fill = "heat") ``` + Now we can calculate the affinities on an Eh-pH grid: ```{r EhpH_plot, echo=1, eval=FALSE} ``` +## Potential diagrams + Given values of affinity, the `diagram()` function uses the maximum affinity method to make a potential diagram (i.e. a Pourbaix diagram): ```{r EhpH_plot_echo, eval=FALSE} diagram(a) @@ -889,7 +890,7 @@ ```{r groups_diagram, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", echo=FALSE, message=FALSE, results="hide", cache=TRUE, pngquant=pngquant} ``` -## Choosing a different balance +## Using a different balance How about the choice between balancing constraints? Be default, `equilibrate()` and `diagram()` balance reactions on the first basis species that is present in each of the species of interest. @@ -1103,7 +1104,7 @@ ```{marginfigure} The calculation of *Z*C, which sums elemental ratios, is not affected by the choice of basis species. ``` -The "QEC" keyword to `basis()` loads basis species with a particular combination of three amino acids (glutamine, glutamic acid, cysteine, `r h2o`, `r o2`) that strengthens the relationship between `r zc` and *n*̅`r o2`, but weakens that between *n*̅`r o2` and *n*̅`r h2o` (right column). +The `QEC` keyword to `basis()` loads basis species with a particular combination of three amino acids (glutamine, glutamic acid, cysteine, `r h2o`, `r o2`) that strengthens the relationship between `r zc` and *n*̅`r o2`, but weakens that between *n*̅`r o2` and *n*̅`r h2o` (right column). ```{r rubisco_O2, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap="Compositions of proteins projected into different sets of basis species.", cache=TRUE, pngquant=pngquant} layout(matrix(1:4, nrow = 2)) @@ -1125,7 +1126,7 @@ ```{r rubisco_O2, echo=-(1:2), eval=FALSE} ``` -By projecting the compositions of proteins into the "QEC" set of basis species, *n*̅`r o2` emerges as a strong indicator of oxidation state, while *n*̅`r h2o` is a relatively non-correlated (i.e. independent) compositional variable. +By projecting the compositions of proteins into the `QEC` set of basis species, *n*̅`r o2` emerges as a strong indicator of oxidation state, while *n*̅`r h2o` is a relatively non-correlated (i.e. independent) compositional variable. These independent variables make it easier to distinguish the effects of oxidation and hydration state in proteomic experiments [@Dic17]. ## Normalization to residues @@ -1328,7 +1329,7 @@ a <- affinity(iprotein = ip) ``` -As shown above, the `iprotein` argument of `affinity()` can be used to calculate the affinities of reactionsto form the indicated proteins, bypassing the `species()` step. +As shown above, the `iprotein` argument of `affinity()` can be used to calculate the affinities of reactions to form the indicated proteins, bypassing the `species()` step. Let's see this in action using amino acid compositions deduced from metagenomic sequences in the Bison Pool hot spring in Yellowstone [@DS11]. We read a data file of amino acid compositions produced in that study, taking those labelled "transferase". Then we add the proteins and get their indices using `add.protein()`, set the basis, calculate the affinities, and make a potential diagram with temperature and activity of dissolved hydrogen as variables: @@ -1354,7 +1355,7 @@ ``` Site numbers 1--5 correspond to a cooling gradient along the outflow channel of the hot spring. The colors represent the relative `r zc` of the proteins (red is more reduced). -The dashed line and points show the *T* and log*a*H2 that optimize a thermodynamic model for the relative abundances of phyla in the microbial communities [@DS13]. +The dashed line and points show the *T* and log*a*H2 that optimize a thermodynamic model for the relative abundances of phyla in the microbial communities [@DS13]: ```{r bison_transferase, eval=FALSE, echo=12:15} ``` @@ -1473,7 +1474,7 @@ ``` While running, `findit()` sets the activities of basis species, so we can immediately call `ourfun()` to make make a scatter plot. ```{marginfigure} -The text for `findit()` is red because it has side effects (changing the activities of basis species). +This side effect (changing the activities of basis species) is why the text for `findit()` is colored red. ``` ```{r smoker_plot, eval=FALSE, echo=23:25} ``` @@ -1485,22 +1486,155 @@ According these calculations, two amino acids, serine and threonine, are very far from metastable equilibrium with the others. There is a danger of using too many, or unrepresentative variables, but in some systems, calculations of this type may provide insight on processes affecting reactions of organic compounds. -# Thermodynamic data options +# Functions outside of the main workflow -## Source of data: `browse.refs()` +transfer, wjd, eqdata, RH2obigt, EOSregress, anim, taxonomy -e.g. browse.refs(1) +Gibbs energy minimization with amino acids: [Cob13]? -## water: IAPWS or SUPCRT +# Thermodynamic data -## secondary database: OBIGT-2 +## Viewing data sources: `thermo.refs()` -## Modifying the database: `mod.obigt()`, `mod.buffer()` +The database in CHNOSZ lists one or two sources for each entry, and citation information for the sources is listed in `thermo$refs`. +You can locate and view the references with `thermo.refs()`. +Running the function without any arguments opens a new window in the web browser with the complete table of references. +Where available, links to the web page for the article or book are displayed. +```{r thermo_refs_table, eval=FALSE} +thermo.refs() ## shows table in a browser +``` +A numeric argument to `thermo.refs()` is one or more species indices for which to get the references: +```{r thermo_refs_numeric} +iATP <- info("ATP-4") +iMgATP <- info("MgATP-2") +thermo.refs(c(iATP, iMgATP)) +``` + +A character argument gives the source key(s): +```{r thermo_refs_character} +thermo.refs(c("HDN+78", "MGN03")) +``` + +For a list, the result of `subcrt()`, references for all species in the reaction are returned: +```{marginfigure} +The exception is H2O. +With the default settings, thermodynamic properties for H2O are derived from SUPCRT92 (Johnson et al., 1992). +``` +```{r thermo_refs_subcrt, message=FALSE} +sout <- subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) +thermo.refs(sout) +``` + +The URLs of the references can be copied to a browser, or opened using R's `browseURL()`: +```{r thermo_refs_browse, eval=FALSE} +iFo <- info("forsterite") +ref <- thermo.refs(iFo) +browseURL(ref$URL) ## opens a page on worldcat.org +``` + +## Water: IAPWS or SUPCRT + +XXX + +## Adding data + +Use `add.obigt()` to add data to the database in the current session. + +Without any arguments, `add.obigt()` adds data from the secondary data file (`OBIGT-2.csv`). +There are ca. 300 species listed here, many of which are not present in the main database. +However, many of these datasets include one or more species that are already present in the main database, but have different parameters. +Therefore, these data could not be included in the main database without breaking internal consistency. +Some of the datasets here may have incomplete or have provisional data. +Please check the references! + +Given a file name, `add.obigt()` adds data in that file to database in the running session. +The file must be a CSV (comma separated value) file with column headers that match those in the main database. +To show the requred format, we print here the first few lines of `OBIGT-2.csv`. +Note that missing values are assigned `NA`: +```{marginfigure} +R's `read.csv()` has a useful option: `as.is = TRUE`. +This prevents columns with character data from being read as factors (i.e. categorical data). +Passing factor arguments to some functions that are designed for character data can give unexpected results or errors. +``` +```{r obigt_file, echo=1:2} +file <- system.file("extdata/thermo/OBIGT-2.csv", package = "CHNOSZ") +dat <- read.csv(file, as.is = TRUE) +head(dat, 3) +``` + +The column names with a dot (`.`) refer to different sets of equations for calculating standard thermodynamic properties. +Aqueous species use the revised Helgeson-Kirkham-Flowers (HKF) equations (symbols before the dot), and crystalline, gas and liquid species other than `r h2o` use a general heat capacity equation. +See `?thermo` for details about what's in the data table, and `?hkf` and `?cgl` for information about the thermodynamic equations. + +## Modifying data + +Use `mod.obigt()` to add or modify the database in the current session. +The function requires the name of a species and one or more properties to change. +Let's add data for the S3- ion from @PD15. +Although we could choose anything for the name (e.g. "trisulfur radical anion"), here we make it the same as the formula. +The date for the entry is `today()` (i.e. today's date using the date format inherited from SUPCRT92): +```{r mod_obigt_S3_ghs, echo=1:2} +mod.obigt("S3-", formula = "S3-", state = "aq", ref1 = "PD15", date = today(), + G = 13160, H = 10840, S = 28.6, Cp = 62.3, V = 37.7) +``` + +The function prints a message saying that the species was added, and returns the species index of the new species. +Now let's modify the same species by adding the HKF coefficients: +```{r mod_obigt_S3_eos, echo=1:2} +mod.obigt("S3-", state = "aq", a1 = 2.5, a2 = 19.9, a3 = 9.2, a4 = -3.6, + c1 = 50.2, c2 = 9.6, omega = 0.8, z = -1) +``` + +Let's add it as a basis species to automatically balance the reaction of SO4-2 and 2 H2S: +```{r S3_reaction, message=FALSE} +basis(c("S3-", "O2", "H2O", "H+")) +basis("O2", "gas") +subcrt(c("H2S", "SO4-2"), c(-2, -1), T = c(25, 500), P = c(1, 700)) +``` + +The reaction coefficients are identical to Reaction 4 of Pokrovski and Dubessy (2015), and the calculated values of log*K* match those shown in their Figure 5. + +## Cross-checking data entries + +`info()` automatically performs some cross-checks of the thermodynamic data. +```{marginfigure} +This only checks the parameters for individual species, not the internal consistency of the database itself. +``` +Let's do this for the new S3- species: +```{r info_S3} +iS3 <- info("S3-") +info(iS3) +``` + +Here, `checkGHS()` calculated the value of ?*G*?*f* from those of ?*H*?*f* and *S*? entered for the species and from the entropy of the elements [@CWM89] in the formula entered for the species. +If the difference between the entered and calculated values of ?*G*?*f* is greater than 100 cal mol-1, `checkGHS()` prints a message. +Here, the calculated value of ?*G*?*f* was found to be 661 cal mol-1 higher than the entered value. +Besides double-checking the values entered for ?*G*?*f*, ?*H*?*f*, *S*?, and the chemical formula, the source should be consulted for further clarification. + +Some species in the main and secondary databases are known to have inconsistent entries. +For example, the entry for cyclohexane has *C**P*? and *V*? that differ from those calculated from the HKF parameters. +`checkEOS()` is a function that cross-checks these parameters and reports the differences (greater than 1 cm3 mol-1 or 1 cal K-1 mol-1) when `info()` is run: +```{r info_cyclohexane, message=FALSE, results="hide"} +info(info("cyclohexane")) +## checkEOS: Cp of cyclohexane aq (1762) differs by 9.35 cal K-1 mol-1 from tabulated value +## checkEOS: V of cyclohexane aq (1762) differs by 6.64 cm3 mol-1 from tabulated value +``` + +The species in with detected inconsistencies in `OBIGT.csv` and `OBIGT-2.csv` are listed in the file `obigt_check.csv`. +```{r check_obigt} +file <- system.file("extdata/thermo/obigt_check.csv", package = "CHNOSZ") +dat <- read.csv(file, as.is=TRUE) +nrow(dat) +``` + +Without additional information, there is often no clear strategy for "fixing" these entries, and they are provided as-is. +```{marginfigure} +See the [Numerical Tools at GEOPIG](http://geopig.asu.edu/tools) for SUPCRT updates (slop files), including corrections that have not yet been ported to CHNOSZ. +``` + # Diagnosing problems -## Checking database consistency - ## Tests; errors e.g. "variables define a transect but their lengths are not all equal" @@ -1508,17 +1642,15 @@ ## Messages from functions (Look at messages in calculation above: groups, ER-to-Golgi?) +subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) -# Functions outside of the main workflow - -transfer, wjd, eqdata, RH2obigt, EOSregress, anim, taxonomy - -Gibbs energy minimization with amino acids: [Cob13]? - # Document history * 2010-09-30 Initial version. * 2011-08-15 Add `browse.refs()`; modifying database hint changed to `help(thermo)`. +```{marginfigure} +`browse.refs()` changed to `thermo.refs()` in 2017. +``` * 2012-06-16 Add ?More activity diagrams?. * 2015-05-14 Add warning about internal consistency of thermodynamic data. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 146 From noreply at r-forge.r-project.org Mon Feb 13 07:42:44 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 13 Feb 2017 07:42:44 +0100 (CET) Subject: [CHNOSZ-commits] r147 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170213064244.6A6D21804AE@r-forge.r-project.org> Author: jedick Date: 2017-02-13 07:42:44 +0100 (Mon, 13 Feb 2017) New Revision: 147 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/CITATION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: add messages and errors Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-13 03:26:37 UTC (rev 146) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-13 06:42:44 UTC (rev 147) @@ -1,6 +1,6 @@ Date: 2017-02-13 Package: CHNOSZ -Version: 1.0.8-36 +Version: 1.0.8-37 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/CITATION =================================================================== --- pkg/CHNOSZ/inst/CITATION 2017-02-13 03:26:37 UTC (rev 146) +++ pkg/CHNOSZ/inst/CITATION 2017-02-13 06:42:44 UTC (rev 147) @@ -9,7 +9,7 @@ number = "10", pages = "", month = "October", - url = "http://www.geochemicaltransactions.com/content/9/1/10", + doi = "10.1186/1467-4866-9-10", textVersion = paste("Dick, J. M. (2008). ", "Calculation of the relative metastabilities of proteins using the CHNOSZ software package. ", Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-13 03:26:37 UTC (rev 146) +++ pkg/CHNOSZ/inst/NEWS 2017-02-13 06:42:44 UTC (rev 147) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-36 (2017-02-13) +CHANGES IN CHNOSZ 1.0.8-37 (2017-02-13) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-13 03:26:37 UTC (rev 146) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-13 06:42:44 UTC (rev 147) @@ -75,7 +75,7 @@ # First steps -This document introduces the basic functionality of CHNOSZ, a package for the [R software environment](http://r-project.org). +This document introduces the usage of CHNOSZ, a package for the [R software environment](http://r-project.org). For more information on R, see "An Introduction to R" and other documents in [The R Manuals](http://cran.r-project.org/manuals.html). CHNOSZ has been developed since 2006 to support research projects in geochemistry and compositional biology. @@ -111,7 +111,7 @@ Suggestions for accessing the documentation are indicated here with blue text. For example, read `?"CHNOSZ-package"` to get an overview of the package and a list of features. ```{marginfigure} -That page identifies some features as experimental, i.e. that implement new algorithms and/or have not been extensively compared with published results. +That page identifies some features as experimental, i.e. that implement new algorithms and/or have not been extensively tested. ``` ## Organization of major functions @@ -649,7 +649,7 @@ Now we can calculate affinity along the transect of changing temperature and activities of five basis species. Each variable is given as a named argument; the name for `NH4+` must be quoted. ```{marginfigure} -A shorter expression would use R's `do.call()` to construct the argument list: `do.call(affinity, as.list(rb))` +A shorter expression would use R's `do.call()` to construct the function call: `do.call(``affinity``, as.list(rb))`. ``` ```{marginfigure} The target of the conversion is `G`, or free energy, from `logK`. @@ -674,7 +674,7 @@ Although only temperature is shown on the *x* axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). To override that behavior, we set `balance = 1` to plot the affinities of the formation reactions as written (per mole of the species being formed). -Also, `legend.x=NA` is used to suppress making a legend (so the labels are placed next to the lines instead). +Also, `legend.x = NA` is used to suppress making a legend (so the labels are placed next to the lines instead). ```{r rainbow_diagram, eval=FALSE} ``` @@ -1038,7 +1038,7 @@ Then, in one line, we calculate the formula of the protein, followed by `r zc`. Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numerals inside the symbols reflect the ordering by *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). -```{r rubisco_svg, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, out.width="100%", fig.keep='none', fig.ext='svg', custom.plot=TRUE, embed.tag=TRUE, echo=FALSE, results="hide", message=FALSE, fig.cap='Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms. This is an interactive image. Move the mouse over the points to show the names of the organisms, and click to open a reference in a new window. (Made using [RSVGTipsDevice](https://cran.r-project.org/package=RSVGTipsDevice); code differs from that shown to the left.)', cache=TRUE} +```{r rubisco_svg, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, out.width="100%", fig.keep='none', fig.ext='svg', custom.plot=TRUE, embed.tag=TRUE, echo=FALSE, results="hide", message=FALSE, fig.cap='Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms. **This is an interactive image.** Move the mouse over the points to show the names of the organisms, and click to open a reference in a new window. (Made using [RSVGTipsDevice](https://cran.r-project.org/package=RSVGTipsDevice); code differs from that shown to the left.)', cache=TRUE} if(require("RSVGTipsDevice")) { datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") @@ -1522,8 +1522,8 @@ With the default settings, thermodynamic properties for H2O are derived from SUPCRT92 (Johnson et al., 1992). ``` ```{r thermo_refs_subcrt, message=FALSE} -sout <- subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) -thermo.refs(sout) +substuff <- subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) +thermo.refs(substuff) ``` The URLs of the references can be copied to a browser, or opened using R's `browseURL()`: @@ -1586,10 +1586,9 @@ c1 = 50.2, c2 = 9.6, omega = 0.8, z = -1) ``` -Let's add it as a basis species to automatically balance the reaction of SO4-2 and 2 H2S: +Let's include it with basis species to automatically balance the reaction of SO4-2 and 2 H2S: ```{r S3_reaction, message=FALSE} -basis(c("S3-", "O2", "H2O", "H+")) -basis("O2", "gas") +basis(c("S3-", "O2", "H2O", "H+"), c("aq", "gas", "liq", "aq")) subcrt(c("H2S", "SO4-2"), c(-2, -1), T = c(25, 500), P = c(1, 700)) ``` @@ -1633,24 +1632,104 @@ See the [Numerical Tools at GEOPIG](http://geopig.asu.edu/tools) for SUPCRT updates (slop files), including corrections that have not yet been ported to CHNOSZ. ``` -# Diagnosing problems +# Messages and errors -## Tests; errors +As you get started writing your own code and functions that use CHNOSZ, it is not uncommon to encounter problems. +For example, mismatched data types can cause problems (the important difference between factor and character was mentioned above). -e.g. "variables define a transect but their lengths are not all equal" +Many functions in CHNOSZ perform various degrees of "sanity checks" on the arguments and will report errors if an inconsistency is detected. +For example, unequal lengths of variables in the transect mode of `affinity()` (when the variables have more than 3 values) causes an error: -## Messages from functions +```{r affinity_error, error=TRUE, message=FALSE, results="hide"} +basis("CHNOS") +aa <- c("D", "T", "S", "E", "G", "A", "K", "H") +species(aminoacids("", aa)) +a <- affinity(O2=seq(-80, -50), T=seq(0, 100)) +``` -(Look at messages in calculation above: groups, ER-to-Golgi?) +In normal operation, without errors, many functions print informative messages. +```{marginfigure} +To reduce clutter, messages have not been shown in the output of most of the examples in this vignette. +``` +Checking these can help you decide if the system and calculations have the desired configuration. +Here, we fix the condition that caused the error above: +```{r message_example, results="hide"} +a <- affinity(O2=seq(-80, -50, length.out=101), T=seq(0, 100)) +e <- equilibrate(a) +#diagram(e, alpha=TRUE, legend.x=NA) +``` + +The messages give some useful information, such as the variables and their ranges, the "wetness" of the reactions (i.e. they contain water and/or aqueous species), the balanced basis species and balance coefficients, the logarithm of total activity of the balanced basis species, and the equilibration method. +The commented call to `diagram()` would produce a diagram that, in this case, doesn't result in any messages. + +Here is another example, with the output hidden, but where the messages show the species in the reaction and the other states that are available for the same compounds in the database. +The number of *T* and *P* values comes from the default arguments for `subcrt()`: +```{r message_subcrt, results="hide"} subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) +``` +You may occasionally encounter programming bugs or limits of the algorithms. +The following setup breaks the reaction-matrix calculation for equilibration. +Here, C5H9NO4 (glutamic acid) is identified as the balance (the only basis species present in the formation reactions of all species). +Both a warning and an error are generated due to missing values in a computation within `equil.reaction()`: + +`r op <- options(warn = -1)` +```{r equilibrate_error, error=TRUE, results="hide", warning=FALSE} +basis("QEC") +species(aminoacids("", aa)) +a <- affinity() +e <- equilibrate(a) +## Warning in logafun(logactfun(Abar, i)): NaNs produced +``` +`r options(op)` + +This is a case where further development and testing are needed. + +If you have problems, be sure to read the help pages, examples, and code itself. +Another resource is the tests that are included in the `testthat` directory. +Reading and running these tests can be useful for getting a sense of the error conditions and other limitations of the functions. + +# Citation and contact information + +If you use CHNOSZ for publications, it would be appreciated if you cite the following paper: + +```{r citation_CHNOSZ, results="asis"} +cref <- citation("CHNOSZ") +print(cref, style = "html") +``` + +If you have bug reports, questions that haven't been answered here or in the other documentation, or contributions of code or data, please contact the maintainer: + +```{r maintainer_CHNOSZ} +maintainer("CHNOSZ") +``` + +Thank you for reading, and have fun! + +> "As any practitioner knows, the effort of research is so tedious and time consuming that when the work stops being fun, there's no sense in continuing. The best scientists live a life of keen amusement." +> +> `r tufte::quote_footer('--- Stephen Jay Gould')` + + # Document history * 2010-09-30 Initial version. * 2011-08-15 Add `browse.refs()`; modifying database hint changed to `help(thermo)`. ```{marginfigure} -`browse.refs()` changed to `thermo.refs()` in 2017. +`browse.refs()` renamed to `thermo.refs()` in 2017. ``` * 2012-06-16 Add ?More activity diagrams?. * 2015-05-14 Add warning about internal consistency of thermodynamic data. * 2017-02-15 Complete rewrite; switch from Sweave to knitr (Tufte style). + +View the R Markdown source of this document [on R-Forge](https://r-forge.r-project.org/scm/viewvc.php/pkg/CHNOSZ/vignettes/anintro.Rmd?view=markup&root=chnosz) or in R: + +```{r file_edit_anintro, eval=FALSE} +file.edit(system.file("doc/anintro.Rmd", package = "CHNOSZ")) +``` + +*** From noreply at r-forge.r-project.org Mon Feb 13 17:54:47 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 13 Feb 2017 17:54:47 +0100 (CET) Subject: [CHNOSZ-commits] r148 - in pkg/CHNOSZ: . R data inst inst/extdata/cpetc man vignettes Message-ID: <20170213165447.888A6188637@r-forge.r-project.org> Author: jedick Date: 2017-02-13 17:54:47 +0100 (Mon, 13 Feb 2017) New Revision: 148 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/data/OBIGT.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/read.expr.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/equilibrium.Rnw pkg/CHNOSZ/vignettes/equilibrium.lyx pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add activity coefficients Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-13 16:54:47 UTC (rev 148) @@ -1,6 +1,6 @@ Date: 2017-02-13 Package: CHNOSZ -Version: 1.0.8-37 +Version: 1.0.8-38 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/R/diagram.R 2017-02-13 16:54:47 UTC (rev 148) @@ -22,7 +22,7 @@ # colors col=par("col"), col.names=par("col"), fill=NULL, # labels - names=NULL, main=NULL, legend.x="topright", format.names=TRUE, + names=NULL, main=NULL, legend.x=NA, format.names=TRUE, # plotting controls add=FALSE, plot.it=TRUE, tplot=TRUE, ... ) { @@ -240,8 +240,6 @@ } # draw the lines for(i in 1:length(plotvals)) lines(xvalues, plotvals[[i]], col=col[i], lty=lty[i], lwd=lwd[i]) - # turn off legend if too many species - if(ngroups > 10 & missing(legend.x)) legend.x <- NA if(!add & !is.null(legend.x)) { # 20120521: use legend.x=NA to label lines rather than make legend if(is.na(legend.x)) { Modified: pkg/CHNOSZ/data/OBIGT.csv =================================================================== --- pkg/CHNOSZ/data/OBIGT.csv 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/data/OBIGT.csv 2017-02-13 16:54:47 UTC (rev 148) @@ -1721,7 +1721,7 @@ MgADP-,MgADP-,MgC10H12N5O10P2-,aq,LH06b,NA,21.May.03,-567524,-730933,55.74,139.985659655832,189.17,2.4109,127.142,-19.16,-2.477,175.24,-3.8947,3,-1 MgHADP,MgHADP,MgC10H13N5O10P2,aq,LH06b,NA,10.Jun.03,-574465,-731643,76.54,161.472275334608,199.93,2.4625,137.497,-19.3997,-2.9051,244.57,-19.376,4.8,0 Mg2ADP+,Mg2ADP+,Mg2C10H12N5O10P2+,aq,LH06b,NA,6.Jun.03,-678301,-839029,41.31,159.440726577438,174.77,2.3411,113.105,-18.834,-1.8968,166.84,-1.3991,0.5,1 -MgATP-2,MgATP-2,MgC10H12N5O13P3-2,aq,LH06b,NA,24.Sep.06,-773608.986615679,-966278.680688336,56.5965583173996,150.143403441683,193.48,2.45028680688337,135.083891013384,-19.343690248566,-2.80544933078394,256.022944550669,-26.0994263862333,5.73613766730401,-1 +MgATP-2,MgATP-2,MgC10H12N5O13P3-2,aq,LH06b,NA,24.Sep.06,-773608.986615679,-966278.680688336,56.5965583173996,150.143403441683,193.48,2.45028680688337,135.083891013384,-19.343690248566,-2.80544933078394,256.022944550669,-26.0994263862333,5.73613766730401,-2 MgHATP-,MgHATP-,MgC10H13N5O13P3-,aq,LH06b,NA,11.Jun.03,-780995,-965191,85.01,210.803059273423,208.97,2.5011,145.27,-19.58,-3.2265,315.61,-25.582,5.8,-1 MgH2ATP,MgH2ATP,MgC10H14N5O13P3,aq,LH06b,NA,11.Jun.03,-786200,-970481,84.72,267.208413001912,208.63,2.4936,143.766,-19.545,-3.1643,362.6,-24.126,5.1,0 Mg2ATP,Mg2ATP,Mg2C10H12N5O13P3,aq,LH06b,NA,16.Jun.03,-884603,-1072754,48.32,204.134799235182,191.55,2.4505,135.089,-19.344,-2.8056,310.31,-23.113,6.5,0 Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/inst/NEWS 2017-02-13 16:54:47 UTC (rev 148) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-37 (2017-02-13) +CHANGES IN CHNOSZ 1.0.8-38 (2017-02-13) --------------------------------------- DOCUMENTATION: @@ -58,6 +58,9 @@ - read.fasta(): change argument `i` to `iseq`; this is used to select particular sequences to read from the file. +- diagram(): default of `legend.x` changed to NA (instead of making a + legend, put labels near the lines). + CLEANUP AND BUG FIXES: - subcrt() returns `loggam` using the common logarithm; add @@ -76,6 +79,8 @@ - Correct charge (-2) of NAD(red)-2 in OBIGT.csv. Thanks to Peter Canovas. +- Also correct charge (-2) of MgATP-2. + - Remove msgout(), and replace previous calls to that function with message() from base R. As a result, the messages don't appear in Sweave vignettes, but can be turned on or off in knitr vignettes. Modified: pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/inst/extdata/cpetc/rubisco.csv 2017-02-13 16:54:47 UTC (rev 148) @@ -10,7 +10,7 @@ L0RHZ1,35,35,B,"Desulfovibrio hydrothermalis",http://dx.doi.org/10.1099/ijs.0.02323-0 Q8THG2,35,40,A,"Methanosarcina acetivorans",http://aem.asm.org/content/47/5/971 F9ZLP0,45,45,B,"Acidithiobacillus caldus",http://dx.doi.org/10.1099/13500872-140-12-3451 -P37393,45,45,E,"Cyanidium caldarium",http://dx.doi.org/10.1007/BF00409031 +P37393,45,45,E,"Cyanidium caldarium",http://link.springer.com/article/10.1007/BF00409031 P72383,45,50,B,"Sulfobacillus acidophilus",http://dx.doi.org/10.1099/00221287-142-4-775 Q51856,52,52,B,"Pseudomonas hydrogenothermophila",http://dx.doi.org/10.1271/bbb1961.41.685 Q2JIP3,50,55,B,"Synechococcus sp. (strain JA-2-3B'a(2-13))",http://dx.doi.org/10.1128/AEM.72.1.544-550.2006 @@ -18,7 +18,7 @@ Q8DIS5,57,57,B,"Thermosynechococcus elongatus",http://dx.doi.org/10.1093/oxfordjournals.pcp.a075684 G8LZL2,60,60,B,"Clostridium clariflavum",http://dx.doi.org/10.1099/ijs.0.003483-0 F8IID7,65,65,B,"Bacillus acidocaldarius",http://dx.doi.org/10.1099/00221287-67-1-9 -A8F7V4,65,65,B,"Thermotoga lettingae",http://dx.doi.org/10.1099/ijs.0.02165-0 +A8F7V4,65,65,B,"Thermotoga lettingae",http://dx.doi.org/10.1099/00207713-52-4-1361 B9KXE5,70,70,B,"Thermomicrobium roseum",http://dx.doi.org/10.1371/journal.pone.0004207 O28635,76,76,A,"Archaeoglobus fulgidus",http://aem.asm.org/content/60/4/1227 Q58632,85,85,A,"Methanocaldococcus jannaschii",http://dx.doi.org/10.1007/BF00425213 Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-13 16:54:47 UTC (rev 148) @@ -15,7 +15,7 @@ cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, col=par("col"), col.names=par("col"), fill=NULL, - names=NULL, main=NULL, legend.x="topright", format.names=TRUE, + names=NULL, main=NULL, legend.x=NA, format.names=TRUE, add=FALSE, plot.it=TRUE, tplot=TRUE, ...) strip(affinity, ispecies = NULL, col = NULL, ns = NULL, xticks = NULL, ymin = -0.2, xpad = 1, cex.names = 0.7) @@ -78,8 +78,8 @@ The names of the list are used to label the lines or fields for the summed activities of the resulting groups. For 1-D diagrams, the default setting for the y-axis is a logarithmic scale (unless \code{alpha} is TRUE) with limits corresponding to the range of logarithms of activities (or 0,1 if \code{alpha} is TRUE); these actions can be overridden by \code{ylog} and \code{ylim}. -A \code{\link{legend}} is placed at the location identified by \code{legend.x}, or omitted if \code{legend.x} is \code{FALSE}. -If \code{legend.x} is NA, instead of a legend, the lines are labeled with the names of the species near the maximum value. +If \code{legend.x} is NA (the default), the lines are labeled with the names of the species near the maximum value. +Otherwise, a \code{\link{legend}} is placed at the location identified by \code{legend.x}, or omitted if \code{legend.x} is NULL. The line type and line width can be controlled with \code{lty} and \code{lwd}, respectively. On 2-D diagrams, the fields represent the species with the highest equilibrium activity. Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-13 16:54:47 UTC (rev 148) @@ -58,7 +58,7 @@ a <- affinity(O2=c(-100, -65)) # try normalize=FALSE to make Fig. 5a in the paper e <- equilibrate(a, normalize=TRUE) -d <- diagram(e, ylim=c(-5, -1), legend.x=NA, names=organisms) +d <- diagram(e, ylim=c(-5, -1), names=organisms) # add water stability line abline(v=-83.1, lty=2) title(main="Surface-layer proteins, after Dick, 2008") @@ -87,7 +87,7 @@ col <- rep("red", length(prot)) col[ZC > 0] <- "blue" e <- equilibrate(a, normalize=TRUE) -d <- diagram(e, col=col, legend.x=NA) +d <- diagram(e, col=col, format.names=FALSE) title(main="Bovine proteins, GSH/GSSG redox buffer") } Modified: pkg/CHNOSZ/man/read.expr.Rd =================================================================== --- pkg/CHNOSZ/man/read.expr.Rd 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/man/read.expr.Rd 2017-02-13 16:54:47 UTC (rev 148) @@ -102,15 +102,10 @@ a <- affinity(O2=c(-82, -65)) e <- equilibrate(a, loga.balance=0, normalize=TRUE) mycolor <- topo.colors(length(locations)) -diagram(e, names=locations, ylim=c(-5, -3), legend.x=NA, col=mycolor, lwd=2) +diagram(e, names=locations, ylim=c(-5, -3), col=mycolor, lwd=2) dp <- describe.property(c("T", "P"), c(25, 1)) db <- describe.basis(ibasis=(1:6)[-5]) legend("topright", legend=c(dp, db), bty="n") -## Notable features include: proteins in the early Golgi, endoplasmic reticulum (ER) -## and vacuole are chemically the most stable relative to those in other locations in the cell; -## proteins in the vacuole are very oxidized; the stability of proteins decreases going from -## early Golgi to Golgi to late Golgi; the least stable proteins (or most energetic) -## are found in the microtubules and bud neck. ############################# ## examples using stress() ## Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-13 06:42:44 UTC (rev 147) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-13 16:54:47 UTC (rev 148) @@ -79,8 +79,8 @@ For more information on R, see "An Introduction to R" and other documents in [The R Manuals](http://cran.r-project.org/manuals.html). CHNOSZ has been developed since 2006 to support research projects in geochemistry and compositional biology. -The package provides functions and an extensive thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions among minerals and organic or inorganic aqueous species. -These same functions enable calculations of chemical affinities and metastable equilibrium for systems of proteins. +The package provides functions and a thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions among minerals and organic or inorganic aqueous species. +These same functions enable calculations of chemical affinities and metastable equilibrium distributions of proteins. ## Installing and loading CHNOSZ @@ -667,14 +667,13 @@ ```{r rainbow_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, cache=TRUE, fig.cap="Affinities of organic synthesis in a hydrothermal system, after Shock and Canovas (2010).", pngquant=pngquant} diagram(a, balance = 1, ylim = c(-100, 100), ylab = axis.label("A", prefix="k"), - col = rainbow(8), lwd = 2, legend.x = NA, bg = "slategray3") + col = rainbow(8), lwd = 2, bg = "slategray3") abline(h = 0, lty = 2, lwd = 2) ``` Finally, we use `diagram()` to plot the results. Although only temperature is shown on the *x* axis, pH and the activities of CO2, H2, NH4+, and H2S are also varied according to the data in `rb`. By default, `diagram()` attempts to scale the affinities by dividing by the reaction coefficients of a shared basis species (in this case, CO2). To override that behavior, we set `balance = 1` to plot the affinities of the formation reactions as written (per mole of the species being formed). -Also, `legend.x = NA` is used to suppress making a legend (so the labels are placed next to the lines instead). ```{r rainbow_diagram, eval=FALSE} ``` @@ -712,7 +711,7 @@ unlist(affinity(T = 300, P = 100)$values) ``` -We use `mod.buffer()` to choose the `cr2` phase of phyrrhotite, which is stable at this temperature. +We use `mod.buffer()` to choose the `cr2` phase of pyrrhotite, which is stable at this temperature. Then, we set up H2S and `r o2` to be buffered by PPM, and inspect their buffered activities: ```{r PPM_setup, results="hide"} mod.buffer("PPM", "pyrrhotite", "cr2") @@ -778,7 +777,7 @@ diagram(a150, add = TRUE, col = "red") e25 <- equilibrate(a25, loga.balance = -3) e150 <- equilibrate(a150, loga.balance = -3) -diagram(e25, ylim = c(-6, 0), bty = "n") +diagram(e25, ylim = c(-6, 0), legend.x = "topright", bty = "n") diagram(e150, add = TRUE, col = "red") diagram(e25, alpha = TRUE, legend.x = "center", bty = "n") diagram(e150, alpha = TRUE, add = TRUE, col = "red") @@ -868,7 +867,7 @@ par(mfrow = c(1, 3)) groups <- list(inorganic = ii, alcohols = ia, ketones = ik, `carboxylic acids` = c(ic, ica), alkenes = ie) -diagram(e, alpha = TRUE, groups = groups, legend.x = NA) +diagram(e, alpha = TRUE, groups = groups) # plot only alcohols names <- within(species(), name[-ia] <- "")$name lty <- ifelse(names == "", 0, 1) @@ -1038,7 +1037,7 @@ Then, in one line, we calculate the formula of the protein, followed by `r zc`. Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numerals inside the symbols reflect the ordering by *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). -```{r rubisco_svg, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, out.width="100%", fig.keep='none', fig.ext='svg', custom.plot=TRUE, embed.tag=TRUE, echo=FALSE, results="hide", message=FALSE, fig.cap='Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms. **This is an interactive image.** Move the mouse over the points to show the names of the organisms, and click to open a reference in a new window. (Made using [RSVGTipsDevice](https://cran.r-project.org/package=RSVGTipsDevice); code differs from that shown to the left.)', cache=TRUE} +```{r rubisco_svg, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, out.width="100%", fig.keep='none', fig.ext='svg', custom.plot=TRUE, embed.tag=TRUE, echo=FALSE, results="hide", message=FALSE, fig.cap='Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms. **This is an interactive image.** Move the mouse over the points to show the names of the organisms, and click to open a reference in a new window. (Made using [RSVGTipsDevice](https://cran.r-project.org/package=RSVGTipsDevice) with code that can be seen in the source of this document.)', cache=TRUE} if(require("RSVGTipsDevice")) { datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") @@ -1180,9 +1179,9 @@ #mod.obigt("[Met]", G = -35245, H = -59310) a <- affinity(O2 = c(-80, -73), iprotein = ip, loga.protein = logact) e <- equilibrate(a) -diagram(e, ylim = c(-5, -2), format.names = FALSE, legend.x = NA, col=1:5, lwd=2) +diagram(e, ylim = c(-5, -2), format.names = FALSE, col = 1:5, lwd = 2) e <- equilibrate(a, normalize = TRUE) -diagram(e, ylim = c(-5, -2.5), format.names = FALSE, legend.x=NA, col=1:5, lwd=2) +diagram(e, ylim = c(-5, -2.5), format.names = FALSE, col = 1:5, lwd = 2) abline(h = logabundance, lty = 1:5, col = 1:5) revisit(e, "DGinf", logabundance) ``` @@ -1363,8 +1362,138 @@ ## Activity coefficients -XXX Example using `nonideal()` ... Alberty, 2003, Fig. 1.4-1.5 (p. 9-10, 235-236) +`nonideal()` uses the Debye-H?ckel equation, described in Chapter 3 of @Alb03, to calculate activity coefficients of charged species. +The calculations can be invoked by setting the `IS` argument in `subcrt()` or `affinity()` +The activity coefficients are calculated as a function of ionic strength (*I*), temperature, and charge of the species, without any other species-specific parameters. +Due to these assumptions as well as the limited applicability of the implemented equations to very high *I* and/or *T*, `nonideal()` is presented as an experimental feature. +Let's take a look at calculated activity coefficients at two temperatures and their effect on the standard Gibbs energies of formation (?*G*?*f*) of species with different charge: +```{r subcrt_IS} +subcrt(c("MgATP-2", "MgHATP-", "MgH2ATP"), + T = c(25, 100), IS = c(0, 0.25), property = "G")$out +``` + +The logarithms of the activity coefficients (`loggam`) are more negative for the higher-charged species, as well as at higher temperature, and have a stabilizing effect. +That is, the apparent Gibbs energies at *I* > 0 are less than the standard Gibbs energies at *I* = 0. + +We can use these calculations to make some 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 (-log*a*Mg+2). + +Use `info()` to see what ATP species are available. +The sources of high-temperature thermodynamic data for these species are two papers by LaRowe and Helgeson [- at LH06a; - at LH06b]. +```{r info_ATP, results="hide"} +info(" ATP") +``` + +The plots for this system in Alberty's book were made for *I* = 0.25 M and *T* = 25 ?C. +As a demonstration of CHNOSZ's capabilities, we set the temperature to 100 ?C. +```{r T_100} +T <- 100 +``` + +To begin, we set the basis species, add the variously protonated ATP species, calculate the affinities of the formation reactions, equilibrate the species, and make a degree of formation (?) or mole fraction diagram. +This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 and *T* = 100 ?C: +```{marginfigure} +To make the code more readable, commands for plotting titles and legends are not shown. +All of the commands are available in the source of this document. +``` + +```{r ATP, eval=FALSE, echo=2:6} +par(mfrow = c(1, 4), mar = c(3.1, 3.6, 2.1, 1.6), mgp = c(1.8, 0.5, 0)) +basis("MgCHNOPS+") +species(c("ATP-4", "HATP-3", "H2ATP-2", "H3ATP-", "H4ATP")) +a <- affinity(pH = c(3, 9), T = T) +e <- equilibrate(a) +d <- diagram(e, alpha = TRUE, tplot = FALSE) +title(main = describe.property("T", T)) +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) +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) +species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP")) +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) +} +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) +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) +} +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) +``` + +Note that we have saved the numeric results of `diagram()`, i.e. the degrees of formation of the species (?). +Using that, we can calculate and plot the average number of protons bound per ATP molecule. +To do that, we use R's `rbind()` with `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+): +```{r ATP, eval=FALSE, echo=8:11} +``` + +Adding the `IS` argument to `affinity()`, we can now plot *N*H+ at the given ionic strength. +Here we set `plot.it = FALSE` in `diagram()` because we use the computed ? to make our own plot. +This is similar to Figure 1.3 of Alberty (2003), but at higher temperature: +```{r ATP, eval=FALSE, echo=12:17} +``` + +Next, we add the Mg+2-complexed ATP species: +```{r ATP, eval=FALSE, echo=21} +``` + +Here is a function to calculate and plot *N*H+ for a given pMg: +```{r ATP, eval=FALSE, echo=22:30} +``` + +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): +```{r ATP, eval=FALSE, echo=31:32} +``` + +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 coefficient on Mg+2 in the formation reactions of each species, and negate log*a*Mg+2 (the variable used in `affinity()`) to get pMg: +```{r ATP, eval=FALSE, echo=36:44} +``` + +Using that function, we plot the lines corresponding to pH = 3 to 9. +This is similar to Figure 1.5 of Alberty (2003): +```{r ATP, eval=FALSE, echo=45:47} +``` + +

+```{r ATP, fig.fullwidth=TRUE, fig.width=10, fig.height=2.5, dpi=ifelse(dpi==50, 50, 100), out.width="100%", echo=FALSE, message=FALSE, results="hide", fig.cap="Binding of H+ and Mg+2 to ATP at 100 ?C and *I* = 0 M (first plot) or 0.25 M (third and fourth plots).", cache=TRUE, pngquant=pngquant} +``` +

+ +We have calculated the distribution of ATP species and average binding number of H+ and Mg+2 for given pH, pMg, ionic strength, and temperature. +Other methods using equilibrium constants tabulated for specified ionic strength make an algebraic solution of the equilibrium distribution of species feasible, as shown by the Mathematica code in Alberty (2003). +However, the required calculations can also be performed "on the fly" in CHNOSZ with reference to a conventional standard state. + ## Optimization of chemical activities What are the conditions that minimize the standard deviation of calculated activities of species? @@ -1488,6 +1617,8 @@ # Functions outside of the main workflow +XXX + transfer, wjd, eqdata, RH2obigt, EOSregress, anim, taxonomy Gibbs energy minimization with amino acids: [Cob13]? @@ -1609,7 +1740,7 @@ Here, `checkGHS()` calculated the value of ?*G*?*f* from those of ?*H*?*f* and *S*? entered for the species and from the entropy of the elements [@CWM89] in the formula entered for the species. If the difference between the entered and calculated values of ?*G*?*f* is greater than 100 cal mol-1, `checkGHS()` prints a message. Here, the calculated value of ?*G*?*f* was found to be 661 cal mol-1 higher than the entered value. -Besides double-checking the values entered for ?*G*?*f*, ?*H*?*f*, *S*?, and the chemical formula, the source should be consulted for further clarification. +Besides checking for any typographical errors in the entries for ?*G*?*f*, ?*H*?*f*, *S*?, and the chemical formula, the source should be consulted for further clarification. Some species in the main and secondary databases are known to have inconsistent entries. For example, the entry for cyclohexane has *C**P*? and *V*? that differ from those calculated from the HKF parameters. @@ -1623,7 +1754,7 @@ The species in with detected inconsistencies in `OBIGT.csv` and `OBIGT-2.csv` are listed in the file `obigt_check.csv`. ```{r check_obigt} file <- system.file("extdata/thermo/obigt_check.csv", package = "CHNOSZ") -dat <- read.csv(file, as.is=TRUE) +dat <- read.csv(file, as.is = TRUE) nrow(dat) ``` @@ -1636,15 +1767,16 @@ As you get started writing your own code and functions that use CHNOSZ, it is not uncommon to encounter problems. For example, mismatched data types can cause problems (the important difference between factor and character was mentioned above). +There are many tricks to learn; becoming familiar with R's `lapply()` and `do.call()` will make your programming life easier. -Many functions in CHNOSZ perform various degrees of "sanity checks" on the arguments and will report errors if an inconsistency is detected. -For example, unequal lengths of variables in the transect mode of `affinity()` (when the variables have more than 3 values) causes an error: +Some functions in CHNOSZ perform "sanity checks" on the arguments and will report errors if an inconsistency is detected. +For example, unequal lengths of variables in the transect mode of `affinity()` (when the variables have more than 3 values) cause an error: ```{r affinity_error, error=TRUE, message=FALSE, results="hide"} basis("CHNOS") aa <- c("D", "T", "S", "E", "G", "A", "K", "H") species(aminoacids("", aa)) -a <- affinity(O2=seq(-80, -50), T=seq(0, 100)) +a <- affinity(O2 = seq(-80, -50), T = seq(0, 100)) ``` In normal operation, without errors, many functions print informative messages. @@ -1654,15 +1786,15 @@ Checking these can help you decide if the system and calculations have the desired configuration. Here, we fix the condition that caused the error above: ```{r message_example, results="hide"} -a <- affinity(O2=seq(-80, -50, length.out=101), T=seq(0, 100)) +a <- affinity(O2 = seq(-80, -50, length.out = 101), T = seq(0, 100)) e <- equilibrate(a) #diagram(e, alpha=TRUE, legend.x=NA) ``` -The messages give some useful information, such as the variables and their ranges, the "wetness" of the reactions (i.e. they contain water and/or aqueous species), the balanced basis species and balance coefficients, the logarithm of total activity of the balanced basis species, and the equilibration method. +The messages give some useful information, such as the variables and their ranges, the "wetness" of the reactions (i.e. whether they contain water and/or aqueous species), the balanced basis species and balance coefficients, the logarithm of total activity of the balanced basis species, and the equilibration method. The commented call to `diagram()` would produce a diagram that, in this case, doesn't result in any messages. -Here is another example, with the output hidden, but where the messages show the species in the reaction and the other states that are available for the same compounds in the database. +Here is another example, with the results hidden, but where the messages show the species in the reaction and the other states that are available for the same compounds in the database. The number of *T* and *P* values comes from the default arguments for `subcrt()`: ```{r message_subcrt, results="hide"} subcrt(c("C2H5OH", "O2", "CO2", "H2O"), c(-1, -3, 2, 3)) @@ -1670,7 +1802,7 @@ You may occasionally encounter programming bugs or limits of the algorithms. The following setup breaks the reaction-matrix calculation for equilibration. -Here, C5H9NO4 (glutamic acid) is identified as the balance (the only basis species present in the formation reactions of all species). +Here, C5H9NO4 (glutamic acid) is identified as the balance (the only basis species present in all the formation reactions of species). Both a warning and an error are generated due to missing values in a computation within `equil.reaction()`: [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 151 From noreply at r-forge.r-project.org Wed Feb 15 17:14:28 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 15 Feb 2017 17:14:28 +0100 (CET) Subject: [CHNOSZ-commits] r152 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170215161428.DB83F1805D1@r-forge.r-project.org> Author: jedick Date: 2017-02-15 17:14:28 +0100 (Wed, 15 Feb 2017) New Revision: 152 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: spellcheck Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-15 15:34:03 UTC (rev 151) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-15 16:14:28 UTC (rev 152) @@ -1,6 +1,6 @@ Date: 2017-02-15 Package: CHNOSZ -Version: 1.0.8-41 +Version: 1.0.8-42 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-15 15:34:03 UTC (rev 151) +++ pkg/CHNOSZ/inst/NEWS 2017-02-15 16:14:28 UTC (rev 152) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-41 (2017-02-15) +CHANGES IN CHNOSZ 1.0.8-42 (2017-02-15) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-15 15:34:03 UTC (rev 151) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-15 16:14:28 UTC (rev 152) @@ -245,7 +245,7 @@ The inspiration for the name `subcrt()`, and the source of the Fortran subroutine used to calculate the thermodynamic properties of H2O, is SUPCRT (Johnson et al., 1992). ``` [- at JOH92] -If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of invididual species: +If no reaction coefficients are given, `subcrt()` calculates the standard molal properties of individual species: ```{r subcrt_water} subcrt("water") ``` @@ -478,7 +478,7 @@ ```{r methanogenesis_plot, eval=FALSE} ``` -Let't not forget to clear the system settings, which were modified by `basis()` and `E.units()`, before running other calculations: +Let's not forget to clear the system settings, which were modified by `basis()` and `E.units()`, before running other calculations: ```{r data_thermo, message=FALSE} ``` @@ -497,9 +497,9 @@ See `?basis` for more options. ``` ```{marginfigure} -What is `SO42-`? Is it 1 S, 4 O, and 2 -ve charges, or 1 S, 42 O, and 1 -ve charge? +What is `SO42-`? Is it 1 S, 4 O, and 2 negative charges, or 1 S, 42 O, and 1 negative charge? The ambiguity of a digit that could belong to the coefficient for the following charge or to that for the preceding element is why formulas in CHNOSZ are written with the number of charges after the + or - symbol. -`SO4-2` is unambiguously parsed as 1 S, 4 O and 2 -ve charges. +`SO4-2` is unambiguously parsed as 1 S, 4 O and 2 negative charges. ``` ```{r basis_CHNOSZ, results="hide"} basis("CHNOS+") @@ -774,7 +774,7 @@ For a given total activity of the balanced basis species, activities of the species can be found such that the affinities of the formation reactions are all equal. This is an example of metastable equilibrium. -With additional constraints, the affinites of the formation reactions are not only equal to each other, but equal to zero. +With additional constraints, the affinities of the formation reactions are not only equal to each other, but equal to zero. This is total equilibrium. An example of total equilibrium was given above for the PPM buffer. In contrast, models for systems of organic and biomolecules often involve metastable equilibrium constraints. @@ -940,7 +940,7 @@ ``` There are some broad similarities---increasing `r logfO2` favors more oxidized amino acids---but also substantial differences. -It is interesting that there is more "going on" in the middle part of the digram showing volume conservation. +It is interesting that there is more "going on" in the middle part of the diagram showing volume conservation. *Caveat lector*. These plots demonstrate some possibilities in CHNOSZ and are not necessarily realistic portrayals of this system. It does seem odd to balance on a fugacious component like `r o2` or `r h2o`. @@ -1357,7 +1357,7 @@ As shown there, the `iprotein` argument of `affinity()` can be used to calculate the affinities of reactions to form the indicated proteins, bypassing the `species()` step. Let's see this in action using amino acid compositions deduced from metagenomic sequences in the Bison Pool hot spring in Yellowstone [@DS11]. -We read a data file of amino acid compositions produced in that study, taking those labelled "transferase". +We read a data file of amino acid compositions produced in that study, taking those labeled "transferase". Then we add the proteins and get their indices using `add.protein()`, set the basis, calculate the affinities, and make a potential diagram with temperature and activity of dissolved hydrogen as variables: ```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferases in the outflow channel of Bison Pool hot spring. See also the vignette *Hot-spring proteins in CHNOSZ*.', cache=TRUE, pngquant=pngquant, timeit=timeit} @@ -1607,7 +1607,7 @@ ourfun(c(2, 3, 5), "right") ``` -Now, we write a function that calculates the affinities and metasable equilibrium activities at a single condition and uses `revisit()` to make a scatter plot. +Now, we write a function that calculates the affinities and metastable equilibrium activities at a single condition and uses `revisit()` to make a scatter plot. The plot includes a 1:1 line (grey), a trend line calculated using R's `loess.smooth()` (red), and a title with the minimum value of RMSD. The function also adds a legend summarizing the optimal conditions: ```{r smoker_plot, eval=FALSE, echo=7:14} @@ -1703,7 +1703,7 @@ Given a file name, `add.obigt()` adds data in that file to database in the running session. The file must be a CSV (comma separated value) file with column headers that match those in the main database. -To show the requred format, we print here the first few lines of `OBIGT-2.csv`. +To show the required format, we print here the first few lines of `OBIGT-2.csv`. Missing values are indicated by `NA`: ```{marginfigure} R's `read.csv()` has a useful option: `as.is = TRUE`. From noreply at r-forge.r-project.org Thu Feb 16 14:30:36 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 16 Feb 2017 14:30:36 +0100 (CET) Subject: [CHNOSZ-commits] r153 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170216133036.57977188A9B@r-forge.r-project.org> Author: jedick Date: 2017-02-16 14:30:36 +0100 (Thu, 16 Feb 2017) New Revision: 153 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: better handling of optional RSVGTipsDevice dependency Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-15 16:14:28 UTC (rev 152) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-16 13:30:36 UTC (rev 153) @@ -1,6 +1,6 @@ -Date: 2017-02-15 +Date: 2017-02-16 Package: CHNOSZ -Version: 1.0.8-42 +Version: 1.0.8-43 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-15 16:14:28 UTC (rev 152) +++ pkg/CHNOSZ/inst/NEWS 2017-02-16 13:30:36 UTC (rev 153) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-42 (2017-02-15) +CHANGES IN CHNOSZ 1.0.8-43 (2017-02-16) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-15 16:14:28 UTC (rev 152) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 13:30:36 UTC (rev 153) @@ -30,6 +30,15 @@ options(digits = 6) ``` +```{r HTML, include=FALSE} +## some frequently used HTML expressions +logfO2 <- "logfO2" +# use lowercase here because these tend to be variable names in the examples +zc <- "ZC" +o2 <- "O2" +h2o <- "H2O" +``` + ```{r setup, include=FALSE} library(knitr) # invalidate cache when the tufte version changes @@ -44,7 +53,8 @@ knit_hooks$set(smallish.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, 0.9, 0.9)) # smallish margins on top and right }) -# use pngquant to optimize PNG images + +## use pngquant to optimize PNG images knit_hooks$set(pngquant = hook_pngquant) # pngquant isn't available on R-Forge ... if (!nzchar(Sys.which("pngquant"))) { @@ -55,23 +65,58 @@ pngquant <- "--speed=1 --quality=0-50" dpi <- 72 } -# some frequently used HTML expressions -logfO2 <- "logfO2" -# use lowercase here because these tend to be variable names in the examples -zc <- "ZC" -o2 <- "O2" -h2o <- "H2O" -# http://stackoverflow.com/questions/23852753/knitr-with-gridsvg -# Set up a chunk hook for manually saved plots. -knit_hooks$set(custom.plot = hook_plot_custom) -# hook to change to -- required for interactive SVG + +## extend knitr's hook_plot_custom to check for existence of figure file 20170216 +## first, we need to copy a couple of knitr's utility functions +# if LHS is NULL, return the RHS +`%n%` = function(x, y) if (is.null(x)) y else x +# recycle some plot options such as fig.cap, out.width/height, etc when there +# are multiple plots per chunk +.recyle.opts = c('fig.cap', 'fig.scap', 'fig.env', 'fig.pos', 'fig.subcap', + 'out.width', 'out.height', 'out.extra', 'fig.link') +# when passing options to plot hooks, reduce the recycled options to scalars +reduce_plot_opts = function(options) { + i = options$fig.cur %n% 1L + for (o in .recyle.opts) { + v = options[[o]] + if ((n <- length(v)) == 0) next + if ((j <- i %% n) == 0) j = n + options[o] = list(v[j]) + } + options +} +hook_plot_custom_checkfile = function(before, options, envir){ + if (before) return() # run hook after the chunk + if (options$fig.show == 'hide') return() # do not show figures + + ext = options$fig.ext %n% dev2ext(options$dev) + hook = knit_hooks$get('plot') + + # do not show non-existent figure (causes pandoc error) + if (!file.exists(fig_path(ext, options, 1))) return() + + n = options$fig.num + if (n == 0L) n = options$fig.num = 1L # make sure fig.num is at least 1 + res = unlist(lapply(seq_len(n), function(i) { + options$fig.cur = i + hook(fig_path(ext, options, i), reduce_plot_opts(options)) + }), use.names = FALSE) + paste(res, collapse = '') +} + +## http://stackoverflow.com/questions/23852753/knitr-with-gridsvg +## Set up a chunk hook for manually saved plots. +knit_hooks$set(custom.plot = hook_plot_custom_checkfile) + +## hook to change to -- required for interactive SVG hook_plot <- knit_hooks$get("plot") knit_hooks$set(plot = function(x, options) { x <- hook_plot(x, options) if (!is.null(options$embed.tag) && options$embed.tag) x <- gsub("`equilibrate()` and `diagram()` balance reactions on the first basis species that is present in each of the species of interest. Let's look at some amino acids in a hypothetical metastable equilibrium. -This calculation is based on one described by @Sho90b for five amino acids, but here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. +This calculation is loosely based on one described by @Sho90b for five amino acids. +Here we include 20 proteinogenic amino acids, whose names are returned by `aminoacids("")`. We use `ZC.col()` to generate colors based on the average oxidation state of carbon of the amino acids (red and blue for relatively reduced and oxidized). ```{r aminoacids_setup, results="hide", message=FALSE} basis("CHNOS") @@ -1064,7 +1110,8 @@ Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numbers inside the symbols show the ordering of *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). ```{r rubisco_svg, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, out.width="100%", fig.keep='none', fig.ext='svg', custom.plot=TRUE, embed.tag=TRUE, echo=FALSE, results="hide", message=FALSE, fig.cap='Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms. **This is an interactive image.** Move the mouse over the points to show the names of the organisms, and click to open a reference in a new window. (Made using [RSVGTipsDevice](https://cran.r-project.org/package=RSVGTipsDevice) with code that can be found in the source of this document.)', cache=TRUE, timeit=timeit} -if(require("RSVGTipsDevice")) { +if(!identical(class(try(find.package("RSVGTipsDevice"), silent=TRUE)), "try-error")) { + library(RSVGTipsDevice) datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") dat <- read.csv(datfile) @@ -1099,7 +1146,7 @@ } ``` ```{r rubisco_ZC, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms.", cache=TRUE, pngquant=pngquant, timeit=timeit} -if(!require("RSVGTipsDevice")) { +if(identical(class(try(find.package("RSVGTipsDevice"), silent=TRUE)), "try-error")) { datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") dat <- read.csv(datfile) @@ -1134,7 +1181,7 @@ ```{r rubisco_O2, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap="Compositions of proteins projected into different sets of basis species.", cache=TRUE, pngquant=pngquant, timeit=timeit} layout(matrix(1:4, nrow = 2)) -par(mgp=c(1.8, 0.5, 0)) +par(mgp = c(1.8, 0.5, 0)) pl <- protein.length(aa) ZClab <- axis.label("ZC") nO2lab <- expression(bar(italic(n))[O[2]]) @@ -1780,7 +1827,7 @@ nrow(dat) ``` -Without additional information, there is often no clear strategy for "fixing" these entries, and they are provided as-is. +Without additional information, there is often no clear strategy for "fixing" these entries, and they are provided as is. ```{marginfigure} See the [Numerical Tools from GEOPIG](http://geopig.asu.edu/tools) for SUPCRT updates (slop files), including corrections that have not yet been ported to CHNOSZ. ``` @@ -1869,7 +1916,7 @@ ## Regressing thermodynamic data -`EOSregress()` and related functions can be used to regress "equation of state" parameters (e.g. coefficients in the HKF equations) from heat capacity and volumetric data. See `?EOSregress` and the vignette, *Regressing thermodynamic data*. +`EOSregress()` and related functions can be used to regress "equation of state" parameters (e.g. coefficients in the HKF equations) from heat capacity and volumetric data. See `?EOSregress` and the vignette, [*Regressing thermodynamic data*](../eos-regress.html). ## Gibbs energy minimization @@ -1941,3 +1988,8 @@ ### ### ### ### ### ### ### ### ### ### ### ### ### ```

+ + +```{r sessionInfo} +sessionInfo() +``` From noreply at r-forge.r-project.org Thu Feb 16 17:03:13 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 16 Feb 2017 17:03:13 +0100 (CET) Subject: [CHNOSZ-commits] r154 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170216160313.55E011881AC@r-forge.r-project.org> Author: jedick Date: 2017-02-16 17:03:13 +0100 (Thu, 16 Feb 2017) New Revision: 154 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: add links to other vignettes Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-16 13:30:36 UTC (rev 153) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-16 16:03:13 UTC (rev 154) @@ -1,6 +1,6 @@ Date: 2017-02-16 Package: CHNOSZ -Version: 1.0.8-43 +Version: 1.0.8-44 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-16 13:30:36 UTC (rev 153) +++ pkg/CHNOSZ/inst/NEWS 2017-02-16 16:03:13 UTC (rev 154) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-43 (2017-02-16) +CHANGES IN CHNOSZ 1.0.8-44 (2017-02-16) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 13:30:36 UTC (rev 153) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 16:03:13 UTC (rev 154) @@ -828,7 +828,7 @@ The `equilibrate()` function in CHNOSZ automatically chooses between two methods for calculating equilibrium. ```{marginfigure} -For more information, see the vignette *Equilibrium in CHNOSZ*. +For more information, see the vignette [*Equilibrium in CHNOSZ*](equilibrium.pdf). ``` The method based on the Boltzmann equation is fast, but is applicable only to systems where the coefficient on the balanced basis species in each of the formation reactions is one. The reaction-matrix method is slower, but can be applied to systems were the balanced basis species has reaction coefficients other than one. @@ -1213,7 +1213,7 @@ The metastable coexistence of the *residues* (i.e. per-residue formulas, or residue equivalents) of the same proteins spans a much smaller range of chemical activities. In CHNOSZ, the calculation of metastable equilibrium activities of the residue equivalents is referred to as *normalization*. ```{marginfigure} -See the vignette *Equilibrium in CHNOSZ* for other examples using normalization. +See the vignette [*Equilibrium in CHNOSZ*](equilibrium.pdf) for other examples using normalization. ``` To take an example, let's look at the metastable equilibrium distribution of selected proteins in the ER-to-Golgi location of *S. cerevisiae* (yeast). @@ -1407,7 +1407,7 @@ We read a data file of amino acid compositions produced in that study, taking those labeled "transferase". Then we add the proteins and get their indices using `add.protein()`, set the basis, calculate the affinities, and make a potential diagram with temperature and activity of dissolved hydrogen as variables: -```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferases in the outflow channel of Bison Pool hot spring. See also the vignette *Hot-spring proteins in CHNOSZ*.', cache=TRUE, pngquant=pngquant, timeit=timeit} +```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferases in the outflow channel of Bison Pool hot spring. See also the vignette [*Hot-spring proteins in CHNOSZ*](hotspring.pdf).', cache=TRUE, pngquant=pngquant, timeit=timeit} aa <- read.aa(system.file("extdata/protein/DS11.csv", package = "CHNOSZ")) aa <- aa[grep("transferase", aa$protein), ] ip <- add.protein(aa) @@ -1916,12 +1916,12 @@ ## Regressing thermodynamic data -`EOSregress()` and related functions can be used to regress "equation of state" parameters (e.g. coefficients in the HKF equations) from heat capacity and volumetric data. See `?EOSregress` and the vignette, [*Regressing thermodynamic data*](../eos-regress.html). +`EOSregress()` and related functions can be used to regress "equation of state" parameters (e.g. coefficients in the HKF equations) from heat capacity and volumetric data. See `?EOSregress` and the vignette, [*Regressing thermodynamic data*](eos-regress.html). ## Gibbs energy minimization `wjd()` implements a Gibbs energy minimization using the method of steepest descent described by @WJD58. -See `?wjd` as well as the vignette, *Winding journey down (in Gibbs energy)*. +See `?wjd` as well as the vignette, [*Winding journey down (in Gibbs energy)*](wjd.pdf). ## Reaction paths (experimental feature) {#Reaction-paths-experimental-feature} From noreply at r-forge.r-project.org Thu Feb 16 17:35:19 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 16 Feb 2017 17:35:19 +0100 (CET) Subject: [CHNOSZ-commits] r155 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170216163519.B78AB188AA5@r-forge.r-project.org> Author: jedick Date: 2017-02-16 17:35:19 +0100 (Thu, 16 Feb 2017) New Revision: 155 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: workaround R CMD check warning: Unknown language engine 'marginfigure' Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-16 16:03:13 UTC (rev 154) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-16 16:35:19 UTC (rev 155) @@ -1,6 +1,6 @@ Date: 2017-02-16 Package: CHNOSZ -Version: 1.0.8-44 +Version: 1.0.8-45 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-16 16:03:13 UTC (rev 154) +++ pkg/CHNOSZ/inst/NEWS 2017-02-16 16:35:19 UTC (rev 155) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-44 (2017-02-16) +CHANGES IN CHNOSZ 1.0.8-45 (2017-02-16) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 16:03:13 UTC (rev 154) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 16:35:19 UTC (rev 155) @@ -41,9 +41,14 @@ ```{r setup, include=FALSE} library(knitr) + +## from "Tufte Handout" example dated 2016-12-27 # invalidate cache when the tufte version changes opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte')) options(htmltools.dir.version = FALSE) + +## adjust plot margins +## first one from https://yihui.name/knitr/hooks/ knit_hooks$set(small.mar = function(before, options, envir) { if (before) par(mar = c(4.2, 4.2, .1, .1)) # smaller margin on top and right }) @@ -66,7 +71,8 @@ dpi <- 72 } -## extend knitr's hook_plot_custom to check for existence of figure file 20170216 +## pandoc error is caused by non-existent figure in rubisco_svg chunk when RSVGTipsDevice is not available, +## so extend knitr's hook_plot_custom to check for existence of figure file 20170216 ## first, we need to copy a couple of knitr's utility functions # if LHS is NULL, return the RHS `%n%` = function(x, y) if (is.null(x)) y else x @@ -92,7 +98,7 @@ ext = options$fig.ext %n% dev2ext(options$dev) hook = knit_hooks$get('plot') - # do not show non-existent figure (causes pandoc error) + # do not show non-existent figure if (!file.exists(fig_path(ext, options, 1))) return() n = options$fig.num @@ -125,6 +131,28 @@ } }) timeit <- NULL + +## 20170216 workaround for R CMD check warning only on Windows (R-Forge, winbuilder): +# * checking re-building of vignette outputs ... WARNING +# Error in re-building vignettes: +# ... +# Warning in get_engine(options$engine) : +# Unknown language engine 'marginfigure' (must be registered via knit_engines$set()). +## +## from html.R in tufte package: +knitr::knit_engines$set(marginfigure = function(options) { + options$type = 'marginnote' + if (is.null(options$html.tag)) options$html.tag = 'span' + options$html.before = marginnote_html() + eng_block = knitr::knit_engines$get('block') + eng_block(options) +}) +marginnote_html = function(text = '', icon = '⊕') { + sprintf(paste0( + '', + '%s' + ), icon, text) +} ``` # First steps From noreply at r-forge.r-project.org Fri Feb 17 01:31:55 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 17 Feb 2017 01:31:55 +0100 (CET) Subject: [CHNOSZ-commits] r156 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170217003155.59D22180FCD@r-forge.r-project.org> Author: jedick Date: 2017-02-17 01:31:54 +0100 (Fri, 17 Feb 2017) New Revision: 156 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: tracking down windows R CMD check warning Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-16 16:35:19 UTC (rev 155) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-17 00:31:54 UTC (rev 156) @@ -1,6 +1,6 @@ -Date: 2017-02-16 +Date: 2017-02-17 Package: CHNOSZ -Version: 1.0.8-45 +Version: 1.0.8-46 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-16 16:35:19 UTC (rev 155) +++ pkg/CHNOSZ/inst/NEWS 2017-02-17 00:31:54 UTC (rev 156) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-45 (2017-02-16) +CHANGES IN CHNOSZ 1.0.8-46 (2017-02-17) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-16 16:35:19 UTC (rev 155) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-17 00:31:54 UTC (rev 156) @@ -20,7 +20,7 @@ \usepackage[utf8]{inputenc} bibliography: vig.bib link-citations: yes -# The custom CSL file gives a build error on R-Forge (2017-02-12): +# The custom CSL file gives a build error on R-Forge (20170212): # pandoc-citeproc: error while parsing the XML string #csl: elementa.csl --- @@ -1137,44 +1137,45 @@ Then, we calculate `r zc` from the formulas of the proteins. Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numbers inside the symbols show the ordering of *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). + ```{r rubisco_ZC, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms.", cache=TRUE, pngquant=pngquant, timeit=timeit} -if(identical(class(try(find.package("RSVGTipsDevice"), silent=TRUE)), "try-error")) { +#if(!suppressWarnings(require(RSVGTipsDevice))) { datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") dat <- read.csv(datfile) @@ -1192,7 +1193,7 @@ abline(v = c(36, 63), lty = 2, col = "grey") legend("topright", legend = c("Archaea", "Bacteria", "Eukaryota"), pch = c(2, 1, 0), col = 2:4, pt.cex = 2) -} +#} ``` ```{r rubisco_ZC, eval=FALSE, echo=2:18} ``` @@ -1496,7 +1497,7 @@ T <- 100 ``` -Use the following commands set the basis species, add the variously protonated ATP species, calculate the affinities of the formation reactions, equilibrate the species, and make a degree of formation (?) or mole fraction diagram. +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 (?) or mole fraction diagram. This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 and *T* = 100 ?C: ```{marginfigure} To make the code more readable, commands for plotting titles and legends are not shown. From noreply at r-forge.r-project.org Fri Feb 17 03:51:35 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 17 Feb 2017 03:51:35 +0100 (CET) Subject: [CHNOSZ-commits] r157 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170217025135.C24FA187E91@r-forge.r-project.org> Author: jedick Date: 2017-02-17 03:51:34 +0100 (Fri, 17 Feb 2017) New Revision: 157 Added: pkg/CHNOSZ/vignettes/rubisco.svg Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: use premade rubisco.svg Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-17 00:31:54 UTC (rev 156) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-17 02:51:34 UTC (rev 157) @@ -1,6 +1,6 @@ Date: 2017-02-17 Package: CHNOSZ -Version: 1.0.8-46 +Version: 1.0.8-47 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-17 00:31:54 UTC (rev 156) +++ pkg/CHNOSZ/inst/NEWS 2017-02-17 02:51:34 UTC (rev 157) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-46 (2017-02-17) +CHANGES IN CHNOSZ 1.0.8-47 (2017-02-17) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-17 00:31:54 UTC (rev 156) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-17 02:51:34 UTC (rev 157) @@ -71,48 +71,9 @@ dpi <- 72 } -## pandoc error is caused by non-existent figure in rubisco_svg chunk when RSVGTipsDevice is not available, -## so extend knitr's hook_plot_custom to check for existence of figure file 20170216 -## first, we need to copy a couple of knitr's utility functions -# if LHS is NULL, return the RHS -`%n%` = function(x, y) if (is.null(x)) y else x -# recycle some plot options such as fig.cap, out.width/height, etc when there -# are multiple plots per chunk -.recyle.opts = c('fig.cap', 'fig.scap', 'fig.env', 'fig.pos', 'fig.subcap', - 'out.width', 'out.height', 'out.extra', 'fig.link') -# when passing options to plot hooks, reduce the recycled options to scalars -reduce_plot_opts = function(options) { - i = options$fig.cur %n% 1L - for (o in .recyle.opts) { - v = options[[o]] - if ((n <- length(v)) == 0) next - if ((j <- i %% n) == 0) j = n - options[o] = list(v[j]) - } - options -} -hook_plot_custom_checkfile = function(before, options, envir){ - if (before) return() # run hook after the chunk - if (options$fig.show == 'hide') return() # do not show figures - - ext = options$fig.ext %n% dev2ext(options$dev) - hook = knit_hooks$get('plot') - - # do not show non-existent figure - if (!file.exists(fig_path(ext, options, 1))) return() - - n = options$fig.num - if (n == 0L) n = options$fig.num = 1L # make sure fig.num is at least 1 - res = unlist(lapply(seq_len(n), function(i) { - options$fig.cur = i - hook(fig_path(ext, options, i), reduce_plot_opts(options)) - }), use.names = FALSE) - paste(res, collapse = '') -} - ## http://stackoverflow.com/questions/23852753/knitr-with-gridsvg ## Set up a chunk hook for manually saved plots. -knit_hooks$set(custom.plot = hook_plot_custom_checkfile) +knit_hooks$set(custom.plot = hook_plot_custom) ## hook to change to -- required for interactive SVG hook_plot <- knit_hooks$get("plot") @@ -131,28 +92,6 @@ } }) timeit <- NULL - -## 20170216 workaround for R CMD check warning only on Windows (R-Forge, winbuilder): -# * checking re-building of vignette outputs ... WARNING -# Error in re-building vignettes: -# ... -# Warning in get_engine(options$engine) : -# Unknown language engine 'marginfigure' (must be registered via knit_engines$set()). -## -## from html.R in tufte package: -knitr::knit_engines$set(marginfigure = function(options) { - options$type = 'marginnote' - if (is.null(options$html.tag)) options$html.tag = 'span' - options$html.before = marginnote_html() - eng_block = knitr::knit_engines$get('block') - eng_block(options) -}) -marginnote_html = function(text = '', icon = '⊕') { - sprintf(paste0( - '', - '%s' - ), icon, text) -} ``` # First steps @@ -1137,9 +1076,11 @@ Then, we calculate `r zc` from the formulas of the proteins. Next, point symbols are assigned according to domain (Archaea, Bacteria, Eukaryota); numbers inside the symbols show the ordering of *T*opt in three temperature ranges (0--35 ?C, 37.5--60 ?C, and 65--100 ?C). - -```{r rubisco_ZC, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, message=FALSE, fig.cap="Average oxidation state of carbon in Rubisco compared with optimal growth temperature of organisms.", cache=TRUE, pngquant=pngquant, timeit=timeit} -#if(!suppressWarnings(require(RSVGTipsDevice))) { + +```{r rubisco_ZC, fig.keep="none"} datfile <- system.file("extdata/cpetc/rubisco.csv", package = "CHNOSZ") fastafile <- system.file("extdata/fasta/rubisco.fasta", package = "CHNOSZ") dat <- read.csv(datfile) @@ -1193,10 +1133,7 @@ abline(v = c(36, 63), lty = 2, col = "grey") legend("topright", legend = c("Archaea", "Bacteria", "Eukaryota"), pch = c(2, 1, 0), col = 2:4, pt.cex = 2) -#} ``` -```{r rubisco_ZC, eval=FALSE, echo=2:18} -``` Let's look at the different ways of representing the chemical compositions of the proteins. `protein.basis()` returns the stoichiometry for the formation reaction of each proteins. Added: pkg/CHNOSZ/vignettes/rubisco.svg =================================================================== (Binary files differ) Property changes on: pkg/CHNOSZ/vignettes/rubisco.svg ___________________________________________________________________ Added: svn:mime-type + image/svg From noreply at r-forge.r-project.org Fri Feb 17 14:49:46 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 17 Feb 2017 14:49:46 +0100 (CET) Subject: [CHNOSZ-commits] r158 - in pkg/CHNOSZ: . R demo inst man Message-ID: <20170217134946.2FFFE187FD5@r-forge.r-project.org> Author: jedick Date: 2017-02-17 14:49:45 +0100 (Fri, 17 Feb 2017) New Revision: 158 Added: pkg/CHNOSZ/demo/activity_ratios.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/util.expression.Rd Log: Add demo activity_ratios.R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-17 13:49:45 UTC (rev 158) @@ -1,6 +1,6 @@ Date: 2017-02-17 Package: CHNOSZ -Version: 1.0.8-47 +Version: 1.0.8-48 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/R/diagram.R 2017-02-17 13:49:45 UTC (rev 158) @@ -12,7 +12,7 @@ what="loga.equil", alpha=FALSE, normalize=FALSE, as.residue=FALSE, balance=NULL, groups=as.list(1:length(eout$values)), xrange=NULL, # plot dimensions - mar=NULL, yline=par("mgp")[1]+0.7, side=1:4, + mar=NULL, yline=par("mgp")[1]+0.5, side=1:4, # axes ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, # sizes Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/R/examples.R 2017-02-17 13:49:45 UTC (rev 158) @@ -5,7 +5,7 @@ examples <- function(do.png=FALSE) { # run all the examples in CHNOSZ documentation .ptime <- proc.time() - topics <- c("CHNOSZ-package", "thermo", "sideeffects", "examples", + topics <- c("thermo", "sideeffects", "examples", "util.args", "util.array", "util.blast", "util.character", "util.data", "util.expression", "util.fasta", "util.formula", "util.matrix", "util.misc", "util.program", @@ -31,7 +31,7 @@ demos <- function(which=c("sources", "protein.equil", "add.obigt", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", - "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE) { + "copper", "solubility", "wjd", "dehydration", "bugstab", "activity_ratios"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/R/util.expression.R 2017-02-17 13:49:45 UTC (rev 158) @@ -21,9 +21,10 @@ # recover the coefficient if(elements[i]==1) coeff <- "" else coeff <- elements[i] # append the coefficient - # subscripts within subscripts (log) are too small - if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) - else expr <- substitute(a[b], list(a=expr, b=coeff)) + ## subscripts within subscripts (log) are too small + #if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) + #else expr <- substitute(a[b], list(a=expr, b=coeff)) + expr <- substitute(a[b], list(a=expr, b=coeff)) } else { # for charged species, don't show "Z" but do show e.g. "+2" coeff <- elements[i] @@ -49,7 +50,7 @@ if(log %in% c("aq", "cr", "liq", "cr1", "cr2", "cr3", "cr4")) acity <- "a" else if(log %in% c("g", "gas")) acity <- "f" else stop(paste("'", log, "' is not a recognized state", sep="")) - logacity <- substitute(log*italic(a), list(a=acity)) + logacity <- substitute(log~italic(a), list(a=acity)) expr <- substitute(a[b], list(a=logacity, b=expr)) # write a value if given if(!is.null(value)) { @@ -248,3 +249,26 @@ return(desc) } +# make formatted text for activity ratio 20170217 +ratlab <- function(ion="K+") { + # the charge + Z <- makeup(ion)["Z"] + # the text for the exponent on aH+ + exp.H <- as.character(Z) + # the expression for the ion and H+ + expr.ion <- expr.species(ion) + expr.H <- expr.species("H+") + # the final expression + if(exp.H=="1") substitute(log~(italic(a)[expr.ion] / italic(a)[expr.H]), list(expr.ion=expr.ion, expr.H=expr.H)) + else substitute(log~(italic(a)[expr.ion] / italic(a)[expr.H]^exp.H), list(expr.ion=expr.ion, expr.H=expr.H, exp.H=exp.H)) +} + +# make formatted text for thermodynamic system 20170217 +syslab <- function(system = c("K2O", "Al2O3", "SiO2", "H2O")) { + for(i in seq_along(system)) { + expr <- expr.species(system[i]) + # use en dash here + if(i==1) lab <- expr else lab <- substitute(a*"\u2013"*b, list(a=lab, b=expr)) + } + lab +} Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/demo/00Index 2017-02-17 13:49:45 UTC (rev 158) @@ -17,3 +17,4 @@ wjd run.wjd() with proteins: cell periphery of yeast dehydration log K of dehydration reactions; SVG file contains tooltips and links bugstab formation potential of microbial proteins in colorectal cancer +activity_ratios mineral stability plots with activity ratios on the axes Added: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R (rev 0) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-02-17 13:49:45 UTC (rev 158) @@ -0,0 +1,61 @@ +## Equilibrium activity diagrams for minerals using activity ratios as variables +## These are made with pH = 0 (activity of H+ = 1), so (activity of the ion) is equal to +## (activity of the ion) / [(activity of H+) ^ (charge of the ion)] + +par(mfrow = c(2, 2)) +res <- 200 +fill <- "heat" + +## K2O-Al2O3-SiO2-H2O, 25 degree C, 1 bar +## Steinmann et al., 1994 (http://ccm.geoscienceworld.org/content/42/2/197) +## Garrels and Christ, p. 361 (http://www.worldcat.org/oclc/517586) +## https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-75.html +# use add.obigt to get H4SiO4 +add.obigt() +basis(c("Al+3", "H4SiO4", "K+", "H2O", "H+", "O2")) +species(c("gibbsite", "kaolinite", "pyrophyllite", "k-feldspar", "muscovite")) +a <- affinity(H4SiO4 = c(-6, 0, res), `K+` = c(0, 8, res)) +diagram(a, ylab = ratlab("K+"), fill = fill) +title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O"))) +legend("topright", describe.property(c("T", "P"), c(25, 1)), bty = "n") +# reset database +data(thermo) + +## H2O-CaO-MgO-SiO2 at 300 degree C and 1000 bar +## Helgeson et al., 1969, p. 136 (http://www.worldcat.org/oclc/902423149) +## Bowers et al., 1984, p. 246 (http://www.worldcat.org/oclc/224591948) +basis(c("H2O", "Ca+2", "Mg+2", "SiO2", "O2", "H+")) +species(c("quartz", "talc", "chrysotile", "forsterite", "monticellite", + "merwinite", "wollastonite", "diopside", "tremolite")) +# calculate the chemical affinities of formation reactions +a <- affinity("Mg+2" = c(4, 9, res), "Ca+2" = c(5, 14, res), T = 300, P = 1000) +diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill) +title(main = syslab(c("H2O", "CaO", "MgO", "SiO2"))) +legend("bottomright", describe.property(c("T", "P"), c(300, 1000)), bty = "n") +# note: Bowers et al. use more complicated variables +# (involving the hydration numbers of H2O and the ion) +# with accordingly different axis ranges + +## MgO-CaO-SiO2-H2O at 300 degree C and Psat +## Russell et al., 2010 (http://dx.doi.org/10.1111/j.1472-4669.2010.00249.x) +basis(c("Mg+2", "Ca+2", "SiO2", "H2O", "O2", "H+")) +species(c("brucite", "chrysotile", "talc", "tremolite", "diopside", "akermanite")) +a <- affinity(SiO2 = c(-10, 0, res), `Ca+2` = c(0, 20, res), T = 300) +diagram(a, ylab = ratlab("Ca+2"), fill = fill) +title(main = syslab(c("MgO", "CaO", "SiO2", "H2O"))) +legend("topright", describe.property(c("T", "P"), c(300, 85.84)), bty = "n") + +## CaO-MgO-SiO2-H2O and +## CaO-Al2O3-MgO-SiO2-H2O at 300 degree C and 500 bar +## Bach and Klein, 2009 (http://dx.doi.org/10.1016/j.lithos.2008.10.022) +basis(c("Ca+2", "Al+3", "Mg+2", "SiO2", "H2O", "O2", "H+")) +species(c("clinochlore,14a", "clinozoisite", "prehnite", "grossular")) +a <- affinity(SiO2 = c(-5, 0, res), `Ca+2` = c(6, 11, res), T = 300, P = 500) +diagram(a, ylab = ratlab("Ca+2"), balance = "Al+3", fill = fill) +# (Hmmm... where is clinochlore? it doesn't appear on our diagram) +species(delete = TRUE) +species(c("brucite", "chrysotile", "talc", "tremolite", "diopside")) +a <- affinity(SiO2 = c(-5, 0, res), `Ca+2` = c(6, 11, res), T = 300, P = 500) +diagram(a, add = TRUE, col = "blue", col.names = "blue") +title(main = syslab(c("CaO", "Al2O3", "MgO", "SiO2", "H2O"))) +legend("topright", describe.property(c("T", "P"), c(300, 500)), bty = "n") Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/inst/NEWS 2017-02-17 13:49:45 UTC (rev 158) @@ -1,31 +1,47 @@ -CHANGES IN CHNOSZ 1.0.8-47 (2017-02-17) +CHANGES IN CHNOSZ 1.0.8-48 (2017-02-17) --------------------------------------- DOCUMENTATION: -- Replace anintro.Rnw (Sweave) with rewritten anintro.Rmd (knitr, Tufte - style). +- Replace anintro.Rnw (using Sweave) with rewritten anintro.Rmd (using + knitr with Tufte style). -- Add eos-regress.Rmd. +- Add eos-regress.Rmd (Regressing thermodynamic data). -- Demos: Move examples from help pages to protein.equil.R, add.obigt.R, - and affinity.R; add bugstab.R; update buffer.R and rename old buffer.R - to protbuff.R; remove nucleobase.R. +- New demos: bugstab.R (potential diagrams for microbial proteins in + colorectal cancer), activity_ratios.R (mineral stability diagrams + with activity ratios on the axes). -NEW DATA AND FEATURES: +- Converted demos: move examples from help pages to protein.equil.R, + add.obigt.R, and affinity.R. -- OBIGT.csv: Add data for citric acid cycle metabolites from Canovas and - Shock, 2016. +- Updated and removed demos: update buffer.R (logfH2 set by mineral + buffers and aqueous species) and rename old buffer.R to protbuff.R + (proteins as buffers); remove nucleobase.R. -- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, - SS98_Fig5b, PM90 (all used by anintro.Rmd). +CHANGES TO diagram(): +- For the `groups` argument, activities are multiplied by the balance + coefficients before the summation. + +- Draw smoother boundary lines (with contour(); `lty` is usable), at the + expense of not being precisely aligned with the grid used for plotting + colors. For the old behavior, use `dotted=0`. + +- Default of `legend.x` changed to NA (instead of making a legend, put + labels near the lines). + +- Field labels: apply formatting (subscripts and superscripts) to names + that parse as chemical formulas; use `format.names=FALSE` to disable. + +- Chemical formulas that are part of the axis labels (log activity or + fugacity) now have formatting applied. + +NEW FEATURES: + - Add ZC.col() for generating a red-grey-blue color scale from numeric values. -- For the `groups` argument in diagram(), activities are multiplied - by the balance coefficients before the summation. - - Add "QEC" as a keyword for preset species in basis() (glutamine, glutamic acid, cysteine, H2O, oxygen). @@ -36,13 +52,6 @@ (accession, name, organism) into columns of the output data frame (protein, abbrv, organism). -- diagram() draws smoother boundary lines (with contour(); `lty` is - usable), at the expense of not being precisely aligned with the grid - used for plotting colors. For the old behavior, use `dotted=0`. - -- diagram() applies formatting (subscripts and superscripts) to names - that parse as chemical formulas; use `format.names=FALSE` to disable. - - Add `...` argument to thermo.plot.new() (additional arguments for par()). @@ -50,7 +59,7 @@ marks and lines; this is used in diagram() to redraw the axes on filled diagrams. -- Add `...` argument to read.aaa() (additional arguments for +- Add `...` argument to read.aa() (additional arguments for read.csv()). - seq2aa() removes newlines and whitespace before counting the @@ -59,9 +68,17 @@ - read.fasta(): change argument `i` to `iseq`; this is used to select particular sequences to read from the file. -- diagram(): default of `legend.x` changed to NA (instead of making a - legend, put labels near the lines). +- Add syslab() and ratlab() to make formatted expressions for + sets of thermodynamic components and activity ratios. +NEW DATA: + +- OBIGT.csv: Add data for citric acid cycle metabolites from Canovas and + Shock, 2016. + +- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, + SS98_Fig5b, PM90 (all used by anintro.Rmd). + CLEANUP AND BUG FIXES: - subcrt() returns `loggam` using the common logarithm; add Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-17 13:49:45 UTC (rev 158) @@ -10,7 +10,7 @@ \usage{ diagram(eout, what = "loga.equil", alpha = FALSE, normalize = FALSE, as.residue = FALSE, balance=NULL, groups=as.list(1:length(eout$values)), - xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.7, side=1:4, + xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.5, side=1:4, ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, @@ -199,28 +199,6 @@ title(main=paste("Fe-S-O, 200 degrees C, 1 bar", "After Helgeson, 1970", sep="\n")) -## Mineral equilibrium activity diagram -## After Bowers et al., 1984, p. 246 -# Consider the system denoted by BJH84 as -# HCl-H2O-CaO-CO2-MgO-(SiO2) at 300 deg C and 1000 bar -# HCl, CO2, O2 have zero stoichiometric coeffs in the species -# Ca+2, Mg+2 are going to be on the diagram -# SiO2 will be conserved (the immobile component) -# (try changing any of the 999's, the diagram will be unaffected) -basis(c("HCl","H2O","Ca+2","CO2","Mg+2","SiO2","O2","H+"), - c(999,0,999,999,999,999,999,-7)) -# we have to tell CHNOSZ which species to include; there are -# others that could be in this system -species(c("quartz","talc","forsterite","tremolite","diopside", - "wollastonite","monticellite","merwinite")) -# calculate the chemical affinities of formation reactions -a <- affinity("Mg+2"=c(-12,-4),"Ca+2"=c(-8,0),T=300,P=1000) -diagram(a) -title(main=paste("HCl-H2O-CaO-CO2-MgO-(SiO2) at 300 degrees C,", - "1000 bar and pH=7. After Bowers et al., 1984", sep="\n")) -# note: Bowers et al. use different variables (e.g. (a_Ca+2)/(a_H+)^2), -# so the plot here is not an exact reproduction - ## Temperature-Pressure: kayanite-sillimanite-andalusite # cf. Fig. 49 of Helgeson et al., 1978 # this is a system of one component (Al2SiO5), but we need the same @@ -250,8 +228,6 @@ Aksu, S. and Doyle, F. M. (2001) Electrochemistry of copper in aqueous glycine solutions. \emph{J. Electrochem. Soc.} \bold{148}, B51--B57. \url{http://dx.doi.org/10.1149/1.1344532} - Bowers, T. S., Jackson, K. J. and Helgeson, H. C., 1984. \emph{Equilibrium Activity Diagrams for Coexisting Minerals and Aqueous Solutions at Pressures and Temperatures to 5 kb and 600} \eqn{^{\circ}}{degrees }\emph{C}. Springer-Verlag, Heidelberg, 397 p. \url{http://www.worldcat.org/oclc/224591948} - Helgeson, H. C. (1970) A chemical and thermodynamic model of ore deposition in hydrothermal systems. \emph{Mineral. Soc. Amer. Spec. Pap.} \bold{3}, 155--186. \url{http://www.worldcat.org/oclc/583263} Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K. (1978) Summary and critique of the thermodynamic properties of rock-forming minerals. \emph{Am. J. Sci.} \bold{278-A}, 1--229. \url{http://www.worldcat.org/oclc/13594862} Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/man/examples.Rd 2017-02-17 13:49:45 UTC (rev 158) @@ -16,7 +16,8 @@ examples(do.png = FALSE) demos(which = c("sources", "protein.equil", "add.obigt", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", - "copper", "solubility", "wjd", "dehydration", "bugstab"), to.file=FALSE) + "copper", "solubility", "wjd", "dehydration", "bugstab", "activity_ratios"), + to.file=FALSE) } \details{ @@ -50,6 +51,7 @@ \code{wjd} \tab run.wjd() with proteins: cell periphery of yeast \cr \code{dehydration} \tab log K of dehydration reactions; SVG file contains tooltips and links \cr \code{bugstab} \tab formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr + \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr } } Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-17 13:49:45 UTC (rev 158) @@ -58,7 +58,7 @@ a <- affinity(O2=c(-100, -65)) # try normalize=FALSE to make Fig. 5a in the paper e <- equilibrate(a, normalize=TRUE) -d <- diagram(e, ylim=c(-5, -1), names=organisms) +d <- diagram(e, ylim=c(-5, -1), names=organisms, format.names=FALSE) # add water stability line abline(v=-83.1, lty=2) title(main="Surface-layer proteins, after Dick, 2008") Modified: pkg/CHNOSZ/man/util.expression.Rd =================================================================== --- pkg/CHNOSZ/man/util.expression.Rd 2017-02-17 02:51:34 UTC (rev 157) +++ pkg/CHNOSZ/man/util.expression.Rd 2017-02-17 13:49:45 UTC (rev 158) @@ -7,6 +7,8 @@ \alias{describe.basis} \alias{describe.property} \alias{describe.reaction} +\alias{syslab} +\alias{ratlab} \title{Functions to Express Chemical Formulas and Properties} \description{Generate expressions suitable for axis labels and plot legends describing chemical species, properties and reactions.} @@ -20,6 +22,8 @@ describe.property(property, value, digits = 1, oneline = FALSE, ret.val = FALSE) describe.reaction(reaction, iname = numeric(), states = NULL) + syslab(system = c("K2O", "Al2O3", "SiO2", "H2O")) + ratlab(ion = "K+") } \arguments{ @@ -40,6 +44,8 @@ \item{reaction}{data frame, definition of reaction} \item{iname}{numeric, show names instead of formulas for these species} \item{states}{character, if \samp{all}, show states for all species} + \item{system}{character, thermodynamic components} + \item{ion}{character, an ion} } \details{ @@ -85,8 +91,16 @@ \code{describe.reaction} makes an expression summarizing a chemical reaction. The \code{reaction} data frame can be generated using \code{\link{subcrt}}. Based on the sign of their reaction coefficients, species are placed on the reactant (left) or product (right) side of the reaction, where the species with their coefficients are separated by plus signs; the two sides of the reaction are separated by an equals sign. Coefficients equal to 1 are not shown. Chemical formulas of species include a designation of physical state if \code{states} is \samp{all}. Names of species (as provided in \code{reaction}) are shown instead of chemical formulas for the species identified by \code{iname}. +\code{syslab} formats the given thermodynamic components (using \code{expr.species}) and adds intervening en dashes. + +\code{ratlab} produces a expression for the activity ratio, viz. (activity of the ion) / [(activity of H+) ^ (charge of the ion)]. + } +\seealso{ +\code{demo(activity_ratio)} for examples of \code{syslab} and \code{ratlab}. +} + \examples{\dontshow{data(thermo)} ## show descriptions of species and properties on a plot plot(0, 0, xlim=c(1,5), ylim=c(1,5), xlab="function", ylab="example") From noreply at r-forge.r-project.org Fri Feb 17 20:16:30 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 17 Feb 2017 20:16:30 +0100 (CET) Subject: [CHNOSZ-commits] r159 - in pkg/CHNOSZ: . R demo inst inst/extdata/thermo man Message-ID: <20170217191630.C0ACD188572@r-forge.r-project.org> Author: jedick Date: 2017-02-17 20:16:30 +0100 (Fri, 17 Feb 2017) New Revision: 159 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/transfer.R pkg/CHNOSZ/demo/activity_ratios.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv pkg/CHNOSZ/man/transfer.Rd pkg/CHNOSZ/man/util.data.Rd Log: OBIGT-2.csv: name H4SiO4 as a pseudospecies Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-17 19:16:30 UTC (rev 159) @@ -1,6 +1,6 @@ -Date: 2017-02-17 +Date: 2017-02-18 Package: CHNOSZ -Version: 1.0.8-48 +Version: 1.0.8-49 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/transfer.R =================================================================== --- pkg/CHNOSZ/R/transfer.R 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/R/transfer.R 2017-02-17 19:16:30 UTC (rev 159) @@ -809,7 +809,7 @@ basis(delete=TRUE) # SLS89 use H4SiO4 instead of SiO2 - use the secondary database add.obigt() - basis(c('Al+3','H4SiO4','K+','H2O','H+','O2')) + basis(c('Al+3','pseudo-H4SiO4_25C','K+','H2O','H+','O2')) # some of SLS89's initial conditions basis(c('K+','H4SiO4'),c(-6,-6)) # the candidate species @@ -818,7 +818,7 @@ # setup a diagram on which to plot a reaction path basis('pH',0) a <- affinity(H4SiO4=c(-6,-2),'K+'=c(-3,8)) - diagram(a) + diagram(a, ylab=ratlab("K+")) # identify the basis species whose activities will # be plotted by transfer() plot <- c(2,3) Modified: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-02-17 19:16:30 UTC (rev 159) @@ -4,20 +4,20 @@ par(mfrow = c(2, 2)) res <- 200 -fill <- "heat" +fill <- "terrain" ## K2O-Al2O3-SiO2-H2O, 25 degree C, 1 bar ## Steinmann et al., 1994 (http://ccm.geoscienceworld.org/content/42/2/197) ## Garrels and Christ, p. 361 (http://www.worldcat.org/oclc/517586) ## https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-75.html -# use add.obigt to get H4SiO4 +# use add.obigt to make H4SiO4 pseudospecies available as a basis species add.obigt() -basis(c("Al+3", "H4SiO4", "K+", "H2O", "H+", "O2")) -species(c("gibbsite", "kaolinite", "pyrophyllite", "k-feldspar", "muscovite")) -a <- affinity(H4SiO4 = c(-6, 0, res), `K+` = c(0, 8, res)) +basis(c("Al+3", "pseudo-H4SiO4_25C", "K+", "H2O", "H+", "O2")) +species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "k-feldspar")) +a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res)) diagram(a, ylab = ratlab("K+"), fill = fill) title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O"))) -legend("topright", describe.property(c("T", "P"), c(25, 1)), bty = "n") +legend("bottomleft", describe.property(c("T", "P"), c(25, 1)), bty = "n") # reset database data(thermo) @@ -25,8 +25,8 @@ ## Helgeson et al., 1969, p. 136 (http://www.worldcat.org/oclc/902423149) ## Bowers et al., 1984, p. 246 (http://www.worldcat.org/oclc/224591948) basis(c("H2O", "Ca+2", "Mg+2", "SiO2", "O2", "H+")) -species(c("quartz", "talc", "chrysotile", "forsterite", "monticellite", - "merwinite", "wollastonite", "diopside", "tremolite")) +species(c("quartz", "talc", "chrysotile", "forsterite", "tremolite", + "diopside", "wollastonite", "monticellite", "merwinite")) # calculate the chemical affinities of formation reactions a <- affinity("Mg+2" = c(4, 9, res), "Ca+2" = c(5, 14, res), T = 300, P = 1000) diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/inst/NEWS 2017-02-17 19:16:30 UTC (rev 159) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-48 (2017-02-17) +CHANGES IN CHNOSZ 1.0.8-49 (2017-02-18) --------------------------------------- DOCUMENTATION: @@ -79,6 +79,9 @@ - extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, SS98_Fig5b, PM90 (all used by anintro.Rmd). +- OBIGT-2.csv: Make pseudospecies for H4SiO4: rename existing H4SiO4 to + pseudo-H4SiO4_highT, and add pseudo-H4SiO4_25C. + CLEANUP AND BUG FIXES: - subcrt() returns `loggam` using the common logarithm; add Modified: pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-17 19:16:30 UTC (rev 159) @@ -229,7 +229,7 @@ YbCl2+,NA,YbCl2+,aq,MWW09,NA,03.Jul.10,-216360,NA,-19.22,-4.55,-0.6,1.9985,-2.9017,6.8906,-2.659,11.1191,-3.9614,0.8351,1 LuCl2+,NA,LuCl2+,aq,MWW09,NA,03.Jul.10,-222750,NA,-30.31,11.26,-1.23,1.9757,-2.9572,6.9124,-2.6567,21.9175,-0.7409,1.0031,1 Ti(OH)4,NA,Ti(OH)4,aq,Ste01,NA,31.Aug.06,-313690.248565966,-361331.022944551,5.23900573613767,48.4942638623327,40.6,7.36687380497132,10.210086042065,1.15296367112811,-3.20100382409178,51.2762906309751,-1.27652963671128,0.0149856596558317,0 -H4SiO4,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 +pseudo-H4SiO4_highT,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 arsenolite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137640,-156930,25.67,23.15,51.12,20.9,17.73,-2.7,0,0,0,0,548 claudetite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137730,-156600,27.09,23.19,47.26,23.86,10.74,-3.44,0,0,0,0,588 orpiment,NA,As2S3,cr,PGS+96,NA,25.Aug.06,-20550,-20700,39.1,27.53,70.5,22.73,13.82,0.605,0,0,0,0,580 @@ -289,3 +289,4 @@ starkeyite,NA,MgSO4*4H2O,cr,GM09,NA,24.Nov.15,-514770,-596580,62.12,NA,NA,0,0,0,0,0,0,0,400 hexahydrite,NA,MgSO4*6H2O,cr,GM09,NA,24.Nov.15,-629130,-737880,83.29,NA,NA,48.56,1.6,-10.68,0,0,0,0,400 epsomite,NA,MgSO4*7H2O,cr,GM09,NA,24.Nov.15,-686190,-809920,88.74,NA,NA,52.29,1.78,-11.67,0,0,0,0,400 +pseudo-H4SiO4_25C,NA,H4SiO4,aq,CHNOSZ,NA,17.Feb.17,-312565.4,-346408.5,51.42456,-40.096352,52.19983,NA,NA,NA,NA,NA,NA,NA,0 Modified: pkg/CHNOSZ/man/transfer.Rd =================================================================== --- pkg/CHNOSZ/man/transfer.Rd 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/man/transfer.Rd 2017-02-17 19:16:30 UTC (rev 159) @@ -71,9 +71,9 @@ \examples{\dontshow{data(thermo)} ## react potassium feldspar in a closed system ## after Steinmann et al., 1994 and Helgeson et al., 1969 -# load the secondary database to use H4SiO4 +# load the secondary database to use pseudo-H4SiO4 as a basis species add.obigt() -basis(c("Al+3", "H4SiO4", "K+", "H2O", "H+", "O2"), c(0, -6, -6, 0, 0, 0)) +basis(c("Al+3", "pseudo-H4SiO4_25C", "K+", "H2O", "H+", "O2"), c(0, -6, -6, 0, 0, 0)) species(c("k-feldspar", "muscovite", "pyrophyllite", "kaolinite", "gibbsite")) a <- affinity(H4SiO4=c(-6, -2), "K+"=c(-3, 8)) diagram(a, fill="heat") Modified: pkg/CHNOSZ/man/util.data.Rd =================================================================== --- pkg/CHNOSZ/man/util.data.Rd 2017-02-17 13:49:45 UTC (rev 158) +++ pkg/CHNOSZ/man/util.data.Rd 2017-02-17 19:16:30 UTC (rev 159) @@ -49,6 +49,12 @@ \code{add.obigt} reads data from the specified \code{file} and adds it to \code{\link{thermo}$obigt}. Set \code{force} to TRUE to replace species that exist in the thermodynamic database (each unique combination of a name and a state in the database is considered to be a unique species). \code{force}, if not specified, reverts to TRUE if the \code{file} is left at its default. Given the default setting of \code{E.units}, the function does not perform any unit conversions. If \code{E.units} is set to \samp{J}, then the thermodynamic parameters are converted from units of Joules to calories, as used in the CHNOSZ database. + Notes on the secondary database added by \code{add.obigt} (OBIGT-2.csv): + + \itemize{ + \item pseudo-H4SiO4_25T and pseudo-H4SiO4-highT are approximate pseudospecies for H4SiO4. They are chosen to minimize the properties of the reaction H4SiO4 = SiO2 + 2H2O at two temperature conditions. The properties of the 25T species, calculated using \code{\link{subcrt}}, are valid only at 25 \eqn{^{\circ}}{?}C. The highT species, taken from Steff?nson, 2001, is applicable near 300 \eqn{^{\circ}}{?}C (see Figure 3 of that paper). These pseudospecies can be used to make diagrams with H4SiO4 as a basis species, instead of SiO2(aq). + } + \code{mod.obigt} changes one or more of the properties of species or adds species to the thermodynamic database. These changes are lost if you reload the database by calling \code{\link{data}(thermo)} or if you quit the \R session without saving it. The name of the species to add or change must be supplied as the first argument of \code{...} or as a named argument (named \samp{name}). @@ -90,7 +96,7 @@ } \seealso{ - The default supplementary thermodynamic database for \code{add.obigt} (\code{\link{extdata}/thermo/OBIGT-2.csv}) is used in some of the example calculations in the help page for \code{\link{diagram}} and also in \code{\link{anim.TCA}}. + The secondary thermodynamic database for \code{add.obigt} (\code{\link{extdata}/thermo/OBIGT-2.csv}) is used in some of the example calculations in the help page for \code{\link{diagram}} and also in \code{\link{anim.TCA}}. \code{\link{mod.buffer}} for updating the list of available buffers. } @@ -130,6 +136,8 @@ Richard, L. and Helgeson, H. C. (1998) Calculation of the thermodynamic properties at elevated temperatures and pressures of saturated and aromatic high molecular weight solid and liquid hydrocarbons in kerogen, bitumen, petroleum, and other organic matter of biogeochemical interest. \emph{Geochim. Cosmochim. Acta} \bold{62}, 3591--3636. \url{http://dx.doi.org/10.1016/S0016-7037(97)00345-1} + Stef?nsson, Andri (2001) Dissolution of primary minerals of basalt in natural waters. I. Calculation of mineral solubilities from 0?C to 350?C \emph{Chem. Geol.} \bold{172}, 225--250. \url{http://dx.doi.org/10.1016/S0009-2541(00)00263-1} + } From noreply at r-forge.r-project.org Sat Feb 18 08:17:19 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 18 Feb 2017 08:17:19 +0100 (CET) Subject: [CHNOSZ-commits] r160 - in pkg/CHNOSZ: . R data demo inst inst/extdata/cpetc inst/extdata/thermo man vignettes Message-ID: <20170218071719.1EBD3187A7D@r-forge.r-project.org> Author: jedick Date: 2017-02-18 08:17:18 +0100 (Sat, 18 Feb 2017) New Revision: 160 Removed: pkg/CHNOSZ/inst/extdata/cpetc/BKM60_Fig7.csv pkg/CHNOSZ/inst/extdata/thermo/groups_big.csv pkg/CHNOSZ/inst/extdata/thermo/groups_small.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/transfer.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/data/OBIGT.csv pkg/CHNOSZ/demo/activity_ratios.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/EOSregress.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/transfer.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: eos-regress.Rmd: add "Making a pseudospecies: H4SiO4" Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-18 07:17:18 UTC (rev 160) @@ -1,6 +1,6 @@ Date: 2017-02-18 Package: CHNOSZ -Version: 1.0.8-49 +Version: 1.0.8-50 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/transfer.R =================================================================== --- pkg/CHNOSZ/R/transfer.R 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/R/transfer.R 2017-02-18 07:17:18 UTC (rev 160) @@ -805,12 +805,9 @@ # call feldspar("closed") # or feldspar("open") # setup conditions for feldspar reaction - #basis(c('Al+3','SiO2','K+','H2O','H+','O2')) basis(delete=TRUE) - # SLS89 use H4SiO4 instead of SiO2 - use the secondary database - add.obigt() - basis(c('Al+3','pseudo-H4SiO4_25C','K+','H2O','H+','O2')) - # some of SLS89's initial conditions + basis(c('Al+3','pseudo-H4SiO4','K+','H2O','H+','O2')) + # some of SLS94's initial conditions basis(c('K+','H4SiO4'),c(-6,-6)) # the candidate species species(delete=TRUE) @@ -822,7 +819,7 @@ # identify the basis species whose activities will # be plotted by transfer() plot <- c(2,3) - # return to SLS89 initial conditions + # return to SLS94 initial conditions basis('pH',4) # start with miniscule amounts of all species species(1:5,-999) Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/R/util.plot.R 2017-02-18 07:17:18 UTC (rev 160) @@ -210,27 +210,6 @@ for(i in 1:l) mtext(main[i], line=line+l-i, ...) } - -residualsplot <- function(residuals,property="Cp",model="big") { - # a barchart useful for plotting residuals - # (see 'xadditivy' vignette) - # plot horizontal bars stacked with largest on top - # put them in order of increasing size - residuals <- residuals[order(abs(residuals))] - bp <- barplot(residuals,horiz=TRUE,axisnames=FALSE) - # to plot names, first find the sign of the residual - ispos <- residuals > 0 - # put some padding around the names - nr <- paste("",names(residuals),"") - # align left or right depending on sign of residual - text(0,bp[ispos],nr[ispos],adj=1) - text(0,bp[!ispos],nr[!ispos],adj=0) - # assemble stuff for the title - title(main=paste("residuals in",property,"using",model,"model")) - # add axis label - mtext(axis.label(property),1,3) -} - # get colors for range of ZC values 20170206 ZC.col <- function(z) { # scale values to [1, 1000] Modified: pkg/CHNOSZ/data/OBIGT.csv =================================================================== --- pkg/CHNOSZ/data/OBIGT.csv 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/data/OBIGT.csv 2017-02-18 07:17:18 UTC (rev 160) @@ -1833,6 +1833,7 @@ oxaloacetate-2,NA,C4H2O5-2,aq,CS16,NA,21.Dec.16,-190600,-230300,57.2,-60.7,66.1,11.7014,19.7949,0.1041,-3.5973,-29.4812,-4.8417,2.3465,-2 "pyruvic acid",NA,CH3COCOOH,aq,CS16,NA,21.Dec.16,-117000,-140300,62.1,36.3,64.6,10.5381,17.1584,0.7032,-3.4883,37.4903,-1.3746,-0.176,0 pyruvate,NA,CH3COCOO-,aq,CS16,NA,21.Dec.16,-113600,-137400,60.4,-3.7,51.5,9.0836,13.862,1.4526,-3.3521,11.2428,-4.1508,0.7144,-1 +pseudo-H4SiO4,NA,H4SiO4,aq,CHNOSZ,NA,18.Feb.17,-312565,-346409,51.4246,-40.0964,52.1998,89.2031,-176.5071,-452.1431,101.36051,67.0854,-52.0776,0.1215745,0 acanthite,Acn,Ag2S,cr1,HDN+78,NA,5.May.78,-9446,-7550,34.3,NA,34.2,15.63,8.6,0,0,0,0,0,450 acanthite,Acn,Ag2S,cr2,HDN+78,NA,5.May.78,-9235.197,-7024.866,35.3543,NA,34.2,1.819,53,0,0,0,0,0,620 acanthite,Acn,Ag2S,cr3,HDN+78,NA,5.May.78,-8227.324,-4960.457,38.898,NA,34.2,21.6,0,0,0,0,0,0,1000 Modified: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-02-18 07:17:18 UTC (rev 160) @@ -10,16 +10,14 @@ ## Steinmann et al., 1994 (http://ccm.geoscienceworld.org/content/42/2/197) ## Garrels and Christ, p. 361 (http://www.worldcat.org/oclc/517586) ## https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-75.html -# use add.obigt to make H4SiO4 pseudospecies available as a basis species -add.obigt() -basis(c("Al+3", "pseudo-H4SiO4_25C", "K+", "H2O", "H+", "O2")) +# the pseudospecies H4SiO4 is used as a basis species +# (see the vignette "Regressing thermodynamic data") +basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2")) species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "k-feldspar")) a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res)) diagram(a, ylab = ratlab("K+"), fill = fill) title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O"))) legend("bottomleft", describe.property(c("T", "P"), c(25, 1)), bty = "n") -# reset database -data(thermo) ## H2O-CaO-MgO-SiO2 at 300 degree C and 1000 bar ## Helgeson et al., 1969, p. 136 (http://www.worldcat.org/oclc/902423149) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/inst/NEWS 2017-02-18 07:17:18 UTC (rev 160) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-49 (2017-02-18) +CHANGES IN CHNOSZ 1.0.8-50 (2017-02-18) --------------------------------------- DOCUMENTATION: @@ -6,7 +6,8 @@ - Replace anintro.Rnw (using Sweave) with rewritten anintro.Rmd (using knitr with Tufte style). -- Add eos-regress.Rmd (Regressing thermodynamic data). +- Add eos-regress.Rmd (Regressing thermodynamic data), including + section on Making a pseudospecies: H4SiO4. - New demos: bugstab.R (potential diagrams for microbial proteins in colorectal cancer), activity_ratios.R (mineral stability diagrams @@ -76,12 +77,14 @@ - OBIGT.csv: Add data for citric acid cycle metabolites from Canovas and Shock, 2016. +- OBIGT.csv: Add H4SiO4 pseudospecies (pseudo-H4SiO4); see calculations + in eos-regress.Rmd. + +- OBIGT-2.csv: Rename H4SiO4 to pseudo-H4SiO4_Ste01 (Steff?nson, 2001). + - extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, SS98_Fig5b, PM90 (all used by anintro.Rmd). -- OBIGT-2.csv: Make pseudospecies for H4SiO4: rename existing H4SiO4 to - pseudo-H4SiO4_highT, and add pseudo-H4SiO4_25C. - CLEANUP AND BUG FIXES: - subcrt() returns `loggam` using the common logarithm; add Deleted: pkg/CHNOSZ/inst/extdata/cpetc/BKM60_Fig7.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/cpetc/BKM60_Fig7.csv 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/inst/extdata/cpetc/BKM60_Fig7.csv 2017-02-18 07:17:18 UTC (rev 160) @@ -1,425 +0,0 @@ -type,pH,Eh -normal,8.9,0.216 -normal,9,0.266 -normal,8.3,0.277 -normal,8.11,0.299 -normal,7.98,0.328 -normal,7.66,0.291 -normal,7.61,0.32 -normal,7.68,0.322 -normal,7.65,0.337 -normal,7.82,0.348 -normal,7.64,0.359 -normal,7.49,0.359 -normal,7.41,0.358 -normal,7.29,0.343 -normal,7.3,0.333 -normal,7.33,0.325 -normal,7.36,0.321 -normal,7.11,0.311 -normal,7.1,0.32 -normal,7.46,0.39 -normal,7.46,0.397 -normal,7.58,0.4 -normal,7.39,0.419 -normal,7.97,0.38 -normal,8.15,0.399 -normal,7.98,0.41 -normal,7.99,0.426 -normal,7.7,0.445 -normal,7.67,0.453 -normal,7.75,0.471 -normal,7.58,0.497 -normal,7.7,0.512 -normal,7.6,0.583 -normal,7.18,0.495 -normal,7.33,0.435 -normal,7.13,0.453 -normal,6.91,0.441 -normal,6.97,0.425 -normal,6.8,0.427 -normal,7.09,0.412 -normal,7.08,0.401 -normal,7.15,0.392 -normal,6.98,0.399 -normal,6.96,0.389 -normal,6.83,0.389 -normal,6.79,0.395 -normal,6.79,0.404 -normal,6.8,0.41 -normal,6.71,0.408 -normal,7.11,0.38 -normal,7.19,0.371 -normal,7.11,0.367 -normal,7.23,0.359 -normal,6.9,0.363 -normal,6.82,0.366 -normal,6.57,0.386 -normal,6.44,0.37 -normal,6.51,0.359 -normal,6.63,0.35 -normal,6.28,0.362 -normal,6.21,0.366 -normal,5.97,0.373 -normal,6.19,0.408 -normal,6.04,0.401 -normal,5.92,0.403 -normal,5.99,0.408 -normal,6.03,0.412 -normal,5.96,0.415 -normal,5.98,0.425 -normal,6.18,0.431 -normal,6.15,0.437 -normal,6.3,0.444 -normal,6.28,0.45 -normal,6.57,0.452 -normal,6.69,0.44 -normal,6.59,0.422 -normal,6.57,0.416 -normal,6.7,0.48 -normal,6.61,0.484 -normal,6.61,0.478 -normal,6.87,0.508 -normal,6.67,0.535 -normal,6.7,0.564 -normal,6.49,0.57 -normal,6.49,0.587 -normal,6.52,0.6 -normal,6.18,0.614 -normal,6.19,0.588 -normal,6.1,0.579 -normal,5.97,0.595 -normal,6.29,0.519 -normal,6.38,0.463 -normal,6.19,0.472 -normal,6.23,0.48 -normal,6.21,0.491 -normal,6.14,0.491 -normal,6.09,0.493 -normal,6.01,0.501 -normal,6.01,0.49 -normal,6.01,0.48 -normal,6.04,0.475 -normal,6.06,0.471 -normal,6.05,0.464 -normal,5.98,0.435 -normal,5.85,0.438 -normal,5.85,0.45 -normal,5.82,0.46 -normal,5.74,0.44 -normal,5.75,0.405 -normal,5.67,0.39 -normal,5.4,0.386 -normal,5.39,0.415 -normal,5.23,0.44 -normal,5.48,0.441 -normal,5.49,0.446 -normal,5.51,0.452 -normal,5.45,0.46 -normal,5.53,0.465 -normal,5.6,0.478 -normal,5.75,0.497 -normal,5.77,0.517 -normal,5.99,0.551 -normal,5.91,0.562 -normal,5.62,0.559 -normal,5.69,0.603 -normal,5.79,0.622 -normal,5.39,0.534 -normal,5.42,0.501 -normal,5.41,0.494 -normal,5.41,0.486 -normal,5.41,0.479 -normal,5.33,0.48 -normal,5.27,0.49 -normal,5.28,0.494 -normal,5.28,0.499 -normal,5.24,0.505 -normal,5.22,0.44 -normal,5.3,0.452 -normal,5.19,0.459 -normal,5.15,0.464 -normal,5.1,0.471 -normal,5.16,0.475 -normal,4.98,0.412 -normal,4.69,0.414 -normal,4.66,0.405 -normal,4.51,0.437 -normal,5.08,0.514 -normal,5.12,0.521 -normal,5.1,0.559 -normal,5.2,0.564 -normal,5.22,0.58 -normal,5.08,0.634 -normal,4.88,0.637 -normal,4.8,0.655 -normal,5.08,0.69 -normal,5.41,0.693 -normal,4.82,0.734 -normal,4.49,0.678 -normal,4.37,0.649 -normal,4.24,0.621 -normal,3.72,0.619 -normal,3.08,0.602 -normal,3.48,0.595 -normal,3.6,0.598 -normal,3.85,0.598 -normal,3.67,0.579 -normal,3.47,0.579 -normal,3.34,0.581 -normal,3.29,0.574 -normal,3.3,0.55 -normal,3.51,0.551 -normal,4.39,0.594 -normal,4.49,0.584 -normal,4.71,0.572 -normal,4.79,0.558 -normal,4.69,0.554 -normal,4.3,0.572 -normal,4.11,0.57 -normal,4.03,0.555 -normal,3.95,0.542 -normal,3.88,0.561 -normal,3.85,0.555 -normal,3.82,0.55 -normal,3.78,0.544 -normal,4.68,0.52 -normal,4.72,0.514 -normal,4.78,0.509 -normal,4.89,0.513 -normal,4.78,0.499 -normal,4.38,0.521 -normal,4.19,0.51 -normal,4.33,0.509 -normal,4.3,0.505 -normal,4.3,0.499 -normal,4.28,0.49 -normal,4.24,0.479 -normal,4.4,0.494 -normal,4.45,0.491 -normal,4.49,0.486 -normal,4.52,0.476 -normal,4.48,0.475 -normal,4.4,0.461 -normal,4.32,0.467 -normal,4.25,0.446 -normal,4.17,0.442 -normal,4.06,0.456 -normal,4.16,0.463 -normal,4.05,0.468 -normal,3.99,0.474 -normal,3.95,0.47 -normal,4.1,0.494 -normal,4.06,0.49 -normal,3.99,0.494 -normal,3.91,0.498 -normal,4,0.513 -normal,3.96,0.516 -normal,3.96,0.524 -normal,3.91,0.524 -normal,3.86,0.523 -normal,3.89,0.519 -normal,3.84,0.514 -normal,3.77,0.509 -normal,3.81,0.459 -normal,3.7,0.465 -normal,3.76,0.471 -normal,3.65,0.48 -normal,3.69,0.486 -normal,3.7,0.491 -normal,3.7,0.495 -normal,3.5,0.478 -normal,2.84,0.501 -normal,3.23,0.493 -normal,3.33,0.494 -normal,3.31,0.504 -normal,3.27,0.509 -normal,3.25,0.513 -normal,3.21,0.513 -normal,3.14,0.513 -normal,3.43,0.499 -normal,3.51,0.502 -normal,3.55,0.494 -normal,3.5,0.509 -normal,3.55,0.51 -normal,3.52,0.516 -normal,3.41,0.523 -normal,3.4,0.528 -normal,3.43,0.535 -normal,3.29,0.532 -normal,3.55,0.532 -normal,3.6,0.536 -normal,3.67,0.532 -normal,3.7,0.523 -normal,3.61,0.524 -normal,3.63,0.527 -normal,3.33,0.536 -wet,3.69,0.432 -wet,3.74,0.409 -wet,4.01,0.406 -wet,3.8,0.39 -wet,3.68,0.372 -wet,3.83,0.349 -wet,3.8,0.335 -wet,4.08,0.244 -wet,4.14,0.247 -wet,4.27,0.268 -wet,4.72,0.304 -wet,4.62,0.323 -wet,4.54,0.354 -wet,4.84,0.315 -wet,4.96,0.308 -wet,5.13,0.301 -wet,5.1,0.289 -wet,5.07,0.274 -wet,4.9,0.247 -wet,5.11,0.203 -wet,5.12,0.197 -wet,4.99,0.334 -wet,5.08,0.331 -wet,5.04,0.326 -wet,5.11,0.323 -wet,5.15,0.322 -wet,5.07,0.343 -wet,4.96,0.354 -wet,4.78,0.354 -wet,4.81,0.36 -wet,4.85,0.365 -wet,4.77,0.373 -wet,4.78,0.379 -wet,4.71,0.377 -wet,4.64,0.38 -wet,4.72,0.383 -wet,4.77,0.386 -wet,4.7,0.388 -wet,4.74,0.391 -wet,4.81,0.392 -wet,4.75,0.395 -wet,4.59,0.402 -wet,4.03,0.433 -wet,5.35,0.364 -wet,5.3,0.368 -wet,5.83,0.339 -wet,5.61,0.334 -wet,5.68,0.321 -wet,5.41,0.312 -wet,5.47,0.3 -wet,5.55,0.29 -wet,5.81,0.276 -wet,5.51,0.237 -wet,5.67,0.207 -wet,6.36,0.225 -wet,6.08,0.271 -wet,5.97,0.29 -wet,6.05,0.297 -wet,6.22,0.315 -wet,6.6,0.308 -wet,6.35,0.278 -wet,6.33,0.27 -wet,6.75,0.246 -wet,7.27,0.275 -wet,7.27,0.223 -wet,6.95,0.203 -wet,7.37,0.177 -wet,6.8,0.173 -wet,6.04,0.161 -wet,6.71,0.162 -wet,6.65,0.169 -wet,6.58,0.173 -wet,6.49,0.165 -wet,6.54,0.161 -wet,6.46,0.155 -wet,6.39,0.151 -wet,6.47,0.148 -wet,6.57,0.141 -wet,6.71,0.141 -wet,6.82,0.139 -wet,6.93,0.132 -wet,6.71,0.128 -wet,6.79,0.125 -wet,7.17,0.144 -wet,7.39,0.125 -wet,7.83,0.095 -wet,8.36,0.073 -waterlogged,7.01,-0.352 -waterlogged,6.67,-0.333 -waterlogged,6.35,-0.327 -waterlogged,6.47,-0.301 -waterlogged,6.38,-0.284 -waterlogged,6.87,-0.281 -waterlogged,6.91,-0.27 -waterlogged,6.67,-0.269 -waterlogged,7.1,-0.282 -waterlogged,7.38,-0.303 -waterlogged,5.59,-0.292 -waterlogged,5.6,-0.28 -waterlogged,5.87,-0.254 -waterlogged,6.17,-0.224 -waterlogged,5.96,-0.213 -waterlogged,5.87,-0.216 -waterlogged,6.07,-0.202 -waterlogged,6.48,-0.203 -waterlogged,6.77,-0.167 -waterlogged,7.08,-0.126 -waterlogged,6.28,-0.087 -waterlogged,5.47,-0.101 -waterlogged,5.28,-0.111 -waterlogged,5.29,-0.124 -waterlogged,5.36,-0.068 -waterlogged,5.89,-0.029 -waterlogged,5.6,-0.021 -waterlogged,5.68,0.003 -waterlogged,5.59,0.005 -waterlogged,5.32,0.004 -waterlogged,5.08,-0 -waterlogged,7.46,0.079 -waterlogged,7.45,0.066 -waterlogged,7.55,0.053 -waterlogged,7.25,0.038 -waterlogged,7.15,0.064 -waterlogged,7.18,0.079 -waterlogged,7.07,0.086 -waterlogged,6.97,0.079 -waterlogged,6.96,0.087 -waterlogged,6.87,0.088 -waterlogged,6.82,0.081 -waterlogged,7.08,0.054 -waterlogged,6.97,0.06 -waterlogged,7.03,0.034 -waterlogged,6.91,0.035 -waterlogged,6.76,0.013 -waterlogged,6.88,-0.003 -waterlogged,6.88,-0.021 -waterlogged,7.21,-0.021 -waterlogged,7.59,0.005 -waterlogged,5.76,0.024 -waterlogged,5.3,0.043 -waterlogged,5.37,0.056 -waterlogged,5.09,0.056 -waterlogged,5.05,0.045 -waterlogged,5.73,0.065 -waterlogged,5.88,0.084 -waterlogged,6.15,0.094 -waterlogged,6.14,0.086 -waterlogged,6.48,0.081 -waterlogged,6.5,0.066 -waterlogged,5.2,0.114 -waterlogged,5.48,0.101 -waterlogged,5.5,0.118 -waterlogged,5.45,0.129 -waterlogged,5.33,0.121 -waterlogged,5.87,0.109 -waterlogged,5.8,0.124 -waterlogged,5.75,0.128 -waterlogged,5.43,0.146 -waterlogged,5.47,0.154 -waterlogged,5.37,0.152 -waterlogged,5.32,0.155 -waterlogged,5.26,0.143 -waterlogged,5.18,0.159 -waterlogged,6.68,0.116 -waterlogged,5.55,0.173 -waterlogged,5.51,0.166 -waterlogged,5.1,0.187 -waterlogged,4.88,0.199 -waterlogged,7.12,0.083 Modified: pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-18 07:17:18 UTC (rev 160) @@ -229,7 +229,7 @@ YbCl2+,NA,YbCl2+,aq,MWW09,NA,03.Jul.10,-216360,NA,-19.22,-4.55,-0.6,1.9985,-2.9017,6.8906,-2.659,11.1191,-3.9614,0.8351,1 LuCl2+,NA,LuCl2+,aq,MWW09,NA,03.Jul.10,-222750,NA,-30.31,11.26,-1.23,1.9757,-2.9572,6.9124,-2.6567,21.9175,-0.7409,1.0031,1 Ti(OH)4,NA,Ti(OH)4,aq,Ste01,NA,31.Aug.06,-313690.248565966,-361331.022944551,5.23900573613767,48.4942638623327,40.6,7.36687380497132,10.210086042065,1.15296367112811,-3.20100382409178,51.2762906309751,-1.27652963671128,0.0149856596558317,0 -pseudo-H4SiO4_highT,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 +pseudo-H4SiO4_Ste01,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 arsenolite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137640,-156930,25.67,23.15,51.12,20.9,17.73,-2.7,0,0,0,0,548 claudetite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137730,-156600,27.09,23.19,47.26,23.86,10.74,-3.44,0,0,0,0,588 orpiment,NA,As2S3,cr,PGS+96,NA,25.Aug.06,-20550,-20700,39.1,27.53,70.5,22.73,13.82,0.605,0,0,0,0,580 @@ -289,4 +289,3 @@ starkeyite,NA,MgSO4*4H2O,cr,GM09,NA,24.Nov.15,-514770,-596580,62.12,NA,NA,0,0,0,0,0,0,0,400 hexahydrite,NA,MgSO4*6H2O,cr,GM09,NA,24.Nov.15,-629130,-737880,83.29,NA,NA,48.56,1.6,-10.68,0,0,0,0,400 epsomite,NA,MgSO4*7H2O,cr,GM09,NA,24.Nov.15,-686190,-809920,88.74,NA,NA,52.29,1.78,-11.67,0,0,0,0,400 -pseudo-H4SiO4_25C,NA,H4SiO4,aq,CHNOSZ,NA,17.Feb.17,-312565.4,-346408.5,51.42456,-40.096352,52.19983,NA,NA,NA,NA,NA,NA,NA,0 Deleted: pkg/CHNOSZ/inst/extdata/thermo/groups_big.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/groups_big.csv 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/inst/extdata/thermo/groups_big.csv 2017-02-18 07:17:18 UTC (rev 160) @@ -1,25 +0,0 @@ -,[-CH3],[-CH2-],[-CH2OH],[-CO-],[-COOH] -ethane,2,,,, -propane,2,1,,, -butane,2,2,,, -methanol,1,-1,1,, -ethanol,1,,1,, -1-propanol,1,1,1,, -1-butanol,1,2,1,, -1-pentanol,1,3,1,, -3-pentanol,1,3,1,, -2-propanol,1,1,1,, -2-butanol,1,2,1,, -2-pentanol,1,3,1,, -acetone,2,,,1, -butanone,2,1,,1, -3-pentanone,2,2,,1, -2-heptanone,2,4,,1, -acetaldehyde,2,-1,,1, -"acetic acid",1,,,,1 -"propanoic acid",1,1,,,1 -"butanoic acid",1,2,,,1 -"2-methylpropanoic acid",3,-1,,,1 -"2,4-dimethyl-3-pentanone",6,-2,,1, -"lactic acid",,1,1,,1 -"citric acid",-2,4,1,,3 Deleted: pkg/CHNOSZ/inst/extdata/thermo/groups_small.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/groups_small.csv 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/inst/extdata/thermo/groups_small.csv 2017-02-18 07:17:18 UTC (rev 160) @@ -1,26 +0,0 @@ -,C-(H)3C,C-(H)2(C)2,O-(H)(C),C-(H)2(O)(C),C-(H)(O)(C)2,CH3corr(tert),C-(H)3(CO),CO-(C)2,C-(HorO)(H)(CO)(C),CO-(HorO)(C),O-(H)(CO),C-(H)(CO)(C)2 -ethane,2,,,,,,,,,,, -propane,2,1,,,,,,,,,, -butane,2,2,,,,,,,,,, -methanol,1,,1,,,,,,,,, -ethanol,1,,1,1,,,,,,,, -1-propanol,1,1,1,1,,,,,,,, -1-butanol,1,2,1,1,,,,,,,, -1-pentanol,1,3,1,1,,,,,,,, -3-pentanol,2,2,1,,1,,,,,,, -2-propanol,2,,1,,1,2,,,,,, -2-butanol,2,1,1,,1,1,,,,,, -2-pentanol,2,2,1,,1,1,,,,,, -acetone,,,,,,,2,1,,,, -butanone,2,,,,,,,1,1,,, -3-pentanone,2,,,,,,,1,2,,, -2-heptanone,2,2,,,,,,1,2,,, -acetaldehyde,1,,,,,,,,,1,, -"acetic acid",1,,,,,,,,,1,1, -"propanoic acid",1,,,,,,,,1,1,1, -"butanoic acid",1,1,,,,,,,1,1,1, -"2-methylpropanoic acid",2,,,,,2,,,,1,1,1 -"2,4-dimethyl-3-pentanone",4,,,,,4,,1,,,,2 -"lactic acid",1,,1,,,1,,,1,1,1, -"citric acid",,,1,,,,1,,,3,3,2 -"isocitric acid",,,1,,,,,,2,3,3,1 Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -10,7 +10,7 @@ \section{Getting Help}{ The major features of the package are outlined in the Overview given below, with links to specific help topics. -If you are a new user, the \sQuote{anintro} vignette (An introduction to CHNOSZ) may offer a more comfortable way to get started with using the package. +See the vignette \emph{An Introduction to CHNOSZ} for more in-depth example of the usage the functions. The help pages have been given either keywords or \dQuote{concept index entries} which are visible to \code{\link{help.search}} (aka \code{??}). Use \code{??primary} to browse the most commonly used functions and \code{??secondary} to see other high-level, but less often-used functions. \code{??protein} shows functions for working with proteins, and \code{??extra} lists functions with extra functionality (beyond the main workflow). Modified: pkg/CHNOSZ/man/EOSregress.Rd =================================================================== --- pkg/CHNOSZ/man/EOSregress.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/EOSregress.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -94,7 +94,6 @@ For charged species, the variables \code{Cp_s_var} and \code{V_s_var} can be used in the regressions. They correspond to the solvation contribution to heat capacity or volume, respectively, in the HKF EOS, divided by the value of \eqn{\omega}{omega} at the reference temperature and pressure. Because these variables are themselves a function of \code{omega.PrTr}, an iterative procedure is needed to perform the regression. -See the \code{EOSregress} vignette for an example. Note that variables \code{QBorn} and \code{V_s_var} are both negated, so that the value of \eqn{\omega}{omega} has its proper sign in the corresponding equations. } @@ -104,7 +103,7 @@ } \seealso{ -The \code{EOSregress.Rmd} vignette has more references and examples. +The vignette \emph{Regressing thermodynamic data} has more references and examples, including an iterative method to retrieve \code{omega.PrTr}. } \references{ Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/data.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -92,6 +92,13 @@ \item The standard molal properties and equations-of-state parameters of four phase species (see below) of Fe(cr) were generated from heat capacity data given by Robie and Hemingway, 1995. } + Notes on the secondary database added by \code{add.obigt} (OBIGT-2.csv): + + \itemize{ + \item \samp{pseudo-H4SiO4} and \samp{pseudo-H4SiO4_Ste01} are approximate pseudospecies for H4SiO4. \samp{pseudo-H4SiO4} has thermodynamic properties that give zero properties for the reaction H4SiO4 = SiO2 + 2H2O at 25 \eqn{^{\circ}}{?}C, and HKF coefficients that are applicable to moderate temperatures (see the vignette `eos-regress.Rmd`). \samp{pseudo-H4SiO4_Ste01}, taken from Steff?nson, 2001, is applicable near 300 \eqn{^{\circ}}{?}C (see Figure 3 of that paper). \samp{pseudo-H4SiO4} can be used to make diagrams with H4SiO4 as a basis species, instead of SiO2(aq). + } + + These modifications are indicated in \code{OBIGT.csv} by having \samp{CHNOSZ} as one of the sources of data. Note also that some data appearing in the \acronym{slop98.dat} file (Shock et al., 1998) were corrected or modified as noted in that file, and are indicated in \code{OBIGT.csv} by having \samp{SLOP98} as one of the sources of data. In order to represent thermodynamic data for minerals with phase transitions, the different phases of these minerals are represented as phase species that have states denoted by \samp{cr1}, \samp{cr2}, etc. The standard molar thermodynamic properties at 25 \eqn{^{\circ}}{?}C and 1 bar (\eqn{T_r}{Pr} and \eqn{P_r}{Pr}) of the \samp{cr2} phase species of minerals were generated by first calculating those of the \samp{cr1} phase species at the transition temperature (\eqn{T_{tr}}{Ttr}) and 1 bar then taking account of the volume and entropy of transition (the latter can be retrieved by combining the former with the Clausius-Clapeyron equation and values of \eqn{(dP/dT)} of transitions taken from the \acronym{SUPCRT92} data file) to calculate the standard molar entropy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}, and taking account of the enthalpy of transition (\eqn{{\Delta}H^{\circ}}{DeltaH0}, taken from the \acronym{SUPCRT92} data file) to calculate the standard molar enthalpy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}. The standard molar properties of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr} and 1 bar calculated in this manner were combined with the equations-of-state parameters of the species to generate values of the standard molar properties at 25 \eqn{^{\circ}}{?}C and 1 bar. This process was repeated as necessary to generate the standard molar properties of phase species represented by \samp{cr3} and \samp{cr4}, referencing at each iteration the previously calculated values of the standard molar properties of the lower-temperature phase species (i.e., \samp{cr2} and \samp{cr3}). A consequence of tabulating the standard molar thermodynamic properties of the phase species is that the values of \eqn{(dP/dT)} and \eqn{{\Delta}H^{\circ}}{DeltaH0} of phase transitions can be calculated using the equations of state and therefore do not need to be stored in the thermodynamic database. However, the transition temperatures (\eqn{T_{tr}}{Ttr}) generally can not be assessed by comparing the Gibbs energies of phase species and are tabulated in the database. @@ -246,6 +253,8 @@ Shock, E. L. et al. {1998} \emph{SLOP98.dat} (computer data file). http://geopig.asu.edu/supcrt92_data/slop98.dat, accessed on 2005-11-05. Current location: \url{http://geopig.asu.edu/sites/default/files/slop98.dat}. + Stef?nsson, Andri (2001) Dissolution of primary minerals of basalt in natural waters. I. Calculation of mineral solubilities from 0?C to 350?C \emph{Chem. Geol.} \bold{172}, 225--250. \url{http://dx.doi.org/10.1016/S0009-2541(00)00263-1} + Wagman, D. D., Evans, W. H., Parker, V. B., Schumm, R. H., Halow, I., Bailey, S. M., Churney, K. L. and Nuttall, R. L. (1982) The NBS tables of chemical thermodynamic properties. Selected values for inorganic and C\eqn{_1}{1} and C\eqn{_2}{2} organic substances in SI units. \emph{J. Phys. Chem. Ref. Data} \bold{11} (supp. 2), 1--392. \url{https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf} } Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -146,7 +146,7 @@ \seealso{ Other examples are present in the help for \code{\link{protein}} and \code{\link{buffer}}, and even more can be found in \code{\link{demos}}. -See the vignette hotspring.Rnw for an example of the \code{strip} charts. +See the vignette \emph{Hot-spring proteins in CHNOSZ} for an example of the \code{strip} charts. } \examples{ Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -33,7 +33,6 @@ \item \code{RT71.csv} pH titration measurements for unfolded lysozyme (\samp{LYSC_CHICK}) taken from Roxby and Tanford, 1971. pH is in the first column, net charge in the second. See \code{\link{ionize.aa}} for an example that uses this file. \item \code{SOJSH.csv} Experimental equilibrium constants for the reaction NaCl(aq) = Na+ + Cl- as a function of temperature and pressure taken from Fig. 1 of Shock et al., 1992. Data were extracted from the figure using g3data (\url{http://www.frantz.fi/software/g3data.php}). See \code{\link{water}} for an example that uses this file. \item \code{Cp.CH4.HW97.csv}, \code{V.CH4.HWM96.csv} Apparent molar heat capacities and volumes of CH4 in dilute aqueous solutions reported by Hnedkovsky and Wood, 1997 and Hnedkovsky et al., 1996. See \code{\link{EOSregress}} for examples that use these files. - \item \code{BKM60_Fig7.dat} Eh-pH values for normal, wet and waterlogged soils from Fig. 7 of Baas Becking et al., 1960. See the \sQuote{anintro} vignette for an example that uses this file. \item \code{SC10_Rainbow.csv} Values of temperature (\eqn{^{\circ}}{?}C), pH and logarithms of activity of \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2}}{H2}, \eqn{\mathrm{NH_4^+}}{NH4+}, \eqn{\mathrm{H_2S}}{H2S} and \eqn{\mathrm{CH_4}}{CH4} for mixing of seawater and hydrothermal fluid at Rainbow field (Mid-Atlantic Ridge), taken from Shock and Canovas, 2010. \item \code{SS98_Fig5a.csv}, \code{SS98_Fig5b.csv} Values of logarithm of fugacity of \eqn{\mathrm{O_2}}{O2} and pH as a function of temperature for mixing of seawater and hydrothermal fluid, digitized from Figs. 5a and b of Shock and Schulte, 1998. \item \code{rubisco.csv} UniProt IDs for Rubisco, ranges of optimal growth temperature of organisms, domain and name of organisms, and URL of reference for growth temperature, from Dick, 2014. @@ -41,7 +40,7 @@ Files in \code{fasta} contain protein sequences: \itemize{ - \item \code{EF-Tu.aln} consists of aligned sequences (394 amino acids) of elongation factor Tu (EF-Tu). The sequences correspond to those taken from UniProtKB for ECOLI (\emph{Escherichia coli}), THETH (\emph{Thermus thermophilus}) and THEMA (\emph{Thermotoga maritima}), and reconstructed ancestral sequences taken from Gaucher et al., 2003 (maximum likelihood bacterial stem and mesophilic bacterial stem, and alternative bacterial stem). See the \sQuote{formation} vignette for an example that uses this file. + \item \code{EF-Tu.aln} consists of aligned sequences (394 amino acids) of elongation factor Tu (EF-Tu). The sequences correspond to those taken from UniProtKB for ECOLI (\emph{Escherichia coli}), THETH (\emph{Thermus thermophilus}) and THEMA (\emph{Thermotoga maritima}), and reconstructed ancestral sequences taken from Gaucher et al., 2003 (maximum likelihood bacterial stem and mesophilic bacterial stem, and alternative bacterial stem) \item \code{rubisco.csv} Sequences of Rubisco obtained from UniProt (see Dick, 2014). } @@ -59,7 +58,7 @@ \item \code{DS11.csv}, \code{DS13.csv} These two files contain amino acid compositions of metagenomically encoded proteins, averaged together according to functional annotation (DS11) or taxonomic affiliation (DS13). The data are from Dick and Shock, 2011 and 2013. - They are used in the vignette \file{hotspring.Rnw}. + They are used in the vignette \emph{Hot-spring proteins in CHNOSZ}. \item \code{microbial.aa.csv} Overall protein compositions of microbial species reported to be positively or negatively enriched in colorectal cancer. This file is taken from Dick, 2016. @@ -92,8 +91,6 @@ \itemize{ \item \code{OBIGT-2.csv} contains supplementary thermodynamic data in the same format as the primary database in \code{data/OBIGT.csv}. Data for some entries in the primary database are taken from different literature sources in this file. The default action of \code{\link{add.obigt}} is to add the contents of this file to CHNOSZ's working database in \code{thermo$obigt}. See \code{\link{diagram}} and the code of \code{\link{anim.TCA}} for examples that use this file. \item \code{obigt_check.csv} contains the results of running \code{\link{check.obigt}} to check the internal consistency of entries in the primary and supplementary databases. - \item \code{groups_big.csv} Group contribution matrix: five structural groups on the columns ([-CH3],[-CH2-],[-CH2OH],[-CO-],[-COOH]) and 24 compounds on the rows (alkanes, alcohols, ketones, acids, multiply substituted compounds). - \item \code{groups_small.csv} Group contribution matrix: twelve bond-specific groups on the columns, and 25 compounds on the rows (as above, plus isocitrate). Group identity and naming conventions adapted from Benson and Buss (1958) and Domalski and Hearing (1993). See the \sQuote{xadditivity} vignette for examples that use this file and \code{groups_big.csv}. \item \code{RH98_Table15.csv} Group stoichiometries for high molecular weight crystalline and liquid organic compounds taken from Table 15 of Richard and Helgeson, 1998. The first three columns have the \code{compound} name, \code{formula} and physical \code{state} (\samp{cr} or \samp{liq}). The remaining columns have the numbers of each group in the compound; the names of the groups (columns) correspond to species in \code{\link{thermo}$obigt}. The compound named \samp{5a(H),14a(H)-cholestane} in the paper has been changed to \samp{5a(H),14b(H)-cholestane} here to match the group stoichiometry given in the table. See \code{\link{RH2obigt}} for a function that uses this file. \item \code{DLEN67.csv} Standard Gibbs energies of formation, in kcal/mol, from Dayhoff et al., 1967, for nitrogen (N2) plus 17 compounds shown in Fig. 2 of Dayhoff et al., 1964, at 300, 500, 700 and 1000 K. } Modified: pkg/CHNOSZ/man/transfer.Rd =================================================================== --- pkg/CHNOSZ/man/transfer.Rd 2017-02-17 19:16:30 UTC (rev 159) +++ pkg/CHNOSZ/man/transfer.Rd 2017-02-18 07:17:18 UTC (rev 160) @@ -71,12 +71,10 @@ \examples{\dontshow{data(thermo)} ## react potassium feldspar in a closed system ## after Steinmann et al., 1994 and Helgeson et al., 1969 -# load the secondary database to use pseudo-H4SiO4 as a basis species -add.obigt() -basis(c("Al+3", "pseudo-H4SiO4_25C", "K+", "H2O", "H+", "O2"), c(0, -6, -6, 0, 0, 0)) +basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2"), c(0, -6, -6, 0, 0, 0)) species(c("k-feldspar", "muscovite", "pyrophyllite", "kaolinite", "gibbsite")) a <- affinity(H4SiO4=c(-6, -2), "K+"=c(-3, 8)) -diagram(a, fill="heat") +diagram(a, fill="heat", ylab=ratlab("K+")) basis("pH", 4) species(1:5, c(-4, rep(-999, 4))) tr <- transfer(190, dmode="coupled", plot=c(2, 3), devmax=1, alphamax=-1.5) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 160 From noreply at r-forge.r-project.org Sat Feb 18 11:15:38 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 18 Feb 2017 11:15:38 +0100 (CET) Subject: [CHNOSZ-commits] r161 - in pkg/CHNOSZ: . inst inst/extdata/thermo man vignettes Message-ID: <20170218101538.AA90A1873F4@r-forge.r-project.org> Author: jedick Date: 2017-02-18 11:15:38 +0100 (Sat, 18 Feb 2017) New Revision: 161 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/vignettes/eos-regress.Rmd Log: eos-regress.Rmd: try to discuss H4SiO4_Ste01 carefully Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-18 10:15:38 UTC (rev 161) @@ -1,6 +1,6 @@ Date: 2017-02-18 Package: CHNOSZ -Version: 1.0.8-50 +Version: 1.0.8-51 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/inst/NEWS 2017-02-18 10:15:38 UTC (rev 161) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-50 (2017-02-18) +CHANGES IN CHNOSZ 1.0.8-51 (2017-02-18) --------------------------------------- DOCUMENTATION: @@ -80,7 +80,7 @@ - OBIGT.csv: Add H4SiO4 pseudospecies (pseudo-H4SiO4); see calculations in eos-regress.Rmd. -- OBIGT-2.csv: Rename H4SiO4 to pseudo-H4SiO4_Ste01 (Steff?nson, 2001). +- OBIGT-2.csv: Rename H4SiO4 to H4SiO4_Ste01 (Steff?nson, 2001). - extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, SS98_Fig5b, PM90 (all used by anintro.Rmd). Modified: pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv 2017-02-18 10:15:38 UTC (rev 161) @@ -229,7 +229,7 @@ YbCl2+,NA,YbCl2+,aq,MWW09,NA,03.Jul.10,-216360,NA,-19.22,-4.55,-0.6,1.9985,-2.9017,6.8906,-2.659,11.1191,-3.9614,0.8351,1 LuCl2+,NA,LuCl2+,aq,MWW09,NA,03.Jul.10,-222750,NA,-30.31,11.26,-1.23,1.9757,-2.9572,6.9124,-2.6567,21.9175,-0.7409,1.0031,1 Ti(OH)4,NA,Ti(OH)4,aq,Ste01,NA,31.Aug.06,-313690.248565966,-361331.022944551,5.23900573613767,48.4942638623327,40.6,7.36687380497132,10.210086042065,1.15296367112811,-3.20100382409178,51.2762906309751,-1.27652963671128,0.0149856596558317,0 -pseudo-H4SiO4_Ste01,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 +H4SiO4_Ste01,NA,H4SiO4,aq,Ste01,NA,31.Aug.06,-312919.933078394,-348676.147227533,45.1003824091778,15.0095602294455,52.3,18.7299235181644,-21.2600382409178,18.6199808795411,-1.20004780114723,58.0305927342256,-20.789913957935,0.0869024856596558,0 arsenolite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137640,-156930,25.67,23.15,51.12,20.9,17.73,-2.7,0,0,0,0,548 claudetite,NA,As2O3,cr,PGS+96,NA,25.Aug.06,-137730,-156600,27.09,23.19,47.26,23.86,10.74,-3.44,0,0,0,0,588 orpiment,NA,As2S3,cr,PGS+96,NA,25.Aug.06,-20550,-20700,39.1,27.53,70.5,22.73,13.82,0.605,0,0,0,0,580 Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/man/data.Rd 2017-02-18 10:15:38 UTC (rev 161) @@ -90,15 +90,9 @@ \item The properties and parameters of some reference unfolded proteins used by Dick et al., 2006 are included here. Their names have dashes, instead of underscores, so that they are not confused with proteins whose properties are generated at runtime. \item The standard molal Gibbs energies and enthalpies of formation of the elements and entropies at 25 \eqn{^{\circ}}{?}C and 1 bar of aqueous metal-amino acid (alanate or glycinate) complexes reported by Shock and Koretsky, 1995 were recalculated by adding to their values the differences in the corresponding properties between the values for aqueous alanate and glycinate used by Shock and Koretsky, 1995, and those used by Amend and Helgeson, 1997b and Dick et al., 2006. \item The standard molal properties and equations-of-state parameters of four phase species (see below) of Fe(cr) were generated from heat capacity data given by Robie and Hemingway, 1995. + \item \samp{pseudo-H4SiO4} is an approximate pseudospecies for H4SiO4. \samp{pseudo-H4SiO4} has thermodynamic properties that give zero properties for the reaction H4SiO4 = SiO2 + 2H2O at 25 \eqn{^{\circ}}{?}C, and HKF coefficients that are applicable to moderate temperatures (see the vignette \emph{Regressing thermodynamic data}). } - Notes on the secondary database added by \code{add.obigt} (OBIGT-2.csv): - - \itemize{ - \item \samp{pseudo-H4SiO4} and \samp{pseudo-H4SiO4_Ste01} are approximate pseudospecies for H4SiO4. \samp{pseudo-H4SiO4} has thermodynamic properties that give zero properties for the reaction H4SiO4 = SiO2 + 2H2O at 25 \eqn{^{\circ}}{?}C, and HKF coefficients that are applicable to moderate temperatures (see the vignette `eos-regress.Rmd`). \samp{pseudo-H4SiO4_Ste01}, taken from Steff?nson, 2001, is applicable near 300 \eqn{^{\circ}}{?}C (see Figure 3 of that paper). \samp{pseudo-H4SiO4} can be used to make diagrams with H4SiO4 as a basis species, instead of SiO2(aq). - } - - These modifications are indicated in \code{OBIGT.csv} by having \samp{CHNOSZ} as one of the sources of data. Note also that some data appearing in the \acronym{slop98.dat} file (Shock et al., 1998) were corrected or modified as noted in that file, and are indicated in \code{OBIGT.csv} by having \samp{SLOP98} as one of the sources of data. In order to represent thermodynamic data for minerals with phase transitions, the different phases of these minerals are represented as phase species that have states denoted by \samp{cr1}, \samp{cr2}, etc. The standard molar thermodynamic properties at 25 \eqn{^{\circ}}{?}C and 1 bar (\eqn{T_r}{Pr} and \eqn{P_r}{Pr}) of the \samp{cr2} phase species of minerals were generated by first calculating those of the \samp{cr1} phase species at the transition temperature (\eqn{T_{tr}}{Ttr}) and 1 bar then taking account of the volume and entropy of transition (the latter can be retrieved by combining the former with the Clausius-Clapeyron equation and values of \eqn{(dP/dT)} of transitions taken from the \acronym{SUPCRT92} data file) to calculate the standard molar entropy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}, and taking account of the enthalpy of transition (\eqn{{\Delta}H^{\circ}}{DeltaH0}, taken from the \acronym{SUPCRT92} data file) to calculate the standard molar enthalpy of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr}. The standard molar properties of the \samp{cr2} phase species at \eqn{T_{tr}}{Ttr} and 1 bar calculated in this manner were combined with the equations-of-state parameters of the species to generate values of the standard molar properties at 25 \eqn{^{\circ}}{?}C and 1 bar. This process was repeated as necessary to generate the standard molar properties of phase species represented by \samp{cr3} and \samp{cr4}, referencing at each iteration the previously calculated values of the standard molar properties of the lower-temperature phase species (i.e., \samp{cr2} and \samp{cr3}). A consequence of tabulating the standard molar thermodynamic properties of the phase species is that the values of \eqn{(dP/dT)} and \eqn{{\Delta}H^{\circ}}{DeltaH0} of phase transitions can be calculated using the equations of state and therefore do not need to be stored in the thermodynamic database. However, the transition temperatures (\eqn{T_{tr}}{Ttr}) generally can not be assessed by comparing the Gibbs energies of phase species and are tabulated in the database. @@ -253,8 +247,6 @@ Shock, E. L. et al. {1998} \emph{SLOP98.dat} (computer data file). http://geopig.asu.edu/supcrt92_data/slop98.dat, accessed on 2005-11-05. Current location: \url{http://geopig.asu.edu/sites/default/files/slop98.dat}. - Stef?nsson, Andri (2001) Dissolution of primary minerals of basalt in natural waters. I. Calculation of mineral solubilities from 0?C to 350?C \emph{Chem. Geol.} \bold{172}, 225--250. \url{http://dx.doi.org/10.1016/S0009-2541(00)00263-1} - Wagman, D. D., Evans, W. H., Parker, V. B., Schumm, R. H., Halow, I., Bailey, S. M., Churney, K. L. and Nuttall, R. L. (1982) The NBS tables of chemical thermodynamic properties. Selected values for inorganic and C\eqn{_1}{1} and C\eqn{_2}{2} organic substances in SI units. \emph{J. Phys. Chem. Ref. Data} \bold{11} (supp. 2), 1--392. \url{https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf} } Modified: pkg/CHNOSZ/man/util.data.Rd =================================================================== --- pkg/CHNOSZ/man/util.data.Rd 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/man/util.data.Rd 2017-02-18 10:15:38 UTC (rev 161) @@ -49,6 +49,8 @@ \code{add.obigt} reads data from the specified \code{file} and adds it to \code{\link{thermo}$obigt}. Set \code{force} to TRUE to replace species that exist in the thermodynamic database (each unique combination of a name and a state in the database is considered to be a unique species). \code{force}, if not specified, reverts to TRUE if the \code{file} is left at its default. Given the default setting of \code{E.units}, the function does not perform any unit conversions. If \code{E.units} is set to \samp{J}, then the thermodynamic parameters are converted from units of Joules to calories, as used in the CHNOSZ database. + \code{add.obigt} affects the order of entries in \code{thermo}$obigt; therefore, it should be called before any \code{basis} or \code{species} definition. Also, there is no attempt made to keep the order of physical states in the database (aq-cr-liq-gas); the function simply adds new rows to the end of \code{thermo}$obigt. As a result, retrieving the properties of an added aqueous species using \code{\link{info}} requires an explicit \code{state="aq"} argument to that function if a species with the same name is in one of the cr, liq or gas states. + \code{mod.obigt} changes one or more of the properties of species or adds species to the thermodynamic database. These changes are lost if you reload the database by calling \code{\link{data}(thermo)} or if you quit the \R session without saving it. The name of the species to add or change must be supplied as the first argument of \code{...} or as a named argument (named \samp{name}). @@ -82,7 +84,11 @@ } \section{Warning}{ - \code{add.obigt} affects the order of entries in \code{thermo}$obigt; therefore, it should be called before any \code{basis} or \code{species} definition. Also, there is no attempt made to keep the order of physical states in the database (aq-cr-liq-gas); the function simply adds new rows to the end of \code{thermo}$obigt. As a result, retrieving the properties of an added aqueous species using \code{\link{info}} requires an explicit \code{state="aq"} argument to that function if a species with the same name is in one of the cr, liq or gas states. + Cautionary advice about the secondary database added by \code{add.obigt} (OBIGT-2.csv): + + \itemize{ + \item \samp{H4SiO4_Ste01}, taken from Steff?nson, 2001, is used in the vignette \emph{Regressing thermodynamic data} for comparison with the H4SiO4 pseudospecies made in CHNOSZ (\samp{pseudo-H4SiO4}). As with other species in OBIGT-2.csv, it is likely to be inconsistent with specific minerals and other species in the default database, so use it with care. + } } \value{ @@ -130,6 +136,9 @@ Richard, L. and Helgeson, H. C. (1998) Calculation of the thermodynamic properties at elevated temperatures and pressures of saturated and aromatic high molecular weight solid and liquid hydrocarbons in kerogen, bitumen, petroleum, and other organic matter of biogeochemical interest. \emph{Geochim. Cosmochim. Acta} \bold{62}, 3591--3636. \url{http://dx.doi.org/10.1016/S0016-7037(97)00345-1} + Stef?nsson, Andri (2001) Dissolution of primary minerals of basalt in natural waters. I. Calculation of mineral solubilities from 0?C to 350?C \emph{Chem. Geol.} \bold{172}, 225--250. \url{http://dx.doi.org/10.1016/S0009-2541(00)00263-1} + + } Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-18 07:17:18 UTC (rev 160) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-18 10:15:38 UTC (rev 161) @@ -7,6 +7,7 @@ tufte::tufte_html: tufte_features: ["background"] css: "vig.css" + toc: true mathjax: null tufte::tufte_handout: citation_package: natbib @@ -95,7 +96,7 @@ Applying a linear model (`lm`), the *coefficients* in the model can be obtained. In this case, they correspond to the HKF parameters, e.g. `c1` (the intercept), `c2` and ?. -The coefficients are constants, meaning that **the model is applicable only to neutral (uncharged) species**, for which the high-temperature derivatives of ? are 0. +The coefficients **in this model** are constants, restricing application of the model to neutral (uncharged) species, for which the high-temperature derivatives of ? are 0. Further below, a procedure is described to iteratively solve the equations for charged species. # An example for neutral species @@ -147,7 +148,7 @@ Note the second call to `EOSplot()`, where the coefficients are not provided. This causes the data to be re-regressed, this time without the *T* < 600 K limitation. Although the overall fit, represented by the dotted line, is better, the fit to the low-temperature data is considerably worse. -For nonelectroyltes, consider excluding extreme near-critical values from the regression (or modify the procedure to give them lower weight) in order to obtain more generally useful results. +For nonelectrolytes, consider excluding extreme near-critical values from the regression (or modify the procedure to give them lower weight) in order to obtain more generally useful results. `EOScoeffs()` is a small function to retrieve the HKF parameters from the database in CHNOSZ. The `stopifnot` expression tests that the regressed values are within 10% of the database values of `r c1`, `r c2` and ? for `r ch4`. @@ -237,7 +238,7 @@ # An example for charged species For this example, let's generate synthetic data for Na+ using its parameters in the database. -In the call to `subcrt()` below, `convert=FALSE` means to take *T* in units of K. +In the call to `subcrt()` below, `convert = FALSE` means to take *T* in units of K. ```{r Nadat} T <- convert(seq(0, 600, 50), "K") @@ -260,9 +261,9 @@ The fits using constant ? are clearly not acceptable. There is, however, a way out. -A different variable, `Cp_s_var`, can be used to specify the calculation of the "solvation" heat capacity in the HKF equations **using the temperature- and pressure-dependent corrections for charged species**. +A different variable, `Cp_s_var`, can be used to specify the calculation of the "solvation" heat capacity in the HKF equations using the temperature- and pressure-dependent corrections for charged species. To use this variable, the values of `r wPrTr` (omega at the reference temperature and pressure) and *Z* (charge) must be given, in addition to *T* and *P*. -Of course, right now we **don't know** the value of `r wPrTr` -- it is the purpose of the regression to find it! +Of course, right now we *don't know* the value of `r wPrTr`---it is the purpose of the regression to find it! But we can make a first guess using the value of ? found above. ```{r Navars1} @@ -325,14 +326,14 @@ Some mineral stability diagrams use the activity of `r h4sio4` as a variable. However, the primary species for dissolved silica in CHNOSZ is `r sio2`(aq) [@SHS89]. -The reaction with zero properties, `r h4sio4` = `r sio2` + 2 `r h2o`, defines the properties of the pseudospecies `r h4sio4`. +The pseudo-reaction with zero properties, `r h4sio4` = `r sio2` + 2 `r h2o`, defines the properties of the pseudospecies `r h4sio4`. First we go about calculating the properties of `r sio2` + 2 `r h2o`. We do this over a range of *T* and *P*, but include many points near 25 ?C to improve the fit of the regression in that region: `r op <- options(warn = -1)` ```{r SiO2_2H2O, message=FALSE} s_25C <- subcrt(c("SiO2", "H2O"), c(1, 2), T = 25)$out -s_near25 <- subcrt(c("SiO2", "H2O"), c(1, 2), T = seq(20, 30, length.out = 50))$out +s_near25 <- subcrt(c("SiO2", "H2O"), c(1, 2), T = seq(20, 30, length.out=50))$out s_lowT <- subcrt(c("SiO2", "H2O"), c(1, 2), T = seq(0, 100, 10))$out s_Psat <- subcrt(c("SiO2", "H2O"), c(1, 2))$out s_P500 <- subcrt(c("SiO2", "H2O"), c(1, 2), T = seq(0, 1000, 100), P = 500)$out @@ -342,8 +343,9 @@ Now we can start making the new species, with thermodynamic properties calculated at 25 ?C: ```{r new_H4SiO4} -mod.obigt("new-H4SiO4", formula = "H4SiO4", ref1 = "this_vignette", date = today(), - G = s_25C$G, H = s_25C$H, S = s_25C$S, Cp = s_25C$Cp, V = s_25C$V, z = 0) +mod.obigt("new-H4SiO4", formula = "H4SiO4", ref1 = "this_vignette", + date = today(), G = s_25C$G, H = s_25C$H, S = s_25C$S, + Cp = s_25C$Cp, V = s_25C$V, z = 0) ``` To prepare for the regression, combine the calculated data and convert ?C to K: @@ -385,36 +387,38 @@ ``` We just made a new `r h4sio4` pseudospecies. -The database in CHNOSZ was previously updated with a `pseudo-H4SiO4` that was made using this procedure. -The secondary database has a `pseudo-H4SiO4_Ste01` with properties of `r h4sio4` from @Ste01: +In February 2017, the database in CHNOSZ was updated with a `pseudo-H4SiO4` that was made using this procedure. +In addition, the secondary database has a `H4SiO4_Ste01` with properties of `r h4sio4` from @Ste01: ```{r width180, include=FALSE} options(width = 180) ``` ```{r info_H4SiO4, message=FALSE} add.obigt() -info(info(c("new-H4SiO4", "pseudo-H4SiO4", "pseudo-H4SiO4_Ste01"))) +info(info(c("new-H4SiO4", "pseudo-H4SiO4", "H4SiO4_Ste01"))) ``` ```{r width80, include=FALSE} ``` ```{r subcrt_H4SiO4, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, echo=FALSE, results="hide", message=FALSE, dpi=dpi, out.width="100%", cache=TRUE, fig.cap="Comparison of H4SiO4 pseudospecies.", pngquant=pngquant} s1 <- subcrt(c("pseudo-H4SiO4", "SiO2", "H2O"), c(-1, 1, 2)) -plot(s1$out$T, s1$out$G, type = "l", ylim = c(-200, 500), +plot(s1$out$T, s1$out$G, type = "l", ylim = c(-100, 600), xlab = axis.label("T"), ylab = axis.label("DG0")) add.obigt() -s2 <- subcrt(c("pseudo-H4SiO4_Ste01", "SiO2", "H2O"), c(-1, 1, 2)) +s2 <- subcrt(c("H4SiO4_Ste01", "SiO2", "H2O"), c(-1, 1, 2)) lines(s2$out$T, s2$out$G, lty = 2) abline(h = 0, lty = 3) legend("topright", legend = c("pseudo-H4SiO4 (CHNOSZ)", - "pseudo-H4SiO4_Ste01", "\t(Stef?nsson, 2001)"), lty = c(1, 2, NA), bty = "n") + "H4SiO4_Ste01", "\t(Stef?nsson, 2001)"), lty = c(1, 2, NA), bty = "n") text(225, 250, describe.reaction(s1$reaction)) ``` -Let's compare `pseudo-H4SiO4` (with the same properties as `new-H4SiO4`) and `pseudo-H4SiO4_Ste01` with the actual properties of `r sio2` + 2 `r h2o` as a function of temperature: +Let's compare CHNOSZ's `pseudo-H4SiO4` (with the same properties as the `new-H4SiO4` we just made) and `H4SiO4_Ste01` from Stef?nsson (2001) with the calculated properties of `r sio2` + 2 `r h2o` as a function of temperature: ```{r subcrt_H4SiO4, eval=FALSE} ``` -Neither pseudospecies is perfect, but `pseudo-H4SiO4` is preferable for making low-temperature mineral activity diagrams---see `?transfer` and `demo(activity_ratios)`. +The large differences for `H4SiO4_Ste01` at low temperature agree with the comparison to Shock et al. (1989) shown in Figure 3 of Stef?nsson (2001). +Therefore, `H4SiO4_Ste01` should not be used _in CHNOSZ_ for making low-temperature mineral activity diagrams. +Instead, the pseudospecies with properties calculated here, `pseudo-H4SiO4`, is preferable for use _in CHNOSZ_---see `?transfer` and `demo(activity_ratios)`. # Other possibilities From noreply at r-forge.r-project.org Sat Feb 18 15:18:11 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 18 Feb 2017 15:18:11 +0100 (CET) Subject: [CHNOSZ-commits] r162 - in pkg/CHNOSZ: . R inst man src vignettes Message-ID: <20170218141811.E122F188AEA@r-forge.r-project.org> Author: jedick Date: 2017-02-18 15:18:11 +0100 (Sat, 18 Feb 2017) New Revision: 162 Added: pkg/CHNOSZ/src/init.c Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/water.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/util.water.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd Log: register native routines Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-18 14:18:11 UTC (rev 162) @@ -1,6 +1,6 @@ Date: 2017-02-18 Package: CHNOSZ -Version: 1.0.8-51 +Version: 1.0.8-52 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/NAMESPACE 2017-02-18 14:18:11 UTC (rev 162) @@ -1,8 +1,9 @@ -# Export all names -exportPattern(".") +# Export all names except those beginning with F_ +# (so we don't export F_h2o92 created below) +exportPattern("^([^F]|F($|[^_])).*") # Load shared objects -useDynLib(CHNOSZ) +useDynLib(CHNOSZ, .registration = TRUE, .fixes = "F_") # Imports from default packages importFrom("grDevices", "dev.cur", "dev.off", "extendrange", @@ -19,4 +20,3 @@ # Imports from colorspace importFrom("colorspace", "diverge_hcl") - Modified: pkg/CHNOSZ/R/water.R =================================================================== --- pkg/CHNOSZ/R/water.R 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/R/water.R 2017-02-18 14:18:11 UTC (rev 162) @@ -83,8 +83,8 @@ rho.out[i] <- NA } else { # now to the actual calculations - H2O <- .Fortran("H2O92", as.integer(specs), as.double(states), - as.double(rep(0, 46)), as.integer(0), PACKAGE="CHNOSZ") + H2O <- .Fortran(F_h2o92, as.integer(specs), as.double(states), + as.double(rep(0, 46)), as.integer(0)) # errors err.out[i] <- H2O[[4]] # density of two states Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/inst/NEWS 2017-02-18 14:18:11 UTC (rev 162) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-51 (2017-02-18) +CHANGES IN CHNOSZ 1.0.8-52 (2017-02-18) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/man/util.water.Rd =================================================================== --- pkg/CHNOSZ/man/util.water.Rd 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/man/util.water.Rd 2017-02-18 14:18:11 UTC (rev 162) @@ -73,7 +73,7 @@ \references{ - Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-H?ckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{https://www.nist.gov/data/PDFfiles/jpcrd383.pdf} + Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-H?ckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{https://srd.nist.gov/JPCRD/jpcrd383.pdf} Wagner, W. and Pru?, A. (2002) The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. \emph{J. Phys. Chem. Ref. Data} \bold{31}, 387--535. \url{http://dx.doi.org/10.1063/1.1461829} Added: pkg/CHNOSZ/src/init.c =================================================================== --- pkg/CHNOSZ/src/init.c (rev 0) +++ pkg/CHNOSZ/src/init.c 2017-02-18 14:18:11 UTC (rev 162) @@ -0,0 +1,17 @@ +#include +#include // for NULL +#include + +/* .Fortran calls */ +extern void F77_NAME(h2o92)(void *, void *, void *, void *); + +static const R_FortranMethodDef FortranEntries[] = { + {"h2o92", (DL_FUNC) &F77_NAME(h2o92), 4}, + {NULL, NULL, 0} +}; + +void R_init_CHNOSZ(DllInfo *dll) +{ + R_registerRoutines(dll, NULL, NULL, FortranEntries, NULL); + R_useDynamicSymbols(dll, FALSE); +} Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-18 14:18:11 UTC (rev 162) @@ -1795,7 +1795,7 @@ Without additional information, there is often no clear strategy for "fixing" these entries, and they are provided as is. ```{marginfigure} -See the [Numerical Tools from GEOPIG](http://geopig.asu.edu/tools) for SUPCRT updates (slop files), including corrections that have not yet been ported to CHNOSZ. +See the [Numerical Tools from GEOPIG](http://geopig.asu.edu/?q=tools) for SUPCRT updates (slop files), including corrections that have not yet been ported to CHNOSZ. ``` ## Water: SUPCRT92 or IAPWS-95 Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-18 10:15:38 UTC (rev 161) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2017-02-18 14:18:11 UTC (rev 162) @@ -286,8 +286,8 @@ EOScoeffs("Na+", "Cp") ``` -Alrighty! We managed to obtain EOS parameters from synthetic data for Na+. -The regressed values of the EOS parameters (shown in the plot legend) are very close to the database values (printed by the call to `EOScoeffs()`) used to generate the synthetic data. +Alrighty! We managed to obtain HKF coefficients from synthetic data for Na+. +The regressed values of the HKF coefficients (shown in the plot legend) are very close to the database values (printed by the call to `EOScoeffs()`) used to generate the synthetic data. ## Doing it for volume @@ -403,7 +403,6 @@ s1 <- subcrt(c("pseudo-H4SiO4", "SiO2", "H2O"), c(-1, 1, 2)) plot(s1$out$T, s1$out$G, type = "l", ylim = c(-100, 600), xlab = axis.label("T"), ylab = axis.label("DG0")) -add.obigt() s2 <- subcrt(c("H4SiO4_Ste01", "SiO2", "H2O"), c(-1, 1, 2)) lines(s2$out$T, s2$out$G, lty = 2) abline(h = 0, lty = 3) From noreply at r-forge.r-project.org Sun Feb 19 06:30:46 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 19 Feb 2017 06:30:46 +0100 (CET) Subject: [CHNOSZ-commits] r163 - in pkg/CHNOSZ: . R demo inst man vignettes Message-ID: <20170219053046.E6B2118794A@r-forge.r-project.org> Author: jedick Date: 2017-02-19 06:30:45 +0100 (Sun, 19 Feb 2017) New Revision: 163 Added: pkg/CHNOSZ/vignettes/dayhoff.pdf Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/R/wjd.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/demo/NaCl.R pkg/CHNOSZ/demo/activity_ratios.R pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/bugstab.R pkg/CHNOSZ/demo/protbuff.R pkg/CHNOSZ/demo/solubility.R pkg/CHNOSZ/demo/wjd.R pkg/CHNOSZ/demo/yeastgfp.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/equilibrium.Rnw pkg/CHNOSZ/vignettes/equilibrium.lyx pkg/CHNOSZ/vignettes/wjd.Rnw pkg/CHNOSZ/vignettes/wjd.lyx Log: clean up demos and vignettes Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-19 05:30:45 UTC (rev 163) @@ -1,6 +1,6 @@ -Date: 2017-02-18 +Date: 2017-02-19 Package: CHNOSZ -Version: 1.0.8-52 +Version: 1.0.8-53 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/R/diagram.R 2017-02-19 05:30:45 UTC (rev 163) @@ -12,7 +12,7 @@ what="loga.equil", alpha=FALSE, normalize=FALSE, as.residue=FALSE, balance=NULL, groups=as.list(1:length(eout$values)), xrange=NULL, # plot dimensions - mar=NULL, yline=par("mgp")[1]+0.5, side=1:4, + mar=NULL, yline=par("mgp")[1]+0.3, side=1:4, # axes ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, # sizes Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/R/util.expression.R 2017-02-19 05:30:45 UTC (rev 163) @@ -10,30 +10,34 @@ # the counts of elements in the species: # here we don't care too much if an "element" is a real element # (listed in thermo$element), so we suppress warnings - elements <- suppressWarnings(makeup(species)) - # where we'll put the expression - expr <- "" - # loop over elements - for(i in 1:length(elements)) { - if(names(elements)[i] != 'Z') { - # append the elemental symbol - expr <- substitute(paste(a, b), list(a=expr, b=names(elements)[i])) - # recover the coefficient - if(elements[i]==1) coeff <- "" else coeff <- elements[i] - # append the coefficient - ## subscripts within subscripts (log) are too small - #if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) - #else expr <- substitute(a[b], list(a=expr, b=coeff)) - expr <- substitute(a[b], list(a=expr, b=coeff)) - } else { - # for charged species, don't show "Z" but do show e.g. "+2" - coeff <- elements[i] - if(coeff==-1) coeff <- "-" - else if(coeff==1) coeff <- "+" - else if(coeff > 0) coeff <- paste("+", as.character(coeff), sep="") - # append the coefficient (as a superscript if we're not in a log expression) - if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) - else expr <- substitute(a^b, list(a=expr, b=coeff)) + elements <- suppressWarnings(try(makeup(species), TRUE)) + # if `species` can't be parsed as a chemical formula, we don't do the formula formatting + if(identical(class(elements), "try-error")) expr <- species + else { + # where we'll put the expression + expr <- "" + # loop over elements + for(i in 1:length(elements)) { + if(names(elements)[i] != 'Z') { + # append the elemental symbol + expr <- substitute(paste(a, b), list(a=expr, b=names(elements)[i])) + # recover the coefficient + if(elements[i]==1) coeff <- "" else coeff <- elements[i] + # append the coefficient + ## subscripts within subscripts (log) are too small + #if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) + #else expr <- substitute(a[b], list(a=expr, b=coeff)) + expr <- substitute(a[b], list(a=expr, b=coeff)) + } else { + # for charged species, don't show "Z" but do show e.g. "+2" + coeff <- elements[i] + if(coeff==-1) coeff <- "-" + else if(coeff==1) coeff <- "+" + else if(coeff > 0) coeff <- paste("+", as.character(coeff), sep="") + # append the coefficient (as a superscript if we're not in a log expression) + if(log != "") expr <- substitute(a*b, list(a=expr, b=coeff)) + else expr <- substitute(a^b, list(a=expr, b=coeff)) + } } } # write a designation of physical state Modified: pkg/CHNOSZ/R/util.plot.R =================================================================== --- pkg/CHNOSZ/R/util.plot.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/R/util.plot.R 2017-02-19 05:30:45 UTC (rev 163) @@ -2,7 +2,7 @@ # Functions to create and modify plots thermo.plot.new <- function(xlim,ylim,xlab,ylab,cex=par('cex'),mar=NULL,lwd=par('lwd'),side=c(1,2,3,4), - mgp=c(1.5,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE, + mgp=c(1.7,0.3,0),cex.axis=par('cex'),col=par('col'),yline=NULL,axs='i',do.box=TRUE, las=1,xline=NULL, ...) { # start a new plot with some customized settings thermo <- get("thermo") Modified: pkg/CHNOSZ/R/wjd.R =================================================================== --- pkg/CHNOSZ/R/wjd.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/R/wjd.R 2017-02-19 05:30:45 UTC (rev 163) @@ -217,7 +217,7 @@ par(mfrow=c(length(iplot),1)) for(i in iplot) { ylab <- as.expression(substitute(mu[x]/RT,list(x=colnames(ep)[i]))) - plot(ep[,i],xlab="species combination",ylab=ylab) + plot(ep[,i],xlab="species combination",ylab=ylab, pch=19) title(main=paste("max difference (range) =",format(diff(range(ep[,i])),digits=2))) } } Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/00Index 2017-02-19 05:30:45 UTC (rev 163) @@ -5,16 +5,16 @@ NaCl equilibrium constant for aqueous NaCl dissociation density density of H2O, inverted from IAPWS-95 equations ORP oxidation-reduction potential of redox standards as a function of temperature -revisit detailed example of usage of revisit() -findit detailed example of usage of findit() +revisit coefficient of variation of metastable equilibrium activities of proteins +findit minimize the standard deviation of logarithms of activities of sulfur species ionize ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK buffer minerals and aqueous species as buffers of hydrogen fugacity -protbuff ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) -yeastgfp logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations +protbuff chemical activities buffered by thiol peroxidases or sigma factors +yeastgfp YeastGFP locations: log fO2 - log aH2O and log a - log fO2 diagrams mosaic Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species copper another example of mosaic(): complexation of copper with glycine species solubility solubility of calcite or CO2(gas) as a function of pH -wjd run.wjd() with proteins: cell periphery of yeast +wjd Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast dehydration log K of dehydration reactions; SVG file contains tooltips and links bugstab formation potential of microbial proteins in colorectal cancer activity_ratios mineral stability plots with activity ratios on the axes Modified: pkg/CHNOSZ/demo/NaCl.R =================================================================== --- pkg/CHNOSZ/demo/NaCl.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/NaCl.R 2017-02-19 05:30:45 UTC (rev 163) @@ -34,8 +34,7 @@ } legend("bottomleft",pch=unique(expt$pch), legend=c(unique(expt$source),tail(expt$source,1))) -title(main=paste("NaCl(aq) = Na+ + Cl-\n", - "Psat and 500-4000 bar, after Shock et al., 1992")) +mtitle(c(describe.reaction(s$reaction), expression(italic(P)[sat]~"or 500-4000 bar, after Shock et al., 1992"))) # where do we diverge most from experiment? imaxdiff <- which.max(abs(logK - expt$logK)) stopifnot(all.equal(c("Psat", 347.7), Modified: pkg/CHNOSZ/demo/activity_ratios.R =================================================================== --- pkg/CHNOSZ/demo/activity_ratios.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/activity_ratios.R 2017-02-19 05:30:45 UTC (rev 163) @@ -15,7 +15,7 @@ basis(c("Al+3", "pseudo-H4SiO4", "K+", "H2O", "H+", "O2")) species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "k-feldspar")) a <- affinity(H4SiO4 = c(-6, -2, res), `K+` = c(-3, 6, res)) -diagram(a, ylab = ratlab("K+"), fill = fill) +diagram(a, ylab = ratlab("K+"), fill = fill, yline = 1.7) title(main = syslab(c("K2O", "Al2O3", "SiO2", "H2O"))) legend("bottomleft", describe.property(c("T", "P"), c(25, 1)), bty = "n") @@ -27,7 +27,7 @@ "diopside", "wollastonite", "monticellite", "merwinite")) # calculate the chemical affinities of formation reactions a <- affinity("Mg+2" = c(4, 9, res), "Ca+2" = c(5, 14, res), T = 300, P = 1000) -diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill) +diagram(a, xlab = ratlab("Mg+2"), ylab = ratlab("Ca+2"), fill = fill, yline = 1.7) title(main = syslab(c("H2O", "CaO", "MgO", "SiO2"))) legend("bottomright", describe.property(c("T", "P"), c(300, 1000)), bty = "n") # note: Bowers et al. use more complicated variables @@ -39,7 +39,7 @@ basis(c("Mg+2", "Ca+2", "SiO2", "H2O", "O2", "H+")) species(c("brucite", "chrysotile", "talc", "tremolite", "diopside", "akermanite")) a <- affinity(SiO2 = c(-10, 0, res), `Ca+2` = c(0, 20, res), T = 300) -diagram(a, ylab = ratlab("Ca+2"), fill = fill) +diagram(a, ylab = ratlab("Ca+2"), fill = fill, yline = 1.7) title(main = syslab(c("MgO", "CaO", "SiO2", "H2O"))) legend("topright", describe.property(c("T", "P"), c(300, 85.84)), bty = "n") @@ -49,7 +49,7 @@ basis(c("Ca+2", "Al+3", "Mg+2", "SiO2", "H2O", "O2", "H+")) species(c("clinochlore,14a", "clinozoisite", "prehnite", "grossular")) a <- affinity(SiO2 = c(-5, 0, res), `Ca+2` = c(6, 11, res), T = 300, P = 500) -diagram(a, ylab = ratlab("Ca+2"), balance = "Al+3", fill = fill) +diagram(a, ylab = ratlab("Ca+2"), balance = "Al+3", fill = fill, yline = 1.7) # (Hmmm... where is clinochlore? it doesn't appear on our diagram) species(delete = TRUE) species(c("brucite", "chrysotile", "talc", "tremolite", "diopside")) Modified: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-19 05:30:45 UTC (rev 163) @@ -27,8 +27,10 @@ d <- diagram(a, what="H2", lty=c(3, 2), add=TRUE) text(a$vals[[1]][13], mean(sapply(d$plotvals, c)[13, ]), logact) } -# add legend +# add legends and title legend("topright", legend = c("minerals", "formaldehyde", "HCN"), lty=c(1, 3, 2), col=c(3, 1, 1), bg="white", cex=0.9) legend("bottomright", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4))), bg="white", cex=0.9) +title(main=paste("Mineral buffers and activities of aqueous species", + "(Schulte and Shock, 1995)", sep="\n"), cex.main=0.9) Modified: pkg/CHNOSZ/demo/bugstab.R =================================================================== --- pkg/CHNOSZ/demo/bugstab.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/bugstab.R 2017-02-19 05:30:45 UTC (rev 163) @@ -45,10 +45,10 @@ a <- affinity(O2=O2, H2O=H2O, iprotein=ip, T=37) names <- bugs$abbrv[ibug] d <- diagram(a, names=names, fill=col, as.residue=TRUE, tplot=FALSE, xlab=logfO2lab, ylab=logaH2Olab, format.names=FALSE) - if(i==1) title(main="fecal 16S rRNA", cex.main=1) - if(i==2) title(main="fecal metagenome (ZTV+14)", cex.main=1) - if(i==3) title(main="co-abundance groups", cex.main=1) - if(i==4) title(main="fecal metagenome (FLJ+15)", cex.main=1) + if(i==1) title(main="Fecal 16S rRNA", cex.main=1) + if(i==2) title(main="Fecal metagenome (ZTV+14)", cex.main=1) + if(i==3) title(main="Co-abundance groups", cex.main=1) + if(i==4) title(main="Fecal metagenome (FLJ+15)", cex.main=1) box() label.figure(LETTERS[i], yfrac=0.96, paren=FALSE, font=2, cex=1) # store locations of healthy bug zones @@ -62,6 +62,6 @@ ys <- seq(H2O[1], H2O[2], length.out=H2O[3]) hhh <- healthbugs[[1]] + healthbugs[[2]] + healthbugs[[3]] + healthbugs[[4]] image(xs, ys, hhh, col=c(red, lightred, neutral, lightblue, blue), useRaster=TRUE, xlab=logfO2lab, ylab=logaH2Olab) -title(main="cumulative stability count") +title(main="Cumulative stability count") box() label.figure("E", yfrac=0.96, paren=FALSE, font=2, cex=1) Modified: pkg/CHNOSZ/demo/protbuff.R =================================================================== --- pkg/CHNOSZ/demo/protbuff.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/protbuff.R 2017-02-19 05:30:45 UTC (rev 163) @@ -13,9 +13,10 @@ basis(c("CO2", "H2O", "NH3", "O2"), as.numeric(a[1:4])) a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300)) e <- equilibrate(a, normalize=TRUE) -diagram(e, fill=NULL, format.names=FALSE) +fill <- ZC.col(ZC(protein.formula(species()$name))) +diagram(e, fill=fill, format.names=FALSE) title(main="Thiol peroxidases from bacteria") -legend("topleft", describe.basis(thermo$basis[-6,])) +legend("topleft", describe.basis(thermo$basis[-6,]), bg="grey80", box.lwd=0) ## Buffer + ionization: relative stabilities ## of E. coli sigma factors on a T-pH diagram @@ -33,11 +34,12 @@ # stabilities as a function of T and pH basis(c("CO2", "NH3", "H2S", "O2"), as.numeric(logact)) species(paste(proteins, "ECOLI", sep="_")) -a <- affinity(pH=c(5, 10), T=c(10, 40)) -diagram(a, normalize=FALSE, fill="heat", format.names=FALSE) -title(main="Relative stabilities of sigma factors in E. coli") +a <- affinity(pH=c(5, 10, 300), T=c(10, 40, 300)) +fill <- ZC.col(ZC(protein.formula(species()$name))) +diagram(a, normalize=FALSE, fill=fill, format.names=FALSE) +title(main=expression("Sigma factors in"~italic("E. coli"))) ptext <- c(describe.property("T", 25), describe.basis(ibasis=c(2, 6), oneline=TRUE)) +legend("topleft", legend=c("preset conditions:", ptext), bg="grey80", box.lwd=0) btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE) -legend("bottomleft", legend=c("preset (input values):", - ptext, "buffered (results):", btext), bty="n") +legend("bottomright", legend=c("buffered conditions:", btext), bg="grey80", box.lwd=0) Modified: pkg/CHNOSZ/demo/solubility.R =================================================================== --- pkg/CHNOSZ/demo/solubility.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/solubility.R 2017-02-19 05:30:45 UTC (rev 163) @@ -80,4 +80,4 @@ lines(pHs, loga.CO3, lty=3, lwd=2) legend(ifelse(what=="calcite", "topright", "topleft"), lty=c(1, 1:3), lwd=c(4, 2, 2, 2), col=c("green2", rep("black", 3)), legend=as.expression(c("total", expr.species("CO2", state="aq"), expr.species("HCO3-"), expr.species("CO3-2")))) -title(main=substitute(what~"solubility at"~T~degree*"C", list(what=what, T=T))) +title(main=substitute("Solubility of"~what~"at"~T~degree*"C", list(what=what, T=T))) Modified: pkg/CHNOSZ/demo/wjd.R =================================================================== --- pkg/CHNOSZ/demo/wjd.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/wjd.R 2017-02-19 05:30:45 UTC (rev 163) @@ -1,3 +1,37 @@ +## carbon-containing compounds in prebiological atmospheres +## Dayhoff et al., 1964 (http://dx.doi.org/10.1126/science.146.3650.1461) +#pdf("dayhoff.pdf", width=6, height=6) +# read formulas and Gibbs energies +file <- system.file("extdata/thermo/DLEN67.csv", package="CHNOSZ") +dlen <- read.csv(file, as.is=TRUE, row.names=1) +# turn formulas into a stoichiometric matrix +A <- i2A(dlen$formula) +# assemble Gibbs energies/RT at 500 K +G0.RT <- 1000 * dlen$G500 / thermo$opt$R / thermo$opt$Tr +# a function to minimize Gibbs energy for system with +# given mole fraction of carbon (xC) +min.atmos <- function(xC) { + # the bulk composition C:H:N:O + B <- c(xC, 100-40-xC, xC, 40) + # guess the initial composition + Y <- guess(A, B) + w <- wjd(A=A, G0.RT=G0.RT, Y=Y, P=1, imax=90, Gfrac=1e-14) + if(!is.near.equil(w)) cat(paste("not near equilibrium for xC=", xC, "\n")) + return(w) +} +# vary carbon content +xCs <- seq(8, 47, 1) +Xs <- sapply(xCs, function(xC) min.atmos(xC)$X) +# normalize the mole numbers to mole fractions +Xs <- t(t(Xs)/colSums(Xs)) +plot(-10, 0, xlim=c(0, 55), ylim=c(-25, 1), xlab="mole percent C", ylab="log10 mole fraction") +for(i in 1:nrow(Xs)) lines(xCs, log10(Xs[i, ])) +text(48, log10(Xs[, length(xCs)]), dlen$formula, adj=0) +text(35, log10(Xs[, 27]) + 0.5, dlen$formula, adj=0) +text(7, log10(Xs[, 1]), dlen$formula, adj=1) +title(main="Prebiological atmospheres (Dayhoff et al., 1964)") +#dev.off() + ## run.wjd with proteins: cell periphery of yeast # get the proteins in the requested location y <- yeastgfp("cell.periphery") @@ -28,6 +62,6 @@ basis("CHNOS") bl <- basis.logact(emu) # make a title and legend -title(main="relative abundances of proteins: yeast cell periphery") +title(main="Relative abundances of proteins: yeast cell periphery") basis(names(bl), bl) legend("topleft", describe.basis(digits=2)) Modified: pkg/CHNOSZ/demo/yeastgfp.R =================================================================== --- pkg/CHNOSZ/demo/yeastgfp.R 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/demo/yeastgfp.R 2017-02-19 05:30:45 UTC (rev 163) @@ -30,8 +30,7 @@ layout(matrix(c(1, 1,2:7), byrow=TRUE, nrow=4), heights=c(0.7, 3, 3, 3)) par(mar=c(0, 0, 0, 0)) plot.new() -text(0.5, 0.5, paste("Subcellular proteins of S. cerevisiae,", - "after Dick, 2009\n"), cex=1.5) +text(0.5, 0.7, expression("Proteins in subcellular locations of"~italic("S. cerevisiae")~"(Dick, 2009)"), cex=1.5) text(0.5, 0.2, describe.basis(ibasis=c(1, 3, 4, 6), oneline=TRUE), cex=1.5) opar <- par(mar=c(3, 4, 1, 1), xpd=TRUE) fill <- heat.colors(length(names)) @@ -65,9 +64,7 @@ e <- equilibrate(a, loga.balance=0, normalize=TRUE) mycolor <- topo.colors(length(locations)) diagram(e, names=locations, ylim=c(-5, -3), col=mycolor, lwd=2) -dp <- describe.property(c("T", "P"), c(25, 1)) -db <- describe.basis(ibasis=(1:6)[-5]) -legend("topright", legend=c(dp, db), bty="n") +title(main=expression("Proteins in subcellular locations of"~italic("S. cerevisiae"))) # reset thermodynamic database data(thermo) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/inst/NEWS 2017-02-19 05:30:45 UTC (rev 163) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-52 (2017-02-18) +CHANGES IN CHNOSZ 1.0.8-53 (2017-02-19) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-19 05:30:45 UTC (rev 163) @@ -10,7 +10,7 @@ \usage{ diagram(eout, what = "loga.equil", alpha = FALSE, normalize = FALSE, as.residue = FALSE, balance=NULL, groups=as.list(1:length(eout$values)), - xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.5, side=1:4, + xrange=NULL, mar=NULL, yline=par("mgp")[1]+0.3, side=1:4, ylog=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/man/examples.Rd 2017-02-19 05:30:45 UTC (rev 163) @@ -39,16 +39,16 @@ \code{NaCl} \tab equilibrium constant for aqueous NaCl dissociation (Shock et al., 1992) \cr \code{density} \tab density of H2O, inverted from IAPWS-95 equations (\code{\link{rho.IAPWS95}}) \cr \code{ORP} \tab oxidation-reduction potential of redox standards as a function of temperature \cr - \code{revisit} \tab detailed example of usage of \code{\link{revisit}} \cr - \code{findit} \tab detailed example of usage of \code{\link{findit}} \cr + \code{revisit} \tab coefficient of variation of metastable equilibrium activities of proteins \cr + \code{findit} \tab minimize the standard deviation of logarithms of activities of sulfur species \cr \code{ionize} \tab ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK \cr \code{buffer} \tab minerals and aqueous species as buffers of hydrogen fugacity (Schulte and Shock, 1995) \cr - \code{protbuff} \tab ionized proteins as a chemical activity buffer (1. thiol peroxidases 2. sigma factors) \cr - \code{yeastgfp} \tab logfO2-logaH2O diagrams for model proteins based on YeastGFP localizations (Dick, 2009) \cr + \code{protbuff} \tab chemical activities buffered by thiol peroxidases or sigma factors \cr + \code{yeastgfp} \tab YeastGFP locations: log fO2 - log aH2O and log a - log fO2 diagrams (Dick, 2009) \cr \code{mosaic} \tab Eh-pH diagram with two sets of changing basis species (Garrels and Christ, 1965) \cr \code{copper} \tab another example of \code{\link{mosaic}}: complexation of Cu with glycine (Aksu and Doyle, 2001) \cr \code{solubility} \tab solubility of calcite (cf. Manning et al., 2013) or CO2(gas) (cf. Stumm and Morgan, 1996) \cr - \code{wjd} \tab run.wjd() with proteins: cell periphery of yeast \cr + \code{wjd} \tab Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast \cr \code{dehydration} \tab log K of dehydration reactions; SVG file contains tooltips and links \cr \code{bugstab} \tab formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr Modified: pkg/CHNOSZ/man/util.plot.Rd =================================================================== --- pkg/CHNOSZ/man/util.plot.Rd 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/man/util.plot.Rd 2017-02-19 05:30:45 UTC (rev 163) @@ -18,7 +18,7 @@ \usage{ thermo.plot.new(xlim, ylim, xlab, ylab, cex = par("cex"), mar = NULL, lwd = par("lwd"), side = c(1,2,3,4), - mgp = c(1.5, 0.3, 0), cex.axis = par("cex"), col = par("col"), + mgp = c(1.7, 0.3, 0), cex.axis = par("cex"), col = par("col"), yline = NULL, axs = "i", do.box = TRUE, las = 1, xline = NULL, ...) thermo.axis(lab = NULL, side = 1:4, line = 1.5, cex = par("cex"), Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-19 05:30:45 UTC (rev 163) @@ -574,6 +574,11 @@ ```{r EhpH_plot_color, echo=TRUE, eval=FALSE} ``` +Mineral stability diagrams often depict activity ratios, e.g. log (*a*Ca+2/*a*H+2), on one or both axes. +The variables used for potential calculations in CHNOSZ include only a single chemical activity, e.g. log *a*Ca+2. +However, you can set pH = 0 to generate diagrams that are geometrically equivalent to those calculated using activity ratios, and use `ratlab()` to make the axes labels for the ratios. +See `demo(activity_ratios)` for some examples. + ## Mosaic diagrams {#Mosaic-diagrams} If sulfur is in the basis species, then we should consider that its speciation is sensitive to Eh and pH, as shown in the preceding diagram. @@ -633,7 +638,7 @@ For instance, we can use H2 or `r o2` in place of *e*-. To do that, let's write a function to swap those basis species and make a diagram. We use R's `do.call()` to construct the argument list for `mosaic()`; this way, the name of the `newvar` argument to our function indicates the chosen variable. -```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system. The choice between them depends on convenience rather than correctness.", pngquant=pngquant, timeit=timeit} +```{r mosaicfun, fig.fullwidth=TRUE, fig.width=9, fig.height=3, small.mar=TRUE, dpi=dpi, out.width="85%", message=FALSE, results="hide", cache=TRUE, fig.cap="Different projections (defined by the basis species) of the same thermodynamic system.", pngquant=pngquant, timeit=timeit} mosaicfun <- function(newvar, T = 200) { swap.basis("e-", names(newvar)) if (names(newvar) == "O2") basis("O2", "gas") @@ -942,11 +947,13 @@ To make plots using different balance constraints, let's write a function that sets the `balance` argument of `diagram()` and adds a title to the plot. The first plot is the most similar to Figure 4 of Shock (1990), except for the absence of alanine (probably due to different thermodynamic data) and the presence of some other amino acids. There, we set `balance = 1`, which indicates that moles of species are conserved; this is equivalent to balancing on the amino acid backbone. -In the remaining plots, the balance is set to each of the basis species in turn (except for O2), then on volume (in the last plot). -```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", cache=TRUE, pngquant=pngquant, timeit=timeit} +In the remaining plots, the balance is set to each of the basis species in turn (except for O2), then on volume. +`expr.species()` together with R's `substitute()` is used to make titles that include formatted chemical formulas: +```{r aafun, fig.fullwidth=TRUE, fig.width=12.5, fig.height=2.5, small.mar=TRUE, dpi=dpi, out.width="100%", message=FALSE, results="hide", fig.cap="Plots of maximum affinity at 250 ?C and 265 bar using different reaction balances for 20 amino acids.", cache=TRUE, pngquant=pngquant, timeit=timeit} aafun <- function(balance) { diagram(a, balance = balance, fill = col) - title(main = paste("balanced on", balance)) + blab <- expr.species(balance) + title(main = substitute("balanced on" ~ b, list(b = blab))) } par(mfrow = c(1, 5)) lapply(c("1", "CO2", "H2O", "N2", "volume"), aafun) @@ -1435,7 +1442,7 @@ ``` 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 (?) or mole fraction diagram. -This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 and *T* = 100 ?C: +This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 M and *T* = 100 ?C: ```{marginfigure} To make the code more readable, commands for plotting titles and legends are not shown. All of the commands are available in the source of this document. @@ -1949,9 +1956,9 @@ ```

```{r the_end} - ### ### ### ### ### ### ### ### ### ### ### ### ### -### ### ### ### ### ### ### ### ### ### ### ### ### ### - ### ### ### ### ### ### ### ### ### ### ### ### ### + ###### ## ## ## ## ###### ##### ##### +## ##---## ## \ ## ## ## \\ // +###### ## ## ## ## ###### ##### ##### ```

Added: pkg/CHNOSZ/vignettes/dayhoff.pdf =================================================================== (Binary files differ) Property changes on: pkg/CHNOSZ/vignettes/dayhoff.pdf ___________________________________________________________________ Added: svn:mime-type + application/pdf Modified: pkg/CHNOSZ/vignettes/equilibrium.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/equilibrium.Rnw 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/vignettes/equilibrium.Rnw 2017-02-19 05:30:45 UTC (rev 163) @@ -634,7 +634,7 @@ reads ``percent GSH that has been oxidized to GSSG'', the lines in their figure are closer to the black lines in the figure below. \end{itemize} -<>= +<>= basis(c("GSH", "NH3", "H2S", "H2O", "H+", "e-")) basis("pH", 7) species(c("GSH", "GSSG")) @@ -652,20 +652,7 @@ mtext(side=2, "- - - - - - - - - - - - - - - - - - -", las=0, line=2.1, cex=0.8) legend("topleft", lty=1:3, legend=paste(mM, "mM GSH")) @ -\begin{itemize} -\item Protein examples (with \texttt{normalize = TRUE}): -\begin{itemize} -\item See ``Subcellular proteins'' in the vignette \emph{An introduction -to CHNOSZ}, ``speciation diagram for ER.to.Golgi proteins'' in \texttt{?read.expr}, -and \texttt{demo(\textquotedbl{}yeastgfp\textquotedbl{})}, after \citet{Dic09}. -\item Also see the vignette \emph{Hot-spring proteins in CHNOSZ}. -\end{itemize} -\item For systems of many proteins, equilibrium diagrams such as this can -become very cluttered, and it may be desirable to use summary statistics -to identify trends in the activities or affinities (see \texttt{revisit()}). -\end{itemize} - \subsection{Mosaic diagrams} The examples using \texttt{mosaic()} shown below are based on the Modified: pkg/CHNOSZ/vignettes/equilibrium.lyx =================================================================== --- pkg/CHNOSZ/vignettes/equilibrium.lyx 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/vignettes/equilibrium.lyx 2017-02-19 05:30:45 UTC (rev 163) @@ -2763,7 +2763,7 @@ \begin_layout Plain Layout -<>= +<>= \end_layout \begin_layout Plain Layout @@ -2858,77 +2858,6 @@ \end_layout -\begin_layout Itemize -Protein examples (with -\family typewriter -normalize = TRUE -\family default -): -\begin_inset Separator latexpar -\end_inset - - -\end_layout - -\begin_deeper -\begin_layout Itemize -See -\begin_inset Quotes eld -\end_inset - -Subcellular proteins -\begin_inset Quotes erd -\end_inset - - in the vignette -\emph on -An introduction to CHNOSZ -\emph default -, -\begin_inset Quotes eld -\end_inset - -speciation diagram for ER.to.Golgi proteins -\begin_inset Quotes erd -\end_inset - - in -\family typewriter -?read.expr -\family default -, and -\family typewriter -demo("yeastgfp") -\family default -, after -\begin_inset CommandInset citation -LatexCommand citet -key "Dic09" - -\end_inset - -. -\end_layout - -\begin_layout Itemize -Also see the vignette -\emph on -Hot-spring proteins in CHNOSZ -\emph default -. -\end_layout - -\end_deeper -\begin_layout Itemize -For systems of many proteins, equilibrium diagrams such as this can become - very cluttered, and it may be desirable to use summary statistics to identify - trends in the activities or affinities (see -\family typewriter -revisit() -\family default -). -\end_layout - \begin_layout Subsection Mosaic diagrams \end_layout Modified: pkg/CHNOSZ/vignettes/wjd.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/wjd.Rnw 2017-02-18 14:18:11 UTC (rev 162) +++ pkg/CHNOSZ/vignettes/wjd.Rnw 2017-02-19 05:30:45 UTC (rev 163) @@ -8,6 +8,7 @@ \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} \usepackage{color} \usepackage{babel} +\usepackage{graphicx} \usepackage[authoryear]{natbib} \usepackage[unicode=true, bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, @@ -125,15 +126,15 @@ Then apply the function over the different numbers of iterations, from 0 (initial conditions) to \Sexpr{niter}, and plot the values. -\setkeys{Gin}{width=1.0\textwidth} +\setkeys{Gin}{width=0.7\textwidth} <<>>= -<>= -par(mfrow=c(1, 2)) -sa <- sapply(0:niter, iterfun, i=oX[1]) -plot(0:niter, sa, xlab="iteration", ylab=paste("x", f1)) -sa <- sapply(0:niter, iterfun, i=oX[4]) -plot(0:niter, sa, xlab="iteration", ylab=paste("x", f4)) +<>= +par(mfrow = c(1, 2), mar = c(4.2, 4.2, .1, .1)) +sa <- sapply(0:niter, iterfun, i = oX[1]) +plot(0:niter, sa, xlab = "iteration", ylab = paste("x", f1), pch = 19) +sa <- sapply(0:niter, iterfun, i = oX[4]) +plot(0:niter, sa, xlab = "iteration", ylab = paste("x", f4), pch = 19) @ \setkeys{Gin}{width=1.0\textwidth} @@ -200,25 +201,37 @@ first look at a plot showing the results after 3 iterations. \setkeys{Gin}{width=0.6\textwidth} +\begin{center} <<>>= -<>= +<>= +par(mar = c(4.2, 4.2, 1.1, 1.1)) +par(mgp = c(2, 1, 0)) +@ + +<<>>= +<>= +<> w3 <- wjd(imax=3) ep3 <- element.potentials(w3, plot.it=TRUE) @ +\end{center} \setkeys{Gin}{width=1.0\textwidth} Here's the plot for the default settings of \texttt{wjd()} which takes 6 iterations: \setkeys{Gin}{width=0.6\textwidth} +\begin{center} <<>>= -<>= +<>= +<> ep <- element.potentials(w, plot.it=TRUE) @ +\end{center} \setkeys{Gin}{width=1.0\textwidth} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 163 From noreply at r-forge.r-project.org Sun Feb 19 13:59:01 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 19 Feb 2017 13:59:01 +0100 (CET) Subject: [CHNOSZ-commits] r164 - in pkg/CHNOSZ: . R data demo inst man tests/testthat vignettes Message-ID: <20170219125901.43023188A3E@r-forge.r-project.org> Author: jedick Date: 2017-02-19 13:59:00 +0100 (Sun, 19 Feb 2017) New Revision: 164 Added: pkg/CHNOSZ/demo/Shh.R Removed: pkg/CHNOSZ/inst/doc/ Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/data/protein.csv pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/demo/protbuff.R pkg/CHNOSZ/demo/revisit.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/tests/testthat/test-util.program.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/vig.bib Log: anintro.Rmd: add an affinity baseline Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-19 12:59:00 UTC (rev 164) @@ -1,6 +1,6 @@ Date: 2017-02-19 Package: CHNOSZ -Version: 1.0.8-53 +Version: 1.0.8-54 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/R/diagram.R 2017-02-19 12:59:00 UTC (rev 164) @@ -174,6 +174,7 @@ col.names <- rep(col.names, length.out=ngroups) ## make up some names for lines/fields if they are missing + is.pname <- FALSE if(missing(names)) { # properties of basis species or reactions? if(eout$property %in% c("G.basis", "logact.basis")) names <- rownames(eout$basis) @@ -185,6 +186,7 @@ else names <- as.character(eout$species$name) # remove non-unique organism or protein names if(all(grepl("_", names))) { + is.pname <- TRUE # everything before the underscore (the protein) pname <- gsub("_.*$", "", names) # everything after the underscore (the organism) @@ -201,13 +203,10 @@ } ## apply formatting to chemical formulas 20170204 - if(format.names) { + if(all(grepl("_", names))) is.pname <- TRUE + if(format.names & !is.pname) { exprnames <- as.expression(names) - for(i in seq_along(exprnames)) { - # can the name be parsed as a chemical formula? - mtry <- suppressWarnings(try(makeup(exprnames[[i]]), TRUE)) - if(!identical(class(mtry), "try-error")) exprnames[[i]] <- expr.species(exprnames[[i]]) - } + for(i in seq_along(exprnames)) exprnames[[i]] <- expr.species(exprnames[[i]]) names <- exprnames } Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/R/examples.R 2017-02-19 12:59:00 UTC (rev 164) @@ -31,7 +31,7 @@ demos <- function(which=c("sources", "protein.equil", "add.obigt", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", - "copper", "solubility", "wjd", "dehydration", "bugstab", "activity_ratios"), to.file=FALSE) { + "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one for(i in 1:length(which)) { # say something so the user sees where we are Modified: pkg/CHNOSZ/data/protein.csv =================================================================== --- pkg/CHNOSZ/data/protein.csv 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/data/protein.csv 2017-02-19 12:59:00 UTC (rev 164) @@ -452,3 +452,20 @@ RBL1,HALNC,BBA+03,O85040,1,45,6,32,31,23,46,14,25,25,35,11,16,21,12,28,16,30,31,10,16 RBL2,HALNC,BBA+03,Q9ZHZ4,1,47,2,33,26,23,51,14,31,28,30,19,14,23,14,20,20,20,18,5,21 RBS,HALNC,BBA+03,P45686,1,11,1,3,8,4,5,2,5,6,7,5,7,5,8,4,6,2,8,3,10 +SHH,HUMAN,UniProt,Q15465.N,1,14,3,10,14,5,16,6,7,15,11,3,8,7,3,13,12,8,9,3,7 +OLIG2,HUMAN,UniProt,Q13516,1,51,5,10,10,5,35,18,7,14,29,11,4,31,5,13,50,11,10,1,3 +NKX22,HUMAN,UniProt,O95096,1,29,1,14,18,7,18,6,4,16,23,4,8,25,19,17,24,15,11,4,10 +FOXA2,HUMAN,UniProt,Q9Y261,1,55,4,9,18,9,53,23,8,19,31,30,19,42,24,13,55,12,8,4,21 +IRX3,HUMAN,UniProt,P78415,1,80,2,23,43,11,47,9,8,18,51,4,13,62,13,25,44,17,13,5,13 +PAX6,HUMAN,UniProt,P26367,1,19,6,14,21,9,32,6,19,13,25,14,21,37,30,33,51,31,23,6,12 +NKX62,HUMAN,UniProt,Q9C056,1,35,1,15,11,9,35,5,5,21,30,5,7,26,9,16,16,9,12,4,6 +DBX1,HUMAN,UniProt,A6NMT0,1,23,1,12,22,17,27,6,8,18,31,6,5,46,14,24,46,17,11,3,6 +DBX2,HUMAN,UniProt,Q6ZNG2,1,40,8,10,19,11,22,3,8,17,35,4,10,39,17,24,37,10,14,6,5 +NKX61,HUMAN,UniProt,P78426,1,52,1,11,17,8,29,8,6,21,35,8,6,44,12,15,60,16,7,4,7 +PAX7,HUMAN,UniProt,P23759,1,37,8,23,29,14,43,14,22,25,34,14,14,50,27,35,55,29,26,5,16 +GLI1,HUMAN,UniProt,P08151,1,65,31,39,63,24,117,40,17,33,89,21,35,149,48,66,128,58,44,5,34 +GLI2,HUMAN,UniProt,P10070,1,148,27,64,71,28,140,68,33,48,135,40,50,174,94,80,188,81,75,4,38 +GLI3,HUMAN,UniProt,P10071,1,112,29,71,75,34,122,67,52,58,121,42,63,152,88,83,215,90,63,4,39 +PTC1,HUMAN,UniProt,Q13635,1,116,27,63,78,64,101,42,62,50,153,31,49,102,57,79,105,83,108,21,56 +SMO,HUMAN,UniProt,Q99835,1,70,26,28,36,37,57,15,33,29,71,14,25,61,26,47,52,43,53,19,18 +GLI3R,HUMAN,UniProt,P10071,1,10,0,6,4,5,5,12,7,0,7,5,3,26,0,7,17,6,3,0,8 Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/demo/00Index 2017-02-19 12:59:00 UTC (rev 164) @@ -17,4 +17,5 @@ wjd Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast dehydration log K of dehydration reactions; SVG file contains tooltips and links bugstab formation potential of microbial proteins in colorectal cancer +Shh affinities of transcription factors relative to Sonic hedgehog activity_ratios mineral stability plots with activity ratios on the axes Added: pkg/CHNOSZ/demo/Shh.R =================================================================== --- pkg/CHNOSZ/demo/Shh.R (rev 0) +++ pkg/CHNOSZ/demo/Shh.R 2017-02-19 12:59:00 UTC (rev 164) @@ -0,0 +1,197 @@ +# Compare affinities of Sonic hedgehog and transcription factors involved in dorsal-ventral patterning +# (Dick, 2015. Chemical integration of proteins in signaling and development. http://dx.doi.org/10.1101/015826) + +# UniProt names of the proteins +pname <- c("SHH", "OLIG2", "NKX22", "FOXA2", "IRX3", "PAX6", "NKX62", "DBX1", + "DBX2", "NKX61", "PAX7", "GLI1", "GLI2", "GLI3", "PTC1", "SMO", "GLI3R")[1:11] + +# colors modified from Dessaud et al., 2008 and Hui and Angers, 2011 +fill <- c(SHH = "#c8c7c8", OLIG2 = "#f9a330", NKX22 = "#ef2b2c", FOXA2 = "#6ab0b9", + NKX61 = "#b76775", DBX2 = "#35bcba", PAX7 = "#f6ef42", + PAX6 = "#4d2a59", IRX3 = "#63c54e", NKX62 = "#f24e33", DBX1 = "#d4e94e", + PTC1 = "#c7b0ee", SMO = "#8fd4ef", GLI1 = "#fcdc7e", GLI2 = "#c7e3b0", GLI3 = "#fcdc7e", + GLI3R = "#f1b1ae") + +# names for plotting +names <- c(SHH = "Shh", OLIG2 = "Olig2", NKX22 = "Nkx2.2", FOXA2 = "Foxa2", + NKX61 = "Nkx6.1", DBX2 = "Dbx2", PAX7 = "Pax7", + PAX6 = "Pax6", IRX3 = "Irx3", NKX62 = "Nkx6.2", DBX1 = "Dbx1", + PTC1 = "Ptch1", SMO = "Smo", GLI1 = "Gli1A", GLI2 = "Gli2A", GLI3 = "Gli3A", + GLI3R = "Gli3R") + +# protein indices of Shh and the transcription factors +ip <- match(pname, thermo$protein$protein) +aa <- thermo$protein[ip, ] + +# set up basis species +basis("CHNOS") +basis("NH3", -7) + +# save as PDF file? +pdf <- FALSE +# draw interpretive legend? +interp <- TRUE + +# set up ranges of logfO2 and logaH2O +O2 <- seq(-70, -100, length.out = 500) +H2O <- seq(0.5, -4.5, length.out = 500) +A <- affinity(H2O = H2O, O2 = O2, iprotein = ip) +# plot affinities per residue, compared to SHH +pl <- protein.length(ip) +names(A$values) <- pname +for(i in 1:length(A$values)) A$values[[i]] <- A$values[[i]] / pl[i] +A.SSH <- A$values$SHH +for(i in 1:length(A$values)) A$values[[i]] <- A$values[[i]] - A.SSH +ylab <- expression(bold(A)/2.303*italic(RT)*" vs Shh") +xlab <- expression(log*italic(a)[H[2]][O]) +# set up normal plot, or plot with interpretive drawings +if(interp) { + if(pdf) pdf("tfactor_interp.pdf", width=6, height=6) + plot.new() + plot.window(rev(range(H2O)), c(-0.7, 4.7), xaxs="i", yaxs="i") + par(xpd=FALSE) + clip(range(H2O)[1], range(H2O)[2], -0.3, 4.2) +} else { + if(pdf) pdf("tfactor_affinity.pdf", width=6, height=6) + plot(range(H2O), c(-0.5, 4.5), type="n", xaxs="i", yaxs="i", xlab=xlab, ylab=ylab, xlim=rev(range(H2O)), mgp=c(2.5, 1, 0)) +} +for(i in 1:length(pl)) { + lty <- 3 + lwd <- 1 + # highlight SHH with solid line + if(pname[i]=="SHH") { + lty <- 1 + lwd <- 3 + } + lines(H2O, A$values[[i]], lty=lty, lwd=lwd) +} +# highlight lines for reaction sequence from OLIG2 to SHH +A <- A$values +names(A) <- pname +# Olig2 +iOLIG2 <- A$OLIG2 > A$SHH +lines(H2O[iOLIG2], A$OLIG2[iOLIG2], col=fill["OLIG2"], lwd=3) +# Foxa2 with offset to distinguish it from Nkx6.1/Dbx2 +iFOXA2 <- A$FOXA2 > A$OLIG2 & A$FOXA2 > A$NKX22 +lines(H2O[iFOXA2], A$FOXA2[iFOXA2], col=fill["FOXA2"], lwd=3) +# Nkx2.2 +iNKX22 <- A$NKX22 > A$FOXA2 & A$NKX22 > A$SHH +lines(H2O[iNKX22], A$NKX22[iNKX22], col=fill["NKX22"], lwd=3) +# Pax6 +iPAX6 <- A$PAX6 > A$SHH +lines(H2O[iPAX6], A$PAX6[iPAX6], col=fill["PAX6"], lwd=3) +# Nkx6.1 with overstepping +iNKX61 <- A$NKX61 > A$DBX2 +imax <- max(which(iNKX61)) +iNKX61[1: (imax-20)] <- FALSE +lines(H2O[iNKX61], A$NKX61[iNKX61], col=fill["NKX61"], lwd=3) +# Dbx2 +iDBX2 <- A$DBX2 > A$NKX61 & A$DBX2 < A$IRX3 +lines(H2O[iDBX2], A$DBX2[iDBX2], col=fill["DBX2"], lwd=3) +# Irx3 +iIRX3 <- A$IRX3 > A$NKX62 & A$IRX3 > A$OLIG2 +lines(H2O[iIRX3], A$IRX3[iIRX3], col=fill["IRX3"], lwd=3) +# Nkx6.2 +iNKX62 <- A$NKX62 > A$IRX3 & A$NKX62 > A$DBX1 +lines(H2O[iNKX62], A$NKX62[iNKX62], col=fill["NKX62"], lwd=3) +# Dbx1 +iDBX1 <- A$DBX1 > A$NKX62 & A$DBX1 > A$SHH +lines(H2O[iDBX1], A$DBX1[iDBX1], col=fill["DBX1"], lwd=3) +# Shh +#iSHH <- A$SHH > A$DBX1 +#lines(H2O[iSHH], A$SHH[iSHH], col=fill["SHH"], lwd=3) +# the lines need names +if(interp) { + # remove plot clip region + par(xpd=NA) + text(-2.12, -0.48, "Nkx2.2", srt=90) + text(-0.87, -0.65, "Olig2", srt=90) + text(0, -0.72, "Pax6", srt=90) + text(0.06, 4.3, "Olig2", srt=90) + text(-0.13, 4.3, "Irx3", srt=90) + text(-0.77, 4.3, "Nkx6.1", srt=90) + text(-.97, 4.3, "Dbx2", srt=90) + text(-3.45, 4.3, "Nkx6.2", srt=90) + text(-3.65, 4.3, "Dbx1", srt=90) +} else { + text(-1.5, 0.5, "Nkx2.2") + text(-0.1, 0.3, "Pax6") + text(-0.2, 3.8, "Olig2") + text(-0.75, 2.45, "Irx3") + text(-1.13, 1.3, "Nkx6.1") + text(-1.5, 1, "Dbx2") + text(-2.4, 1.3, "Nkx6.2") + text(-3.8, 0.3, "Dbx1") +} +text(0.3, -0.15, "Shh") +text(-4.25, 0.15, "Shh") +text(-0.47, 0.5, "Pax7", srt=-35) +text(-0.22, 2, "Foxa2", srt=-61) +# are we making an interpretive plot? +if(interp) { + # the left,bottom x,y-position and horizontal width of the bottom gradient wedge + xbot <- H2O[1] + ybot <- -1.4 + wbot <- 3 + # the height of the bottom gradient wedge as a function of the x position + hbot <- function(x) 0.3 + 0.08*(xbot - x) + lines(c(xbot, xbot-wbot), ybot+hbot(c(xbot, xbot-wbot))) + # draw the base and sides of the bottom gradient wedge + lines(c(xbot, xbot-wbot), c(ybot, ybot)) + lines(rep(xbot, 2), c(ybot, ybot+hbot(xbot))) + lines(rep(xbot, 2)-wbot, c(ybot, ybot+hbot(xbot-wbot))) + # draw drop lines from reactions between TFs and Shh + xNKX22 <- H2O[max(which(A$NKX22 > A$SHH))] + lines(rep(xNKX22, 2), c(ybot, 0), lty=2) + xOLIG2 <- H2O[max(which(A$OLIG2 > A$SHH))] + lines(rep(xOLIG2, 2), c(ybot, 0), lty=2) + xPAX6 <- H2O[max(which(A$PAX6 > A$SHH))] + lines(rep(xPAX6, 2), c(ybot, 0), lty=2) + # the left,bottom x,y-position and horizontal width of the top gradient wedge + xtop <- H2O[2] + ytop <- 4.7 + wtop <- 5 + # the height of the top gradient wedge as a function of the x position + htop <- function(x) 0.4 - 0.08*(xtop - x) + lines(c(xtop, xtop-wtop), ytop+htop(c(xtop, xtop-wtop))) + # draw the base and sides of the top gradient wedge + lines(c(xtop, xtop-wtop), c(ytop, ytop)) + lines(rep(xtop, 2), c(ytop, ytop+htop(xtop))) + lines(rep(xtop, 2)-wtop, c(ytop, ytop+htop(xtop-wtop))) + # draw drop lines to reactions between TFs + iIRX3 <- min(which(A$IRX3 > A$OLIG2)) + lines(rep(H2O[iIRX3], 2), c(A$IRX3[iIRX3], ytop+htop(H2O[iIRX3])), lty=2) + iDBX2 <- min(which(A$DBX2 > A$NKX61)) + lines(rep(H2O[iDBX2], 2), c(A$DBX2[iDBX2], ytop+htop(H2O[iDBX2])), lty=2) + iDBX1 <- min(which(A$DBX1 > A$NKX62)) + lines(rep(H2O[iDBX1], 2), c(A$DBX1[iDBX1], ytop+htop(H2O[iDBX1])), lty=2) + # indicate plot variables + arrows(-2.7, 2, -2.7, 2.5, 0.1) + text(-2.8, 2.3, "affinity\nvs. Shh", adj=0) + arrows(-2.7, 2, -2.27, 2, 0.1) + text(-2.3, 1.8, expression(list(log*italic(f)[O[2]], )), adj=0) + text(-2.3, 1.6, expression(list(log*italic(a)[H[2]*O])), adj=0) + # label neural progenitors + text(-2.37, -1.55, "FP") + text(-1.6, -1.55, "p3") + text(-0.53, -1.55, "pMN") + text(0.2, -1.55, "p2") + text(0.2, 5.25, "pMN") + text(-0.47, 5.25, "p2") + text(-2.2, 5.25, "p1") + text(-4, 5.25, "p0") + # label Shh gradient and stages + text(1.2, -1.2, "Shh\ngradient", adj=0) + text(1.2, 4.9, "Shh\ngradient", adj=0) + text(-2.6, -0.6, expression(italic("Stage 1: loading")), adj=0) + text(-1.5, 4.3, expression(italic("Stage 2: unloading")), adj=0) +} else { + # add second axis: logfO2 + pu <- par("usr") + pu[1:2] <- rev(range(O2)) + par(usr=pu) + axis(3, at=seq(-75, -105, by=-5)) + mtext(expression(log*italic(f)[O[2]]), line=2) +} +# all done! +if(pdf) dev.off() Modified: pkg/CHNOSZ/demo/protbuff.R =================================================================== --- pkg/CHNOSZ/demo/protbuff.R 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/demo/protbuff.R 2017-02-19 12:59:00 UTC (rev 164) @@ -14,9 +14,9 @@ a <- affinity(pH=c(4, 10, 300), T=c(40, 60, 300)) e <- equilibrate(a, normalize=TRUE) fill <- ZC.col(ZC(protein.formula(species()$name))) -diagram(e, fill=fill, format.names=FALSE) +diagram(e, fill=fill) title(main="Thiol peroxidases from bacteria") -legend("topleft", describe.basis(thermo$basis[-6,]), bg="grey80", box.lwd=0) +legend("topleft", describe.basis(thermo$basis[-6,]), bg="slategray1", box.lwd=0) ## Buffer + ionization: relative stabilities ## of E. coli sigma factors on a T-pH diagram @@ -36,10 +36,10 @@ species(paste(proteins, "ECOLI", sep="_")) a <- affinity(pH=c(5, 10, 300), T=c(10, 40, 300)) fill <- ZC.col(ZC(protein.formula(species()$name))) -diagram(a, normalize=FALSE, fill=fill, format.names=FALSE) +diagram(a, normalize=FALSE, fill=fill) title(main=expression("Sigma factors in"~italic("E. coli"))) ptext <- c(describe.property("T", 25), describe.basis(ibasis=c(2, 6), oneline=TRUE)) -legend("topleft", legend=c("preset conditions:", ptext), bg="grey80", box.lwd=0) +legend("topleft", legend=c("preset conditions:", ptext), bg="slategray1", box.lwd=0) btext <- describe.basis(ibasis=c(1, 3, 4, 5), oneline=TRUE) -legend("bottomright", legend=c("buffered conditions:", btext), bg="grey80", box.lwd=0) +legend("bottomright", legend=c("buffered conditions:", btext), bg="slategray1", box.lwd=0) Modified: pkg/CHNOSZ/demo/revisit.R =================================================================== --- pkg/CHNOSZ/demo/revisit.R 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/demo/revisit.R 2017-02-19 12:59:00 UTC (rev 164) @@ -29,7 +29,7 @@ # calculate affinities in logfO2-logaH2O space a <- affinity(O2=c(-85, -65), H2O=c(-5, 5), iprotein=ip) # show the predominances -diagram(a, normalize=TRUE, fill="heat", format.names=FALSE) +diagram(a, normalize=TRUE, fill="heat") # calculate the equilibrium activities e <- equilibrate(a, loga.balance=0, normalize=TRUE) # show the coefficient of variation Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/inst/NEWS 2017-02-19 12:59:00 UTC (rev 164) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-53 (2017-02-19) +CHANGES IN CHNOSZ 1.0.8-54 (2017-02-19) --------------------------------------- DOCUMENTATION: @@ -11,7 +11,8 @@ - New demos: bugstab.R (potential diagrams for microbial proteins in colorectal cancer), activity_ratios.R (mineral stability diagrams - with activity ratios on the axes). + with activity ratios on the axes), Shh.R (affinities of + transcription factors relative to Sonic hedgehog). - Converted demos: move examples from help pages to protein.equil.R, add.obigt.R, and affinity.R. Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/man/examples.Rd 2017-02-19 12:59:00 UTC (rev 164) @@ -16,7 +16,7 @@ examples(do.png = FALSE) demos(which = c("sources", "protein.equil", "add.obigt", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", - "copper", "solubility", "wjd", "dehydration", "bugstab", "activity_ratios"), + "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios"), to.file=FALSE) } @@ -51,6 +51,7 @@ \code{wjd} \tab Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast \cr \code{dehydration} \tab log K of dehydration reactions; SVG file contains tooltips and links \cr \code{bugstab} \tab formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr + \code{Shh} \tab affinities of transcription factors relative to Sonic hedgehog \cr \code{activity_ratios} \tab mineral stability plots with activity ratios on the axes \cr } Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-19 12:59:00 UTC (rev 164) @@ -87,7 +87,7 @@ col <- rep("red", length(prot)) col[ZC > 0] <- "blue" e <- equilibrate(a, normalize=TRUE) -d <- diagram(e, col=col, format.names=FALSE) +d <- diagram(e, col=col) title(main="Bovine proteins, GSH/GSSG redox buffer") } Modified: pkg/CHNOSZ/tests/testthat/test-util.program.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-util.program.R 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/tests/testthat/test-util.program.R 2017-02-19 12:59:00 UTC (rev 164) @@ -17,10 +17,10 @@ # CHNOSZ no longer has a large FASTA file to test this with 20170205 #ff <- system.file("extdata/fasta/HTCC1062.faa.xz", package="CHNOSZ") #expect_message(aa <- read.fasta(ff), "read.fasta running 1354 calculations") + basis("CHNOS") ip <- 1:nrow(thermo$protein) - basis("CHNOS") - expect_message(a <- affinity(iprotein=rep(ip, 3)), "affinity running 1359 calculations") - expect_message(e <- equilibrate(a, normalize=TRUE), "equil.boltzmann running 1359 calculations") + expect_message(a <- affinity(iprotein=rep(ip, 3)), "affinity running .* calculations") + expect_message(e <- equilibrate(a, normalize=TRUE), "equil.boltzmann running .* calculations") # test reaction method species(c("CO2", "acetic acid")) a <- affinity(O2=c(-90, -60, 1000)) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-19 12:59:00 UTC (rev 164) @@ -1226,9 +1226,9 @@ #mod.obigt("[Met]", G = -35245, H = -59310) a <- affinity(O2 = c(-80, -73), iprotein = ip, loga.protein = logact) e <- equilibrate(a) -diagram(e, ylim = c(-5, -2), format.names = FALSE, col = 1:5, lwd = 2) +diagram(e, ylim = c(-5, -2), col = 1:5, lwd = 2) e <- equilibrate(a, normalize = TRUE) -diagram(e, ylim = c(-5, -2.5), format.names = FALSE, col = 1:5, lwd = 2) +diagram(e, ylim = c(-5, -2.5), col = 1:5, lwd = 2) abline(h = logabundance, lty = 1:5, col = 1:5) revisit(e, "DGinf", logabundance) ``` @@ -1253,6 +1253,75 @@ The minimum free energy difference occurs near `r logfO2` = -78. This agrees with the assessment shown in Figure 4 of @Dic09 (note that the old parameters for the methionine sidechain group were used in that study). +## An affinity baseline + +Because affinities of proteins often vary strongly with oxygen fugacity and other variables, it can be helpful to express the values as differences from a baseline. +The following example compares the affinities of transcription factors involved in embryonic dorsal-ventral patterning with that of Sonic hedgehog (Shh) as a function of `r logfO2` and log*a*`r h2o` [@Dic15]. +We first list the UniProt names of Shh and 10 transcription factors, and get the `iprotein` indices (rownumbers of `thermo$protein`): +```{r Shh_pname} +pname <- c("SHH", "OLIG2", "NKX22", "FOXA2", "IRX3", + "PAX6", "NKX62", "DBX1", "DBX2", "NKX61", "PAX7") +ip <- match(pname, thermo$protein$protein) +``` + +Next, set up the basis species: +```{r Shh_basis, results="hide"} +basis("CHNOS") +basis("NH3", -7) +``` + +Now calculate the affinities of formation of the proteins from the basis species. +The values chosen for `r logfO2` and log*a*`r h2o` covary, so we are using the transect mode of `affinity()`: +```{r Shh_affinity, message=FALSE} +O2 <- seq(-70, -100, length.out = 10) +H2O <- seq(0.5, -4.5, length.out = 10) +a <- affinity(H2O = H2O, O2 = O2, iprotein = ip) +``` + +We would like to compare the affinities of the proteins on a per-residue scale. +R's `lapply()` could be used here, but to show the operation more clearly we use a `for()` loop: +```{r Shh_residue} +pl <- protein.length(ip) +for(i in seq_along(a$values)) a$values[[i]] <- a$values[[i]] / pl[i] +``` + +Then, we calculate the relative affinities with Shh as the baseline: +```{r Shh_minusShh} +a.Shh <- a$values[[1]] +for(i in 1:length(a$values)) a$values[[i]] <- a$values[[i]] - a.Shh +``` + +Next we use `diagram()` to plot the affinities. +We set `balance = 1` to plot the values as they are---without that, `diagram()` divides the values by protein length, which we have already done! +```{marginfigure} +See `demo(Shh)` for a plot with more interpretive labels and comments. +``` +For this plot, we highlight and label the proteins with the highest relative affinity at some combination of `logfO2` and log*a*`r h2o` along the transect. +Those proteins are Olig2, Irx3, Nkx6.2, Dbx1, and Shh (numbers 2, 5, 7, 8, 1 in the set we have identified). +The last few lines are used to set up the second (upper) *x* axis, using a label generated with `axis.label()`: + +```{r Shh_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap="Per-residue affinities of formation of transcription factors relative to Shh.", cache=TRUE, pngquant=pngquant, timeit=timeit} +# line type, width, and color +twc <- lapply(c(3, 1, 1), rep, length(pname)) +ihigh <- c(2, 5, 7, 8, 1) +twc[[1]][ihigh] <- 1 +twc[[2]][ihigh] <- 3 +col <- c("#f9a330", "#63c54e", "#f24e33", "#d4e94e", "#0f0f0f") +twc[[3]][ihigh] <- col +diagram(a, balance = 1, ylim = c(-0.5, 4.5), xlim = c(0.5, -4.5), + lty = twc[[1]], lwd=twc[[2]], col = twc[[3]], names = NA) +legend("topright", legend = c("Olig2", "Irx3", "Nkx6.2", "Dbx1", "Shh"), + lwd = 2, col = col) +par(usr = c(-70, -100, -0.5, 4.5), tcl = -0.3) +axis(3, at = seq(-70, -100, by = -5)) +mtext(axis.label("O2"), line = 1.2) +``` +```{r Shh_diagram, eval=FALSE} +``` + +Among these proteins, Olig2 and Shh have the greatest affinities for formation at the extremes of oxidation and hydration state. +This thermodynamic description suggests links between the chemical compositions of the proteins and their order of appearance along with chemical changes in developing embryos (Dick, 2015). + ## Adding proteins In the Rubisco example above, we saw the use of `read.fasta()` to read amino acid sequences from a FASTA file. @@ -1391,7 +1460,7 @@ res <- 300 a <- affinity(T = c(T, res), H2 = c(-8, -3, res), iprotein = ip) fill <- ZC.col(ZC(protein.formula(ip))) -diagram(a, normalize = TRUE, fill = fill, names = 1:5, format.names = FALSE) +diagram(a, normalize = TRUE, fill = fill, names = 1:5) T <- c(93.3, 79.4, 67.5, 65.3, 57.1) logaH2 <- c(-3.38, -4.14, -5.66, -7.47, -10.02) lines(T, logaH2, lty = 2, lwd = 2) @@ -1442,7 +1511,7 @@ ``` 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 (?) or mole fraction diagram. -This is similar to Figure 1.3 of Alberty (2003), but calculated for *I* = 0 M and *T* = 100 ?C: +This is similar to Figure 1.3 of Alberty (2003), but is calculated for *I* = 0 M and *T* = 100 ?C: ```{marginfigure} To make the code more readable, commands for plotting titles and legends are not shown. All of the commands are available in the source of this document. Modified: pkg/CHNOSZ/vignettes/vig.bib =================================================================== --- pkg/CHNOSZ/vignettes/vig.bib 2017-02-19 05:30:45 UTC (rev 163) +++ pkg/CHNOSZ/vignettes/vig.bib 2017-02-19 12:59:00 UTC (rev 164) @@ -96,6 +96,14 @@ doi = {10.1098/rsif.2013.1095}, } + at Article{Dic15, + author = {Dick, Jeffrey M.}, + journal = {bioRxiv}, + title = {{C}hemical integration of proteins in signaling and development}, + year = {2015}, + doi = {10.1101/015826}, +} + @Article{DLH06, author = {Dick, Jeffrey M. and LaRowe, Douglas E. and Helgeson, Harold C.}, journal = {Biogeosciences}, From noreply at r-forge.r-project.org Sun Feb 19 16:26:25 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 19 Feb 2017 16:26:25 +0100 (CET) Subject: [CHNOSZ-commits] r165 - in pkg/CHNOSZ: . inst vignettes Message-ID: <20170219152625.5F251187C78@r-forge.r-project.org> Author: jedick Date: 2017-02-19 16:26:25 +0100 (Sun, 19 Feb 2017) New Revision: 165 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/vignettes/anintro.Rmd Log: anintro.Rmd: copyediting Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-19 12:59:00 UTC (rev 164) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-19 15:26:25 UTC (rev 165) @@ -1,6 +1,6 @@ Date: 2017-02-19 Package: CHNOSZ -Version: 1.0.8-54 +Version: 1.0.8-55 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-19 12:59:00 UTC (rev 164) +++ pkg/CHNOSZ/inst/NEWS 2017-02-19 15:26:25 UTC (rev 165) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-54 (2017-02-19) +CHANGES IN CHNOSZ 1.0.8-55 (2017-02-19) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-19 12:59:00 UTC (rev 164) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-19 15:26:25 UTC (rev 165) @@ -97,7 +97,7 @@ # First steps This document introduces the usage of CHNOSZ, a package for the [R software environment](http://r-project.org). -For more information on R, see "[An Introduction to R](http://cran.r-project.org/manuals.html)" and the [Contributed Documentation](https://cran.r-project.org/other-docs.html) for R. +For more information on R, see "[An Introduction to R](http://cran.r-project.org/manuals.html)" and the [contributed documentation](https://cran.r-project.org/other-docs.html) for R. CHNOSZ has been developed since 2006 to support research projects in geochemistry and compositional biology. The package provides functions and a thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions among minerals and organic or inorganic aqueous species. @@ -1256,7 +1256,7 @@ ## An affinity baseline Because affinities of proteins often vary strongly with oxygen fugacity and other variables, it can be helpful to express the values as differences from a baseline. -The following example compares the affinities of transcription factors involved in embryonic dorsal-ventral patterning with that of Sonic hedgehog (Shh) as a function of `r logfO2` and log*a*`r h2o` [@Dic15]. +The following example compares the affinities for formation of transcription factors involved in embryonic dorsal-ventral patterning with that of the morphogen, Sonic hedgehog (Shh), as a function of `r logfO2` and log*a*`r h2o` [@Dic15]. We first list the UniProt names of Shh and 10 transcription factors, and get the `iprotein` indices (rownumbers of `thermo$protein`): ```{r Shh_pname} pname <- c("SHH", "OLIG2", "NKX22", "FOXA2", "IRX3", @@ -1285,7 +1285,7 @@ for(i in seq_along(a$values)) a$values[[i]] <- a$values[[i]] / pl[i] ``` -Then, we calculate the relative affinities with Shh as the baseline: +Then, we calculate the relative affinities, using Shh as the baseline: ```{r Shh_minusShh} a.Shh <- a$values[[1]] for(i in 1:length(a$values)) a$values[[i]] <- a$values[[i]] - a.Shh @@ -1296,11 +1296,11 @@ ```{marginfigure} See `demo(Shh)` for a plot with more interpretive labels and comments. ``` -For this plot, we highlight and label the proteins with the highest relative affinity at some combination of `logfO2` and log*a*`r h2o` along the transect. +For this plot, we highlight and label the proteins with the highest relative affinity at some combination of `r logfO2` and log*a*`r h2o` along the transect. Those proteins are Olig2, Irx3, Nkx6.2, Dbx1, and Shh (numbers 2, 5, 7, 8, 1 in the set we have identified). -The last few lines are used to set up the second (upper) *x* axis, using a label generated with `axis.label()`: +The last few lines are used to make a second *x* axis, using a label generated with `axis.label()`: -```{r Shh_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap="Per-residue affinities of formation of transcription factors relative to Shh.", cache=TRUE, pngquant=pngquant, timeit=timeit} +```{r Shh_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap="Per-residue affinities for formation of transcription factors relative to Shh.", cache=TRUE, pngquant=pngquant, timeit=timeit} # line type, width, and color twc <- lapply(c(3, 1, 1), rep, length(pname)) ihigh <- c(2, 5, 7, 8, 1) @@ -1308,8 +1308,9 @@ twc[[2]][ihigh] <- 3 col <- c("#f9a330", "#63c54e", "#f24e33", "#d4e94e", "#0f0f0f") twc[[3]][ihigh] <- col +ylab <- substitute(italic(A) / 2.303 * italic(RT) * ", relative to Shh") diagram(a, balance = 1, ylim = c(-0.5, 4.5), xlim = c(0.5, -4.5), - lty = twc[[1]], lwd=twc[[2]], col = twc[[3]], names = NA) + lty = twc[[1]], lwd=twc[[2]], col = twc[[3]], names = NA, ylab = ylab) legend("topright", legend = c("Olig2", "Irx3", "Nkx6.2", "Dbx1", "Shh"), lwd = 2, col = col) par(usr = c(-70, -100, -0.5, 4.5), tcl = -0.3) @@ -1460,7 +1461,7 @@ res <- 300 a <- affinity(T = c(T, res), H2 = c(-8, -3, res), iprotein = ip) fill <- ZC.col(ZC(protein.formula(ip))) -diagram(a, normalize = TRUE, fill = fill, names = 1:5) +diagram(a, normalize = TRUE, fill = fill, names = 1:5, format.names = FALSE) T <- c(93.3, 79.4, 67.5, 65.3, 57.1) logaH2 <- c(-3.38, -4.14, -5.66, -7.47, -10.02) lines(T, logaH2, lty = 2, lwd = 2) @@ -1470,7 +1471,7 @@ ``` Site numbers 1--5 correspond to a cooling gradient along the outflow channel of the hot spring. The colors represent the relative `r zc` of the proteins (red is more reduced). -The points indicate the *T* and log*a*H2 that optimize a thermodynamic model for the relative abundances of phyla as estimated by taxonomic classification of metagenomic sequences [@DS13]: +The points indicate the *T* and log*a*H2 that optimize a thermodynamic model for relative abundances of phyla that were estimated by taxonomic classification of metagenomic sequences [@DS13]: ```{r bison_transferase, eval=FALSE, echo=12:15} ``` @@ -2025,9 +2026,9 @@ ```

```{r the_end} - ###### ## ## ## ## ###### ##### ##### -## ##---## ## \ ## ## ## \\ // -###### ## ## ## ## ###### ##### ##### + ###### ## ## ## ## ###### ##### ##### + ## ##---## ## \ ## ## ## \\ // + ###### ## ## ## ## ###### ##### ##### ```

From noreply at r-forge.r-project.org Mon Feb 20 12:27:12 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 20 Feb 2017 12:27:12 +0100 (CET) Subject: [CHNOSZ-commits] r166 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes Message-ID: <20170220112712.3752D187A58@r-forge.r-project.org> Author: jedick Date: 2017-02-20 12:27:11 +0100 (Mon, 20 Feb 2017) New Revision: 166 Added: pkg/CHNOSZ/R/add.protein.R pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/tests/testthat/test-add.protein.R Removed: pkg/CHNOSZ/R/iprotein.R pkg/CHNOSZ/man/iprotein.Rd pkg/CHNOSZ/tests/testthat/test-iprotein.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/protein.info.R pkg/CHNOSZ/R/util.affinity.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/demo/bugstab.R pkg/CHNOSZ/demo/protein.equil.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/info.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/tests/testthat/test-affinity.R pkg/CHNOSZ/tests/testthat/test-ionize.aa.R pkg/CHNOSZ/tests/testthat/test-protein.info.R pkg/CHNOSZ/tests/testthat/test-util.affinity.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/equilibrium.Rnw pkg/CHNOSZ/vignettes/equilibrium.lyx pkg/CHNOSZ/vignettes/hotspring.Rnw pkg/CHNOSZ/vignettes/hotspring.lyx Log: rename iprotein() to protein.info() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-20 11:27:11 UTC (rev 166) @@ -1,6 +1,6 @@ -Date: 2017-02-19 +Date: 2017-02-20 Package: CHNOSZ -Version: 1.0.8-55 +Version: 1.0.8-56 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Copied: pkg/CHNOSZ/R/add.protein.R (from rev 165, pkg/CHNOSZ/R/iprotein.R) =================================================================== --- pkg/CHNOSZ/R/add.protein.R (rev 0) +++ pkg/CHNOSZ/R/add.protein.R 2017-02-20 11:27:11 UTC (rev 166) @@ -0,0 +1,164 @@ +# CHNOSZ/add.protein.R +# calculate properties of proteins 20061109 jmd +# reorganize protein functions 20120513 + +# add.protein - add amino acid counts to thermo$protein (returns iprotein) +# ip2aa - select amino acid counts (data frame) from thermo$protein +# aa2eos - perform group additivity calculations +# seq2aa - calculate amino acid counts from a sequence +# aasum - combine amino acid counts (sum, average, or weighted sum by abundance) +# read.aa - read amino acid counts from a file + +ip2aa <- function(protein, organism=NULL, residue=FALSE) { + # return amino acid counts (rows from thermo$protein) + # or 'protein' if it is a data frame + if(is.data.frame(protein)) return(protein) + iprotein <- protein.info(protein, organism) + # drop NA matches + iprotein <- iprotein[!is.na(iprotein)] + out <- get("thermo")$protein[iprotein, ] + # compute per-residue counts + if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) + return(out) +} + +aa2eos <- function(aa, state=get("thermo")$opt$state) { + # display and return the properties of + # proteins calculated from amino acid composition + # the names of the protein backbone groups depend on the state + # [UPBB] for aq or [PBB] for cr + if(state=="aq") bbgroup <- "UPBB" else bbgroup <- "PBB" + # names of the AABB, sidechain and protein backbone groups + groups <- c("AABB", colnames(aa)[6:25], bbgroup) + # put brackets around the group names + groups <- paste("[", groups, "]", sep="") + # the rownumbers of the groups in thermo$obigt + groups_state <- paste(groups, state) + obigt <- get("thermo")$obigt + obigt_state <- paste(obigt$name, obigt$state) + igroup <- match(groups_state, obigt_state) + # the properties are in columns 8-20 of thermo$obigt + groupprops <- obigt[igroup, 8:20] + # the elements in each of the groups + groupelements <- i2A(igroup) + # a function to work on a single row of aa + eosfun <- function(aa) { + # numbers of groups: chains [=AABB], sidechains, protein backbone + nchains <- as.numeric(aa[, 5]) + length <- sum(as.numeric(aa[, 6:25])) + npbb <- length - nchains + ngroups <- c(nchains, as.numeric(aa[, 6:25]), npbb) + # the actual adding and multiplying of thermodynamic properties + # hmm. seems like we have to split up the multiplication/transposition + # operations to get the result into multiple columns. 20071213 + eos <- t(data.frame(colSums(groupprops * ngroups))) + # to get the formula, add up and round the group compositions 20090331 + f.in <- round(colSums(groupelements * ngroups), 3) + # take out any elements that don't appear (sometimes S) + f.in <- f.in[f.in!=0] + # turn it into a formula + f <- as.chemical.formula(f.in) + # now the species name + name <- paste(aa$protein, aa$organism, sep="_") + # make some noise for the user + message("aa2eos: found ", appendLF=FALSE) + message(name, " (", f, ", ", appendLF=FALSE) + message(round(length, 3), " residues)") + ref <- aa$ref + header <- data.frame(name=name, abbrv=NA, formula=f, state=state, ref1=ref, ref2=NA, date=NA, stringsAsFactors=FALSE) + eosout <- cbind(header, eos) + return(eosout) + } + # loop over each row of aa + out <- lapply(1:nrow(aa), function(i) eosfun(aa[i, ])) + out <- do.call(rbind, out) + rownames(out) <- NULL + return(out) +} + +seq2aa <- function(protein, sequence) { + # remove newlines and whitespace + sequence <- gsub("\\s", "", gsub("[\r\n]", "", sequence)) + # make a data frame from counting the amino acids in the sequence + caa <- count.aa(sequence) + colnames(caa) <- aminoacids(3) + # a protein with no amino acids is sort of boring + if(all(caa==0)) stop("no characters match an amino acid") + ip <- suppressMessages(protein.info(protein)) + # now make the data frame + po <- strsplit(protein, "_")[[1]] + aa <- data.frame(protein=po[1], organism=po[2], ref=NA, abbrv=NA, stringsAsFactors=FALSE) + aa <- cbind(aa, chains=1, caa) + return(aa) +} + +aasum <- function(aa, abundance=1, average=FALSE, protein=NULL, organism=NULL) { + # returns the sum of the amino acid counts in aa, + # multiplied by the abundances of the proteins + abundance <- rep(abundance, length.out=nrow(aa)) + # drop any NA rows or abundances + ina.aa <- is.na(aa$chains) + ina.ab <- is.na(abundance) + ina <- ina.aa | ina.ab + if(any(ina)) { + aa <- aa[!ina, ] + abundance <- abundance[!ina] + message("aasum: dropped ", sum(ina), " proteins with NA composition and/or abundance") + } + # we don't know how to deal with different numbers of polypeptide chains + if(!all(aa$chains==aa$chains[1])) stop("different numbers of polypeptide chains") + # multiply + aa[, 6:25] <- aa[, 6:25] * abundance + # sum + out <- aa[1, ] + out[, 5:25] <- colSums(aa[, 5:25]) + # average if told to do so + if(average) { + # polypeptide chains by number of proteins, residues by frequence + out[, 5] <- out[, 5]/nrow(aa) + out[, 6:25] <- out[, 6:25]/sum(abundance) + } + # add protein and organism names if given + if(!is.null(protein)) out$protein <- protein + if(!is.null(organism)) out$organism <- organism + return(out) +} + +read.aa <- function(file="protein.csv", ...) { + # 20090428 added colClasses here + # 20140128 added as.is=TRUE (in case numeric values are stored in ref or abbrv column) + aa <- read.csv(file, colClasses=c(rep("character", 2), NA, NA, rep("numeric", 21)), as.is=TRUE, ...) + if(!identical(colnames(aa), colnames(get("thermo")$protein))) + stop(paste("format of", file, "is incompatible with thermo$protein")) + return(aa) +} + +add.protein <- function(aa) { + # add a properly constructed data frame of + # amino acid counts to thermo$protein + thermo <- get("thermo") + if(!identical(colnames(aa), colnames(thermo$protein))) + stop("the value of 'aa' is not a data frame with the same columns as thermo$protein") + # find any protein IDs that are duplicated + po <- paste(aa$protein, aa$organism, sep="_") + ip <- suppressMessages(protein.info(po)) + ipdup <- !is.na(ip) + # now we're ready to go + tp.new <- thermo$protein + if(!all(ipdup)) tp.new <- rbind(tp.new, aa[!ipdup, ]) + if(any(ipdup)) { + if(any(sapply(1:4, function(i){is.factor(aa[, i])}))) + stop(paste("converting factors causes problems replacing protein data", + " data file should be read using e.g. aa <- read.csv(file, stringsAsFactors=FALSE)", sep="\n")) + tp.new[ip[ipdup], ] <- aa[ipdup, ] + } + rownames(tp.new) <- NULL + thermo$protein <- tp.new + assign("thermo", thermo, "CHNOSZ") + # return the new rownumbers + ip <- protein.info(po) + # make some noise + if(!all(ipdup)) message("add.protein: added ", nrow(aa)-sum(ipdup), " new protein(s) to thermo$protein") + if(any(ipdup)) message("add.protein: replaced ", sum(ipdup), " existing protein(s) in thermo$protein") + return(ip) +} Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/examples.R 2017-02-20 11:27:11 UTC (rev 166) @@ -11,7 +11,7 @@ "util.misc", "util.program", "util.seq", "util.units", "taxonomy", "info", "protein.info", "hkf", "water", "subcrt", "makeup", "basis", "swap.basis", "species", "affinity", "util.affinity", "equil.boltzmann", - "diagram", "buffer", "iprotein", "protein", "ionize.aa", "more.aa", "read.expr", + "diagram", "buffer", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr", "objective", "revisit", "transfer", "anim", "EOSregress", "wjd") plot.it <- FALSE if(is.character(do.png)) Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/info.R 2017-02-20 11:27:11 UTC (rev 166) @@ -31,7 +31,7 @@ # since thermo$obigt$abbrv contains NAs, convert NA results to FALSE matches.species[is.na(matches.species)] <- FALSE # turn it in to no match if it's a protein in the wrong state - ip <- suppressMessages(iprotein(species)) + ip <- suppressMessages(protein.info(species)) if(any(matches.species) & !is.na(ip) & !is.null(state)) { matches.state <- matches.species & grepl(state, thermo$obigt$state) if(!any(matches.state)) matches.species <- FALSE Deleted: pkg/CHNOSZ/R/iprotein.R =================================================================== --- pkg/CHNOSZ/R/iprotein.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/iprotein.R 2017-02-20 11:27:11 UTC (rev 166) @@ -1,191 +0,0 @@ -# CHNOSZ/iprotein.R -# calculate properties of proteins 20061109 jmd -# reorganize protein functions 20120513 - -# iprotein - find rownumber in thermo$protein -# ip2aa - select amino acid counts (data frame) from thermo$protein -# aa2eos - perform group additivity calculations -# seq2aa - calculate amino acid counts from a sequence -# aasum - combine amino acid counts (sum, average, or weighted sum by abundance) -# read.aa - read amino acid counts from a file -# add.protein - add amino acid counts to thermo$protein (returns iprotein) - -iprotein <- function(protein, organism=NULL) { - # find the rownumber(s) of thermo$protein that matches - # 'protein' numeric (the rownumber itself) - # 'protein' character, e.g. LYSC_CHICK - # 'protein' and 'organism', e.g. 'LYSC', 'CHICK' - thermo <- get("thermo") - if(is.numeric(protein)) { - iproteins <- 1:nrow(thermo$protein) - protein[!protein %in% iproteins] <- NA - iprotein <- protein - } else { - # from here we'll search by protein/organism pairs - tp.po <- paste(thermo$protein$protein, thermo$protein$organism, sep="_") - if(is.null(organism)) my.po <- protein - else my.po <- paste(protein, organism, sep="_") - iprotein <- match(my.po, tp.po) - } - # tell the user about NA's - if(any(is.na(iprotein))) { - nNA <- sum(is.na(iprotein)) - if(nNA==1) ptext <- "" else ptext <- "s" - message("iprotein: ", sum(is.na(iprotein)), " protein", ptext, " not matched") - } - return(iprotein) -} - -ip2aa <- function(protein, organism=NULL, residue=FALSE) { - # return amino acid counts (rows from thermo$protein) - # or 'protein' if it is a data frame - if(is.data.frame(protein)) return(protein) - iprotein <- iprotein(protein, organism) - # drop NA matches - iprotein <- iprotein[!is.na(iprotein)] - out <- get("thermo")$protein[iprotein, ] - # compute per-residue counts - if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) - return(out) -} - -aa2eos <- function(aa, state=get("thermo")$opt$state) { - # display and return the properties of - # proteins calculated from amino acid composition - # the names of the protein backbone groups depend on the state - # [UPBB] for aq or [PBB] for cr - if(state=="aq") bbgroup <- "UPBB" else bbgroup <- "PBB" - # names of the AABB, sidechain and protein backbone groups - groups <- c("AABB", colnames(aa)[6:25], bbgroup) - # put brackets around the group names - groups <- paste("[", groups, "]", sep="") - # the rownumbers of the groups in thermo$obigt - groups_state <- paste(groups, state) - obigt <- get("thermo")$obigt - obigt_state <- paste(obigt$name, obigt$state) - igroup <- match(groups_state, obigt_state) - # the properties are in columns 8-20 of thermo$obigt - groupprops <- obigt[igroup, 8:20] - # the elements in each of the groups - groupelements <- i2A(igroup) - # a function to work on a single row of aa - eosfun <- function(aa) { - # numbers of groups: chains [=AABB], sidechains, protein backbone - nchains <- as.numeric(aa[, 5]) - length <- sum(as.numeric(aa[, 6:25])) - npbb <- length - nchains - ngroups <- c(nchains, as.numeric(aa[, 6:25]), npbb) - # the actual adding and multiplying of thermodynamic properties - # hmm. seems like we have to split up the multiplication/transposition - # operations to get the result into multiple columns. 20071213 - eos <- t(data.frame(colSums(groupprops * ngroups))) - # to get the formula, add up and round the group compositions 20090331 - f.in <- round(colSums(groupelements * ngroups), 3) - # take out any elements that don't appear (sometimes S) - f.in <- f.in[f.in!=0] - # turn it into a formula - f <- as.chemical.formula(f.in) - # now the species name - name <- paste(aa$protein, aa$organism, sep="_") - # make some noise for the user - message("aa2eos: found ", appendLF=FALSE) - message(name, " (", f, ", ", appendLF=FALSE) - message(round(length, 3), " residues)") - ref <- aa$ref - header <- data.frame(name=name, abbrv=NA, formula=f, state=state, ref1=ref, ref2=NA, date=NA, stringsAsFactors=FALSE) - eosout <- cbind(header, eos) - return(eosout) - } - # loop over each row of aa - out <- lapply(1:nrow(aa), function(i) eosfun(aa[i, ])) - out <- do.call(rbind, out) - rownames(out) <- NULL - return(out) -} - -seq2aa <- function(protein, sequence) { - # remove newlines and whitespace - sequence <- gsub("\\s", "", gsub("[\r\n]", "", sequence)) - # make a data frame from counting the amino acids in the sequence - caa <- count.aa(sequence) - colnames(caa) <- aminoacids(3) - # a protein with no amino acids is sort of boring - if(all(caa==0)) stop("no characters match an amino acid") - ip <- suppressMessages(iprotein(protein)) - # now make the data frame - po <- strsplit(protein, "_")[[1]] - aa <- data.frame(protein=po[1], organism=po[2], ref=NA, abbrv=NA, stringsAsFactors=FALSE) - aa <- cbind(aa, chains=1, caa) - return(aa) -} - -aasum <- function(aa, abundance=1, average=FALSE, protein=NULL, organism=NULL) { - # returns the sum of the amino acid counts in aa, - # multiplied by the abundances of the proteins - abundance <- rep(abundance, length.out=nrow(aa)) - # drop any NA rows or abundances - ina.aa <- is.na(aa$chains) - ina.ab <- is.na(abundance) - ina <- ina.aa | ina.ab - if(any(ina)) { - aa <- aa[!ina, ] - abundance <- abundance[!ina] - message("aasum: dropped ", sum(ina), " proteins with NA composition and/or abundance") - } - # we don't know how to deal with different numbers of polypeptide chains - if(!all(aa$chains==aa$chains[1])) stop("different numbers of polypeptide chains") - # multiply - aa[, 6:25] <- aa[, 6:25] * abundance - # sum - out <- aa[1, ] - out[, 5:25] <- colSums(aa[, 5:25]) - # average if told to do so - if(average) { - # polypeptide chains by number of proteins, residues by frequence - out[, 5] <- out[, 5]/nrow(aa) - out[, 6:25] <- out[, 6:25]/sum(abundance) - } - # add protein and organism names if given - if(!is.null(protein)) out$protein <- protein - if(!is.null(organism)) out$organism <- organism - return(out) -} - -read.aa <- function(file="protein.csv", ...) { - # 20090428 added colClasses here - # 20140128 added as.is=TRUE (in case numeric values are stored in ref or abbrv column) - aa <- read.csv(file, colClasses=c(rep("character", 2), NA, NA, rep("numeric", 21)), as.is=TRUE, ...) - if(!identical(colnames(aa), colnames(get("thermo")$protein))) - stop(paste("format of", file, "is incompatible with thermo$protein")) - return(aa) -} - -add.protein <- function(aa) { - # add a properly constructed data frame of - # amino acid counts to thermo$protein - thermo <- get("thermo") - if(!identical(colnames(aa), colnames(thermo$protein))) - stop("the value of 'aa' is not a data frame with the same columns as thermo$protein") - # find any protein IDs that are duplicated - po <- paste(aa$protein, aa$organism, sep="_") - ip <- suppressMessages(iprotein(po)) - ipdup <- !is.na(ip) - # now we're ready to go - tp.new <- thermo$protein - if(!all(ipdup)) tp.new <- rbind(tp.new, aa[!ipdup, ]) - if(any(ipdup)) { - if(any(sapply(1:4, function(i){is.factor(aa[, i])}))) - stop(paste("converting factors causes problems replacing protein data", - " data file should be read using e.g. aa <- read.csv(file, stringsAsFactors=FALSE)", sep="\n")) - tp.new[ip[ipdup], ] <- aa[ipdup, ] - } - rownames(tp.new) <- NULL - thermo$protein <- tp.new - assign("thermo", thermo, "CHNOSZ") - # return the new rownumbers - ip <- iprotein(po) - # make some noise - if(!all(ipdup)) message("add.protein: added ", nrow(aa)-sum(ipdup), " new protein(s) to thermo$protein") - if(any(ipdup)) message("add.protein: replaced ", sum(ipdup), " existing protein(s) in thermo$protein") - return(ip) -} Modified: pkg/CHNOSZ/R/protein.info.R =================================================================== --- pkg/CHNOSZ/R/protein.info.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/protein.info.R 2017-02-20 11:27:11 UTC (rev 166) @@ -2,12 +2,38 @@ # calculate formulas and summarize properties of proteins # MP90.cp: additive heat capacity from groups of Makhatadze and Privalov, 1990 # group.formulas: chemical makeup of the amino acid residues +# protein.info: find rownumber in thermo$protein # protein.formula: chemical makeup of the indicated proteins # protein.length: lengths of the indicated proteins -# protein.info: summarize properties of proteins # protein.basis: coefficients of basis species in formation reactions of [ionized] proteins [residues] # protein.equil: step-by-step example of protein equilibrium calculation +protein.info <- function(protein, organism=NULL) { + # find the rownumber(s) of thermo$protein that matches + # 'protein' numeric (the rownumber itself) + # 'protein' character, e.g. LYSC_CHICK + # 'protein' and 'organism', e.g. 'LYSC', 'CHICK' + thermo <- get("thermo") + if(is.numeric(protein)) { + iproteins <- 1:nrow(thermo$protein) + protein[!protein %in% iproteins] <- NA + iprotein <- protein + } else { + # from here we'll search by protein/organism pairs + tp.po <- paste(thermo$protein$protein, thermo$protein$organism, sep="_") + if(is.null(organism)) my.po <- protein + else my.po <- paste(protein, organism, sep="_") + iprotein <- match(my.po, tp.po) + } + # tell the user about NA's + if(any(is.na(iprotein))) { + nNA <- sum(is.na(iprotein)) + if(nNA==1) ptext <- "" else ptext <- "s" + message("iprotein: ", sum(is.na(iprotein)), " protein", ptext, " not matched") + } + return(iprotein) +} + MP90.cp <- function(protein, T) { # T (temperature, degrees C), protein (name of protein) # returns heat capacity of protein (kj/mol) @@ -49,7 +75,6 @@ return(cnew) } - group.formulas <- function() { # return a matrix with chemical formulas of residues # names of the sidechain groups @@ -84,56 +109,6 @@ return(pl) } -protein.info <- function(protein, T=25, residue=FALSE, round.it=FALSE) { - # make a table of selected properties for proteins - # listed in protein - aa <- ip2aa(protein) - pname <- paste(aa$protein, aa$organism, sep="_") - length <- protein.length(aa) - pf <- protein.formula(aa) - G <- unlist(subcrt(pname, T=T, property="G")$out) - Z <- rep(NA, length(pname)) - G.Z <- rep(NA, length(pname)) - ZC <- ZC(pf) - # run ionization calculations if we have H+ - thermo <- get("thermo") - if(!is.null(thermo$basis)) { - iHplus <- match("H+", rownames(thermo$basis)) - if(!is.na(iHplus)) { - pH <- -thermo$basis$logact[iHplus] - Z <- ionize.aa(aa, T=T, pH=pH)[1, ] - G.ionization <- ionize.aa(aa, T=T, pH=pH, property="G")[1, ] - G.Z <- G + G.ionization - # add charge to the chemical formulas - pf <- cbind(pf, Z) - iH <- match("H", colnames(pf)) - pf[, iH] <- pf[, iH] + Z - } - } - # take care of residue conversion - if(residue) { - pf <- pf / length - G <- G / length - Z <- Z / length - G.Z <- G.Z / length - length <- length / length - # round the coefficients in the formulas - if(round.it) pf <- round(pf, 3) - } - # convert each protein formula to a single line - formula <- as.chemical.formula(round(pf, 3)) - if(round.it) { - length <- round(length, 1) - G <- round(G, 3) - Z <- round(Z, 3) - G.Z <- round(G.Z, 3) - ZC <- round(ZC, 3) - } - out <- data.frame(protein=pname, length=length, formula=formula, G=G, Z=Z, G.Z=G.Z, ZC=ZC, stringsAsFactors=FALSE) - rownames(out) <- NULL - return(out) -} - protein.basis <- function(protein, T=25, normalize=FALSE) { # 20090902 calculate the coefficients of basis species in reactions # to form proteins (possibly per normalized by length) listed in protein Modified: pkg/CHNOSZ/R/util.affinity.R =================================================================== --- pkg/CHNOSZ/R/util.affinity.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/util.affinity.R 2017-02-20 11:27:11 UTC (rev 166) @@ -162,7 +162,7 @@ isprotein <- grepl("_", myspecies$name) if(any(isprotein)) { # the rownumbers in thermo$protein - ip <- iprotein(myspecies$name[isprotein]) + ip <- protein.info(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 Modified: pkg/CHNOSZ/R/util.expression.R =================================================================== --- pkg/CHNOSZ/R/util.expression.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/R/util.expression.R 2017-02-20 11:27:11 UTC (rev 166) @@ -7,6 +7,8 @@ # that include subscripts, superscripts (if charged) # and optionally designations of states +/- loga or logf prefix if(length(species) > 1) (stop("more than one species")) + # convert to character so that "1", "2", etc. don't get converted to chemical formulas via makeup() + species <- as.character(species) # the counts of elements in the species: # here we don't care too much if an "element" is a real element # (listed in thermo$element), so we suppress warnings Modified: pkg/CHNOSZ/demo/bugstab.R =================================================================== --- pkg/CHNOSZ/demo/bugstab.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/demo/bugstab.R 2017-02-20 11:27:11 UTC (rev 166) @@ -2,13 +2,14 @@ # based on "bugstab" function in Supporting Information of Dick, 2016 # (http://dx.doi.org/10.7717/peerj.2238) +# set up graphics device +layout(cbind(matrix(sapply(list(c(1, 2), c(3, 4)), function(x) rep(rep(x, each=3), 3)), nrow=6, byrow=TRUE), + matrix(rep(c(0, 5, 5, 5, 5, 0), each=4), nrow=6, byrow=TRUE))) +opar <- par(mar=c(3.3, 3.3, 1.5, 1.5), mgp=c(2.1, 0.7, 0), xaxs="i", yaxs="i", las=1, cex=0.9) # resolution for plots res <- 500 # basis can be "QEC" or "CHNOS" basis <- "QEC" -layout(cbind(matrix(sapply(list(c(1, 2), c(3, 4)), function(x) rep(rep(x, each=3), 3)), nrow=6, byrow=TRUE), - matrix(rep(c(0, 5, 5, 5, 5, 0), each=4), nrow=6, byrow=TRUE))) -par(mar=c(3.3, 3.3, 1.5, 1.5), mgp=c(2.1, 0.7, 0), xaxs="i", yaxs="i", las=1, cex=0.9) # read bioproject ids, species names mfile <- system.file("extdata/abundance/microbes.csv", package="CHNOSZ") bugs <- read.csv(mfile, as.is=TRUE) @@ -65,3 +66,7 @@ title(main="Cumulative stability count") box() label.figure("E", yfrac=0.96, paren=FALSE, font=2, cex=1) + +# reset graphics device to default +par(opar) +layout(1) Modified: pkg/CHNOSZ/demo/protein.equil.R =================================================================== --- pkg/CHNOSZ/demo/protein.equil.R 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/demo/protein.equil.R 2017-02-20 11:27:11 UTC (rev 166) @@ -1,6 +1,6 @@ ## steps in calculation of chemical activities of two proteins ## in metastable equilibrium, after Dick and Shock, 2011 -protein <- iprotein(c("CSG_METVO", "CSG_METJA")) +protein <- protein.info(c("CSG_METVO", "CSG_METJA")) # clear out amino acid residues loaded by the example above # ( in affinity(iprotein=ip) ) data(thermo) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/inst/NEWS 2017-02-20 11:27:11 UTC (rev 166) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-55 (2017-02-19) +CHANGES IN CHNOSZ 1.0.8-56 (2017-02-20) --------------------------------------- DOCUMENTATION: @@ -118,6 +118,9 @@ - Rename browse.refs() to thermo.refs(); remove URL browsing (except for summary table). +- Rename iprotein() to protein.info(), replacing the previous function + of the same name. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Copied: pkg/CHNOSZ/man/add.protein.Rd (from rev 165, pkg/CHNOSZ/man/iprotein.Rd) =================================================================== --- pkg/CHNOSZ/man/add.protein.Rd (rev 0) +++ pkg/CHNOSZ/man/add.protein.Rd 2017-02-20 11:27:11 UTC (rev 166) @@ -0,0 +1,86 @@ +\name{add.protein} +\alias{ip2aa} +\alias{aa2eos} +\alias{seq2aa} +\alias{aasum} +\alias{read.aa} +\alias{add.protein} +\title{Amino Acid Compositions of Proteins} +\description{ + Functions to identify proteins, get and set amino acid compositions, and calculate thermodynamic properties from group additivity. +} + +\usage{ + ip2aa(protein, organism=NULL, residue=FALSE) + aa2eos(aa, state=get("thermo")$opt$state) + seq2aa(protein, sequence) + aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) + read.aa(file = "protein.csv", ...) + add.protein(aa) +} + +\arguments{ + \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}$protein})} + \item{organism}{character, name of organism} + \item{residue}{logical, compute per-residue counts?} + \item{aa}{data frame, amino acid composition in the format of \code{thermo$protein}} + \item{state}{character, physical state} + \item{sequence}{character, protein sequence} + \item{abundance}{numeric, abundances of proteins} + \item{average}{logical, return the weighted average of amino acid counts?} + \item{file}{character, path to file with amino acid compositions} + \item{...}{additional arguments passed to \code{\link{read.csv}}} +} + +\details{ + A \samp{protein} in CHNOSZ is defined by a name and by the counts of amino acids, stored in \code{\link{thermo}$protein}. The purpose of the functions described here is to identify proteins and work with their amino acid compositions. From the amino acid compositions, the thermodynamic properties of the proteins can be estimated (Dick et al., 2006) for use in other functions in the package. + + Often, the names of proteins are sufficient to set up calculations using functions such as \code{\link{subcrt}} or \code{\link{species}}. The names of proteins in CHNOSZ are distinguished from those of other chemical species by having an underscore character ("_") that separates two identifiers, referred to as the \code{protein} and \code{organism} (but any other meaning can be attached to these names). An example is \samp{LYSC_CHICK}. + + The first few functions provide low-level operations: + + \code{ip2aa} returns the row(s) of \code{thermo$protein} that match the supplied protein names, OR the protein indices found by \code{iprotin}. Set \code{residue} to TRUE to return the per-residue composition (i.e. amino acid composition of the protein divided by total number of residues). For this function only, if the \code{protein} argument is a data frame, it is returned unchanged, except for possibly the per-residue calculation. + + \code{aa2eos} calculates the thermodynamic properties and equations-of-state parameters for the completely nonionized proteins using group additivity with parameters taken from Dick et al., 2006 (aqueous proteins) and LaRowe and Dick, 2012 (crystalline proteins and revised aqueous methionine sidechain group). The return value is a data frame in the same format as \code{thermo$obigt}. \code{state} indicates the physical state for the parameters used in the calculation (\samp{aq} or \samp{cr}). + + The remaining functions are more likely to be called directly by the user: + + \code{seq2aa} returns a data frame of amino acid composition, in the format of \code{thermo$protein}, corresponding to the provided \code{sequence}. Here, the \code{protein} argument indicates the name of the protein with an underscore (e.g. \samp{LYSC_CHICK}). + + \code{aasum} returns a data frame representing the sum of amino acid compositions in the rows of the input \code{aa} data frame. The amino acid compositions are multiplied by the indicated \code{abundance}; that argument is recycled to match the number of rows of \code{aa}. If \code{average} is TRUE the final sum is divided by the number of input compositions. The name used in the output is taken from the first row of \code{aa} or from \code{protein} and \code{organism} if they are specified. This function is useful for calculating bulk amino acid compositions in stress response experiments or localization studies; see \code{\link{read.expr}} for examples of its use. + +\code{read.aa} returns a data frame of amino acid composition based on the contents of the indicated \code{file}, which should be a CSV file with the same column names as \code{thermo$protein}. + +\code{add.protein} completes the loop; any amino acid composition returned by the \code{*aa} functions described above can be added to \code{thermo$protein} using this function to be made available to other functions in the package. +The amino acid compositions of proteins in \code{aa} with the same name as one in \code{thermo$protein} are replaced. +The value returned by this function is the rownumbers of \code{thermo$protein} that are added and/or replaced. + +} + +\examples{ +\dontshow{data(thermo)} +# manually adding a new protein +# Human Gastric juice peptide 1 +aa <- seq2aa("GAJU_HUMAN", "LAAGKVEDSD") +ip <- add.protein(aa) +stopifnot(protein.length(ip)==10) +# the chemical formula of this peptide +stopifnot(as.chemical.formula(protein.formula(ip))=="C41H69N11O18") +# we can also calculate a formula without using add.protein +as.chemical.formula(protein.formula(seq2aa("pentapeptide_test", "ANLSG"))) +} + +\seealso{ +\code{\link{read.fasta}} and \code{\link{uniprot.aa}} for getting amino acid compositions from a FASTA file or downloading them from UniProt, and \code{\link{more.aa}} for getting amino acid compositions for model organisms from additional data files in the \code{\link{extdata}/protein} directory. + +\code{\link{protein.info}} for protein-level functions (chemical formulas, summaries of reaction coefficients and energies), and \code{\link{read.expr}} for working with protein abundance and subcellular localization data. + +Examples of stability calculations for proteins are in \code{\link{protein}}. +} + +\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. \emph{Biogeosciences} \bold{3}, 311--336. \url{http://dx.doi.org/10.5194/bg-3-311-2006} + +} + +\concept{Protein thermodynamic modeling} Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-02-19 15:26:25 UTC (rev 165) +++ pkg/CHNOSZ/man/data.Rd 2017-02-20 11:27:11 UTC (rev 166) @@ -166,7 +166,7 @@ } \item \code{thermo$protein} - Data frame of amino acid compositions of selected proteins. Many of the compositions were taken from the SWISS-PROT/UniProt online database (Boeckmann et al., 2003) and the protein and organism names usually follow the conventions adopted there. In some cases different isoforms of proteins are identified using modifications of the protein names; for example, \samp{MOD5.M} and \code{MOD5.N} proteins of \samp{YEAST} denote the mitochondrial and nuclear isoforms of this protein. See \code{\link{iprotein}} to search this data frame by protein name, and other functions to work with the amino acid compositions. + Data frame of amino acid compositions of selected proteins. Many of the compositions were taken from the SWISS-PROT/UniProt online database (Boeckmann et al., 2003) and the protein and organism names usually follow the conventions adopted there. In some cases different isoforms of proteins are identified using modifications of the protein names; for example, \samp{MOD5.M} and \code{MOD5.N} proteins of \samp{YEAST} denote the mitochondrial and nuclear isoforms of this protein. See \code{\link{protein.info}} to search this data frame by protein name, and other functions to work with the amino acid compositions. \tabular{lll}{ \code{protein} \tab character \tab Identification of protein\cr [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 166 From noreply at r-forge.r-project.org Mon Feb 20 13:27:25 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 20 Feb 2017 13:27:25 +0100 (CET) Subject: [CHNOSZ-commits] r167 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes Message-ID: <20170220122725.51123186D91@r-forge.r-project.org> Author: jedick Date: 2017-02-20 13:27:24 +0100 (Mon, 20 Feb 2017) New Revision: 167 Added: pkg/CHNOSZ/R/util.protein.R pkg/CHNOSZ/man/util.protein.Rd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/add.protein.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/protein.info.R pkg/CHNOSZ/R/util.affinity.R pkg/CHNOSZ/demo/ionize.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/man/info.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/tests/testthat/test-add.protein.R pkg/CHNOSZ/tests/testthat/test-ionize.aa.R pkg/CHNOSZ/tests/testthat/test-util.affinity.R pkg/CHNOSZ/vignettes/anintro.Rmd Log: merge ip2aa() with protein.info() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-20 12:27:24 UTC (rev 167) @@ -1,6 +1,6 @@ Date: 2017-02-20 Package: CHNOSZ -Version: 1.0.8-56 +Version: 1.0.8-57 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/add.protein.R =================================================================== --- pkg/CHNOSZ/R/add.protein.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/R/add.protein.R 2017-02-20 12:27:24 UTC (rev 167) @@ -3,25 +3,11 @@ # reorganize protein functions 20120513 # add.protein - add amino acid counts to thermo$protein (returns iprotein) -# ip2aa - select amino acid counts (data frame) from thermo$protein # aa2eos - perform group additivity calculations # seq2aa - calculate amino acid counts from a sequence # aasum - combine amino acid counts (sum, average, or weighted sum by abundance) # read.aa - read amino acid counts from a file -ip2aa <- function(protein, organism=NULL, residue=FALSE) { - # return amino acid counts (rows from thermo$protein) - # or 'protein' if it is a data frame - if(is.data.frame(protein)) return(protein) - iprotein <- protein.info(protein, organism) - # drop NA matches - iprotein <- iprotein[!is.na(iprotein)] - out <- get("thermo")$protein[iprotein, ] - # compute per-residue counts - if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) - return(out) -} - aa2eos <- function(aa, state=get("thermo")$opt$state) { # display and return the properties of # proteins calculated from amino acid composition Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/R/info.R 2017-02-20 12:27:24 UTC (rev 167) @@ -45,7 +45,7 @@ # here we use a default state from thermo$opt$state if(is.null(state)) state <- thermo$opt$state # retrieve the amino acid composition - aa <- ip2aa(ip) + aa <- protein.info(ip) # add up protein properties eos <- aa2eos(aa, state) # the real assignment work Modified: pkg/CHNOSZ/R/protein.info.R =================================================================== --- pkg/CHNOSZ/R/protein.info.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/R/protein.info.R 2017-02-20 12:27:24 UTC (rev 167) @@ -1,99 +1,52 @@ -# CHNOSZ/util.protein.R +# CHNOSZ/protein.info.R + # calculate formulas and summarize properties of proteins -# MP90.cp: additive heat capacity from groups of Makhatadze and Privalov, 1990 -# group.formulas: chemical makeup of the amino acid residues # protein.info: find rownumber in thermo$protein # protein.formula: chemical makeup of the indicated proteins # protein.length: lengths of the indicated proteins # protein.basis: coefficients of basis species in formation reactions of [ionized] proteins [residues] # protein.equil: step-by-step example of protein equilibrium calculation -protein.info <- function(protein, organism=NULL) { - # find the rownumber(s) of thermo$protein that matches - # 'protein' numeric (the rownumber itself) - # 'protein' character, e.g. LYSC_CHICK - # 'protein' and 'organism', e.g. 'LYSC', 'CHICK' +protein.info <- function(protein, organism=NULL, residue=FALSE) { + # return the `protein` (possibly per residue) for: + # dataframe `protein` + # return the rownumber(s) of thermo$protein for: + # character `protein`, e.g. LYSC_CHICK + # character `protein` and `organism`, e.g. 'LYSC', 'CHICK' + # return the row(s) of thermo$protein (possibly per residue) for: + # numeric `protein` (the rownumber itself) thermo <- get("thermo") + if(is.data.frame(protein)) out <- protein if(is.numeric(protein)) { + # drop NA matches to thermo$protein iproteins <- 1:nrow(thermo$protein) protein[!protein %in% iproteins] <- NA - iprotein <- protein + # get amino acid counts + out <- thermo$protein[protein, ] + } + if(is.data.frame(protein) | is.numeric(protein)) { + # compute per-residue counts if requested + if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) } else { # from here we'll search by protein/organism pairs tp.po <- paste(thermo$protein$protein, thermo$protein$organism, sep="_") if(is.null(organism)) my.po <- protein else my.po <- paste(protein, organism, sep="_") iprotein <- match(my.po, tp.po) + # tell the user about NA's + if(any(is.na(iprotein))) { + nNA <- sum(is.na(iprotein)) + if(nNA==1) ptext <- "" else ptext <- "s" + message("iprotein: ", sum(is.na(iprotein)), " protein", ptext, " not matched") + } + out <- iprotein } - # tell the user about NA's - if(any(is.na(iprotein))) { - nNA <- sum(is.na(iprotein)) - if(nNA==1) ptext <- "" else ptext <- "s" - message("iprotein: ", sum(is.na(iprotein)), " protein", ptext, " not matched") - } - return(iprotein) + out } -MP90.cp <- function(protein, T) { - # T (temperature, degrees C), protein (name of protein) - # returns heat capacity of protein (kj/mol) - # using algorithm of makhatadze and privalov, 1990. - TMP <- c(5,25,50,75,100,125) - A.cp <- splinefun(TMP,c(175.7,166.7,156.2,144.7,134.6,124.1)) - C.cp <- splinefun(TMP,c(225.4,237.6,250.8,260.7,268.2,276.1)) - D.cp <- splinefun(TMP,c( 72.8, 89.0,106.2,124.5,140.7,154.3)) - E.cp <- splinefun(TMP,c(168.3,179.0,192.0,203.7,211.4,217.8)) - F.cp <- splinefun(TMP,c(395.7,383.0,370.3,358.4,348.3,339.6)) - G.cp <- splinefun(TMP,c( 82.3, 78.0, 71.7, 66.4, 59.7, 53.9)) - H.cp <- splinefun(TMP,c(205.7,179.6,177.2,179.6,187.1,196.8)) - I.cp <- splinefun(TMP,c(406.8,402.3,397.1,390.8,386.0,380.8)) - K.cp <- splinefun(TMP,c(328.8,332.5,334.0,337.5,339.4,343.6)) - L.cp <- splinefun(TMP,c(385.9,381.7,377.8,372.9,369.4,365.5)) - M.cp <- splinefun(TMP,c(197.1,175.9,158.1,150.3,148.1,143.9)) - N.cp <- splinefun(TMP,c( 72.9, 88.8,109.8,125.2,140.5,154.2)) - P.cp <- splinefun(TMP,c(214.6,177.7,152.3,142.8,135.6,130.1)) - Q.cp <- splinefun(TMP,c(168.0,180.2,193.4,203.3,210.8,218.7)) - R.cp <- splinefun(TMP,c(204.6,273.4,305.8,315.1,318.7,318.5)) - S.cp <- splinefun(TMP,c( 75.6, 81.2, 85.7, 91.4, 97.3,102.1)) - T.cp <- splinefun(TMP,c(194.2,184.5,182.2,186.5,199.0,216.2)) - V.cp <- splinefun(TMP,c(324.6,314.4,305.0,294.7,285.7,269.6)) - W.cp <- splinefun(TMP,c(471.2,458.5,445.8,433.9,423.8,415.1)) - Y.cp <- splinefun(TMP,c(310.6,301.7,295.2,294.5,300.1,304.0)) - AA.cp <- splinefun(TMP,c(-158.3,-90.4,-21.5,-32.3,-92.4,-150.0)) - UPBB.cp <- splinefun(TMP,c(3.7,15.2,26.2,29.8,33.7,33.7)) - cnew <- numeric() - for(i in 1:length(T)) { - Ti <- T[i] - cp <- c(A.cp(Ti),C.cp(Ti),D.cp(Ti),E.cp(Ti),F.cp(Ti), - G.cp(Ti),H.cp(Ti),I.cp(Ti),K.cp(Ti),L.cp(Ti), - M.cp(Ti),N.cp(Ti),P.cp(Ti),Q.cp(Ti),R.cp(Ti), - S.cp(Ti),T.cp(Ti),V.cp(Ti),W.cp(Ti),Y.cp(Ti)) - # get the protein composition - tt <- ip2aa(protein)[,6:25] - cnew <- c(cnew, sum(cp * as.numeric(tt)) + sum(as.numeric(tt)) * UPBB.cp(Ti)) - } - return(cnew) -} - -group.formulas <- function() { - # return a matrix with chemical formulas of residues - # names of the sidechain groups - groups <- paste("[", aminoacids(3), "]", sep="") - # the indices of H2O, sidechain groups, and [UPBB] - ig <- suppressMessages(info(c("H2O", groups, "[UPBB]"))) - # their formulas - A <- i2A(ig) - # add [UPBB] to the sidechain groups to get residues - out <- A[1:21,] - out[2:21,] <- t(t(A) + A[22,])[2:21,] - # make "H2O" not "water" - rownames(out)[1] <- "H2O" - return(out) -} - protein.formula <- function(protein, organism=NULL, residue=FALSE) { # return a matrix with chemical formulas of proteins - aa <- ip2aa(protein, organism) + aa <- protein.info(protein.info(protein, organism)) rf <- group.formulas() out <- as.matrix(aa[, 5:25]) %*% as.matrix(rf) if(residue) out <- out / rowSums(aa[, 6:25]) @@ -103,7 +56,7 @@ protein.length <- function(protein, organism=NULL) { # calculate the length(s) of proteins - aa <- ip2aa(protein, organism) + aa <- protein.info(protein.info(protein, organism)) # use rowSums on the columns containing amino acid counts pl <- as.numeric(rowSums(aa[, 6:25])) return(pl) @@ -114,7 +67,7 @@ # to form proteins (possibly per normalized by length) listed in protein # 20120528 renamed protein.basis from residue.info ... # what are the elemental compositions of the proteins - aa <- ip2aa(protein) + aa <- protein.info(protein.info(protein)) pf <- protein.formula(aa) # what are the coefficients of the basis species in the formation reactions sb <- species.basis(pf) @@ -141,7 +94,7 @@ message("protein.equil: temperature from argument is ", T, " degrees C") TK <- convert(T, "K") # get the amino acid compositions of the proteins - aa <- ip2aa(protein) + aa <- protein.info(protein.info(protein)) # get some general information about the proteins pname <- paste(aa$protein, aa$organism, sep="_") plength <- protein.length(aa) Modified: pkg/CHNOSZ/R/util.affinity.R =================================================================== --- pkg/CHNOSZ/R/util.affinity.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/R/util.affinity.R 2017-02-20 12:27:24 UTC (rev 167) @@ -420,7 +420,7 @@ # initialize output list out <- vector("list", length(iprotein)) # get aa from iprotein - aa <- ip2aa(iprotein) + aa <- protein.info(iprotein) # calculate the values of A/2.303RT as a function of T-P-pH A <- ionize.aa(aa=aa, property="A", T=TPpH$T, P=TPpH$P, pH=TPpH$pH) if(transect) { Added: pkg/CHNOSZ/R/util.protein.R =================================================================== --- pkg/CHNOSZ/R/util.protein.R (rev 0) +++ pkg/CHNOSZ/R/util.protein.R 2017-02-20 12:27:24 UTC (rev 167) @@ -0,0 +1,60 @@ +# CHNOSZ/util.protein.R +# MP90.cp: additive heat capacity from groups of Makhatadze and Privalov, 1990 +# group.formulas: chemical makeup of the amino acid residues + +MP90.cp <- function(protein, T) { + # T (temperature, degrees C), protein (name of protein) + # returns heat capacity of protein (kj/mol) + # using algorithm of makhatadze and privalov, 1990. + TMP <- c(5,25,50,75,100,125) + A.cp <- splinefun(TMP,c(175.7,166.7,156.2,144.7,134.6,124.1)) + C.cp <- splinefun(TMP,c(225.4,237.6,250.8,260.7,268.2,276.1)) + D.cp <- splinefun(TMP,c( 72.8, 89.0,106.2,124.5,140.7,154.3)) + E.cp <- splinefun(TMP,c(168.3,179.0,192.0,203.7,211.4,217.8)) + F.cp <- splinefun(TMP,c(395.7,383.0,370.3,358.4,348.3,339.6)) + G.cp <- splinefun(TMP,c( 82.3, 78.0, 71.7, 66.4, 59.7, 53.9)) + H.cp <- splinefun(TMP,c(205.7,179.6,177.2,179.6,187.1,196.8)) + I.cp <- splinefun(TMP,c(406.8,402.3,397.1,390.8,386.0,380.8)) + K.cp <- splinefun(TMP,c(328.8,332.5,334.0,337.5,339.4,343.6)) + L.cp <- splinefun(TMP,c(385.9,381.7,377.8,372.9,369.4,365.5)) + M.cp <- splinefun(TMP,c(197.1,175.9,158.1,150.3,148.1,143.9)) + N.cp <- splinefun(TMP,c( 72.9, 88.8,109.8,125.2,140.5,154.2)) + P.cp <- splinefun(TMP,c(214.6,177.7,152.3,142.8,135.6,130.1)) + Q.cp <- splinefun(TMP,c(168.0,180.2,193.4,203.3,210.8,218.7)) + R.cp <- splinefun(TMP,c(204.6,273.4,305.8,315.1,318.7,318.5)) + S.cp <- splinefun(TMP,c( 75.6, 81.2, 85.7, 91.4, 97.3,102.1)) + T.cp <- splinefun(TMP,c(194.2,184.5,182.2,186.5,199.0,216.2)) + V.cp <- splinefun(TMP,c(324.6,314.4,305.0,294.7,285.7,269.6)) + W.cp <- splinefun(TMP,c(471.2,458.5,445.8,433.9,423.8,415.1)) + Y.cp <- splinefun(TMP,c(310.6,301.7,295.2,294.5,300.1,304.0)) + AA.cp <- splinefun(TMP,c(-158.3,-90.4,-21.5,-32.3,-92.4,-150.0)) + UPBB.cp <- splinefun(TMP,c(3.7,15.2,26.2,29.8,33.7,33.7)) + cnew <- numeric() + for(i in 1:length(T)) { + Ti <- T[i] + cp <- c(A.cp(Ti),C.cp(Ti),D.cp(Ti),E.cp(Ti),F.cp(Ti), + G.cp(Ti),H.cp(Ti),I.cp(Ti),K.cp(Ti),L.cp(Ti), + M.cp(Ti),N.cp(Ti),P.cp(Ti),Q.cp(Ti),R.cp(Ti), + S.cp(Ti),T.cp(Ti),V.cp(Ti),W.cp(Ti),Y.cp(Ti)) + # get the protein composition + tt <- protein.info(protein.info(protein))[,6:25] + cnew <- c(cnew, sum(cp * as.numeric(tt)) + sum(as.numeric(tt)) * UPBB.cp(Ti)) + } + return(cnew) +} + +group.formulas <- function() { + # return a matrix with chemical formulas of residues + # names of the sidechain groups + groups <- paste("[", aminoacids(3), "]", sep="") + # the indices of H2O, sidechain groups, and [UPBB] + ig <- suppressMessages(info(c("H2O", groups, "[UPBB]"))) + # their formulas + A <- i2A(ig) + # add [UPBB] to the sidechain groups to get residues + out <- A[1:21,] + out[2:21,] <- t(t(A) + A[22,])[2:21,] + # make "H2O" not "water" + rownames(out)[1] <- "H2O" + return(out) +} Modified: pkg/CHNOSZ/demo/ionize.R =================================================================== --- pkg/CHNOSZ/demo/ionize.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/demo/ionize.R 2017-02-20 12:27:24 UTC (rev 167) @@ -1,5 +1,5 @@ ## ionize.aa(): Contour plots of net charge and ionization properties of LYSC_CHICK -aa <- ip2aa("LYSC_CHICK") +aa <- protein.info("LYSC_CHICK") pH <- seq(0, 14, 0.2) T <- seq(0, 200, 2) val <- expand.grid(pH=pH, T=T) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/inst/NEWS 2017-02-20 12:27:24 UTC (rev 167) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-56 (2017-02-20) +CHANGES IN CHNOSZ 1.0.8-57 (2017-02-20) --------------------------------------- DOCUMENTATION: @@ -121,6 +121,8 @@ - Rename iprotein() to protein.info(), replacing the previous function of the same name. +- Merge ip2aa() with protein.info(). + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/add.protein.Rd =================================================================== --- pkg/CHNOSZ/man/add.protein.Rd 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/man/add.protein.Rd 2017-02-20 12:27:24 UTC (rev 167) @@ -1,5 +1,4 @@ \name{add.protein} -\alias{ip2aa} \alias{aa2eos} \alias{seq2aa} \alias{aasum} @@ -11,7 +10,6 @@ } \usage{ - ip2aa(protein, organism=NULL, residue=FALSE) aa2eos(aa, state=get("thermo")$opt$state) seq2aa(protein, sequence) aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) @@ -22,7 +20,6 @@ \arguments{ \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}$protein})} \item{organism}{character, name of organism} - \item{residue}{logical, compute per-residue counts?} \item{aa}{data frame, amino acid composition in the format of \code{thermo$protein}} \item{state}{character, physical state} \item{sequence}{character, protein sequence} @@ -37,10 +34,8 @@ Often, the names of proteins are sufficient to set up calculations using functions such as \code{\link{subcrt}} or \code{\link{species}}. The names of proteins in CHNOSZ are distinguished from those of other chemical species by having an underscore character ("_") that separates two identifiers, referred to as the \code{protein} and \code{organism} (but any other meaning can be attached to these names). An example is \samp{LYSC_CHICK}. - The first few functions provide low-level operations: + The first function provides low-level operations: - \code{ip2aa} returns the row(s) of \code{thermo$protein} that match the supplied protein names, OR the protein indices found by \code{iprotin}. Set \code{residue} to TRUE to return the per-residue composition (i.e. amino acid composition of the protein divided by total number of residues). For this function only, if the \code{protein} argument is a data frame, it is returned unchanged, except for possibly the per-residue calculation. - \code{aa2eos} calculates the thermodynamic properties and equations-of-state parameters for the completely nonionized proteins using group additivity with parameters taken from Dick et al., 2006 (aqueous proteins) and LaRowe and Dick, 2012 (crystalline proteins and revised aqueous methionine sidechain group). The return value is a data frame in the same format as \code{thermo$obigt}. \code{state} indicates the physical state for the parameters used in the calculation (\samp{aq} or \samp{cr}). The remaining functions are more likely to be called directly by the user: Modified: pkg/CHNOSZ/man/info.Rd =================================================================== --- pkg/CHNOSZ/man/info.Rd 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/man/info.Rd 2017-02-20 12:27:24 UTC (rev 167) @@ -28,7 +28,7 @@ \details{ \code{info} is the primary function used for querying the thermodynamic database (\code{\link{thermo}$obigt}). In common usage, it is called recursively; first with a character value (or values) for \code{species} indicating the name(s) or formula(s) of the species of interest. The result of this call is a numeric value, which can be provided as an argument in a second call to \code{info} in order to retrieve a data frame of the thermodynamic properties of the species. For its work, \code{info} calls on the other functions that are described below, which unlike \code{info} all expect arguments with length=1. - \code{info.character} searches for matches of the indicated \code{species} to names, chemical formulas, and abbreviations (in the \samp{abbrv} column) in the thermodynamic database. If the text of the \code{species} is matched the index of that species is returned. If there are multiple matches for the \code{species} and \code{state} is NULL, the index of first match is returned. The order of entries in \code{thermo$obigt} is grouped by states in the order \samp{aq}, \samp{cr}, \samp{gas}, \samp{liq}, so for species in both aqueous and gaseous states the index of the aqueous species is returned, unless \code{state} is set to \samp{gas}. The two exceptions are species identified by \samp{O2} or \samp{oxygen} (which without any indicated \code{state} matches the gaseous species) and \samp{H2O} (which matches the liquid species even if the indicated state is \samp{aq}). Normally, if a species match can not be located, the function then looks for proteins with the name of \code{species} (using \code{\link{protein.info}}), computes its properties if found (\code{\link{ip2aa}}) and adds this to the thermodynamic database (\code{\link{mod.obigt}}). \code{check.protein} prevents the processing of proteins and is provided to avoid an infinite loop in the interaction with \code{mod.obigt}. + \code{info.character} searches for matches of the indicated \code{species} to names, chemical formulas, and abbreviations (in the \samp{abbrv} column) in the thermodynamic database. If the text of the \code{species} is matched the index of that species is returned. If there are multiple matches for the \code{species} and \code{state} is NULL, the index of first match is returned. The order of entries in \code{thermo$obigt} is grouped by states in the order \samp{aq}, \samp{cr}, \samp{gas}, \samp{liq}, so for species in both aqueous and gaseous states the index of the aqueous species is returned, unless \code{state} is set to \samp{gas}. The two exceptions are species identified by \samp{O2} or \samp{oxygen} (which without any indicated \code{state} matches the gaseous species) and \samp{H2O} (which matches the liquid species even if the indicated state is \samp{aq}). Normally, if a species match can not be located, the function then looks for proteins with the name of \code{species} (using \code{\link{protein.info}}), computes its properties if found (\code{\link{aa2eos}}) and adds this to the thermodynamic database (\code{\link{mod.obigt}}). \code{check.protein} prevents the processing of proteins and is provided to avoid an infinite loop in the interaction with \code{mod.obigt}. \code{info.character} has additional logic for dealing with proteins and with multiple matches for the \samp{cr} state. If the \code{state} is \samp{cr}, matches will be counted for states entered as \samp{cr1}, \samp{cr2} etc in the database, and all of the species indices will be returned. Note, however, that \code{info} only ever returns a single species index, which becomes NA in the case of multiple matches to \samp{cr}. This functionality of \code{info.character} is used in \code{\link{subcrt}} to handle minerals with phase transitions. Modified: pkg/CHNOSZ/man/ionize.aa.Rd =================================================================== --- pkg/CHNOSZ/man/ionize.aa.Rd 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/man/ionize.aa.Rd 2017-02-20 12:27:24 UTC (rev 167) @@ -32,7 +32,7 @@ } \seealso{ - The amino acid composition in \code{aa} can be generated using e.g. \code{\link{ip2aa}}. + The amino acid composition in \code{aa} can be generated using \code{\link{protein.info}}. This function is called by \code{\link{A.ionization}} as part of a calculation of \code{\link{affinity}} if proteins are among the species of interest, \samp{H+} is in the basis, and \code{thermo$opt$ionize} is TRUE. } @@ -43,7 +43,7 @@ # the rownumber of the protein in thermo$protein ip <- protein.info("LYSC_CHICK") # its amino acid composition -aa <- ip2aa(ip) +aa <- protein.info(ip) # additive charges of unfolded protein at 25, 100, 150 degrees C # as a function of pH pH <- seq(0, 14, 0.1) @@ -72,7 +72,7 @@ plot(T, Cp.nonion, xlab=axis.label("T"), type="l", ylab=axis.label("Cp"), ylim=c(5000, 8000)) # Cp of ionization and ionized protein -aa <- ip2aa("LYSC_CHICK") +aa <- protein.info(protein.info("LYSC_CHICK")) for(pH in c(5, 9, 3)) { Cp.ionized <- Cp.nonion + ionize.aa(aa, "Cp", T=T, pH=pH)[, 1] lines(T, Cp.ionized, lty=2) Modified: pkg/CHNOSZ/man/protein.info.Rd =================================================================== --- pkg/CHNOSZ/man/protein.info.Rd 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/man/protein.info.Rd 2017-02-20 12:27:24 UTC (rev 167) @@ -1,12 +1,10 @@ \encoding{UTF-8} \name{protein.info} -\alias{group.formulas} \alias{protein.formula} \alias{protein.length} \alias{protein.info} \alias{protein.basis} \alias{protein.equil} -\alias{MP90.cp} \title{Summaries of Thermodynamic Properties of Proteins} \description{ @@ -14,13 +12,11 @@ } \usage{ - protein.info(protein, organism=NULL) + protein.info(protein, organism=NULL, residue=FALSE) protein.formula(protein, organism = NULL, residue = FALSE) protein.length(protein, organism = NULL) protein.basis(protein, T = 25, normalize = FALSE) protein.equil(protein, T=25, loga.protein = 0, digits = 4) - MP90.cp(protein, T) - group.formulas() } \arguments{ @@ -34,31 +30,32 @@ } \details{ - These functions accept \code{protein} (and optionally \code{organism}) in the same way as \code{\link{ip2aa}}, that is, as a protein name (optionally with the \code{organism} part separated), one or more row numbers in \code{thermo$protein} that can be identified using \code{\link{protein.info}}, or a data frame in the format of \code{thermo$protein}. +For character \code{protein}, \code{protein.info} returns the rownumber(s) of \code{thermo$protein} that match the protein names. +The names can be supplied in the single \code{protein} argument (with an underscore) or as individual \code{protein}s and \code{organism}s. +Any protein not matched returns an NA and generates a message. - \code{protein.info} returns the rownumber(s) of \code{thermo$protein} that match the protein names. The names can be supplied in the single \code{protein} argument or as separated \code{protein}s and \code{organism}s (without the underscore). Any protein not matched returns an NA and generates a message. +For numeric \code{protein}, \code{protein.info} returns the corresponding row(s) of \code{thermo$protein}. +Set \code{residue} to TRUE to return the per-residue composition (i.e. amino acid composition of the protein divided by total number of residues). - \code{protein.formula} returns a stoichiometrix matrix representing the chemical formulas of the proteins that can be pased to e.g. \code{\link{mass}} or \code{\link{ZC}}. The amino acid compositions are multiplied by the output of \code{group.formulas} to generate the result. \code{group.formulas} returns the chemical formulas of each of the 20 common amino acid residues in proteins, as well as the terminal -H and -H (treated as the [H2O] group). +For dataframe \code{protein}, \code{protein.info} returns it unchanged, except for possibly the per-residue calculation. - \code{protein.length} returns the lengths (number of amino acids) of the proteins. +The following functions accept any specification of protein(s) described above for \code{protein.info}: - The following two functions depend on an existing definition of the basis species: +\code{protein.formula} returns a stoichiometrix matrix representing the chemical formulas of the proteins that can be pased to e.g. \code{\link{mass}} or \code{\link{ZC}}. +The amino acid compositions are multiplied by the output of \code{\link{group.formulas}} to generate the result. +\code{protein.length} returns the lengths (number of amino acids) of the proteins. + +The following functions also depend on an existing definition of the basis species: + \code{protein.basis} calculates the numbers of the basis species (i.e. opposite of the coefficients in the formation reactions) that can be combined to form the composition of each of the proteins. The basis species must be present in \code{thermo$basis}, and if \samp{H+} is among the basis species, the ionization states of the proteins are included. The ionization state of the protein is calculated at the pH defined in \code{thermo$basis} and at the temperature specified by the \code{T} argument. If \code{normalize} is TRUE, the coefficients on the basis species are divided by the lengths of the proteins. \code{protein.equil} produces a series of messages showing step-by-step a calculation of the chemical activities of proteins in metastable equilibrium. For the first protein, it shows the standard Gibbs energies of the reaction to form the nonionized protein from the basis species and of the ionization reaction of the protein (if \samp{H+} is in the basis), then the standard Gibbs energy/RT of the reaction to form the (possibly ionized) protein per residue. The per-residue values of \samp{logQstar} and \samp{Astar/RT} are also shown for the first protein. Equilibrium calculations are then performed, only if more than one protein is specified. This calculation applies the Boltzmann distribution to the calculation of the equilibrium degrees of formation of the residue equivalents of the proteins, then converts them to activities of proteins taking account of \code{loga.protein} and protein length. If the \code{protein} argument is numeric (indicating rownumbers in \code{thermo$protein}), the values of \samp{Astar/RT} are compared with the output of \code{\link{affinity}}, and those of the equilibrium degrees of formation of the residues and the chemical activities of the proteins with the output of \code{\link{diagram}}. If the values in any of these tests are are not \code{\link{all.equal}} an error is produced indicating a bug. - - \code{MP90.cp} takes \code{protein} (name of protein) and \code{T} (one or more temperatures in \eqn{^{\circ}}{?}C) and returns the additive heat capacity (J mol \eqn{^{-1}}{^-1}) of the unfolded protein using values of heat capacities of the residues taken from Makhatadze and Privalov, 1990. Those authors provided values of heat capacity at six points between 5 and 125 \eqn{^{\circ}}{?}C; this function interpolates (using \code{\link{splinefun}}) values at other temperatures. } -\seealso{ -\code{\link{ionize.aa}} for an example that compares \code{MP90.cp} with heat capacities calculated in CHNOSZ at different temperatures and pHs. -See also \code{demo{protein.equil}}. -} - \examples{\dontshow{data(thermo)} # search by name in thermo$protein ip1 <- protein.info("LYSC_CHICK") @@ -68,9 +65,9 @@ # two organisms with the same protein name ip3 <- protein.info("MYG", c("HORSE", "PHYCA")) # their amino acid compositions -ip2aa(ip3) +protein.info(ip3) # their thermodynamic properties by group additivity -aa2eos(ip2aa(ip3)) +aa2eos(protein.info(ip3)) # an example of an unrecognized protein name ip4 <- protein.info("MYGPHYCA") @@ -80,13 +77,13 @@ # index in thermo$protein ip <- protein.info("LYSC_CHICK") # amino acid composition -ip2aa(ip) +protein.info(ip) # length and chemical formula protein.length(ip) protein.formula(ip) # group additivity for thermodynamic properties and HKF equation-of-state # parameters of non-ionized protein -aa2eos(ip2aa(ip)) +aa2eos(protein.info(ip)) # calculation of standard thermodynamic properties # (subcrt uses the species name, not ip) subcrt("LYSC_CHICK") @@ -103,7 +100,7 @@ ## these are all the same protein.formula("P53_PIG") protein.formula(protein.info("P53_PIG")) -protein.formula(ip2aa(protein.info("P53_PIG"))) +protein.formula(protein.info(protein.info("P53_PIG"))) ## using protein.formula: average oxidation state of ## carbon of proteins from different organisms (Dick, 2014) @@ -138,8 +135,6 @@ \references{ Dick, J. M. (2014) Average oxidation state of carbon in proteins. \emph{J. R. Soc. Interface} \bold{11}, 20131095. \url{http://dx.doi.org/10.1098/rsif.2013.1095} - - Makhatadze, G. I. and Privalov, P. L. (1990) Heat capacity of proteins. 1. Partial molar heat capacity of individual amino acid residues in aqueous solution: Hydration effect \emph{J. Mol. Biol.} \bold{213}, 375--384. \url{http://dx.doi.org/10.1016/S0022-2836(05)80197-4} } \concept{Protein thermodynamic modeling} Added: pkg/CHNOSZ/man/util.protein.Rd =================================================================== --- pkg/CHNOSZ/man/util.protein.Rd (rev 0) +++ pkg/CHNOSZ/man/util.protein.Rd 2017-02-20 12:27:24 UTC (rev 167) @@ -0,0 +1,36 @@ +\encoding{UTF-8} +\name{util.protein} +\alias{group.formulas} +\alias{MP90.cp} +\title{Functions for Proteins (Other Calculations)} + +\description{ + Return chemical formulas of groups in proteins, and calculate heat capacity using an additivity model from the literature. +} + +\usage{ + MP90.cp(protein, T) + group.formulas() +} + +\arguments{ + \item{protein}{proteins specified in any format usable by \code{\link{protein.info}}} + \item{T}{numeric, temperature in \eqn{^{\circ}}{?}C} +} + +\details{ +\code{group.formulas} returns the chemical formulas of each of the 20 common amino acid residues in proteins, as well as the terminal -H and -H (treated as the [H2O] group). + +\code{MP90.cp} takes \code{protein} (name of protein) and \code{T} (one or more temperatures in \eqn{^{\circ}}{?}C) and returns the additive heat capacity (J mol \eqn{^{-1}}{^-1}) of the unfolded protein using values of heat capacities of the residues taken from Makhatadze and Privalov, 1990. +Those authors provided values of heat capacity at six points between 5 and 125 \eqn{^{\circ}}{?}C; this function interpolates (using \code{\link{splinefun}}) values at other temperatures. +} + +\seealso{ +\code{\link{ionize.aa}} for an example that compares \code{MP90.cp} with heat capacities calculated in CHNOSZ at different temperatures and pHs. +} + +\references{ + Makhatadze, G. I. and Privalov, P. L. (1990) Heat capacity of proteins. 1. Partial molar heat capacity of individual amino acid residues in aqueous solution: Hydration effect \emph{J. Mol. Biol.} \bold{213}, 375--384. \url{http://dx.doi.org/10.1016/S0022-2836(05)80197-4} +} + +\concept{utilities} Modified: pkg/CHNOSZ/tests/testthat/test-add.protein.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-add.protein.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/tests/testthat/test-add.protein.R 2017-02-20 12:27:24 UTC (rev 167) @@ -19,7 +19,7 @@ expect_message(protein.info(c("LYSC_CHICK", "MYGPHYCA")), "1 protein not matched") expect_error(seq2aa("LYS_CHICK", "XXX"), "no characters match an amino acid") expect_error(add.protein(count.aa("AAA")), "not a data frame with the same columns as thermo\\$protein") - expect_message(add.protein(ip2aa(protein.info("CYC_BOVIN"))), "replaced 1 existing protein\\(s\\)") + expect_message(add.protein(protein.info(protein.info("CYC_BOVIN"))), "replaced 1 existing protein\\(s\\)") }) test_that("group additivity for proteins gives expected values", { Modified: pkg/CHNOSZ/tests/testthat/test-ionize.aa.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-ionize.aa.R 2017-02-20 11:27:11 UTC (rev 166) +++ pkg/CHNOSZ/tests/testthat/test-ionize.aa.R 2017-02-20 12:27:24 UTC (rev 167) @@ -36,7 +36,7 @@ Z.LYSC_CHICK.100 <- c(13.3, 7.8, -3.4, -15.2, -20.9, -20.9) Z.LYSC_CHICK.150 <- c(13.3, 7.1, -8.0, -20.0, -20.9, -20.9) Z.LYSC_CHICK.25_oxid <- c(13.5, 8.7, 7.6, 1.6, -6.2, -12.9) - aa <- ip2aa(protein.info("LYSC_CHICK")) + aa <- protein.info(protein.info("LYSC_CHICK")) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 167 From noreply at r-forge.r-project.org Tue Feb 21 15:34:27 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 21 Feb 2017 15:34:27 +0100 (CET) Subject: [CHNOSZ-commits] r168 - in pkg/CHNOSZ: . R demo inst man tests/testthat vignettes Message-ID: <20170221143427.8B033187DFB@r-forge.r-project.org> Author: jedick Date: 2017-02-21 15:34:27 +0100 (Tue, 21 Feb 2017) New Revision: 168 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/add.protein.R pkg/CHNOSZ/R/affinity.R pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/protein.info.R pkg/CHNOSZ/R/util.affinity.R pkg/CHNOSZ/R/util.protein.R pkg/CHNOSZ/demo/buffer.R pkg/CHNOSZ/demo/ionize.R pkg/CHNOSZ/demo/protein.equil.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/info.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/man/util.protein.Rd pkg/CHNOSZ/tests/testthat/test-add.protein.R pkg/CHNOSZ/tests/testthat/test-affinity.R pkg/CHNOSZ/tests/testthat/test-ionize.aa.R pkg/CHNOSZ/tests/testthat/test-protein.info.R pkg/CHNOSZ/tests/testthat/test-util.affinity.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/equilibrium.Rnw pkg/CHNOSZ/vignettes/equilibrium.lyx pkg/CHNOSZ/vignettes/vig.bib Log: protein.info() renamed to pinfo() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-21 14:34:27 UTC (rev 168) @@ -1,6 +1,6 @@ -Date: 2017-02-20 +Date: 2017-02-21 Package: CHNOSZ -Version: 1.0.8-57 +Version: 1.0.8-58 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/NAMESPACE 2017-02-21 14:34:27 UTC (rev 168) @@ -13,7 +13,7 @@ "plot.new", "plot.window", "points", "rect", "text", "title") importFrom("stats", "D", "as.formula", "cor", "lm", "loess.smooth", "na.omit", "predict.lm", "qqline", "qqnorm", "sd", "splinefun", - "uniroot") + "uniroot", "median") importFrom("utils", "browseURL", "capture.output", "combn", "demo", "example", "head", "installed.packages", "read.csv", "tail", "write.csv", "write.table") Modified: pkg/CHNOSZ/R/add.protein.R =================================================================== --- pkg/CHNOSZ/R/add.protein.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/add.protein.R 2017-02-21 14:34:27 UTC (rev 168) @@ -3,65 +3,10 @@ # reorganize protein functions 20120513 # add.protein - add amino acid counts to thermo$protein (returns iprotein) -# aa2eos - perform group additivity calculations # seq2aa - calculate amino acid counts from a sequence # aasum - combine amino acid counts (sum, average, or weighted sum by abundance) # read.aa - read amino acid counts from a file -aa2eos <- function(aa, state=get("thermo")$opt$state) { - # display and return the properties of - # proteins calculated from amino acid composition - # the names of the protein backbone groups depend on the state - # [UPBB] for aq or [PBB] for cr - if(state=="aq") bbgroup <- "UPBB" else bbgroup <- "PBB" - # names of the AABB, sidechain and protein backbone groups - groups <- c("AABB", colnames(aa)[6:25], bbgroup) - # put brackets around the group names - groups <- paste("[", groups, "]", sep="") - # the rownumbers of the groups in thermo$obigt - groups_state <- paste(groups, state) - obigt <- get("thermo")$obigt - obigt_state <- paste(obigt$name, obigt$state) - igroup <- match(groups_state, obigt_state) - # the properties are in columns 8-20 of thermo$obigt - groupprops <- obigt[igroup, 8:20] - # the elements in each of the groups - groupelements <- i2A(igroup) - # a function to work on a single row of aa - eosfun <- function(aa) { - # numbers of groups: chains [=AABB], sidechains, protein backbone - nchains <- as.numeric(aa[, 5]) - length <- sum(as.numeric(aa[, 6:25])) - npbb <- length - nchains - ngroups <- c(nchains, as.numeric(aa[, 6:25]), npbb) - # the actual adding and multiplying of thermodynamic properties - # hmm. seems like we have to split up the multiplication/transposition - # operations to get the result into multiple columns. 20071213 - eos <- t(data.frame(colSums(groupprops * ngroups))) - # to get the formula, add up and round the group compositions 20090331 - f.in <- round(colSums(groupelements * ngroups), 3) - # take out any elements that don't appear (sometimes S) - f.in <- f.in[f.in!=0] - # turn it into a formula - f <- as.chemical.formula(f.in) - # now the species name - name <- paste(aa$protein, aa$organism, sep="_") - # make some noise for the user - message("aa2eos: found ", appendLF=FALSE) - message(name, " (", f, ", ", appendLF=FALSE) - message(round(length, 3), " residues)") - ref <- aa$ref - header <- data.frame(name=name, abbrv=NA, formula=f, state=state, ref1=ref, ref2=NA, date=NA, stringsAsFactors=FALSE) - eosout <- cbind(header, eos) - return(eosout) - } - # loop over each row of aa - out <- lapply(1:nrow(aa), function(i) eosfun(aa[i, ])) - out <- do.call(rbind, out) - rownames(out) <- NULL - return(out) -} - seq2aa <- function(protein, sequence) { # remove newlines and whitespace sequence <- gsub("\\s", "", gsub("[\r\n]", "", sequence)) @@ -70,7 +15,7 @@ colnames(caa) <- aminoacids(3) # a protein with no amino acids is sort of boring if(all(caa==0)) stop("no characters match an amino acid") - ip <- suppressMessages(protein.info(protein)) + ip <- pinfo(protein) # now make the data frame po <- strsplit(protein, "_")[[1]] aa <- data.frame(protein=po[1], organism=po[2], ref=NA, abbrv=NA, stringsAsFactors=FALSE) @@ -127,7 +72,7 @@ stop("the value of 'aa' is not a data frame with the same columns as thermo$protein") # find any protein IDs that are duplicated po <- paste(aa$protein, aa$organism, sep="_") - ip <- suppressMessages(protein.info(po)) + ip <- pinfo(po) ipdup <- !is.na(ip) # now we're ready to go tp.new <- thermo$protein @@ -142,7 +87,7 @@ thermo$protein <- tp.new assign("thermo", thermo, "CHNOSZ") # return the new rownumbers - ip <- protein.info(po) + ip <- pinfo(po) # make some noise if(!all(ipdup)) message("add.protein: added ", nrow(aa)-sum(ipdup), " new protein(s) to thermo$protein") if(any(ipdup)) message("add.protein: replaced ", sum(ipdup), " existing protein(s) in thermo$protein") Modified: pkg/CHNOSZ/R/affinity.R =================================================================== --- pkg/CHNOSZ/R/affinity.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/affinity.R 2017-02-21 14:34:27 UTC (rev 168) @@ -49,7 +49,8 @@ # is needed here if(!is.null(iprotein)) { # check all proteins are available - if(!all(iprotein %in% 1:nrow(thermo$protein))) stop("some value(s) in iprotein not in rownumbers of thermo$protein") + if(any(is.na(iprotein))) stop("`iprotein` has some NA values") + if(!all(iprotein %in% 1:nrow(thermo$protein))) stop("some value(s) of `iprotein` are not rownumbers of thermo$protein") # add protein residues to the species list resnames <- c("H2O",aminoacids(3)) # residue activities set to zero; Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/diagram.R 2017-02-21 14:34:27 UTC (rev 168) @@ -22,7 +22,7 @@ # colors col=par("col"), col.names=par("col"), fill=NULL, # labels - names=NULL, main=NULL, legend.x=NA, format.names=TRUE, + names=NULL, main=NULL, legend.x=NA, format.names=TRUE, adj=0.5, dy=0, # plotting controls add=FALSE, plot.it=TRUE, tplot=TRUE, ... ) { @@ -242,17 +242,37 @@ if(!add & !is.null(legend.x)) { # 20120521: use legend.x=NA to label lines rather than make legend if(is.na(legend.x)) { + maxvals <- do.call(pmax, pv) for(i in 1:length(plotvals)) { + # y-values for this line myvals <- as.numeric(plotvals[[i]]) # don't take values that lie close to or above the top of plot myvals[myvals > ylim[1] + 0.95*diff(ylim)] <- ylim[1] - imax <- which.max(myvals) - # put labels on the maximum of the line, but avoid the sides of the plot - adj <- 0.5 - if(xvalues[imax] > xlim[1] + 0.8*diff(xlim)) adj <- 1 - if(xvalues[imax] < xlim[1] + 0.2*diff(xlim)) adj <- 0 - # also include y-adjustment (labels bottom-aligned with the line) - text(xvalues[imax], plotvals[[i]][imax], labels=names[i], adj=c(adj, 0)) + # the starting x-adjustment + thisadj <- adj + # if this line has any of the overall maximum values, use only those values + # (useful for labeling straight-line affinity comparisons 20170221) + is.max <- myvals==maxvals + if(any(is.max) & plotvar != "alpha") { + # put labels on the median x-position + imax <- median(which(is.max)) + } else { + # put labels on the maximum of the line + # (useful for labeling alpha plots) + imax <- which.max(myvals) + # try to avoid the sides of the plot; take care of reversed x-axis + if(missing(adj)) { + if(sign(diff(xlim)) > 0) { + if(xvalues[imax] > xlim[1] + 0.8*diff(xlim)) thisadj <- 1 + if(xvalues[imax] < xlim[1] + 0.2*diff(xlim)) thisadj <- 0 + } else { + if(xvalues[imax] > xlim[1] + 0.2*diff(xlim)) thisadj <- 0 + if(xvalues[imax] < xlim[1] + 0.8*diff(xlim)) thisadj <- 1 + } + } + } + # also include y-offset (dy) and y-adjustment (labels bottom-aligned with the line) + text(xvalues[imax], plotvals[[i]][imax] + dy, labels=names[i], adj=c(thisadj, 0)) } } else legend(x=legend.x, lty=lty, legend=names, col=col, cex=cex.names, lwd=lwd, ...) } Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/info.R 2017-02-21 14:34:27 UTC (rev 168) @@ -31,7 +31,7 @@ # since thermo$obigt$abbrv contains NAs, convert NA results to FALSE matches.species[is.na(matches.species)] <- FALSE # turn it in to no match if it's a protein in the wrong state - ip <- suppressMessages(protein.info(species)) + ip <- pinfo(species) if(any(matches.species) & !is.na(ip) & !is.null(state)) { matches.state <- matches.species & grepl(state, thermo$obigt$state) if(!any(matches.state)) matches.species <- FALSE @@ -44,10 +44,8 @@ if(!is.na(ip)) { # here we use a default state from thermo$opt$state if(is.null(state)) state <- thermo$opt$state - # retrieve the amino acid composition - aa <- protein.info(ip) # add up protein properties - eos <- aa2eos(aa, state) + eos <- protein.obigt(ip, state=state) # the real assignment work nrows <- suppressMessages(mod.obigt(eos)) thermo <- get("thermo", "CHNOSZ") Modified: pkg/CHNOSZ/R/protein.info.R =================================================================== --- pkg/CHNOSZ/R/protein.info.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/protein.info.R 2017-02-21 14:34:27 UTC (rev 168) @@ -1,13 +1,14 @@ # CHNOSZ/protein.info.R # calculate formulas and summarize properties of proteins -# protein.info: find rownumber in thermo$protein +# pinfo: find rownumber in thermo$protein +# protein.length: lengths of the indicated proteins # protein.formula: chemical makeup of the indicated proteins -# protein.length: lengths of the indicated proteins +# protein.obigt: perform group additivity calculations # protein.basis: coefficients of basis species in formation reactions of [ionized] proteins [residues] # protein.equil: step-by-step example of protein equilibrium calculation -protein.info <- function(protein, organism=NULL, residue=FALSE) { +pinfo <- function(protein, organism=NULL, residue=FALSE) { # return the `protein` (possibly per residue) for: # dataframe `protein` # return the rownumber(s) of thermo$protein for: @@ -15,30 +16,24 @@ # character `protein` and `organism`, e.g. 'LYSC', 'CHICK' # return the row(s) of thermo$protein (possibly per residue) for: # numeric `protein` (the rownumber itself) - thermo <- get("thermo") + t_p <- get("thermo")$protein if(is.data.frame(protein)) out <- protein if(is.numeric(protein)) { # drop NA matches to thermo$protein - iproteins <- 1:nrow(thermo$protein) + iproteins <- 1:nrow(t_p) protein[!protein %in% iproteins] <- NA # get amino acid counts - out <- thermo$protein[protein, ] + out <- t_p[protein, ] } if(is.data.frame(protein) | is.numeric(protein)) { # compute per-residue counts if requested if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) } else { - # from here we'll search by protein/organism pairs - tp.po <- paste(thermo$protein$protein, thermo$protein$organism, sep="_") - if(is.null(organism)) my.po <- protein - else my.po <- paste(protein, organism, sep="_") - iprotein <- match(my.po, tp.po) - # tell the user about NA's - if(any(is.na(iprotein))) { - nNA <- sum(is.na(iprotein)) - if(nNA==1) ptext <- "" else ptext <- "s" - message("iprotein: ", sum(is.na(iprotein)), " protein", ptext, " not matched") - } + # search for protein or protein_organism in thermo$protein + t_p_names <- paste(t_p$protein, t_p$organism, sep="_") + if(is.null(organism)) my_names <- protein + else my_names <- paste(protein, organism, sep="_") + iprotein <- match(my_names, t_p_names) out <- iprotein } out @@ -46,7 +41,7 @@ protein.formula <- function(protein, organism=NULL, residue=FALSE) { # return a matrix with chemical formulas of proteins - aa <- protein.info(protein.info(protein, organism)) + aa <- pinfo(pinfo(protein, organism)) rf <- group.formulas() out <- as.matrix(aa[, 5:25]) %*% as.matrix(rf) if(residue) out <- out / rowSums(aa[, 6:25]) @@ -56,18 +51,73 @@ protein.length <- function(protein, organism=NULL) { # calculate the length(s) of proteins - aa <- protein.info(protein.info(protein, organism)) + aa <- pinfo(pinfo(protein, organism)) # use rowSums on the columns containing amino acid counts pl <- as.numeric(rowSums(aa[, 6:25])) return(pl) } +protein.obigt <- function(protein, organism=NULL, state=get("thermo")$opt$state) { + # display and return the properties of + # proteins calculated from amino acid composition + aa <- pinfo(pinfo(protein, organism)) + # the names of the protein backbone groups depend on the state + # [UPBB] for aq or [PBB] for cr + if(state=="aq") bbgroup <- "UPBB" else bbgroup <- "PBB" + # names of the AABB, sidechain and protein backbone groups + groups <- c("AABB", colnames(aa)[6:25], bbgroup) + # put brackets around the group names + groups <- paste("[", groups, "]", sep="") + # the rownumbers of the groups in thermo$obigt + groups_state <- paste(groups, state) + obigt <- get("thermo")$obigt + obigt_state <- paste(obigt$name, obigt$state) + igroup <- match(groups_state, obigt_state) + # the properties are in columns 8-20 of thermo$obigt + groupprops <- obigt[igroup, 8:20] + # the elements in each of the groups + groupelements <- i2A(igroup) + # a function to work on a single row of aa + eosfun <- function(aa) { + # numbers of groups: chains [=AABB], sidechains, protein backbone + nchains <- as.numeric(aa[, 5]) + length <- sum(as.numeric(aa[, 6:25])) + npbb <- length - nchains + ngroups <- c(nchains, as.numeric(aa[, 6:25]), npbb) + # the actual adding and multiplying of thermodynamic properties + # hmm. seems like we have to split up the multiplication/transposition + # operations to get the result into multiple columns. 20071213 + eos <- t(data.frame(colSums(groupprops * ngroups))) + # to get the formula, add up and round the group compositions 20090331 + f.in <- round(colSums(groupelements * ngroups), 3) + # take out any elements that don't appear (sometimes S) + f.in <- f.in[f.in!=0] + # turn it into a formula + f <- as.chemical.formula(f.in) + # now the species name + name <- paste(aa$protein, aa$organism, sep="_") + # make some noise for the user + message("protein.obigt: found ", appendLF=FALSE) + message(name, " (", f, ", ", appendLF=FALSE) + message(round(length, 3), " residues)") + ref <- aa$ref + header <- data.frame(name=name, abbrv=NA, formula=f, state=state, ref1=ref, ref2=NA, date=NA, stringsAsFactors=FALSE) + eosout <- cbind(header, eos) + return(eosout) + } + # loop over each row of aa + out <- lapply(1:nrow(aa), function(i) eosfun(aa[i, ])) + out <- do.call(rbind, out) + rownames(out) <- NULL + return(out) +} + protein.basis <- function(protein, T=25, normalize=FALSE) { # 20090902 calculate the coefficients of basis species in reactions # to form proteins (possibly per normalized by length) listed in protein # 20120528 renamed protein.basis from residue.info ... # what are the elemental compositions of the proteins - aa <- protein.info(protein.info(protein)) + aa <- pinfo(pinfo(protein)) pf <- protein.formula(aa) # what are the coefficients of the basis species in the formation reactions sb <- species.basis(pf) @@ -94,7 +144,7 @@ message("protein.equil: temperature from argument is ", T, " degrees C") TK <- convert(T, "K") # get the amino acid compositions of the proteins - aa <- protein.info(protein.info(protein)) + aa <- pinfo(pinfo(protein)) # get some general information about the proteins pname <- paste(aa$protein, aa$organism, sep="_") plength <- protein.length(aa) Modified: pkg/CHNOSZ/R/util.affinity.R =================================================================== --- pkg/CHNOSZ/R/util.affinity.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/util.affinity.R 2017-02-21 14:34:27 UTC (rev 168) @@ -162,7 +162,7 @@ isprotein <- grepl("_", myspecies$name) if(any(isprotein)) { # the rownumbers in thermo$protein - ip <- protein.info(myspecies$name[isprotein]) + 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 @@ -420,7 +420,7 @@ # initialize output list out <- vector("list", length(iprotein)) # get aa from iprotein - aa <- protein.info(iprotein) + aa <- pinfo(iprotein) # calculate the values of A/2.303RT as a function of T-P-pH A <- ionize.aa(aa=aa, property="A", T=TPpH$T, P=TPpH$P, pH=TPpH$pH) if(transect) { Modified: pkg/CHNOSZ/R/util.protein.R =================================================================== --- pkg/CHNOSZ/R/util.protein.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/R/util.protein.R 2017-02-21 14:34:27 UTC (rev 168) @@ -37,7 +37,7 @@ M.cp(Ti),N.cp(Ti),P.cp(Ti),Q.cp(Ti),R.cp(Ti), S.cp(Ti),T.cp(Ti),V.cp(Ti),W.cp(Ti),Y.cp(Ti)) # get the protein composition - tt <- protein.info(protein.info(protein))[,6:25] + tt <- pinfo(pinfo(protein))[,6:25] cnew <- c(cnew, sum(cp * as.numeric(tt)) + sum(as.numeric(tt)) * UPBB.cp(Ti)) } return(cnew) Modified: pkg/CHNOSZ/demo/buffer.R =================================================================== --- pkg/CHNOSZ/demo/buffer.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/demo/buffer.R 2017-02-21 14:34:27 UTC (rev 168) @@ -13,7 +13,7 @@ basis("H2", buffer) a <- affinity(T=xlim, P=300, return.buffer=TRUE, exceed.Ttr=TRUE) lines(a$vals[[1]], a$H2, col=3, lwd=2) - text(a$vals[[1]][ixlab], a$H2[ixlab], buffer) + text(a$vals[[1]][ixlab], a$H2[ixlab] + 0.2, buffer) } bufferline("FeFeO", 20) bufferline("QFM", 38) Modified: pkg/CHNOSZ/demo/ionize.R =================================================================== --- pkg/CHNOSZ/demo/ionize.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/demo/ionize.R 2017-02-21 14:34:27 UTC (rev 168) @@ -1,5 +1,5 @@ ## ionize.aa(): Contour plots of net charge and ionization properties of LYSC_CHICK -aa <- protein.info("LYSC_CHICK") +aa <- pinfo(pinfo("LYSC_CHICK")) pH <- seq(0, 14, 0.2) T <- seq(0, 200, 2) val <- expand.grid(pH=pH, T=T) Modified: pkg/CHNOSZ/demo/protein.equil.R =================================================================== --- pkg/CHNOSZ/demo/protein.equil.R 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/demo/protein.equil.R 2017-02-21 14:34:27 UTC (rev 168) @@ -1,6 +1,6 @@ ## steps in calculation of chemical activities of two proteins ## in metastable equilibrium, after Dick and Shock, 2011 -protein <- protein.info(c("CSG_METVO", "CSG_METJA")) +protein <- pinfo(c("CSG_METVO", "CSG_METJA")) # clear out amino acid residues loaded by the example above # ( in affinity(iprotein=ip) ) data(thermo) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/inst/NEWS 2017-02-21 14:34:27 UTC (rev 168) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-57 (2017-02-20) +CHANGES IN CHNOSZ 1.0.8-58 (2017-02-21) --------------------------------------- DOCUMENTATION: @@ -39,6 +39,9 @@ - Chemical formulas that are part of the axis labels (log activity or fugacity) now have formatting applied. +- Add arguments `adj` and `dy` for x-alignment and y-offset of line + labels. + NEW FEATURES: - Add ZC.col() for generating a red-grey-blue color scale from @@ -118,10 +121,10 @@ - Rename browse.refs() to thermo.refs(); remove URL browsing (except for summary table). -- Rename iprotein() to protein.info(), replacing the previous function - of the same name. +- New function pinfo() merges functionality of old iprotein() and + ip2aa(), which have been removed (along with protein.info()). -- Merge ip2aa() with protein.info(). +- Rename aa2eos() to protein.obigt(). CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/man/add.protein.Rd =================================================================== --- pkg/CHNOSZ/man/add.protein.Rd 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/man/add.protein.Rd 2017-02-21 14:34:27 UTC (rev 168) @@ -1,55 +1,52 @@ \name{add.protein} -\alias{aa2eos} +\alias{add.protein} \alias{seq2aa} -\alias{aasum} \alias{read.aa} -\alias{add.protein} +\alias{aasum} \title{Amino Acid Compositions of Proteins} \description{ - Functions to identify proteins, get and set amino acid compositions, and calculate thermodynamic properties from group additivity. + Functions to get amino acid compositions and add them to protein list for use by other functions. } \usage{ - aa2eos(aa, state=get("thermo")$opt$state) + add.protein(aa) seq2aa(protein, sequence) - aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) read.aa(file = "protein.csv", ...) - add.protein(aa) + aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) } \arguments{ - \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}$protein})} - \item{organism}{character, name of organism} \item{aa}{data frame, amino acid composition in the format of \code{thermo$protein}} - \item{state}{character, physical state} + \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}$protein})} \item{sequence}{character, protein sequence} - \item{abundance}{numeric, abundances of proteins} - \item{average}{logical, return the weighted average of amino acid counts?} \item{file}{character, path to file with amino acid compositions} \item{...}{additional arguments passed to \code{\link{read.csv}}} + \item{abundance}{numeric, abundances of proteins} + \item{average}{logical, return the weighted average of amino acid counts?} + \item{organism}{character, name of organism} } \details{ - A \samp{protein} in CHNOSZ is defined by a name and by the counts of amino acids, stored in \code{\link{thermo}$protein}. The purpose of the functions described here is to identify proteins and work with their amino acid compositions. From the amino acid compositions, the thermodynamic properties of the proteins can be estimated (Dick et al., 2006) for use in other functions in the package. +A \samp{protein} in CHNOSZ is defined by its identifying information and the amino acid composition, stored in \code{\link{thermo}$protein}. +The names of proteins in CHNOSZ are distinguished from those of other chemical species by having an underscore character ("_") that separates two identifiers, referred to as the \code{protein} and \code{organism}. +An example is \samp{LYSC_CHICK}. +The purpose of the functions described here is to identify proteins and work with their amino acid compositions. +From the amino acid compositions, the thermodynamic properties of the proteins can be estimated by group additivity. - Often, the names of proteins are sufficient to set up calculations using functions such as \code{\link{subcrt}} or \code{\link{species}}. The names of proteins in CHNOSZ are distinguished from those of other chemical species by having an underscore character ("_") that separates two identifiers, referred to as the \code{protein} and \code{organism} (but any other meaning can be attached to these names). An example is \samp{LYSC_CHICK}. +\code{seq2aa} returns a data frame of amino acid composition, in the format of \code{thermo$protein}, corresponding to the provided \code{sequence}. +Here, the \code{protein} argument indicates the name of the protein with an underscore (e.g. \samp{LYSC_CHICK}). - The first function provides low-level operations: +\code{aasum} returns a data frame representing the sum of amino acid compositions in the rows of the input \code{aa} data frame. +The amino acid compositions are multiplied by the indicated \code{abundance}; that argument is recycled to match the number of rows of \code{aa}. +If \code{average} is TRUE the final sum is divided by the number of input compositions. +The name used in the output is taken from the first row of \code{aa} or from \code{protein} and \code{organism} if they are specified. +This function is useful for calculating bulk amino acid compositions in stress response experiments or localization studies; see \code{\link{read.expr}} for examples of its use. - \code{aa2eos} calculates the thermodynamic properties and equations-of-state parameters for the completely nonionized proteins using group additivity with parameters taken from Dick et al., 2006 (aqueous proteins) and LaRowe and Dick, 2012 (crystalline proteins and revised aqueous methionine sidechain group). The return value is a data frame in the same format as \code{thermo$obigt}. \code{state} indicates the physical state for the parameters used in the calculation (\samp{aq} or \samp{cr}). - - The remaining functions are more likely to be called directly by the user: - - \code{seq2aa} returns a data frame of amino acid composition, in the format of \code{thermo$protein}, corresponding to the provided \code{sequence}. Here, the \code{protein} argument indicates the name of the protein with an underscore (e.g. \samp{LYSC_CHICK}). - - \code{aasum} returns a data frame representing the sum of amino acid compositions in the rows of the input \code{aa} data frame. The amino acid compositions are multiplied by the indicated \code{abundance}; that argument is recycled to match the number of rows of \code{aa}. If \code{average} is TRUE the final sum is divided by the number of input compositions. The name used in the output is taken from the first row of \code{aa} or from \code{protein} and \code{organism} if they are specified. This function is useful for calculating bulk amino acid compositions in stress response experiments or localization studies; see \code{\link{read.expr}} for examples of its use. - \code{read.aa} returns a data frame of amino acid composition based on the contents of the indicated \code{file}, which should be a CSV file with the same column names as \code{thermo$protein}. -\code{add.protein} completes the loop; any amino acid composition returned by the \code{*aa} functions described above can be added to \code{thermo$protein} using this function to be made available to other functions in the package. +Given amino acid composition returned by the \code{*aa} functions described above, \code{add.protein} adds them to \code{thermo$protein} for use by other functions in CHNOSZ. The amino acid compositions of proteins in \code{aa} with the same name as one in \code{thermo$protein} are replaced. The value returned by this function is the rownumbers of \code{thermo$protein} that are added and/or replaced. - } \examples{ @@ -60,22 +57,20 @@ ip <- add.protein(aa) stopifnot(protein.length(ip)==10) # the chemical formula of this peptide -stopifnot(as.chemical.formula(protein.formula(ip))=="C41H69N11O18") +as.chemical.formula(protein.formula(ip)) # "C41H69N11O18" # we can also calculate a formula without using add.protein -as.chemical.formula(protein.formula(seq2aa("pentapeptide_test", "ANLSG"))) +aa <- seq2aa("pentapeptide_test", "ANLSG") +as.chemical.formula(protein.formula(aa)) } \seealso{ -\code{\link{read.fasta}} and \code{\link{uniprot.aa}} for getting amino acid compositions from a FASTA file or downloading them from UniProt, and \code{\link{more.aa}} for getting amino acid compositions for model organisms from additional data files in the \code{\link{extdata}/protein} directory. +\code{\link{read.fasta}}, \code{\link{uniprot.aa}}, \code{\link{more.aa}} for other ways of getting amino acid compositions. -\code{\link{protein.info}} for protein-level functions (chemical formulas, summaries of reaction coefficients and energies), and \code{\link{read.expr}} for working with protein abundance and subcellular localization data. +\code{\link{pinfo}} for protein-level functions (length, chemical formulas, reaction coefficients of basis species). -Examples of stability calculations for proteins are in \code{\link{protein}}. -} +\code{\link{read.expr}} for working with protein abundance and subcellular localization data. -\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. \emph{Biogeosciences} \bold{3}, 311--336. \url{http://dx.doi.org/10.5194/bg-3-311-2006} - +\code{\link{protein}} for examples of affinity calculations and diagrams. } \concept{Protein thermodynamic modeling} Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/man/data.Rd 2017-02-21 14:34:27 UTC (rev 168) @@ -166,7 +166,7 @@ } \item \code{thermo$protein} - Data frame of amino acid compositions of selected proteins. Many of the compositions were taken from the SWISS-PROT/UniProt online database (Boeckmann et al., 2003) and the protein and organism names usually follow the conventions adopted there. In some cases different isoforms of proteins are identified using modifications of the protein names; for example, \samp{MOD5.M} and \code{MOD5.N} proteins of \samp{YEAST} denote the mitochondrial and nuclear isoforms of this protein. See \code{\link{protein.info}} to search this data frame by protein name, and other functions to work with the amino acid compositions. + Data frame of amino acid compositions of selected proteins. Many of the compositions were taken from the SWISS-PROT/UniProt online database (Boeckmann et al., 2003) and the protein and organism names usually follow the conventions adopted there. In some cases different isoforms of proteins are identified using modifications of the protein names; for example, \samp{MOD5.M} and \code{MOD5.N} proteins of \samp{YEAST} denote the mitochondrial and nuclear isoforms of this protein. See \code{\link{pinfo}} to search this data frame by protein name, and other functions to work with the amino acid compositions. \tabular{lll}{ \code{protein} \tab character \tab Identification of protein\cr \code{organism} \tab character \tab Identification of organism\cr Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-21 14:34:27 UTC (rev 168) @@ -15,7 +15,7 @@ cex=par("cex"), cex.names=1, cex.axis=par("cex"), lty=NULL, lwd=par("lwd"), dotted=NULL, col=par("col"), col.names=par("col"), fill=NULL, - names=NULL, main=NULL, legend.x=NA, format.names=TRUE, + names=NULL, main=NULL, legend.x=NA, format.names=TRUE, adj=0.5, dy=0, add=FALSE, plot.it=TRUE, tplot=TRUE, ...) strip(affinity, ispecies = NULL, col = NULL, ns = NULL, xticks = NULL, ymin = -0.2, xpad = 1, cex.names = 0.7) @@ -52,6 +52,8 @@ \item{main}{character, a main \code{\link{title}} for the plot; \code{NULL} means to plot no title} \item{legend.x}{character, description of legend placement passed to \code{\link{legend}}} \item{format.names}{logical, apply formatting to chemical formulas?} + \item{adj}{numeric, adjustment for line labels} + \item{dy}{numeric, y offset for line labels} \item{add}{logical, add to current plot?} \item{plot.it}{logical, make a plot?} \item{tplot}{logical, set up plot with \code{\link{thermo.plot.new}}?} Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2017-02-20 12:27:24 UTC (rev 167) +++ pkg/CHNOSZ/man/examples.Rd 2017-02-21 14:34:27 UTC (rev 168) @@ -80,8 +80,9 @@ \examples{ \dontshow{data(thermo)} +\dontshow{opar <- par(no.readonly=TRUE)} demos(c("ORP", "NaCl")) -\dontshow{par(thermo$opar)} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 168 From noreply at r-forge.r-project.org Wed Feb 22 14:06:36 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 22 Feb 2017 14:06:36 +0100 (CET) Subject: [CHNOSZ-commits] r169 - in pkg/CHNOSZ: . R data inst inst/extdata inst/extdata/OBIGT man vignettes Message-ID: <20170222130636.31621188479@r-forge.r-project.org> Author: jedick Date: 2017-02-22 14:06:35 +0100 (Wed, 22 Feb 2017) New Revision: 169 Added: pkg/CHNOSZ/inst/extdata/OBIGT/ pkg/CHNOSZ/inst/extdata/OBIGT/Amend_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Canovas_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/H2O_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/LaRowe_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/LaRowe_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/LaRowe_liq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_gas.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_gas.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_liq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Schulte_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_gas.csv pkg/CHNOSZ/inst/extdata/OBIGT/Wagman_gas.csv Removed: pkg/CHNOSZ/data/OBIGT.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/data/thermo.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/man/wjd.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: split OBIGT.csv into multiple files Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-21 14:34:27 UTC (rev 168) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-22 13:06:35 UTC (rev 169) @@ -1,6 +1,6 @@ -Date: 2017-02-21 +Date: 2017-02-22 Package: CHNOSZ -Version: 1.0.8-58 +Version: 1.0.8-59 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-21 14:34:27 UTC (rev 168) +++ pkg/CHNOSZ/R/examples.R 2017-02-22 13:06:35 UTC (rev 169) @@ -24,8 +24,6 @@ if(plot.it) dev.off() } if(is.character(do.png)) dev.off() - # at the end we attempt to restore the old par() (active as of the first call of thermo.plot.new) - par(get("thermo")$opar) cat("Time elapsed: ", proc.time() - .ptime, "\n") } Deleted: pkg/CHNOSZ/data/OBIGT.csv =================================================================== --- pkg/CHNOSZ/data/OBIGT.csv 2017-02-21 14:34:27 UTC (rev 168) +++ pkg/CHNOSZ/data/OBIGT.csv 2017-02-22 13:06:35 UTC (rev 169) @@ -1,3395 +0,0 @@ -name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -water,NA,H2O,liq,NA,NA,25.Oct.06,-56687.711481,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA -e-,NA,Z0-1,aq,NA,NA,28.Oct.06,0,0,15.6166,0,0,0,0,0,0,0,0,0,0 -H+,H+,H+,aq,SH88,NA,06.Nov.97,0,0,0,0,0,0,0,0,0,0,0,0,0 -Li+,Li+,Li+,aq,SH88,NA,06.Nov.97,-69933,-66552,2.7,14.2,-0.87,-0.0237,-0.069,11.58,-2.7761,19.2,-0.24,0.4862,1 -Na+,Na+,Na+,aq,SH88,NA,06.Nov.97,-62591,-57433,13.96,9.06,-1.11,1.839,-2.285,3.256,-2.726,18.18,-2.981,0.3306,1 -K+,K+,K+,aq,SH88,NA,06.Nov.97,-67510,-60270,24.15,1.98,9.06,3.559,-1.473,5.435,-2.712,7.4,-1.791,0.1927,1 -Rb+,Rb+,Rb+,aq,SH88,NA,06.Nov.97,-67800,-60020,28.8,-3,14.26,4.2913,-0.9041,7.407,-2.7416,5.7923,-3.6457,0.1502,1 -Cs+,Cs+,Cs+,aq,SH88,NA,06.Nov.97,-69710,-61670,31.75,-6.29,21.42,6.1475,-0.1309,4.2094,-2.7736,6.27,-5.736,0.0974,1 -Mg+2,Mg+2,Mg+2,aq,SH88,NA,06.Nov.97,-108505,-111367,-33,-5.34,-21.55,-0.8217,-8.599,8.39,-2.39,20.8,-5.892,1.5372,2 -Ca+2,Ca+2,Ca+2,aq,SH88,NA,06.Nov.97,-132120,-129800,-13.5,-7.53,-18.06,-0.1947,-7.252,5.2966,-2.4792,9,-2.522,1.2366,2 -Sr+2,Sr+2,Sr+2,aq,SH88,NA,06.Nov.97,-134760,-131670,-7.53,-10.05,-17.41,0.7071,-10.1508,7.0027,-2.3594,10.7452,-5.0818,1.1363,2 -Ba+2,Ba+2,Ba+2,aq,SH88,NA,06.Nov.97,-134030,-128500,2.3,-12.3,-12.6,2.7383,-10.0565,-0.047,-2.3633,3.8,-3.45,0.985,2 -HCO3-,HCO3-,HCO3-,aq,SH88,NA,06.Nov.97,-140282,-164898,23.53,-8.46,24.6,7.5621,1.1505,1.2346,-2.8266,12.9395,-4.7579,1.2733,-1 -CO3-2,CO3-2,CO3-2,aq,SH88,NA,06.Nov.97,-126191,-161385,-11.95,-69.5,-5.02,2.8524,-3.9844,6.4142,-2.6143,-3.3206,-17.1917,3.3914,-2 -Pb+2,Pb+2,Pb+2,aq,SH88,NA,06.Nov.97,-5710,220,4.2,-12.7,-15.6,-0.0051,-7.7939,8.8134,-2.4568,8.6624,-5.6216,1.0788,2 -NO3-,NO3-,NO3-,aq,SH88,NA,06.Nov.97,-26507,-49429,35.12,-16.4,29,7.3161,6.7824,-4.6838,-3.0594,7.7,-6.725,1.0977,-1 -NO2-,NO2-,NO2-,aq,SH88,NA,06.Nov.97,-7700,-25000,29.4,-23.3,25,5.5864,5.859,3.4472,-3.0212,3.426,-7.7808,1.1847,-1 -NH4+,NH4+,NH4+,aq,SH88,NA,06.Nov.97,-18990,-31850,26.57,15.74,18.13,3.8763,2.3448,8.5605,-2.8759,17.45,-0.021,0.1502,1 -H2PO4-,H2PO4-,H2PO4-,aq,SH88,NA,06.Nov.97,-270140,-309820,21.6,-7,31.3,6.4875,8.0594,2.5823,-3.1122,14.0435,-4.4605,1.3003,-1 -HPO4-2,HPO4-2,HPO4-2,aq,SH88,NA,06.Nov.97,-260310,-308815,-8,-58.3,5.4,3.6315,1.0857,5.3233,-2.8239,2.7357,-14.9103,3.3363,-2 -OH-,OH-,OH-,aq,SH88,NA,06.Nov.97,-37595,-54977,-2.56,-32.79,-4.18,1.2527,0.0738,1.8423,-2.7821,4.15,-10.346,1.7246,-1 -HS-,HS-,HS-,aq,SH88,NA,07.Nov.97,2860,-3850,16.3,-22.17,20.65,5.0119,4.9799,3.4765,-2.9849,3.42,-6.27,1.441,-1 -HSO3-,HSO3-,HSO3-,aq,SH88,NA,07.Nov.97,-126130,-149670,33.4,-1.4,33.3,6.7014,8.5816,2.3771,-3.1338,15.6949,-3.3198,1.1233,-1 -SO4-2,SO4-2,SO4-2,aq,SH88,NA,07.Nov.97,-177930,-217400,4.5,-64.38,13.88,8.3014,-1.9846,-6.2122,-2.697,1.64,-17.998,3.1463,-2 -HSO4-,HSO4-,HSO4-,aq,SH88,NA,07.Nov.97,-180630,-212500,30,5.3,35.2,6.9788,9.259,2.1108,-3.1618,20.0961,-1.955,1.1748,-1 -S2O3-2,S2O3-2,S2O3-2,aq,SH88,NA,07.Nov.97,-124900,-155000,16,-57.3,28.5,6.6685,12.4951,-7.7281,-3.2955,-0.0577,-14.7066,2.9694,-2 -S2O8-2,S2O8-2,S2O8-2,aq,SH88,NA,07.Nov.97,-266500,-321400,58.4,-25,79,13.3622,24.8454,-4.0153,-3.8061,12.9632,-8.1271,2.3281,-2 -F-,F-,F-,aq,SH88,NA,07.Nov.97,-67340,-80150,-3.15,-27.23,-1.32,0.687,1.3588,7.6033,-2.8352,4.46,-7.488,1.787,-1 -Cl-,Cl-,Cl-,aq,SH88,NA,07.Nov.97,-31379,-39933,13.56,-29.44,17.79,4.032,4.801,5.563,-2.847,-4.4,-5.714,1.456,-1 -ClO3-,ClO3-,ClO3-,aq,SH88,NA,07.Nov.97,-1900,-24850,38.8,-12.3,36.9,7.1665,9.7172,1.9307,-3.1807,8.5561,-5.5401,1.0418,-1 -Br-,Br-,Br-,aq,SH88,NA,07.Nov.97,-24870,-29040,19.8,-30.42,24.85,5.269,6.594,4.745,-3.143,-3.8,-6.811,1.3858,-1 -BrO3-,BrO3-,BrO3-,aq,SH88,NA,07.Nov.97,4450,-16030,38.65,-20.6,35.4,6.9617,9.2173,2.1272,-3.16,3.7059,-7.2308,1.0433,-1 -I-,I-,I-,aq,SH88,NA,07.Nov.97,-12410,-13600,25.5,-28.25,36.31,7.7623,8.2762,1.4609,-3.1211,-6.27,-4.944,1.2934,-1 -IO3-,IO3-,IO3-,aq,SH88,NA,07.Nov.97,-30600,-52900,28.3,-16.2,25.9,5.7148,6.1725,3.324,-3.0342,7.7293,-6.3345,1.2002,-1 -Ni+2,Ni+2,Ni+2,aq,SH88,NA,07.Nov.97,-10900,-12900,-30.8,-11.7,-29,-1.6942,-11.9181,10.4344,-2.2863,13.1905,-5.4179,1.5067,2 -Ag+,Ag+,Ag+,aq,SH88,NA,07.Nov.97,18427,25275,17.54,7.9,-0.8,1.7285,-3.5608,7.1496,-2.6318,12.7862,-1.4254,0.216,1 -Cd+2,Cd+2,Cd+2,aq,SH88,NA,07.Nov.97,-18560,-18140,-17.4,-3.5,-15.6,0.0537,-10.708,16.5176,-2.3363,15.6573,-3.7476,1.2528,2 -La+3,La+3,La+3,aq,SH88,NA,07.Nov.97,-164000,-169600,-52,-37.2,-38.6,-2.788,-14.3824,10.9602,-2.1844,4.2394,-10.6122,2.1572,3 -Nd+3,Nd+3,Nd+3,aq,SH88,NA,07.Nov.97,-160600,-166500,-49.5,-43.2,-43.1,-3.3707,-14.5452,8.3211,-2.1777,1.6236,-11.8344,2.255,3 -Sm+3,Sm+3,Sm+3,aq,SH88,NA,07.Nov.97,-159100,-165200,-50.7,-43.3,-42,-3.2065,-15.6108,11.8857,-2.1337,1.9385,-11.8548,2.2955,3 -Eu+3,Eu+3,Eu+3,aq,SH88,NA,07.Nov.97,-137300,-144700,-53,-36.6,-41.3,-3.1037,-15.3599,11.7871,-2.144,6.0548,-10.49,2.3161,3 -Gd+3,Gd+3,Gd+3,aq,SH88,NA,07.Nov.97,-158600,-164200,-49.2,-35.9,-40.4,-2.9771,-15.0506,11.6656,-2.1568,6.5606,-10.3474,2.3265,3 -Dy+3,Dy+3,Dy+3,aq,SH88,NA,07.Nov.97,-158700,-166500,-55.2,-31.7,-40.7,-3.0003,-15.1074,11.6879,-2.1545,9.5076,-9.4919,2.3792,3 -Ho+3,Ho+3,Ho+3,aq,SH88,NA,07.Nov.97,-161400,-169000,-54.3,-33.3,-41.6,-3.1198,-15.3992,11.8026,-2.1424,8.6686,-9.8178,2.3899,3 -Er+3,Er+3,Er+3,aq,SH88,NA,07.Nov.97,-159900,-168500,-58.3,-34.3,-43,-3.3041,-15.8492,11.9794,-2.1238,8.2815,-10.0215,2.4115,3 -Tm+3,Tm+3,Tm+3,aq,SH88,NA,07.Nov.97,-159900,-168500,-58.1,-34.3,-43,-3.2967,-15.8312,11.9724,-2.1245,8.4826,-10.0215,2.4333,3 -Yb+3,Yb+3,Yb+3,aq,SH88,NA,07.Nov.97,-153000,-160300,-56.9,-36.4,-44.6,-3.4983,-16.3233,12.1658,-2.1042,7.3533,-10.4493,2.4443,3 -Lu+3,Lu+3,Lu+3,aq,SH88,NA,07.Nov.97,-159400,-167900,-63.1,-32,-45,-3.563,-16.4812,12.2279,-2.0977,9.565,-9.716,2.4554,3 -BO2-,BO2-,BO2-,aq,SH88,NA,06.Nov.97,-162240,-184600,-8.9,-41,-14.5,-2.2428,-6.2065,-6.3216,-2.5224,-1.6521,-11.3863,1.7595,-1 -BF4-,BF4-,BF4-,aq,SH88,NA,16.Feb.88,-355400,-376400,43,-5.6,43,7.9796,11.7027,1.1504,-3.2628,11.8941,-4.1753,0.9779,-1 -SiF6-2,SiF6-2,SiF6-2,aq,SH88,NA,16.Feb.88,-525700,-571000,29.2,-47.1,42.6,8.5311,13.0492,0.6211,-3.3185,4.097,-12.6289,2.7716,-2 -H2AsO3-,H2AsO3-,H2AsO3-,aq,SH88,NA,3.Jul.87,-140330,-170840,26.4,-2.9,26.4,5.7934,6.3646,3.2485,-3.0421,15.8032,-3.6253,1.2305,-1 -S2-2,S2-2,S2-2,aq,SH88,NA,3.Jul.87,19000,7200,6.8,-65.1,20.2,5.5797,5.8426,3.4536,-3.0205,-3.3496,-16.2955,3.1083,-2 -S3-2,S3-2,S3-2,aq,SH88,NA,3.Jul.87,17600,6200,15.8,-57.9,29.2,6.7661,8.7396,2.315,-3.1403,-0.3595,-14.8288,2.9749,-2 -S4-2,S4-2,S4-2,aq,SH88,NA,3.Jul.87,16500,5500,24.7,-50.7,38.1,7.9381,11.6012,1.1902,-3.2586,2.6081,-13.3622,2.839,-2 -S5-2,S5-2,S5-2,aq,SH88,NA,3.Jul.87,15700,5100,33.6,-43.6,47,9.1107,14.4645,0.0649,-3.377,5.5361,-11.9159,2.7051,-2 -HF2-,HF2-,HF2-,aq,SH88,NA,12.Jul.87,-138160,-155340,22.1,-33.2,22.1,5.2263,4.9797,3.7928,-2.9849,-1.3751,-9.7974,1.2934,-1 -Br3-,Br3-,Br3-,aq,SH88,NA,12.Jul.87,-25590,-31170,51.5,5.6,51.5,9.0992,14.4364,0.0759,-3.3758,17.2705,-1.8939,0.849,-1 -I3-,I3-,I3-,aq,SH88,NA,12.Jul.87,-12300,-12300,57.2,13.1,57.2,9.85,16.2697,-0.6447,-3.4516,20.8712,-0.3661,0.7628,-1 -Ag+2,Ag+2,Ag+2,aq,SH88,NA,16.Feb.88,64300,64200,-21,-5.3,-19.3,-0.4299,-8.831,9.221,-2.4139,15.2224,-4.1142,1.3201,2 -Hg+2,Hg+2,Hg+2,aq,SH88,NA,1.Jul.87,39360,40670,-8.68,2.2,-19.6,-0.528,-9.0707,9.3152,-2.404,18.0613,-2.5865,1.1512,2 -Cu+2,Cu+2,Cu+2,aq,SH88,NA,07.Nov.97,15675,15700,-23.2,-5.7,-24.6,-1.1021,-10.4726,9.8662,-2.3461,20.3,-4.39,1.4769,2 -He,NA,He,aq,SHS89,NA,13.Jul.87,4658,-150,14.02,37.3,13,3.4722,0.6967,5.4762,-2.8078,26.0707,4.5634,-0.2123,0 -Ar,NA,Ar,aq,SHS89,NA,1.Sep.06,3900,-2870,14.3,52.8,31.71,6.003,6.8698,3.0499,-3.063,35.6471,7.316,-0.3073,0 -Xe,NA,Xe,aq,SHS89,NA,13.Jul.87,3225,-4510,14.62,64.8,42.6,7.5196,10.5793,1.5919,-3.2163,42.1036,10.1652,-0.2214,0 -H2,NA,H2,aq,SHS89,NA,13.Jul.87,4236,-1000,13.8,39.9,25.2,5.1427,4.7758,3.8729,-2.9764,27.6251,5.093,-0.209,0 -O2,NA,O2,aq,SHS89,NA,26.Jun.87,3954,-2900,26.04,56,30.38,5.7889,6.3536,3.2528,-3.0417,35.353,8.3726,-0.3943,0 -NH3,NA,NH3,aq,SSW01,SHS89,11.Oct.07,-6383,-19440,25.77,15.63,24.43,5.0911,2.797,8.6248,-2.8946,28.0865,-6.4728,-0.0769,0 -CO2,NA,CO2,aq,SSW01,SHS89,11.Oct.07,-92250,-98900,28.1,51.09,32.8,6.2466,7.4711,2.8136,-3.0879,38.4529,5.3534,-0.1934,0 -H2S,NA,H2S,aq,SSW01,SHS89,11.Oct.07,-6673,-9001,30,42.88,34.92,6.5097,6.7724,5.9646,-3.059,27.8951,6.7164,-0.1471,0 -B(OH)3,NA,B(OH)3,aq,SHS89,NA,13.Jul.87,-231540,-256820,37,12,39.22,7.0643,8.8547,3.5844,-3.1451,11.3568,-0.5902,-0.2,0 -SiO2,NA,SiO2,aq,SHS89,NA,13.Jan.89,-199190,-209775,18,-76.1,16.1,1.9,1.7,20,-2.7,29.1,-51.2,0.1291,0 -H3PO4,NA,H3PO4,aq,SHS89,NA,11.Jul.87,-273100,-307920,38,23.6,48.1,8.2727,12.4182,0.8691,-3.2924,17.9708,1.7727,-0.22,0 -Ne,NA,Ne,aq,SHS89,NA,13.Jul.87,4565,-870,16.74,39.7,20.4,4.4709,3.1352,4.5177,-2.9086,27.0977,5.0523,-0.2535,0 -Kr,NA,Kr,aq,SHS89,NA,13.Jul.87,3554,-3650,15.06,57.6,33.5,6.2721,7.5333,2.7891,-3.0904,37.8226,8.6985,-0.2281,0 -Rn,NA,Rn,aq,SHS89,NA,13.Jul.87,2790,-5000,16,83,54.1,9.0862,14.4045,0.0884,-3.3745,52.5774,13.8725,-0.2423,0 -N2,NA,N2,aq,SHS89,NA,7.Feb.89,4347,-2495,22.9,56,33.3,6.2046,7.3685,2.8539,-3.0836,35.7911,8.3726,-0.3468,0 -SO2,NA,SO2,aq,SSW01,SHS89,1.Sep.06,-71980,-77194,38.7,35.48,38.5,6.9502,9.189,2.1383,-3.1589,30.8993,2.0024,-0.0559,0 -HF,NA,HF,aq,SHS89,NA,7.Feb.89,-71662,-76835,22.5,14,12.5,3.4753,0.7042,5.4732,-2.8081,14.3647,-0.1828,-0.0007,0 -methane,NA,CH4,aq,SH90,NA,31.Aug.87,-8234,-21010,20.99,66.3,37.3,6.7617,8.7279,2.3212,-3.1397,42.0941,10.4707,-0.3179,0 -ethane,NA,C2H6,aq,SH90,NA,31.Aug.87,-3886,-24710,26.59,88.3,51.2,8.75,13.1051,1.6258,-3.3207,73.8072,2.2242,-0.0627,0 -propane,NA,C3H8,aq,SH90,NA,31.Aug.87,-1963,-30490,33.35,110.6,67,10.768,17.6785,-0.5878,-3.5097,84.546,4.6332,-0.165,0 -butane,NA,C4H10,aq,SH90,NA,15.Jan.93,36,-36230,40.02,133.9,82.8,12.8905,23.696,-3.5683,-3.7585,79.0569,24.2408,-0.6061,0 -pentane,NA,C5H12,aq,SH90,NA,15.Jan.93,2130,-41560,47.5,153,98.6,15.0143,28.8771,-5.5949,-3.9727,89.207,28.1315,-0.7193,0 -hexane,NA,C6H14,aq,SH90,NA,15.Jan.93,4420,-47400,52.9,175.2,114.4,17.1487,34.0927,-7.653,-4.1883,101.4642,32.6536,-0.8011,0 -heptane,NA,C7H16,aq,SH90,NA,15.Jan.93,6470,-52950,60,196.4,130.2,19.2745,39.281,-9.6879,-4.4028,112.898,36.9721,-0.9086,0 -octane,NA,C8H18,aq,SH90,NA,15.Jan.93,8580,-59410,63.8,217.6,146,21.4171,44.5126,-11.7437,-4.6191,124.7924,41.2905,-0.9662,0 -ethylene,NA,C2H4,aq,SH90,NA,4.Sep.87,19450,8570,28.7,62.5,45.5,7.856,12.6391,-1.8737,-3.3014,39.1,9.7,-0.4,0 -propene,NA,C3H6,aq,SH90,NA,4.Sep.87,17910,-290,36.7,83.7,61.3,9.9655,16.5518,-0.7564,-3.4632,50.0997,14.0151,-0.5558,0 -butene,NA,C4H8,aq,SH90,NA,4.Sep.87,20310,-5635,43.4,104.9,77.1,12.0932,21.7476,-2.7991,-3.6779,61.5894,18.3335,-0.6572,0 -pentene,NA,C5H10,aq,SH90,NA,4.Sep.87,22470,-11200,50.1,126.1,92.9,14.221,26.9431,-4.8413,-3.8927,73.0791,22.652,-0.7587,0 -hexene,NA,C6H12,aq,SH90,NA,4.Sep.87,24370,-17025,56.8,147.3,108.7,16.3488,32.1387,-6.8838,-4.1075,84.5689,26.9704,-0.8602,0 -heptene,NA,C7H14,aq,SH90,NA,4.Sep.87,26450,-22670,63.5,168.5,124.5,18.4766,37.3342,-8.926,-4.3223,96.0586,31.2889,-0.9616,0 -octene,NA,C8H16,aq,SH90,NA,4.Sep.87,28720,-28120,70.2,189.7,140.3,20.6044,42.5297,-10.9682,-4.5371,107.5483,35.6073,-1.0631,0 -ethyne,NA,C2H2,aq,SH90,NA,31.Aug.87,51890,50700,30,53,49.3,8.3577,12.6272,0.7833,-3.3009,33.0423,7.7615,-0.4543,0 -1-propyne,NA,C3H4,aq,SH90,NA,4.Sep.87,47880,38970,36.7,74.2,65.1,10.4855,17.8227,-1.2588,-3.5157,44.5321,12.0799,-0.5558,0 -1-butyne,NA,C4H6,aq,SH90,NA,4.Sep.87,50030,33400,43.4,95.4,80.9,12.6132,23.0185,-3.3011,-3.7305,56.0218,16.3984,-0.6572,0 -1-pentyne,NA,C5H8,aq,SH90,NA,4.Sep.87,52160,27800,50.1,116.6,96.7,14.741,28.214,-5.3433,-3.9453,67.5117,20.7168,-0.7587,0 -1-hexyne,NA,C6H10,aq,SH90,NA,4.Sep.87,54420,22340,56.8,137.8,112.5,16.8688,33.4096,-7.3857,-4.1601,79.0012,25.0353,-0.8602,0 -1-heptyne,NA,C7H12,aq,SH90,NA,4.Sep.87,56730,16980,63.7,159,128.3,18.9956,38.6015,-9.4245,-4.3747,90.4632,29.3537,-0.9647,0 -1-octyne,NA,C8H14,aq,SH90,NA,4.Sep.87,58860,11330,70.2,180.2,144.1,21.1244,43.8006,-11.4705,-4.5896,101.9808,33.6721,-1.0631,0 -benzene,NA,C6H6,aq,SH90,NA,4.Sep.87,32000,12230,35.5,86.3,83.5,13.1244,18.1143,11.8225,-3.5277,80.8626,1.7799,-0.1976,0 -toluene,NA,C6H5CH3,aq,SH90,NA,4.Sep.87,30260,3280,43.9,102.8,97.71,15.0259,21.9153,12.1349,-3.6849,93.924,2.8953,-0.3248,0 -ethylbenzene,NA,C6H5C2H5,aq,SH90,NA,4.Sep.87,32440,-2500,49.8,120.5,113.8,17.5572,33.0675,-2.9124,-4.1459,102.5478,6.6974,-0.2,0 -n-propylbenzene,NA,C6H5C3H7,aq,SH90,SLOP98,31.Aug.87,34370,-8630,55.3,144.8,129.6,20.1912,39.0352,-4.2632,-4.3926,123.7758,9.3452,-0.208,0 -n-butylbenzene,NA,C6H5C4H9,aq,SH90,SLOP98,31.Aug.87,36110,-13820,63,166,145.4,22.4936,44.2553,-5.4521,-4.6084,132.7179,10.3925,-0.1697,0 -n-pentylbenzene,NA,C6H5C5H11,aq,SH90,SLOP98,2.Sep.87,38790,-19400,69.7,187.2,161.2,24.3697,48.5078,-6.4198,-4.7842,146.7939,12.082,-0.1253,0 -n-hexylbenzene,NA,C6H5C6H13,aq,SH90,SLOP98,2.Sep.87,40880,-24990,76.4,208.4,177,26.6289,53.6288,-7.5847,-4.9959,160.8699,13.7715,-0.0809,0 -n-heptylbenzene,NA,C6H5C7H15,aq,SH90,SLOP98,2.Sep.87,43350,-123420,83.1,229.6,192.8,28.8881,58.7499,-8.7498,-5.2076,174.9459,15.461,-0.0364,0 -n-octylbenzene,NA,C6H5C8H17,aq,SH90,SLOP98,2.Sep.87,45400,-138400,89.8,250.8,208.6,31.1472,63.8712,-9.9148,-5.4193,189.022,17.1504,0.008,0 -methanol,NA,CH3OH,aq,SH90,NA,2.Sep.87,-42050,-58870,32.2,37.8,38.17,6.9383,5.5146,11.4018,-3.0069,39.4852,-1.4986,-0.1476,0 -ethanol,NA,C2H5OH,aq,SH90,NA,2.Sep.87,-43330,-68650,35.9,62.2,55.08,9.2333,9.9581,12.1445,-3.1906,60.0175,0.1507,-0.2037,0 -propanol,1-propanol,C3H7OH,aq,SH90,NA,2.Sep.87,-41910,-75320,41.4,84.3,70.7,11.3426,14.3252,12.1079,-3.3711,78.3142,1.6447,-0.2869,0 -butanol,1-butanol,C4H9OH,aq,SH90,NA,2.Sep.87,-38840,-80320,46.9,104.4,86.6,13.4902,17.94,14.1816,-3.5205,94.8858,3.0034,-0.3702,0 -pentanol,1-pentanol,C5H11OH,aq,SH90,NA,2.Sep.87,-38470,-87730,53.4,125.2,102.68,15.6573,22.623,13.6464,-3.7141,111.9216,4.4095,-0.4687,0 -hexanol,NA,C6H13OH,aq,SH90,SLOP98,2.Jun.98,-37060,-92690,64.8,144.4,118.65,17.7843,27.4289,12.589,-3.9128,126.8936,5.7074,-0.6413,0 -heptanol,NA,C7H15OH,aq,SH90,SLOP98,2.Jun.98,-34095,-97270,72.1,174.2,133.43,19.7695,31.3977,12.9129,-4.0769,151.5815,7.7219,-0.7519,0 -octanol,NA,C8H17OH,aq,SH90,NA,2.Sep.87,-30250,-103060,72.3,195,149.2,21.9264,35.7093,13.267,-4.2551,169.4962,9.128,-0.7549,0 -acetone,NA,C3H6O,aq,SH90,NA,2.Sep.87,-38500,-61720,44.4,57.7,66.92,10.81,13.4912,11.435,-3.3366,54.9496,-0.1534,-0.3324,0 -butanone,2-butanone,C4H8O,aq,SH90,NA,2.Sep.87,-36730,-67880,50.3,80.4,82.52,12.9145,17.6967,11.7839,-3.5105,73.7083,1.381,-0.4217,0 -2-pentanone,NA,C5H10O,aq,SH90,NA,2.Sep.87,-34390,-73460,56.3,101.6,98,15.0021,21.8653,12.1372,-3.6828,91.1588,2.8142,-0.5126,0 -2-hexanone,NA,C6H12O,aq,SH90,NA,2.Sep.87,-32480,-79220,63.4,122.8,113.7,17.1141,26.0886,12.4806,-3.8574,108.456,4.2473,-0.6201,0 -2-heptanone,NA,C7H14O,aq,SH90,NA,2.Sep.87,-30430,-84890,70.1,144,129.5,19.2419,30.3392,12.8366,-4.0331,125.8091,5.6804,-0.7216,0 -2-octanone,NA,C8H16O,aq,SH90,NA,2.Sep.87,-28380,-90560,76.8,165.2,145.3,21.3697,34.596,13.1769,-4.2091,143.162,7.1135,-0.8231,0 -methanamine,NA,CH3NH2,aq,SH90,NA,4.Sep.87,5040,-16320,30.5,37,41.88,7.4547,6.7824,10.8884,-3.0593,39.0324,-1.5527,-0.1219,0 -ethanamine,NA,C2H5NH2,aq,SH90,NA,1.Oct.87,6300,-23830,33.6,56.8,58.61,9.7281,11.3257,11.2651,-3.2471,55.6799,-0.2142,-0.1688,0 -propanamine,NA,C3H7NH2,aq,SH90,NA,4.Sep.87,7010,-30680,40.8,78,74.15,11.8178,15.5013,11.6113,-3.4197,72.9633,1.2188,-0.2779,0 -butanamine,NA,C4H9NH2,aq,SH90,NA,4.Sep.87,9410,-36110,47.2,101,89.8,13.9266,19.7205,11.9476,-3.5941,91.9109,2.7736,-0.3748,0 -pentanamine,NA,C5H11NH2,aq,SH90,NA,1.Oct.87,12800,-40650,53.5,123,105.7,16.0701,24.0048,12.301,-3.7713,110.0099,4.2608,-0.4702,0 -hexanamine,NA,C6H13NH2,aq,SH90,NA,4.Sep.87,14860,-46320,60.2,144,121.6,18.2115,28.2822,12.6611,-3.9481,127.1903,5.6804,-0.5717,0 -heptanamine,NA,C7H15NH2,aq,SH90,NA,4.Sep.87,16910,-51990,66.9,162.8,137.6,20.3667,32.5921,13.0098,-4.1263,142.4729,6.9513,-0.6731,0 -octanamine,NA,C8H17NH2,aq,SH90,NA,4.Sep.87,18960,-57660,73.6,184,153.2,22.4671,36.7896,13.3574,-4.2998,159.8259,8.3844,-0.7746,0 -"a-aminobutyric acid",NA,C4H9NO2,aq,SH90,NA,4.Sep.87,-87120,-138180,46.7,53.1,76.5,12.1092,16.0862,11.6529,-3.4439,50.6605,-0.4643,-0.3672,0 -alanylglycine,NA,C5H10N2O3,aq,Sho92,NA,28.Feb.92,-116730,-186110,50.7,60.3,95.22,14.6503,21.164,12.0751,-3.6538,54.7374,0.7979,-0.4278,0 -leucylglycine,NA,C8H16N2O3,aq,Sho92,NA,27.Aug.06,-110620,-202660,72.6,118.8,145.34,21.3967,34.6501,13.1805,-4.2113,98.6389,6.4783,-0.7594,0 -diglycine,NA,C4H8N2O3,aq,Sho92,NA,28.Feb.92,-117020,-175640,54.2,38,76.27,12.0393,15.9447,11.6466,-3.4381,36.349,-1.3673,-0.4808,0 -diketopiperazine,NA,C4H6N2O2,aq,Sho92,NA,28.Feb.92,-57440,-99300,53.5,17,76.73,12.1058,16.0764,11.6608,-3.4435,19.5904,-3.4064,-0.4702,0 -ethylacetate,NA,CH3COOCH2CH3,aq,Sho93,NA,18.Mar.93,-79300,-116840,53.4,94.8,88.8,13.8375,24.6396,-1.0033,-3.7975,83.6983,4.4052,-0.2334,0 -Pb(Ac)+,NA,PbCH3COO+,aq,SK93,NA,16.Feb.91,-97250,-115880,36,71.4,32.1,6.1543,7.2429,2.9082,-3.0783,48.0824,11.5161,0.0057,1 -Pb(Ac)2,NA,Pb(CH3COO)2,aq,SK93,NA,16.Feb.91,-186890,-229460,69.8,165,85.2,13.409,24.9584,-4.057,-3.8107,102.6053,30.5811,-0.03,2 -Ca(Ac)+,NA,CaCH3COO+,aq,SK93,NA,5.Apr.93,-221660,-245620,12.5,83.1,29.3,5.9002,6.6232,3.1505,-3.0527,58.1976,13.8857,0.3636,1 -Mg(Ac)+,NA,MgCH3COO+,aq,SK93,NA,17.Mar.93,-198520,-229480,-13.1,88,25.4,5.4981,5.6424,3.5341,-3.0122,64.6297,14.8894,0.7483,1 -Li(Ac),NA,LiCH3COO,aq,SK93,NA,17.Aug.92,-158610,-184240,19.5,86.7,48.5,8.388,12.6976,0.7639,-3.3038,56.6767,14.6175,-0.03,0 -Na(Ac),NA,NaCH3COO,aq,SK93,NA,17.Aug.92,-150720,-173540,34.2,75.1,48.2,8.3514,12.6125,0.7884,-3.3003,49.8989,12.2617,-0.03,0 -K(Ac),NA,KCH3COO,aq,SK93,NA,17.Aug.92,-155420,-175220,47.6,59.2,59.5,9.902,16.3937,-0.6874,-3.4566,40.5631,9.0167,-0.03,0 -Sr(Ac)+,NA,SrCH3COO+,aq,SK93,NA,17.Aug.92,-224510,-247220,20,77.4,30.1,5.9602,6.7718,3.0884,-3.0588,53.8109,12.7307,0.2482,1 -Ba(Ac)+,NA,BaCH3COO+,aq,SK93,NA,17.Aug.92,-223650,-242850,33.5,72.3,35.4,6.6253,8.3926,2.4574,-3.1259,48.9806,11.6995,0.0459,1 -Mn(Ac)+,NA,MnCH3COO+,aq,SK93,NA,17.Aug.92,-144430,-169560,6.3,90.8,30.4,6.0776,7.057,2.9786,-3.0706,63.5668,15.4577,0.4555,1 -Mn(Ac)2,NA,Mn(CH3COO)2,aq,SK93,NA,10.Sep.92,-233850,-287670,24.2,202.8,83.3,13.1542,24.3405,-3.8236,-3.7851,124.7315,38.2716,-0.03,2 -Co(Ac)+,NA,CoCH3COO+,aq,SK93,NA,17.Aug.92,-103260,-132080,-6.5,82.5,22.3,5.0294,4.4992,3.9806,-2.9649,60.4543,13.7619,0.6472,1 -Ni(Ac)+,NA,NiCH3COO+,aq,SK93,NA,17.Aug.92,-101120,-131450,-11.7,73.7,17.1,4.3556,2.8512,4.6343,-2.8968,56.0621,11.9745,0.7287,1 -Cu(Ac)+,NA,CuCH3COO+,aq,SK93,NA,19.Aug.92,-75640,-103120,-1.3,87.2,22,4.9722,4.362,4.029,-2.9592,62.495,14.7244,0.5681,1 -Cu(Ac)2,NA,Cu(CH3COO)2,aq,SK93,NA,19.Aug.92,-165820,-222690,14.2,195.8,74,11.8801,21.2264,-2.5925,-3.6564,120.615,36.8408,-0.03,2 -Cd(Ac)+,NA,CdCH3COO+,aq,SK93,NA,17.Aug.92,-109460,-135920,6.6,92.1,32.1,6.3043,7.6112,2.7593,-3.0935,64.3035,15.7327,0.4496,1 -Cd(Ac)2,NA,Cd(CH3COO)2,aq,SK93,NA,17.Aug.92,-199400,-254520,24.6,205.4,85.2,13.409,24.9584,-4.057,-3.8107,126.2752,38.8081,-0.03,2 -Hg(Ac)+,NA,HgCH3COO+,aq,SK93,NA,17.Aug.92,-54760,-79390,18.5,105,27.6,5.6341,5.9787,3.3935,-3.0261,70.1764,18.3452,0.2712,1 -Hg(Ac)2,NA,Hg(CH3COO)2,aq,SK93,NA,17.Aug.92,-146580,-198780,40.1,230.4,80.2,12.7295,23.3004,-3.408,-3.7421,140.9402,43.9053,-0.03,2 -Ag(Ac),NA,AgCH3COO,aq,SK93,NA,17.Aug.92,-70840,-91650,38.9,72.5,48.6,8.3987,12.7257,0.7485,-3.305,48.3694,11.73,-0.03,0 -Ag(Ac)2-,NA,Ag(CH3COO)2-,aq,SK93,NA,17.Aug.92,-158990,-210560,49.9,164.9,103.5,16.2287,31.8418,-6.7592,-4.0952,110.8373,30.5473,0.8741,-1 -Tl(Ac),NA,TlCH3COO,aq,SK93,NA,17.Aug.92,-95860,-113350,55.2,45.3,69.7,11.2955,19.8003,-2.0347,-3.5974,32.4138,6.1843,-0.03,0 -Al(Ac)+2,NA,AlCH3COO+2,aq,SK93,SLOP98,5.Apr.93,-208420,-249360,-63.1,72.2,-0.03,2.4411,-1.8235,6.4722,-2.7035,67.0012,11.6689,2.0115,2 -Al(Ac)2+,NA,Al(CH3COO)2+,aq,SK93,SLOP98,5.Apr.93,-300240,-373010,-55.7,168.7,49.4,8.9971,14.1844,0.1805,-3.3653,117.86,31.3303,1.3918,1 -Bi(Ac)+2,NA,BiCH3COO+2,aq,SK93,NA,26.Sep.92,-67750,-96420,-15.2,153.5,21.7,5.169,4.8386,3.8508,-2.9789,107.9465,28.2236,1.286,2 -Bi(Ac)2+,NA,Bi(CH3COO)2+,aq,SK93,NA,26.Sep.92,-157070,-212380,9.6,327.3,73.6,11.976,21.4619,-2.6877,-3.6661,201.695,63.6303,0.4046,1 -Eu(Ac)+2,NA,EuCH3COO+2,aq,SK93,NA,10.Sep.92,-229390,-264280,-31.1,63,3.4,2.75,-1.0666,6.169,-2.7348,57.1309,9.7898,1.5269,2 -La(Ac)+2,NA,LaCH3COO+2,aq,SK93,NA,17.Aug.92,-255750,-288710,-29.6,61.6,6.4,3.1548,-0.0804,5.7863,-2.7756,56.153,9.5148,1.5067,2 -La(Ac)2+,NA,La(CH3COO)2+,aq,SK93,NA,17.Aug.92,-346160,-407330,-10.1,148.1,56.5,9.7487,16.0216,-0.5464,-3.4412,99.3969,27.1273,0.7003,1 -Nd(Ac)+2,NA,NdCH3COO+2,aq,SK93,NA,17.Aug.92,-252510,-285470,-26.1,48.1,1.4,2.4521,-1.7961,6.4594,-2.7046,47.7869,6.7648,1.4574,2 -Nd(Ac)2+,NA,Nd(CH3COO)2+,aq,SK93,NA,17.Aug.92,-343330,-404110,-5.3,121.7,51,8.9606,14.099,0.2066,-3.3618,83.3168,21.7619,0.6305,1 -Sm(Ac)+2,NA,SmCH3COO+2,aq,SK93,NA,17.Aug.92,-251240,-284550,-27.8,47.9,2.7,2.6264,-1.3667,6.2827,-2.7224,47.8346,6.719,1.4769,2 -Sm(Ac)2+,NA,Sm(CH3COO)2+,aq,SK93,NA,17.Aug.92,-342190,-403500,-7.6,121.3,52.4,9.159,14.5839,0.0138,-3.3818,83.3717,21.6725,0.6644,1 -Yb(Ac)+2,NA,YbCH3COO+2,aq,SK93,NA,17.Aug.92,-244760,-280040,-36.6,63.4,-0.1,2.2906,-2.1905,6.6154,-2.6883,58.1718,9.8814,1.6113,2 -Yb(Ac)2+,NA,Yb(CH3COO)2+,aq,SK93,NA,17.Aug.92,-335520,-399750,-19.6,151.6,49.3,8.7953,13.6959,0.3628,-3.3451,102.7868,27.8427,0.8449,1 -U(Ac)+2,NA,UCH3COO+2,aq,SK93,NA,17.Aug.92,-205480,-235460,-21.3,144.6,19.3,4.8662,4.1031,4.1308,-2.9485,103.6659,26.4274,1.3823,2 -U(Ac)2+,NA,U(CH3COO)2+,aq,SK93,SLOP98,2.Jun.98,-296950,-354300,1.3,310.1,70.9,11.6455,20.6554,-2.3718,-3.6328,192.7896,60.1258,0.5324,1 -U(Ac)3,NA,U(CH3COO)3,aq,SK93,NA,17.Aug.92,-387360,-473790,17.7,496,128.4,19.329,39.4128,-9.7374,-4.4082,296.5739,97.9996,-0.03,0 -UO2(Ac)+,NA,UO2CH3COO+,aq,SK93,SLOP98,2.Jun.98,-320100,-363559,-1.7,123,55.8,9.599,15.6588,-0.4099,-3.4262,83.5297,22.0118,0.5756,1 -UO2(Ac)2,NA,UO2(CH3COO)2,aq,SK93,NA,09.Dec.94,-411840,-484700,13.7,265.6,111.7,17.0325,33.8044,-7.5309,-4.1764,161.5228,51.0592,-0.03,0 -UO2(Ac)3-,NA,UO2(CH3COO)3-,aq,SK93,NA,09.Dec.94,-502400,-607960,18.3,438,173.8,26.0101,55.7294,-16.1571,-5.0828,275.3211,86.1855,1.3526,-1 -Li(Ac)2-,NA,Li(CH3COO)2-,aq,SK93,NA,10.Sep.92,-246810,-304670,25.5,192.5,103.5,16.3412,32.1211,-6.8785,-4.1068,130.4373,36.181,1.2422,-1 -Na(Ac)2-,NA,Na(CH3COO)2-,aq,SK93,NA,10.Sep.92,-238470,-292400,44,170,103.2,16.2062,31.7884,-6.7416,-4.093,114.6437,31.5846,0.9633,-1 -K(Ac)2-,NA,K(CH3COO)2-,aq,SK93,NA,10.Sep.92,-242990,-292900,60.7,138.9,115.8,17.8481,35.7984,-8.3193,-4.2588,94.0916,25.2533,0.7097,-1 -Mg(Ac)2,NA,Mg(CH3COO)2,aq,SK93,SLOP98,2.Jun.98,-287830,-349327,-1.2,197.3,77.8,12.3982,22.4898,-3.0853,-3.7086,121.5413,37.1627,-0.03,0 -Ca(Ac)2,NA,Ca(CH3COO)2,aq,SK93,SLOP98,2.Jun.98,-311570,-363720,32.3,187.7,82.1,12.9911,23.9379,-3.6556,-3.7685,115.9068,35.2043,-0.03,0 -Sr(Ac)2,NA,Sr(CH3COO)2,aq,SK93,NA,10.Sep.92,-313610,-363740,42.2,176.7,82.9,13.1015,24.2102,-3.7685,-3.7797,109.4234,32.9508,-0.03,0 -Ba(Ac)2,NA,Ba(CH3COO)2,aq,SK93,NA,10.Sep.92,-312620,-358010,59.7,166.8,88.9,13.9186,26.2066,-4.5556,-3.8623,103.6344,30.9388,-0.03,0 -Mn(Ac)3-,NA,Mn(CH3COO)3-,aq,SK93,NA,10.Sep.92,-322580,-408280,31.5,331.9,142.3,21.6217,45.0124,-11.9409,-4.6397,211.3036,64.5717,1.1536,-1 -Co(Ac)2,NA,Co(CH3COO)2,aq,SK93,NA,10.Sep.92,-192770,-251460,7.5,186.5,74.2,11.9141,21.312,-2.6321,-3.6599,115.2121,34.9629,-0.03,0 -Co(Ac)3-,NA,Co(CH3COO)3-,aq,SK93,NA,10.Sep.92,-281890,-373730,10.4,304.4,132.2,20.3474,41.8989,-10.7127,-4.511,198.142,58.9793,1.4714,-1 -Ni(Ac)2,NA,Ni(CH3COO)2,aq,SK93,SLOP98,2.Jun.98,-190610,-251340,0.7,169.4,68.5,11.1327,19.4031,-1.8801,-3.581,105.1782,31.4753,-0.03,0 -Ni(Ac)3-,NA,Ni(CH3COO)3-,aq,SK93,SLOP98,2.Jun.98,-279690,-374124,1.9,275.5,125.8,19.5212,39.8827,-9.9226,-4.4277,182.3942,53.0847,1.603,-1 -Cu(Ac)3-,NA,Cu(CH3COO)3-,aq,SK93,NA,10.Sep.92,-255810,-345320,18.99,320,131.9,20.2654,41.7019,-10.6422,-4.5029,206.07,62.1534,1.3408,-1 -Cd(Ac)3-,NA,Cd(CH3COO)3-,aq,SK93,SLOP98,2.Jun.98,-288030,-375080,31.9,336.3,144.3,21.9033,45.7036,-12.2199,-4.6683,213.8505,65.4786,1.1469,-1 -Hg(Ac)3-,NA,Hg(CH3COO)3-,aq,SK93,NA,10.Sep.92,-239020,-321900,51.4,378.6,138.8,21.0462,43.6061,-11.3861,-4.5816,235.9096,74.0939,0.8508,-1 -Pb(Ac)3-,NA,Pb(CH3COO)3-,aq,SK93,NA,08.Apr.93,-277750,-348760,88.6,268.1,144.3,21.6128,44.9921,-11.9361,-4.6389,165.9232,51.5732,0.2871,-1 -Tl(Ac)2-,NA,Tl(CH3COO)2-,aq,SK93,NA,20.Sep.92,-183600,-230620,70.3,111.7,127.1,19.3516,39.4721,-9.7684,-4.4107,76.8519,19.7269,0.5643,-1 -Bi(Ac)3,NA,Bi(CH3COO)3,aq,SK93,NA,26.Sep.92,-245540,-329240,28.6,525.1,131.5,19.7454,40.4309,-10.1406,-4.4503,313.616,103.923,-0.03,0 -Eu(Ac)2+,NA,Eu(CH3COO)2+,aq,SK93,NA,2.Jun.98,-320420,-383670,-12,150.7,53.3,9.3029,14.9307,-0.1123,-3.3961,101.2917,27.6639,0.7384,1 -Eu(Ac)3,NA,Eu(CH3COO)3,aq,SK93,NA,2.Jun.98,-410690,-504320,0.2,226.6,108.8,16.6413,32.8512,-7.1605,-4.137,138.7162,43.1323,-0.03,0 -La(Ac)3,NA,La(CH3COO)3,aq,SK93,SLOP98,2.Jun.98,-436550,-527986,2.8,222.2,112.5,17.1523,34.102,-7.6583,-4.1887,136.1072,42.2254,-0.03,0 -Nd(Ac)3,NA,Nd(CH3COO)3,aq,SK93,NA,10.Sep.92,-433560,-524090,9.1,177.7,106.3,16.3006,32.0216,-6.8393,-4.1027,110.0156,33.1567,-0.03,0 -Sm(Ac)3,NA,Sm(CH3COO)3,aq,SK93,SLOP98,2.Jun.98,-432630,-524009,6,176.9,107.8,16.5088,32.5307,-7.0412,-4.1237,109.5807,33.0056,-0.03,0 -Yb(Ac)3,NA,Yb(CH3COO)3,aq,SK93,NA,10.Sep.92,-425590,-520890,-9.7,228.1,104.4,16.0356,31.3743,-6.5843,-4.0759,139.5859,43.4346,-0.03,0 -Rb(Ac),NA,RbCH3COO,aq,SK93,NA,19.Aug.92,-156110,-174950,53.7,48,65.3,10.6948,18.3352,-1.4623,-3.5369,33.9961,6.7343,-0.03,0 -Rb(Ac)2-,NA,Rb(CH3COO)2-,aq,SK93,NA,10.Sep.92,-244000,-292490,68.3,117,122.2,18.6924,37.8608,-9.1318,-4.3441,80.2139,20.8,0.5941,-1 -Cs(Ac),NA,CsCH3COO,aq,SK93,NA,19.Aug.92,-158010,-176320,57.5,40.6,73.3,11.7865,20.9974,-2.502,-3.6469,29.6579,5.2264,-0.03,0 -Cs(Ac)2-,NA,Cs(CH3COO)2-,aq,SK93,NA,10.Sep.92,-245900,-293570,73.2,102.6,131.1,19.8839,40.767,-10.2671,-4.4642,71.0739,17.858,0.5208,-1 -Cu(Ac),NA,CuCH3COO,aq,SK93,NA,19.Aug.92,-76770,-99970,28.7,85.5,40.5,7.3009,10.0483,1.7946,-3.1943,56.0175,14.3883,-0.03,0 -Cu(Ac)2-,NA,Cu(CH3COO)2-,aq,SK93,NA,10.Sep.92,-165000,-219740,37,190.3,94.6,15.0715,29.0205,-5.6592,-3.9786,127.5564,35.7339,1.0691,-1 -Au(Ac),NA,AuCH3COO,aq,SK93,NA,10.Sep.92,-49870,-68310,48,56.1,61.8,10.213,17.1576,-0.9969,-3.4882,38.7432,8.3843,-0.03,0 -Au(Ac)2-,NA,Au(CH3COO)2-,aq,SK93,NA,10.Sep.92,-138240,-186750,61.3,132.8,118.3,18.1917,36.6392,-8.6534,-4.2936,90.461,24.0193,0.701,-1 -NH4(Ac),NA,NH4CH3COO,aq,SK93,NA,10.Sep.92,-107550,-147230,50.7,90.1,69.6,11.2849,19.7719,-2.0187,-3.5963,58.7075,15.3233,-0.03,0 -NH4(Ac)2-,NA,NH4(CH3COO)2-,aq,SK93,NA,10.Sep.92,-195640,-265200,64.7,199.3,127,19.3685,39.509,-9.7736,-4.4122,128.9386,37.5581,0.6495,-1 -Be(Ac)+,NA,BeCH3COO+,aq,SK93,NA,11.Mar.93,-174020,-213040,-45.6,97.1,21.1,5.0795,4.6238,3.9264,-2.97,74.547,16.741,1.2465,1 -Be(Ac)2,NA,Be(CH3COO)2,aq,SK93,NA,11.Mar.93,-263740,-336230,-43.8,215.1,73,11.7442,20.8961,-2.4661,-3.6427,131.9355,40.7754,-0.03,0 -Ra(Ac)+,NA,RaCH3COO+,aq,SK93,NA,11.Mar.93,-223900,-239380,48,67.6,37.6,6.8554,8.9566,2.2315,-3.1492,44.1726,10.737,-0.1754,1 -Ra(Ac)2,NA,Ra(CH3COO)2,aq,SK93,NA,11.Mar.93,-312940,-353260,78.8,157.6,91.4,14.2584,27.0324,-4.8725,-3.8964,98.2315,29.0609,-0.03,0 -Sc(Ac)+2,NA,ScCH3COO+2,aq,SK93,NA,10.Sep.92,-233010,-268100,-42.4,65.7,2.8,2.7175,-1.1437,6.1937,-2.7316,60.3195,10.3398,1.7013,2 -Sc(Ac)2+,NA,Sc(CH3COO)2+,aq,SK93,NA,10.Sep.92,-324640,-389320,-27.5,156,52.5,9.2794,14.8737,-0.0899,-3.3938,106.5183,28.737,0.9706,1 -Sc(Ac)3,NA,Sc(CH3COO)3,aq,SK93,NA,10.Sep.92,-415370,-511840,-20,235.6,108,16.5277,32.5748,-7.0539,-4.1255,143.9346,44.946,-0.03,0 -Pr(Ac)+2,NA,PrCH3COO+2,aq,SK93,NA,10.Sep.92,-254570,-287880,-26.8,38,2.5,2.6078,-1.4116,6.2996,-2.7205,41.9424,4.7024,1.4671,2 -Pr(Ac)2+,NA,Pr(CH3COO)2+,aq,SK93,NA,10.Sep.92,-345500,-406710,-6.2,102,52.3,9.1362,14.525,0.0441,-3.3794,71.8931,17.7378,0.6472,1 -Pr(Ac)3,NA,Pr(CH3COO)3,aq,SK93,NA,10.Sep.92,-435690,-526750,7.8,144.3,107.7,16.4898,32.4806,-7.0127,-4.1216,90.447,26.3552,-0.03,0 -Ce(Ac)+2,NA,CeCH3COO+2,aq,SK93,NA,10.Sep.92,-253590,-286390,-25.4,58.5,5.1,2.9487,-0.5825,5.9809,-2.7548,53.6757,8.8731,1.4382,2 -Ce(Ac)2+,NA,Ce(CH3COO)2+,aq,SK93,NA,2.Jun.98,-344550,-405090,-4.3,141.9,55.1,9.5157,15.4527,-0.3219,-3.4177,95.0022,25.8754,0.6143,1 -Ce(Ac)3,NA,Ce(CH3COO)3,aq,SK93,NA,10.Sep.92,-434760,-524960,10.3,211.8,110.9,16.9252,33.5426,-7.4282,-4.1656,130.0191,40.1094,-0.03,0 -Gd(Ac)+2,NA,GdCH3COO+2,aq,SK93,NA,10.Sep.92,-250490,-283100,-25.7,64.5,4.4,2.8605,-0.7945,6.0567,-2.7461,57.3241,10.1106,1.4477,2 -Gd(Ac)2+,NA,Gd(CH3COO)2+,aq,SK93,NA,10.Sep.92,-341350,-401740,-4.7,153.8,54.4,9.4165,15.2134,-0.2342,-3.4078,102.023,28.2899,0.6223,1 -Gd(Ac)3,NA,Gd(CH3COO)3,aq,SK93,NA,10.Sep.92,-431490,-521580,9.8,231.8,110,16.8116,33.2662,-7.3215,-4.1541,141.7603,44.1903,-0.03,0 -Tb(Ac)+2,NA,TbCH3COO+2,aq,SK93,NA,10.Sep.92,-251390,-286400,-32.5,54.2,4.7,2.9247,-0.6382,5.9963,-2.7525,52.1779,8.0023,1.5475,2 -Tb(Ac)2+,NA,Tb(CH3COO)2+,aq,SK93,NA,10.Sep.92,-342250,-405780,-14,133.6,54.6,9.4965,15.4094,-0.3132,-3.4159,91.4417,24.1763,0.7584,1 -Tb(Ac)3,NA,Tb(CH3COO)3,aq,SK93,NA,10.Sep.92,-432390,-526470,-2.3,197.7,110.3,16.8495,33.3603,-7.3624,-4.158,121.7569,37.2376,-0.03,0 -Dy(Ac)+2,NA,DyCH3COO+2,aq,SK93,NA,11.Sep.92,-250590,-286150,-34.2,74,4.1,2.8591,-0.797,6.0561,-2.746,64.072,12.0356,1.579,2 -Dy(Ac)2+,NA,Dy(CH3COO)2+,aq,SK93,NA,11.Sep.92,-341450,-405710,-16.3,172.2,54,9.4257,15.233,-0.2363,-3.4086,114.4678,32.0457,0.8002,1 -Dy(Ac)3,NA,Dy(CH3COO)3,aq,SK93,SLOP98,2.Jun.98,-431590,-526752,-5.4,263,109.6,16.7548,33.1279,-7.2677,-4.1484,160.0243,50.5384,-0.03,0 -Ho(Ac)+2,NA,HoCH3COO+2,aq,SK93,NA,11.Sep.92,-253270,-288520,-32.9,70.4,3.1,2.7148,-1.1553,6.2089,-2.7311,61.7679,11.3023,1.5579,2 -Ho(Ac)2+,NA,Ho(CH3COO)2+,aq,SK93,NA,11.Sep.92,-344120,-407930,-14.6,165.2,52.9,9.2621,14.8317,-0.0744,-3.392,110.0599,30.6149,0.7686,1 -Ho(Ac)3,NA,Ho(CH3COO)3,aq,SK93,SLOP98,2.Jun.98,-434250,-528736,-3.1,251.1,108.4,16.5845,32.713,-7.107,-4.1313,153.0665,48.1201,-0.03,0 -Er(Ac)+2,NA,ErCH3COO+2,aq,SK93,NA,11.Sep.92,-251770,-288520,-38.6,68.1,1.5,2.5305,-1.6022,6.3787,-2.7127,61.2455,10.8439,1.6444,2 -Er(Ac)2+,NA,Er(CH3COO)2+,aq,SK93,NA,11.Sep.92,-342620,-408540,-22.3,160.8,51.2,9.0662,14.3528,0.1146,-3.3722,108.6293,29.7206,0.8926,1 -Er(Ac)3,NA,Er(CH3COO)3,aq,SK93,NA,11.Sep.92,-432750,-529992,-13.2,243.7,106.4,16.3195,32.0657,-6.852,-4.1045,148.7181,46.6086,-0.03,0 -Tm(Ac)+2,NA,TmCH3COO+2,aq,SK93,NA,11.Sep.92,-251770,-288500,-38.3,68.1,1.5,2.5268,-1.6112,6.3814,-2.7123,61.1431,10.8439,1.6332,2 -Tm(Ac)2+,NA,Tm(CH3COO)2+,aq,SK93,NA,11.Sep.92,-342620,-408490,-21.9,160.8,51.2,9.0621,14.3448,0.1131,-3.3719,108.5166,29.7206,0.8803,1 -Tm(Ac)3,NA,Tm(CH3COO)3,aq,SK93,NA,11.Sep.92,-432750,-529900,-12.7,243.7,106.4,16.3195,32.0657,-6.852,-4.1045,148.7181,46.6086,-0.03,0 -Lu(Ac)+2,NA,LuCH3COO+2,aq,SK93,NA,10.Sep.92,-251290,-288534,-45.4,73.3,-0.7,2.2608,-2.2622,6.6412,-2.6854,65.2386,11.8981,1.7486,2 -Lu(Ac)2+,NA,Lu(CH3COO)2+,aq,SK93,NA,10.Sep.92,-342150,-409310,-31.6,170.9,48.7,8.7721,13.6382,0.3879,-3.3427,115.7906,31.7774,1.0276,1 -Lu(Ac)3,NA,Lu(CH3COO)3,aq,SK93,NA,10.Sep.92,-432290,-531620,-25.3,260.8,103.7,15.9409,31.1419,-6.4897,-4.0663,158.7197,50.085,-0.03,0 -Y(Ac)+2,NA,YCH3COO+2,aq,SK93,NA,10.Sep.92,-255670,-291130,-41,65,4,2.8774,-0.7576,6.0516,-2.7476,59.7114,10.2023,1.6782,2 -Y(Ac)2+,NA,Y(CH3COO)2+,aq,SK93,NA,10.Sep.92,-346520,-411420,-25.6,154.7,53.9,9.4572,15.3127,-0.2736,-3.4119,105.4982,28.4687,0.9437,1 -Y(Ac)3,NA,Y(CH3COO)3,aq,SK93,NA,10.Sep.92,-436650,-533170,-17.5,233.3,109.5,16.7359,33.0838,-7.255,-4.1466,142.63,44.4926,-0.03,0 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 169 From noreply at r-forge.r-project.org Wed Feb 22 17:46:33 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 22 Feb 2017 17:46:33 +0100 (CET) Subject: [CHNOSZ-commits] r170 - in pkg/CHNOSZ: . R data demo inst inst/extdata/OBIGT inst/extdata/thermo man tests/testthat vignettes Message-ID: <20170222164633.8D2B2187F31@r-forge.r-project.org> Author: jedick Date: 2017-02-22 17:46:33 +0100 (Wed, 22 Feb 2017) New Revision: 170 Added: pkg/CHNOSZ/inst/extdata/OBIGT/Marini_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Tardy_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Tremaine_aq.csv pkg/CHNOSZ/inst/extdata/thermo/BZA10.csv pkg/CHNOSZ/inst/extdata/thermo/Ste01.csv Removed: pkg/CHNOSZ/demo/add.obigt.R pkg/CHNOSZ/inst/extdata/OBIGT/Other_aq.csv pkg/CHNOSZ/inst/extdata/thermo/OBIGT-2.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/anim.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/util.data.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/data/thermo.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/demo/dehydration.R pkg/CHNOSZ/demo/protein.equil.R pkg/CHNOSZ/demo/sources.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_cr.csv pkg/CHNOSZ/inst/extdata/thermo/obigt_check.csv pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/transfer.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/tests/testthat/test-subcrt.R pkg/CHNOSZ/tests/testthat/test-util.data.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/hotspring.Rnw pkg/CHNOSZ/vignettes/hotspring.lyx Log: remove OBIGT-2.csv Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-22 16:46:33 UTC (rev 170) @@ -1,6 +1,6 @@ Date: 2017-02-22 Package: CHNOSZ -Version: 1.0.8-59 +Version: 1.0.8-60 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/anim.R =================================================================== --- pkg/CHNOSZ/R/anim.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/R/anim.R 2017-02-22 16:46:33 UTC (rev 170) @@ -7,9 +7,6 @@ # we depend on an empty png directory if(!"png" %in% dir()) stop("directory 'png' not present") else if(length(dir("png")) > 0) stop("directory 'png' not empty") - # add supplementary data (from default location of data/OBIGT-2.csv) - # which includes properties for the metabolites - add.obigt() # expand default logfO2 range if we're at high temperature if(high.T & missing(redox)) redox <- list(O2=c(-100,-40)) # the name of 'redox' should be either O2 or H2 Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/R/examples.R 2017-02-22 16:46:33 UTC (rev 170) @@ -27,7 +27,7 @@ cat("Time elapsed: ", proc.time() - .ptime, "\n") } -demos <- function(which=c("sources", "protein.equil", "add.obigt", "affinity", "NaCl", "density", +demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic", "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios"), to.file=FALSE) { # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one Modified: pkg/CHNOSZ/R/util.data.R =================================================================== --- pkg/CHNOSZ/R/util.data.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/R/util.data.R 2017-02-22 16:46:33 UTC (rev 170) @@ -97,14 +97,9 @@ return(ispecies) } -add.obigt <- function(file=system.file("extdata/thermo/OBIGT-2.csv",package="CHNOSZ"), - force=FALSE,E.units="cal") { +add.obigt <- function(file, force=FALSE, E.units="cal") { # add/replace entries in thermo$obigt from values saved in a file # only replace if force==TRUE - if(missing(file)) { - # we use force=TRUE for the default data file - if(missing(force)) force <- TRUE - } thermo <- get("thermo") to1 <- thermo$obigt id1 <- paste(to1$name,to1$state) @@ -192,12 +187,6 @@ ns1.2 <- sapply(x$key, function(x) length(which(thermo$obigt$ref2==x)) ) ns1 <- ns1 + ns1.2 ns1[ns1==0] <- "" - # count the times each source is listed in OBIGT-2.csv - o2 <- read.csv(system.file("extdata/thermo/OBIGT-2.csv", package = "CHNOSZ")) - ns2 <- sapply(x$key, function(x) length(which(o2$ref1==x)) ) - ns2.2 <- sapply(x$key, function(x) length(which(o2$ref2==x)) ) - ns2 <- ns2 + ns2.2 - ns2[ns2==0] <- "" # count the times each source is listed in protein.csv npr <- sapply(x$key, function(x) length(which(thermo$protein$ref==x)) ) npr[npr==0] <- "" @@ -207,7 +196,7 @@ nst <- sapply(x$key, function(x) length(which(stressdat[2,]==x)) ) nst[nst==0] <- "" # append the counts to the table to be shown - x <- c(x,list(ns1=ns1,ns2=ns2,npr=npr,nst=nst)) + x <- c(x,list(ns1=ns1,npr=npr,nst=nst)) # title to display for web page title <- "Sources of Thermodynamic Data in CHNOSZ" ### the following is adapted from print.findFn in package 'sos' @@ -233,7 +222,6 @@ .cat("

Click on column headers to sort

") .cat("

Columns 'n..' give number of times each reference appears in data tables:

") .cat("ns1: 'ref1' and 'ref2' in data/OBIGT.csv
") - .cat("ns2: 'ref1' and 'ref2' in extdata/thermo/OBIGT-2.csv
") .cat("npr: 'ref' in data/protein.csv
") .cat("nst: second row in data/stress.csv

") ### start table and headers @@ -408,12 +396,8 @@ # and among G, H, S values # 20110808 jmd replaces 'check=TRUE' argument of info() checkfun <- function(what) { - # looking at thermo$obigt or OBIGT-2.csv + # looking at thermo$obigt if(what=="OBIGT") to <- get("thermo")$obigt - else if(what=="OBIGT-2") { - file <- system.file("extdata/thermo/OBIGT-2.csv",package="CHNOSZ") - to <- read.csv(file,as.is=1:7) - } ntot <- nrow(to) # where to keep the results DCp <- DV <- DG <- rep(NA,ntot) @@ -441,10 +425,8 @@ out <- data.frame(table=what,ispecies=1:ntot,name=to$name,state=to$state,DCp=DCp,DV=DV,DG=DG) return(out) } - # check both databases in CHNOSZ - out1 <- checkfun("OBIGT") - out2 <- checkfun("OBIGT-2") - out <- rbind(out1,out2) + # check OBIGT database in CHNOSZ + out <- checkfun("OBIGT") # set differences within a tolerance to NA out$DCp[abs(out$DCp) < 1] <- NA out$DV[abs(out$DV) < 1] <- NA Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/data/refs.csv 2017-02-22 16:46:33 UTC (rev 170) @@ -5,29 +5,16 @@ AP01,"J. P. Amend and A. V. Plyasunov",2001,"Geochim. Cosmochim. Acta 65, 3901-3917",http://dx.doi.org/10.1016/S0016-7037(01)00707-4 APW+05,"J. Aguilera, T. Petit et al.",2001,"FEMS Yeast Res. 5, 579-593",http://dx.doi.org/10.1016/j.femsyr.2004.09.009 AS01,"J. P. Amend and E. L. Shock",2001,"FEMS Microbiol. Rev. 25, 175-243",http://dx.doi.org/10.1016/S0168-6445(00)00062-0 -AVZP06,"N. N. Akinfiev, M. V. Voronin et al.",2006,"Geochem. Int. 44, 867-878",http://dx.doi.org/10.1134/S0016702906090035 -AZ01,"N. N. Akinfiev and A. V. Zotov",2001,"Geochem. Int. 39, 990-1006",http://www.maik.ru/cgi-perl/search.pl?type=abstract&name=geochem&number=10&year=1&page=990 -AZ99,"N. Akinfiev and A. Zotov",1999,"Geochim. Cosmochim. Acta 63, 2025-2041",http://dx.doi.org/10.1016/S0016-7037(98)00304-4 BBA+03,"B. Boeckmann, A. Bairoch et al.",2003,"Nucleic Acids Res. 31, 365-370",http://dx.doi.org/10.1093/nar/gkg095 -BDP+97,"P. Benezeth, I. I. Diakonov et al.",1997,"Geochim. Cosmochim. Acta 61, 1345-1357",http://dx.doi.org/10.1016/S0016-7037(97)00012-4 BH83a,"T. S. Bowers and H. C. Helgeson",1983,"Geochim. Cosmochim. Acta 47, 1247-1275",http://dx.doi.org/10.1016/0016-7037(83)90066-2 BWP+03,"V. M. Boer, J. H. de Winde et al.",2003,"J. Biol. Chem. 278, 3265-3274",http://dx.doi.org/10.1074/jbc.M209759200 -BZA10,"E. F. Bazarkina, A. V. Zotov and N. N. Akinfiev",2010,"Geol. Ore Deposits 52, 167-178",http://dx.doi.org/10.1134/S1075701510020054 -CGM+81,"S. Cabani, P. Gianni, V. Mollica and L. Lepori",1981,"J. Solution Chem. 10, 563-595",http://dx.doi.org/10.1007/BF00646936 CHNOSZ,"J. M. Dick",2007,"CHNOSZ package documentation",http://chnosz.net CS16,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322",http://dx.doi.org/10.1016/j.gca.2016.08.028 -CSM+07,"M. Censky, J. Sedlbauer et al.",2007,"Geochim. Cosmochim. Acta 71, 580-603",http://dx.doi.org/10.1016/j.gca.2006.10.022 CWM89,"J. D. Cox, D. D. Wagman and V. A. Medvedev, eds.",1989,"CODATA Key Values for Thermodynamics",http://www.worldcat.org/oclc/18559968 Dic07,"J. M. Dick",2007,"Ph.D. Dissertation, U.C. Berkeley", DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 -DPB+97,"I. I. Diakonov, G. S. Pokrovski et al.",1997,"Geochim. Cosmochim. Acta 61, 1333-1343",http://dx.doi.org/10.1016/S0016-7037(97)00011-2 -DPS+96,"I. Diakonov, G. Pokrovski et al.",1996,"Geochim. Cosmochim. Acta 60, 197-211",http://dx.doi.org/10.1016/0016-7037(95)00403-3 -DRT98,"I. I. Diakonov, K. V. Ragnarsdottir and B. R. Tagirov",1998,"Chem. Geol. 151, 327-347",http://dx.doi.org/10.1016/S0009-2541(98)00088-6 -DS09,"P. Dalla-Betta and M. Schulte",2009,"Int. J. Mol. Sci. 10, 2809-2837",http://dx.doi.org/10.3390/ijms10062809 DSM+97,"J. D. Dale, E. L. Shock et al.",1997,"Geochim. Cosmochim. Acta 61, 4017-4024",http://dx.doi.org/10.1016/S0016-7037(97)00212-3 -DSM+99,"I. I. Diakonov, J. Schott et al.",1999,"Geochim. Cosmochim. Acta 63, 2247-2261",http://dx.doi.org/10.1016/S0016-7037(99)00070-8 FDK+04,"P. M. B. Fernandes, T. Domitrovic et al.",2004,"FEBS Lett. 556, 153-160",http://dx.doi.org/10.1016/S0014-5793(03)01396-6 -FPC+04,"D. Fenclova, S. Perez-Casas, M. Costas, and V. Dohnal",2004,"J. Chem. Eng. Data 49, 1833-1838",http://dx.doi.org/10.1021/je049738c GLL+98,"C. Godon, G. Lagniel et al.",1998,"J. Biol. Chem. 273, 22480-22489",http://dx.doi.org/10.1074/jbc.273.35.22480 GM09,"K.-D. Grevel and J. Majzlan",2009,"Geochim. Cosmochim. Acta 73, 6805 - 6815",http://dx.doi.org/10.1016/j.gca.2009.08.005 Gur96,"S. Gurrieri",1996,"personal communication", @@ -57,21 +44,15 @@ MS97,"T. M. McCollom and E. L. Shock",1997,"Geochim. Cosmochim. Acta 61, 4375-4391",http://dx.doi.org/10.1016/S0016-7037(97)00241-X MSB+04,"J. Majzlan, R. Stevens et al.",2004,"Phys. Chem. Mineral. 31, 518-531",http://dx.doi.org/10.1007/s00269-004-0405-z MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"Appl. Geochem. 16, 161-181",http://dx.doi.org/10.1016/S0883-2927(00)00025-1 -MWW09,"Art. A. Migdisov, A. E. Williams-Jones and T. Wagner",2009,"Geochim. Cosmochim. Acta 73, 7087-7109",http://dx.doi.org/10.1016/j.gca.2009.08.023 MYB+05,"L. M. Maurer, E. Yohannes et al.",2005,"J. Bacteriol. 187, 304-319",http://dx.doi.org/10.1128/JB.187.1.304-319.2005 Nei86,"F. C. Neidhardt",1986,"Escherichia coli and Salmonella typhimurium, 3-5",http://www.worldcat.org/oclc/15280827 Pan70,"L. B. Pankratz",1970,"U. S. Bureau of Mines Report of Investigations 7430",http://www.worldcat.org/oclc/14154245 PB82,"L. N. Plummer and E. Busenberg",1982,"Geochim. Cosmochim. Acta 46, 1011-1040",http://dx.doi.org/10.1016/0016-7037(82)90056-4 -PGS+96,"G. Pokrovski, R. Gout et al.",1996,"Geochim. Cosmochim. Acta 60, 737-749",http://dx.doi.org/10.1016/0016-7037(95)00427-0 PI04,"S. Phadtare and M. Inouye",2004,"J. Bacteriol. 186, 7007-7014",http://dx.doi.org/10.1128/JB.186.20.7007-7014.2004 PK70,"L. B. Pankratz and E. G. King",1970,"U. S. Bureau of Mines Report of Investigations 7435",http://www.worldcat.org/oclc/14154292 PK95,"V. B. Parker and I. L. Khodakovskii",1995,"J. Phys. Chem. Ref. Data 24, 1699-1745",http://dx.doi.org/10.1063/1.555964 -PPB+08,"E. Perfetti and G. S. Pokrovski et al.",2008,"Geochim. Cosmochim. Acta 72, 713-731",http://dx.doi.org/10.1016/j.gca.2007.11.017 -PRH+05,"G. S. Pokrovski, J. Roux et al.",2005,"Chem. Geol. 217, 127-145",http://dx.doi.org/10.1016/j.chemgeo.2005.01.006 PS01,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900",http://dx.doi.org/10.1016/S0016-7037(01)00678-0 -PS98,"G. S. Pokrovski and J. Schott",1998,"Geochim. Cosmochim. Acta 62, 1631-1642",http://dx.doi.org/10.1016/S0016-7037(98)00081-7 PSK99,"P. Prapaipong, E. L. Shock and C. M. Koretsky",1999,"Geochim. Cosmochim. Acta 63, 2547-2577",http://dx.doi.org/10.1016/S0016-7037(99)00146-5 -PSS95,"G. S. Pokrovski, J. Schott and A. S. Sergeyev",1995,"Chem. Geol. 124, 253-265",http://dx.doi.org/10.1016/0009-2541(95)00057-S RG11,"L. Richard and X. Gaona",2011,"Geochim. Cosmochim. Acta 75, 7304-7350",http://dx.doi.org/10.1016/j.gca.2011.07.030 RGM+99,"C. S. Richmond, J. D. Glasner et al.",1999,"Nucleic Acids Res. 27, 3821-3835",http://dx.doi.org/10.1093/nar/27.19.3821 RH95,"R. A. Robie and B. S. Hemingway",1995,"U. S. Geological Survey Bull. 2131",http://pubs.er.usgs.gov/publication/b2131 @@ -86,7 +67,6 @@ Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491",http://dx.doi.org/10.1016/0016-7037(92)90392-V Sho93,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349",http://dx.doi.org/10.1016/0016-7037(93)90542-5 Sho95,"E. L. Shock",1990,"Am. J. Sci. 295, 496-580",http://dx.doi.org/10.2475/ajs.295.5.496 -Sho09,"E. L. Shock",2009,"Econ. Geol. 104, 1235-1248",http://dx.doi.org/10.2113/gsecongeo.104.8.1235 SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183",http://dx.doi.org/10.1016/0016-7037(89)90341-4 SK93,"E. L. Shock and C. M. Koretsky",1993,"Geochim. Cosmochim. Acta 57, 4899-4922",http://dx.doi.org/10.1016/0016-7037(93)90128-J SK95,"E. L. Shock and C. M. Koretsky",1995,"Geochim. Cosmochim. Acta 59, 1497-1532",http://dx.doi.org/10.1016/0016-7037(95)00058-8 @@ -100,20 +80,12 @@ SS93,"M. D. Schulte and E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3835-3846",http://dx.doi.org/10.1016/0016-7037(93)90337-V SS98,"D. C. Sassani and E. L. Shock",1998,"Geochim. Cosmochim. Acta 62, 2643-2671",http://dx.doi.org/10.1016/S0016-7037(98)00049-0 SSB97,"E. L. Shock, D. C. Sassani and H. Betz",1997,"Geochim. Cosmochim. Acta 61, 4245-4266",http://dx.doi.org/10.1016/S0016-7037(97)00240-8 -SSB+07,"M.Slavik, J. Sedlbauer, K. Ballerat-Busserolles, and V. Majer",2007,"J. Solution Chem. 36, 107-134",http://dx.doi.org/10.1007/s10953-006-9097-y SSH97,"D. A. Sverjensky, E. L. Shock and H. C. Helgeson",1997,"Geochim. Cosmochim. Acta 61, 1359-1412",http://dx.doi.org/10.1016/S0016-7037(97)00009-4 SSW+97,"E. L. Shock, D. C. Sassani et al.",1997,"Geochim. Cosmochim. Acta 61, 907-950",http://dx.doi.org/10.1016/S0016-7037(96)00339-0 SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"Geochim. Cosmochim. Acta 65, 3919-3930",http://dx.doi.org/10.1016/S0016-7037(01)00717-7 -Ste01,"A. Stefansson",2001,"Chem. Geol. 172, 225-250",http://dx.doi.org/10.1016/S0009-2541(00)00263-1 TBD+05,"S. L. Tai, V. M. Boer et al.",2005,"J. Biol. Chem. 280, 437-447",http://dx.doi.org/10.1074/jbc.M410573200 -TBZ+06,"B. R. Tagirov, N. N. Baranova et al.",2006,"Geochim. Cosmochim. Acta 70, 3689-3701",http://dx.doi.org/10.1016/j.gca.2006.05.006 TDW+07,"S. L. Tai, P. Daran-Lapujade et al.",2007,"Mol. Biol. Cell. 18, 5100-5112",http://dx.doi.org/10.1091/mbc.E07-02-0131 -TS01,"B. Tagirov and J. Schott",2001,"Geochim. Cosmochim. Acta 65, 3965-3992",http://dx.doi.org/10.1016/S0016-7037(01)00705-0 TSD97,"Y. Tardy, R. Schaul, J. Duplay",1997,"C. R. Acad. Sci. Paris 324, 969-976",http://dx.doi.org/10.1016/S1251-8050(97)83981-X TWS+06,"E. T. Hayes, J. C. Wilks et al.",2006,"BMC Microbiol. 6, 89",http://dx.doi.org/10.1186/1471-2180-6-89 -TZA97,"B. R. Tagirov, A. V. Zotov and N. N. Akinfiev",1997,"Geochim. Cosmochim. Acta 61, 4267-4280",http://dx.doi.org/10.1016/S0016-7037(97)00274-3 -TZS+07,"B. Tagirov, A. Zotov et al.",2007,"Geochim. Cosmochim. Acta 71, 1689-1708",http://dx.doi.org/10.1016/j.gca.2007.01.003 +UniProt,"The UniProt Consortium",2017,"The UniProt knowledgebase",http://www.uniprot.org/ WEP+82,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, 1-392",http://dx.doi.org/10.1063/1.555661 -WP02,"W. Wagner and A. Pruss",2002,"J. Phys. Chem. Ref. Data 31, 387-355",http://dx.doi.org/10.1063/1.1461829 -ZKO06,"A. V. Zotov, L. A. Koroleva and E. G. Osadchii",2006,"Geochem. Int. 44, 384-394",http://dx.doi.org/10.1134/S0016702906040057 -ZSA03,"A. V. Zotov, N. D. Shikina and N. N. Akinfiev",2003,"Geochim. Cosmochim. Acta 67, 1821-1836",http://dx.doi.org/10.1016/S0016-7037(02)01281-4 Modified: pkg/CHNOSZ/data/thermo.R =================================================================== --- pkg/CHNOSZ/data/thermo.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/data/thermo.R 2017-02-22 16:46:33 UTC (rev 170) @@ -9,7 +9,8 @@ local({ # create obigt data frame - sources_aq <- paste0(c("H2O", "Shock", "Amend", "Schulte", "LaRowe", "Dick", "Canovas", "Other", "CHNOSZ"), "_aq") + sources_aq <- paste0(c("H2O", "Shock", "Amend", "Schulte", "LaRowe", "Dick", "Canovas", + "Tardy", "Tremaine", "Marini", "CHNOSZ"), "_aq") sources_cr <- paste0(c("Helgeson", "Shock", "Richard", "LaRowe", "Other", "CHNOSZ"), "_cr") sources_liq <- paste0(c("Richard", "LaRowe"), "_liq") sources_gas <- paste0(c("Wagman", "Shock", "Richard", "Other"), "_gas") Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/demo/00Index 2017-02-22 16:46:33 UTC (rev 170) @@ -1,6 +1,5 @@ sources cross-check the reference list with the thermodynamic database protein.equil chemical activities of two proteins in metastable equilibrium -add.obigt a couple of diagrams using the secondary thermodynamic database affinity affinities of metabolic reactions and amino acid synthesis NaCl equilibrium constant for aqueous NaCl dissociation density density of H2O, inverted from IAPWS-95 equations Deleted: pkg/CHNOSZ/demo/add.obigt.R =================================================================== --- pkg/CHNOSZ/demo/add.obigt.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/demo/add.obigt.R 2017-02-22 16:46:33 UTC (rev 170) @@ -1,37 +0,0 @@ -## pe-pH diagram for hydrated iron sulfides, -## goethite and pyrite, after Majzlan et al., 2006 -## Majzlan, J., Navrotsky, A., McClesky, R. B. and Alpers, C. N. (2006) Thermodynamic properties and crystal structure refinement of ferricopiapite, coquimbite, rhomboclase, and Fe2(SO4)3(H2O)5. \emph{Eur. J. Mineral.} \bold{18}, 175--186. \url{http://dx.doi.org/10.1127/0935-1221/2006/0018-0175} -# add some of these species to the database -add.obigt() -basis(c("Fe+2", "SO4-2", "H2O", "H+", "e-"), - c(0, log10(3), log10(0.75), 999, 999)) -species(c("rhomboclase", "ferricopiapite", "hydronium jarosite", - "goethite", "melanterite", "pyrite")) -a <- affinity(pH=c(-1, 4, 256), pe=c(-5, 23, 256)) -d <- diagram(a, main="Fe-S-O-H, after Majzlan et al., 2006") -# the first four species show up along the top of the diagram -stopifnot(all.equal(unique(t(d$predominant)[256,]), 1:4)) -water.lines(yaxis="pe") -text(3, 22, describe.basis(thermo$basis[2:3,], digits=2, oneline=TRUE)) -text(3, 21, describe.property(c("T", "P"), c(25, 1), oneline=TRUE)) -# reset the database -data(thermo) - -## Aqueous Aluminum Species F-/OH-, after Tagirov and Schott, 2001 -## Tagirov, B. and Schott, J. (2001) Aluminum speciation in crustal fluids revisited. \emph{Geochim. Cosmochim. Acta} \bold{65}, 3965--3992. \url{http://dx.doi.org/10.1016/S0016-7037(01)00705-0} -# some of the species are not in the default databse -add.obigt() -# the 999s have no effect on the diagram: -# pH and log_a(F-) are plotting variables -# O2 is not in the formation reactions -# Al+3 is the balanced quantity -basis(c("Al+3", "F-", "H+", "O2", "H2O"), c(rep(999, 4), 0)) -species(c("Al+3", "Al(OH)4-", "AlOH+2", "Al(OH)2+", "Al(OH)3", - "AlF+2", "AlF2+", "AlF3", "AlF4-", "Al(OH)2F2-", "Al(OH)2F", - "AlOHF2"), "aq") -a <- affinity(pH=c(0, 10), "F-"=c(-1, -9), T=200) -diagram(a, fill="heat") -title(main=paste("Aqueous aluminium species, T=200 C, P=Psat\n", - "after Tagirov and Schott, 2001")) -# restore thermodynamic database to default -data(thermo) Modified: pkg/CHNOSZ/demo/dehydration.R =================================================================== --- pkg/CHNOSZ/demo/dehydration.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/demo/dehydration.R 2017-02-22 16:46:33 UTC (rev 170) @@ -14,9 +14,6 @@ plot(range(T), c(-2, 1), type="n", xlab="T, °C", ylab="log K") title(main="Dehydration reactions") -# add.obigt is used to add malate and fumarate, -# and epsomite and hexahydrite to thermo$obigt -add.obigt() reactants <- c("[AABB]", "[AABB]", "malate-2", "goethite", "gypsum", "epsomite", "ethanol") products <- c("[UPBB]", "[PBB]", "fumarate-2", "hematite", "anhydrite", "hexahydrite", "ethylene") rstate <- c("aq", "cr", "aq", "cr", "cr", "cr", "aq") Modified: pkg/CHNOSZ/demo/protein.equil.R =================================================================== --- pkg/CHNOSZ/demo/protein.equil.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/demo/protein.equil.R 2017-02-22 16:46:33 UTC (rev 170) @@ -25,3 +25,5 @@ Aref.residue <- Astar.residue - loga.residue # 0.446, after Eq. 16 # A-star of the residue in natural log units (A/RT) log(10) * Astar.residue # 0.4359, after Eq. 23 +# forget about the old [Met] group for whatever comes next +data(thermo) Modified: pkg/CHNOSZ/demo/sources.R =================================================================== --- pkg/CHNOSZ/demo/sources.R 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/demo/sources.R 2017-02-22 16:46:33 UTC (rev 170) @@ -6,13 +6,8 @@ # sources in the primary thermodynamic database os1 <- thermo$obigt$ref1 os2 <- thermo$obigt$ref2 -# sources also in the supplemental database (OBIGT-2.csv) -add.obigt() -os3 <- thermo$obigt$ref1 -os4 <- thermo$obigt$ref2 -data(thermo) # all of the thermodynamic data sources - some of them might be NA -obigt.source <- unique(c(os1,os2,os3,os4)) +obigt.source <- unique(c(os1,os2)) obigt.source <- obigt.source[!is.na(obigt.source)] # sources of protein compositions protein.source <- thermo$protein$ref Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/inst/NEWS 2017-02-22 16:46:33 UTC (rev 170) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-59 (2017-02-22) +CHANGES IN CHNOSZ 1.0.8-60 (2017-02-22) --------------------------------------- DOCUMENTATION: @@ -76,30 +76,35 @@ - Add syslab() and ratlab() to make formatted expressions for sets of thermodynamic components and activity ratios. -NEW DATA: +NEW AND OLD DATA: +- Split OBIGT.csv and OBIGT-2.csv into multiple files according to + author names. All files are now under extdata/OBIGT/. + - Canovas_aq.csv: Add data for citric acid cycle metabolites from Canovas and Shock, 2016. - CHNOSZ_aq.csv: Add H4SiO4 pseudospecies (pseudo-H4SiO4); see calculations in eos-regress.Rmd. -- OBIGT-2.csv: Rename H4SiO4 to H4SiO4_Ste01 (Steff?nson, 2001). +- Remove superseded data previously in OBIGT-2.csv: citric acid cycle + metabolites from Dalla-Betta and Schulte, 2009. -- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, - SS98_Fig5b, PM90 (all used by anintro.Rmd). +- Remove superseded data previously in OBIGT-2.csv: methionine and [Met] + from Dick et al., 2006. Examples that require the old group additivity + parameters can modify the database using: + `mod.obigt("[Met]", G=-35245, H=-59310)`. -DATA CHANGES: +- Move two datasets that conflict with the primary database, but are + used in tests, examples, or vignettes, from OBIGT-2.csv to + extdata/thermo (Ste01.csv and BZA10.csv). -- Split OBIGT.csv into multiple files according to author names. +- Remove other conflicting datasets previously in OBIGT-2.csv, including + aluminum species from Tagirov and Schott, 2001. -- OBIGT-2.csv: remove data for citric acid cycle metabolites from - Dalla-Betta and Schulte, 2009; thioester species have been kept. +- extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, + SS98_Fig5b, PM90 (all used by anintro.Rmd). -- OBIGT-2.csv: remove data for methionine and [Met] from Dick et al., - 2006. Examples that require the old group additivity parameters - modify the database using: `mod.obigt("[Met]", G=-35245, H=-59310)`. - BUG FIXES: - Correct charge (-2) of NAD(red)-2 in LaRowe_aq.csv. Thanks to Peter Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv 2017-02-22 13:06:35 UTC (rev 169) +++ pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv 2017-02-22 16:46:33 UTC (rev 170) @@ -234,3 +234,8 @@ wollastonite,Wo,CaSiO3,cr,HDN+78,SH88,15.Mar.90,-369225,-389590,19.6,NA,39.93,26.64,3.6,-6.52,0,0,0,0,1400 wurtzite,Wur,ZnS,cr,HDN+78,NA,5.May.78,-44810,-45850,14.064,NA,23.846,11.82,1.16,-1.04,0,0,0,0,1300 zoisite,Zo,Ca2Al3Si3O12(OH),cr,HDN+78,SH88,15.Mar.90,-1549179,-1643691,70.74,NA,135.9,106.118,25.214,-27.145,0,0,0,0,700 +berndtite,Brn,SnS2,cr,JH85b,NA,5.May.78,-34750,-36700,20.9,NA,40.96,15.51,4.2,0,0,0,0,0,1000 +cassiterite,Cst,SnO2,cr,JH85b,NA,5.May.78,-124260,-138800,12.5,NA,21.55,17.246,2.8026,-4.9001,0,0,0,0,1500 +romarchite,Sn-Ox,SnO,cr,JH85b,NA,5.May.78,-61459,-68340,13.66,NA,20.895,9.55,3.5,0,0,0,0,0,1237 +tin,Sn,Sn,cr1,JH85b,NA,Aug.85,0,0,12.24,NA,16.289,4.42,6.3,0,0,0,0,0,505.06 +tin,Sn,Sn,cr2,JH85b,NA,Aug.85,679.802,1607.605,15.3519,NA,16.289,7.3,0,0,0,0,0,0,3000 Added: pkg/CHNOSZ/inst/extdata/OBIGT/Marini_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/Marini_aq.csv (rev 0) +++ pkg/CHNOSZ/inst/extdata/OBIGT/Marini_aq.csv 2017-02-22 16:46:33 UTC (rev 170) @@ -0,0 +1,98 @@ +name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T +NaH2AsO4,NA,NaH2AsO4,aq,MA07,MA10,12.Sep.07,-240179,-272608,41.2,37.8,41.1,7.3772,10.2352,1.1421,-3.2022,27.9202,4.6622,-0.038,0 +KH2AsO4,NA,KH2AsO4,aq,MA07,MA10,12.Sep.07,-244935,-274352,54.5,21.9,52.4,8.9277,14.0226,-0.484,-3.3587,18.6125,1.4173,-0.038,0 +MgH2AsO4+,NA,MgH2AsO4+,aq,MA07,MA10,12.Sep.07,-290910,-332717,-10.4,50.7,18.3,4.5105,3.2335,4.1483,-2.9127,42.265,7.2899,0.7009,1 +CaH2AsO4+,NA,CaH2AsO4+,aq,MA07,MA10,12.Sep.07,-314170,-348007,18.5,45.8,22.2,4.8949,4.1724,3.7452,-2.9515,35.3597,6.2862,0.2639,1 +SrH2AsO4+,NA,SrH2AsO4+,aq,MA07,MA10,12.Sep.07,-315896,-347841,27.3,40.1,22.9,4.9488,4.3041,3.6887,-2.957,30.8142,5.1312,0.1301,1 +MnH2AsO4+,NA,MnH2AsO4+,aq,MA07,MA10,12.Sep.07,-236482,-270828,14.5,53.5,23.3,5.0617,4.5799,3.5702,-2.9684,40.4264,7.8583,0.3244,1 +FeH2AsO4+,NA,FeH2AsO4+,aq,MA07,MA10,12.Sep.07,-205693,-243719,1,44.9,17.6,4.3531,2.849,4.3134,-2.8968,37.3097,6.1166,0.5283,1 +CoH2AsO4+,NA,CoH2AsO4+,aq,MA07,MA10,12.Sep.07,-193388,-232357,-1.5,45.2,13.9,3.8628,1.6516,4.8275,-2.8473,37.7921,6.1625,0.5664,1 +NiH2AsO4+,NA,NiH2AsO4+,aq,MA07,MA10,12.Sep.07,-193146,-233785,-7.1,36.4,10,3.358,0.4185,5.3569,-2.7963,33.4496,4.375,0.6516,1 +CuH2AsO4+,NA,CuH2AsO4+,aq,MA07,MA10,12.Sep.07,-166866,-204382,4.1,49.9,14.9,3.9712,1.9164,4.7138,-2.8583,39.7683,7.1249,0.4813,1 +ZnH2AsO4+,NA,ZnH2AsO4+,aq,MA07,MA10,12.Sep.07,-215927,-255372,-0.3,50.7,15.3,4.0397,2.0836,4.642,-2.8652,40.8741,7.2945,0.5485,1 +PbH2AsO4+,NA,PbH2AsO4+,aq,MA07,MA10,12.Sep.07,-187896,-215577,44.7,34.1,25,5.1359,4.7611,3.4924,-2.9759,24.9084,3.9167,-0.1328,1 +AlH2AsO4+2,NA,AlH2AsO4+2,aq,MA07,MA10,12.Sep.07,-299978,-350717,-57,34.9,-7.1,1.4491,-4.244,7.3587,-2.6036,44.5413,4.0694,1.9508,2 +FeH2AsO4+2,NA,FeH2AsO4+2,aq,MA07,MA10,12.Sep.07,-189949,-235535,-39.9,66.2,1.1,2.4901,-1.7013,6.267,-2.7087,60.4374,10.4402,1.6927,2 +NaHAsO4-,NA,NaHAsO4-,aq,MA07,MA10,12.Sep.07,-234025,-272938,19.4,11,16.4,4.464,3.12,4.197,-2.908,24.8601,-0.79,1.3274,-1 +KHAsO4-,NA,KHAsO4-,aq,MA07,MA10,12.Sep.07,-238754,-275247,30.7,3.9,26.1,5.7282,6.2078,2.8713,-3.0357,19.1455,-2.2322,1.1561,-1 +MgHAsO4,NA,MgHAsO4,aq,MA07,MA10,12.Sep.07,-282655,-326456,-17.1,-3.4,-0.5,1.6885,-3.6591,7.1076,-2.6278,3.8675,-3.7233,-0.038,0 +CaHAsO4,NA,CaHAsO4,aq,MA07,MA10,12.Sep.07,-306038,-344341,3.5,-5.6,2,2.0228,-2.8426,6.757,-2.6615,2.5879,-4.1694,-0.038,0 +SrHAsO4,NA,SrHAsO4,aq,MA07,MA10,12.Sep.07,-307750,-344917,9.8,-8.1,2.4,2.0851,-2.6905,6.6917,-2.6678,1.1155,-4.6827,-0.038,0 +MnHAsO4,NA,MnHAsO4,aq,MA07,MA10,12.Sep.07,-229564,-268033,0.7,-2.1,2.7,2.1148,-2.618,6.6606,-2.6708,4.592,-3.4707,-0.038,0 +FeHAsO4,NA,FeHAsO4,aq,MA07,MA10,12.Sep.07,-196961,-237958,-8.9,-5.9,-0.9,1.6263,-3.8112,7.1729,-2.6215,2.3717,-4.2448,-0.038,0 +CoHAsO4,NA,CoHAsO4,aq,MA07,MA10,12.Sep.07,-187516,-229240,-10.7,-5.8,-3.2,1.3102,-4.5832,7.5044,-2.5896,2.4302,-4.2244,-0.038,0 +NiHAsO4,NA,NiHAsO4,aq,MA07,MA10,12.Sep.07,-185083,-227995,-14.7,-9.7,-5.7,0.9749,-5.4021,7.8559,-2.5557,0.1514,-5.0188,-0.038,0 +CuHAsO4,NA,CuHAsO4,aq,MA07,MA10,12.Sep.07,-160044,-200797,-6.7,-3.7,-2.6,1.3964,-4.3727,7.414,-2.5983,3.6572,-3.7966,-0.038,0 +ZnHAsO4,NA,ZnHAsO4,aq,MA07,MA10,12.Sep.07,-209827,-252128,-9.9,-3.4,-2.4,1.4251,-4.3025,7.3838,-2.6012,3.8733,-3.7213,-0.038,0 +PbHAsO4,NA,PbHAsO4,aq,MA07,MA10,12.Sep.07,-180119,-214509,22.2,-10.7,3.7,2.2585,-2.267,6.5099,-2.6853,-0.4328,-5.2225,-0.038,0 +AlHAsO4+,NA,AlHAsO4+,aq,MA07,MA10,12.Sep.07,-295884,-343378,-46.1,-37.3,-8.2,1.0572,-5.2011,7.7697,-2.564,-4.1613,-10.6336,1.242,1 +FeHAsO4+,NA,FeHAsO4+,aq,MA07,MA10,12.Sep.07,-188188,-232211,-34.7,-23.4,-4.9,1.4545,-4.2306,7.353,-2.6042,2.37,-7.8022,1.0694,1 +NaAsO4-2,NA,NaAsO4-2,aq,MA07,MA10,12.Sep.07,-223700,-253943,48.5,-38.4,-17,0.2824,-7.0935,8.5822,-2.4858,6.8433,-10.8648,2.5085,-2 +KAsO4-2,NA,KAsO4-2,aq,MA07,MA10,12.Sep.07,-228428,-249049,84,-45.5,-9.64,1.1121,-5.0669,7.712,-2.5696,-2.2416,-12.307,1.9714,-2 +MgAsO4-,NA,MgAsO4-,aq,MA07,MA10,12.Sep.07,-271474,-307316,9.64,-55,-25.98,-1.3284,-11.0278,10.2713,-2.3232,-12.33,-14.2311,1.3662,-1 +CaAsO4-,NA,CaAsO4-,aq,MA07,MA10,12.Sep.07,-294913,-323114,37.4,-57.2,-25.5,-1.3685,-11.1259,10.3134,-2.3191,-17.4821,-14.6772,1.0531,-1 +SrAsO4-,NA,SrAsO4-,aq,MA07,MA10,12.Sep.07,-296243,-323239,43.9,-59.7,-25.41,-1.3889,-11.1758,10.3349,-2.317,-19.8655,-15.1905,0.9562,-1 +MnAsO4-,NA,MnAsO4-,aq,MA07,MA10,12.Sep.07,-218289,-247805,30.7,-53.7,-25.37,-1.2541,-10.8464,10.1934,-2.3307,-14.5434,-13.9785,1.339,-1 +FeAsO4-,NA,FeAsO4-,aq,MA07,MA10,12.Sep.07,-186668,-218541,21.7,-57.5,-26.07,-1.3653,-11.1181,10.3101,-2.3194,-15.504,-14.7525,1.2932,-1 +CoAsO4-,NA,CoAsO4-,aq,MA07,MA10,12.Sep.07,-177190,-210481,17.6,-57.4,-26.53,-1.4073,-11.2205,10.3541,-2.3152,-14.8722,-14.7322,1.3555,-1 +NiAsO4-,NA,NiAsO4-,aq,MA07,MA10,12.Sep.07,-176304,-211320,11.8,-61.3,-27.01,-1.4432,-11.3083,10.3918,-2.3116,-16.3404,-15.5266,1.4434,-1 +CuAsO4-,NA,CuAsO4-,aq,MA07,MA10,12.Sep.07,-151743,-183607,23.1,-55.3,-26.4,-1.4178,-11.2463,10.3651,-2.3141,-14.418,-14.3044,1.2716,-1 +ZnAsO4-,NA,ZnAsO4-,aq,MA07,MA10,12.Sep.07,-200121,-233853,18.9,-55,-26.36,-1.3907,-11.1799,10.3366,-2.3169,-13.6104,-14.229,1.3358,-1 +PbAsO4-,NA,PbAsO4-,aq,MA07,MA10,12.Sep.07,-169793,-194437,54.9,-62.3,-25.16,-1.4108,-11.2291,10.3577,-2.3148,-22.9414,-15.7303,0.7904,-1 +AlAsO4,NA,AlAsO4,aq,MA07,MA10,12.Sep.07,-285558,-330011,-35.9,-60.2,-9.75,0.418,-6.7624,8.44,-2.4995,-29.3427,-15.3014,-0.038,0 +FeAsO4,NA,FeAsO4,aq,MA07,MA10,12.Sep.07,-177862,-218546,-23.5,-84.8,-13.09,-0.0391,-7.8787,8.9193,-2.4533,-43.7161,-20.3124,-0.038,0 +NaH2AsO3,NA,NaH2AsO3,aq,MA07,MA10,12.Sep.07,-203270,-228832,39.7,28.4,32.7,6.2236,7.4178,2.3518,-3.0857,22.4338,2.7495,-0.038,0 +AgH2AsO3,NA,AgH2AsO3,aq,MA07,MA10,12.Sep.07,-123526,-147071,44.3,25.8,33,6.2709,7.5332,2.3022,-3.0905,20.9088,2.2178,-0.038,0 +MgH2AsO3+,NA,MgH2AsO3+,aq,MA07,MA10,12.Sep.07,-251410,-286183,-11.3,41.3,9.9,3.3617,0.4276,5.353,-2.7967,36.9078,5.3772,0.7149,1 +CaH2AsO3+,NA,CaH2AsO3+,aq,MA07,MA10,12.Sep.07,-274922,-301872,17.1,36.4,13.8,3.7486,1.3726,4.9473,-2.8358,30.0706,4.3735,0.2853,1 +SrH2AsO3+,NA,SrH2AsO3+,aq,MA07,MA10,12.Sep.07,-275601,-300702,25.8,30.7,14.5,3.8032,1.506,4.89,-2.8413,25.5459,3.2185,0.1538,1 +BaH2AsO3+,NA,BaH2AsO3+,aq,MA07,MA10,12.Sep.07,-276315,-297936,40.1,25.6,19.9,4.4634,3.1185,4.1977,-2.908,20.5926,2.1872,-0.0628,1 +CuH2AsO3+,NA,CuH2AsO3+,aq,MA07,MA10,12.Sep.07,-134368,-164924,3,40.5,6.5,2.8237,-0.8865,5.9172,-2.7424,34.4453,5.2122,0.499,1 +PbH2AsO3+,NA,PbH2AsO3+,aq,MA07,MA10,12.Sep.07,-153138,-174063,42.8,24.7,16.5,3.9918,1.9667,4.6922,-2.8603,19.6811,2.0039,-0.1047,1 +AlH2AsO3+2,NA,AlH2AsO3+2,aq,MA07,MA10,12.Sep.07,-266611,-309612,-55.5,25.5,-15.6,0.2882,-7.0795,8.5761,-2.4864,38.8545,2.1567,1.929,2 +FeH2AsO3+2,NA,FeH2AsO3+2,aq,MA07,MA10,12.Sep.07,-154392,-192413,-39.1,56.8,-7.3,1.3321,-4.5295,7.4813,-2.5918,54.8314,8.5274,1.6797,2 +LiCrO4-,NA,LiCrO4-,aq,AML10,NA,03.Jul.10,-246189,-276987,23.021,-1.86,25.17,5.6394,5.9909,2.9644,-3.0267,16.8298,-3.4143,1.2728,-1 +NaCrO4-,NA,NaCrO4-,aq,AML10,NA,03.Jul.10,-239025,-266828,38.364,-3.93,24.95,5.5308,5.7256,3.0783,-3.0157,13.4846,-3.8343,1.0404,-1 +KCrO4-,NA,KCrO4-,aq,AML10,NA,03.Jul.10,-243870,-269706,48.161,-16.63,33.98,6.7157,8.6197,1.8358,-3.1354,4.6973,-6.4214,0.8921,-1 +NH4CrO4-,NA,NH4CrO4-,aq,AML10,NA,03.Jul.10,-195220,-241227,50.414,1.05,43.22,7.9692,11.6814,0.5212,-3.2619,14.7104,-2.8209,0.858,-1 +BeCrO4,NA,BeCrO4,aq,AML10,NA,03.Jul.10,-268795,-304575,-14.001,-27.06,7.24,2.7431,-1.0832,6.0017,-2.7343,-9.9664,-8.5462,-0.038,0 +MgCrO4,NA,MgCrO4,aq,AML10,NA,03.Jul.10,-286677,-324405,-14.995,-26.44,6.66,2.6638,-1.277,6.0849,-2.7263,-9.6061,-8.4206,-0.038,0 +CaCrO4,NA,CaCrO4,aq,AML10,NA,03.Jul.10,-310665,-342487,6.948,-30.19,10.48,3.1862,-0.0009,5.537,-2.779,-11.7978,-9.1847,-0.038,0 +SrCrO4,NA,SrCrO4,aq,AML10,NA,03.Jul.10,-313068,-343782,13.152,-32.76,10.36,3.1693,-0.0424,5.5548,-2.7773,-13.2959,-9.707,-0.038,0 +BaCrO4,NA,BaCrO4,aq,AML10,NA,03.Jul.10,-312583,-340842,24.015,-35.77,14.65,3.7566,1.3921,4.9389,-2.8366,-15.0586,-10.3215,-0.038,0 +RaCrO4,NA,RaCrO4,aq,AML10,NA,03.Jul.10,-313122,-338458,35.729,-38.45,14.92,3.7932,1.4816,4.9005,-2.8403,-16.6254,-10.8678,-0.038,0 +MnCrO4,NA,MnCrO4,aq,AML10,NA,03.Jul.10,-233415,-265560,3.57,-24.78,10.63,3.2071,0.0501,5.5151,-2.7811,-8.6346,-8.0819,-0.038,0 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 170 From noreply at r-forge.r-project.org Thu Feb 23 12:45:39 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 23 Feb 2017 12:45:39 +0100 (CET) Subject: [CHNOSZ-commits] r171 - in pkg/CHNOSZ: . data inst inst/extdata/OBIGT man vignettes Message-ID: <20170223114539.166A2188800@r-forge.r-project.org> Author: jedick Date: 2017-02-23 12:45:38 +0100 (Thu, 23 Feb 2017) New Revision: 171 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: add (methyl)phenanthrene data from Dick et al., 2013 Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-23 11:45:38 UTC (rev 171) @@ -1,6 +1,6 @@ -Date: 2017-02-22 +Date: 2017-02-23 Package: CHNOSZ -Version: 1.0.8-60 +Version: 1.0.8-61 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/data/refs.csv 2017-02-23 11:45:38 UTC (rev 171) @@ -11,9 +11,10 @@ CHNOSZ,"J. M. Dick",2007,"CHNOSZ package documentation",http://chnosz.net CS16,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322",http://dx.doi.org/10.1016/j.gca.2016.08.028 CWM89,"J. D. Cox, D. D. Wagman and V. A. Medvedev, eds.",1989,"CODATA Key Values for Thermodynamics",http://www.worldcat.org/oclc/18559968 -Dic07,"J. M. Dick",2007,"Ph.D. Dissertation, U.C. Berkeley", +DEH+13,"J. M. Dick, K. A. Evans et al.",2013,"Geochim. Cosmochim. Acta 122, 247-266",http://dx.doi.org/10.1016/j.gca.2013.08.020 DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 DSM+97,"J. D. Dale, E. L. Shock et al.",1997,"Geochim. Cosmochim. Acta 61, 4017-4024",http://dx.doi.org/10.1016/S0016-7037(97)00212-3 +Dic07,"J. M. Dick",2007,"Ph.D. Dissertation, U.C. Berkeley", FDK+04,"P. M. B. Fernandes, T. Domitrovic et al.",2004,"FEBS Lett. 556, 153-160",http://dx.doi.org/10.1016/S0014-5793(03)01396-6 GLL+98,"C. Godon, G. Lagniel et al.",1998,"J. Biol. Chem. 273, 22480-22489",http://dx.doi.org/10.1074/jbc.273.35.22480 GM09,"K.-D. Grevel and J. Majzlan",2009,"Geochim. Cosmochim. Acta 73, 6805 - 6815",http://dx.doi.org/10.1016/j.gca.2009.08.005 Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/inst/NEWS 2017-02-23 11:45:38 UTC (rev 171) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-60 (2017-02-22) +CHANGES IN CHNOSZ 1.0.8-61 (2017-02-23) --------------------------------------- DOCUMENTATION: @@ -87,6 +87,9 @@ - CHNOSZ_aq.csv: Add H4SiO4 pseudospecies (pseudo-H4SiO4); see calculations in eos-regress.Rmd. +- Dick_aq.csv: Add data for aqueous phenanthrene and methylphenanthrene + from Dick et al., 2013. + - Remove superseded data previously in OBIGT-2.csv: citric acid cycle metabolites from Dalla-Betta and Schulte, 2009. @@ -99,8 +102,8 @@ used in tests, examples, or vignettes, from OBIGT-2.csv to extdata/thermo (Ste01.csv and BZA10.csv). -- Remove other conflicting datasets previously in OBIGT-2.csv, including - aluminum species from Tagirov and Schott, 2001. +- Remove other conflicting datasets previously in OBIGT-2.csv (21 + sources). - extdata: Add fasta/rubisco.fasta and cpetc/*.csv files SS98_Fig5a, SS98_Fig5b, PM90 (all used by anintro.Rmd). Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv 2017-02-23 11:45:38 UTC (rev 171) @@ -93,3 +93,9 @@ Gly-Tyr-Gly,GYG,C13H17N3O5,aq,DLH06,NA,10.Sep.11,NA,NA,NA,107.2,194.9,0,0,0,0,126.8,-17.2,-1.68,0 Gly-Val-Gly,GVG,C9H17N3O4,aq,DLH06,NA,10.Sep.11,NA,NA,NA,104.9,160.3,0,0,0,0,111.8,-10.8,-1.65,0 [GXGBB],NA,C6H10N3O4,aq,DLH06,NA,10.Sep.11,NA,NA,NA,30.9,103.2,0,0,0,0,52.6,-17.6,-1.54,0 +phenanthrene,NA,C14H10,aq,DEH+13,NA,13.Dec.12,300730,155570,246.9,447.3,161.6,NA,NA,NA,NA,NA,NA,NA,0 +1-methylphenanthrene,NA,C15H12,aq,DEH+13,NA,13.Dec.12,299310,128600,297.6,549.4,165.6,NA,NA,NA,NA,NA,NA,NA,0 +2-methylphenanthrene,NA,C15H12,aq,DEH+13,NA,13.Dec.12,293740,120150,287.9,539.8,171.1,NA,NA,NA,NA,NA,NA,NA,0 +3-methylphenanthrene,NA,C15H12,aq,DEH+13,NA,13.Dec.12,294290,120610,287.7,539.8,171.1,NA,NA,NA,NA,NA,NA,NA,0 +4-methylphenanthrene,NA,C15H12,aq,DEH+13,NA,13.Dec.12,330230,152660,274.6,569.2,177.6,NA,NA,NA,NA,NA,NA,NA,0 +9-methylphenanthrene,NA,C15H12,aq,DEH+13,NA,13.Dec.12,298090,126760,295.5,549.4,165.6,NA,NA,NA,NA,NA,NA,NA,0 Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-23 11:45:38 UTC (rev 171) @@ -3,9 +3,8 @@ \docType{package} \title{Chemical Thermodynamics and Activity Diagrams} \description{ -CHNOSZ is a package for thermodynamic calculations, primarily with applications in geochemistry and biochemistry. +CHNOSZ is a package for thermodynamic calculations, primarily with applications in geochemistry and compositional biology. It can be used to calculate the standard molal thermodynamic properties and chemical affinities of reactions relevant to geobiochemical processes, and to visualize the equilibrium activities of species on chemical speciation and predominance diagrams. -The package can be used interactively and in batch mode, through the use of R source files containing a sequence of commands. } \section{Getting Help}{ @@ -23,10 +22,7 @@ It is up to you to check not only the accuracy of the data, but also the \emph{suitability of the data AND computational techniques} for your problem. By combining data taken from different sources, it is possible to build an inconsistent and/or nonsensical calculation. An attempt has been made to provide a primary database (OBIGT) that is internally consistent, but no guarantee can be made. -If there is any doubt about the accuracy or suitability of data for a particular problem, please \emph{consult the primary sources} (see \code{\link{thermo.refs}}). -Do not assume that by adding any species to your calculation (or to any of the examples), you will necessarily obtain a reasonable answer. -Do not assume that the examples are correct, or that they can be applied to your problem. -As with the data, please \emph{compare the construction and output of the examples to the primary sources}, cited in the reference list in each help page. +If there is any doubt about the accuracy or suitability of data for a particular problem, please consult the primary sources (see \code{\link{thermo.refs}}). Examples without a reference (and some with references) demonstrate experimental features of CHNOSZ. } @@ -58,7 +54,7 @@ \item Activity statistics (\bold{experimental}) - calculate summary statistics for equilibrium activities of species (\code{\link{revisit}}). - \item Multidimensional optimization (new in 0.9-3) (\bold{experimental}) - using an iterative gridded optimization, find a combination of chemical activities of basis species, temperature and/or pressure that maximize or minimize the value of a target statistic (\code{\link{findit}}). + \item Multidimensional optimization (\bold{experimental}) - using an iterative gridded optimization, find a combination of chemical activities of basis species, temperature and/or pressure that maximize or minimize the value of a target statistic (\code{\link{findit}}). \item Mass transfer calculations (\bold{experimental}) - calculate changes in solution composition and formation of secondary species as a function of incremental reaction of a mineral (or protein) (\code{\link{transfer}}). @@ -67,38 +63,23 @@ Here are some tips for new users: \itemize{ - \item Install the package from CRAN using \code{\link{install.packages}} or its GUI menu equivalent. - \item To begin working with the package after installation, type \code{\link{library}(CHNOSZ)} at the command line (or select the name of the package from the GUI menu). - \item Running the examples shown in the various help topics is a great way to become more familiar with the usage of the functions. From \code{\link{help.start}}, select \sQuote{Packages} then \sQuote{CHNOSZ} and then select a function of interest. Individual examples can be run by pasting the example block directly into the R console. + \item Running the examples shown in the various help topics is a good way to become more familiar with the usage of the functions. From \code{\link{help.start}}, select \sQuote{Packages} then \sQuote{CHNOSZ} and then select a function of interest. Individual examples can be run by pasting the example block directly into the R console. \item Type the command \code{\link{examples}()} to run all of the examples provided in CHNOSZ. This takes a few minutes depending on your system. If things go as expected, the entire set will run without any warnings or errors. - \item Some of the examples require internet or file access or user intervention, or are intentionally written to demonstrate conditions that lead to errors. This code is hidden from \R's package checking mechanism using the \code{dontrun} tag. You can experiment with \code{dontrun} examples by pasting the code to the R console. - \item A couple of other things to note about the examples: 1) There are some \code{\link{stopifnot}} statements that represent expected outcomes of the calculations; if the expectation is not met, the \code{stopifnot} statement causes an error. These tests are useful for checking the code during package development cycles, but are usually not of critical importance for the set-up of the problem (though they do sometimes employ useful programming tricks). 2) Commands written with an enclosing pair of parentheses \code{(z <- "like this one")} are used to display the result of an assignment operation (\code{\link{<-}}), the value of which is needed later in the calculation. In interactive use, the outermost pair of enclosing parentheses is generally not needed. - \item Also try out \code{\link{demos}()} to run the demos (some of these are longer running examples that are not part of the main help pages). - \item To learn how to update the thermodynamic database, look at its documentation in \code{\link{thermo}}. + \item Also try out \code{\link{demos}()} to run the demos (longer examples that are not part of the main help pages). + \item To learn how to update the thermodynamic database, look at \code{\link{add.obigt}}. } } - -\section{Compatibility}{ - Starting with version 1.0.5-1, the package depends on \R version 3.1.0 or greater (for \code{extendInt} argument of \code{\link{uniroot}}, used in code{\link{rho.IAPWS95}}). - As of version 1.0.4 (release 1.0.5 on CRAN), the package depends on \R version 3.0.0 or greater (previous versions use \code{\link{Stangle}} to extract R code from vignettes when installing the source package, leading to failure processing hotspring.Rnw, which now uses knitr instead of Sweave). - Before version 1.0.4, the recommended version of \R was 2.14.0 or greater (to find vignettes in the \code{vignettes} directory, and for availability of \pkg{parallel} in the standard library). - As of version 0.9-9, the package depends on \R version 2.12.0 or greater (so useDynLib in the NAMESPACE can find the shared library on Windows). - Starting with version 0.9-6 of the package, the dependency was given as \R version 2.10.0 or greater (to read compressed data files). - Before version 0.9-6 of the package, the dependency was given as \R version 2.7.0 or greater (major update of the X11 device in 2.7.0). - Without accessing the compressed data files in \code{extdata} it should be possible to run CHNOSZ on Unix-alikes under \R versions 2.4.0 or greater (availability of the \samp{stringsAsFactors} argument of \code{\link{data.frame}}). -} - \section{Acknowledgements}{ This package would not exist without the leadership and encouragement of Professor Harold C. Helgeson. - Hal and his associates are in some way responsible for many of the equations and data contained in this package. - A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with minor modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment. + Hal and his students and collaborators are in some way responsible for many of the equations and data contained in this package. + A direct contribution of code is the file \code{H2O92D.f}, taken from the SUPCRT92 distribution, with minor modifications (masking of WRITE and STOP statements) made for compatibility with an \R environment and for allowing sub-zero degrees C calculations (keep valTP flag TRUE). The revised Helgeson-Kirkham-Flowers equations of state are used in this package, together with the thermodynamic properties and parameters for many species taken from numerous papers coauthored by Helgeson. Work on this package at U.C. Berkeley from ~2003--2008 was supported by research grants to HCH from the U.S. National Science Foundation and Department of Energy. In 2009--2011, development of this package was based upon work supported by the National Science Foundation under grant EAR-0847616. - The files in \code{extdata/bison} are excerpts of results of BLAST calculations made on the Saguaro high performance computer at ASU. + The files in \code{extdata/bison} are derived from BLAST calculations made on the Saguaro high performance computer at Arizona State University. } \section{Known Bugs}{ @@ -106,9 +87,8 @@ The values generated by \code{\link{buffer}} may not be applied correctly by \code{\link{affinity}} in calculating the affinities of the formation reactions. (The values returned by \code{affinity(..., return.buffer=TRUE)} do appear to be correct in the examples). - There is an unidentified inconsistency in \code{\link{transfer}} causing the reaction boundaries in one of the examples (\code{apc("closed")}) to be offset from the stability diagram. OTOH, \code{feldspar("closed")} appears to work correctly. - - Values of activity coefficients may be affected by an unidentified bug in \code{\link{nonideal}}. + There is an unidentified inconsistency in \code{\link{transfer}} causing the reaction boundaries in one of the examples (\code{apc("closed")}) to be offset from the stability diagram. + On the other hand, \code{feldspar("closed")} appears to work correctly. } \keyword{package} Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-23 11:45:38 UTC (rev 171) @@ -2,7 +2,7 @@ \alias{protein} \title{Examples of Calculations for Proteins} \description{ - This page contains some examples of using the functions in CHNOSZ to calculate thermodynamic properties and relative stabilities of proteins. + This page contains some examples of using the functions in CHNOSZ to calculate thermodynamic properties of and make diagrams for proteins. } \examples{\dontshow{data(thermo)} @@ -78,9 +78,4 @@ title(main="Bovine proteins, GSH/GSSG redox buffer") } -\seealso{ - For accessing, updating, and downloading amino acid compositions of proteins, see \code{\link{pinfo}}. -For more examples of metastable equilibrium calculations for proteins, see \code{\link{read.expr}}, \code{\link{more.aa}}, \code{\link{ionize.aa}}, and \code{\link{apc}} for reaction-path calculations. -} - \concept{Protein thermodynamic modeling} Modified: pkg/CHNOSZ/man/util.data.Rd =================================================================== --- pkg/CHNOSZ/man/util.data.Rd 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/man/util.data.Rd 2017-02-23 11:45:38 UTC (rev 171) @@ -92,9 +92,7 @@ The values returned (\code{\link{invisible}}-y) by \code{mod.obigt} are the rownumbers of the affected species. } -\seealso{ - \code{\link{mod.buffer}} -} +\seealso{ \code{\link{thermo}}, \code{\link{mod.buffer}} } \examples{\dontshow{data(thermo)} ## modify an existing species with fake properties Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-22 16:46:33 UTC (rev 170) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-23 11:45:38 UTC (rev 171) @@ -22,7 +22,7 @@ link-citations: yes # The custom CSL file gives a build error on R-Forge (20170212): # pandoc-citeproc: error while parsing the XML string -csl: elementa.csl +#csl: elementa.csl --- ```{r options, include=FALSE} @@ -99,7 +99,7 @@ This document introduces the usage of CHNOSZ, a package for the [R software environment](http://r-project.org). For more information on R, see "[An Introduction to R](http://cran.r-project.org/manuals.html)" and the [contributed documentation](https://cran.r-project.org/other-docs.html) for R. -CHNOSZ has been developed since 2006 to support research projects in geochemistry and compositional biology. +CHNOSZ has been developed since 2006 as a tool for thermodynamic calculations in geochemistry and compositional biology. The package provides functions and a thermodynamic database that can be used to calculate the stoichiometric and energetic properties of reactions involving minerals and inorganic and/or organic aqueous species. These functions also enable calculations of chemical affinities and metastable equilibrium distributions of proteins. A major feature of the package is the production of diagrams to visualize the effects of changing temperature, pressure, and activities of basis species on the potential for reactions among various species. From noreply at r-forge.r-project.org Thu Feb 23 14:52:07 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 23 Feb 2017 14:52:07 +0100 (CET) Subject: [CHNOSZ-commits] r172 - in pkg/CHNOSZ: . R demo inst inst/extdata/abundance man vignettes Message-ID: <20170223135207.C156E18825B@r-forge.r-project.org> Author: jedick Date: 2017-02-23 14:52:07 +0100 (Thu, 23 Feb 2017) New Revision: 172 Removed: pkg/CHNOSZ/inst/extdata/abundance/AA03.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/anim.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/demo/yeastgfp.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/CHNOSZ-package.Rd pkg/CHNOSZ/man/affinity.Rd pkg/CHNOSZ/man/anim.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/read.expr.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: remove anim.plasma() and AA03.csv Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-23 13:52:07 UTC (rev 172) @@ -1,6 +1,6 @@ Date: 2017-02-23 Package: CHNOSZ -Version: 1.0.8-61 +Version: 1.0.8-62 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/anim.R =================================================================== --- pkg/CHNOSZ/R/anim.R 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/R/anim.R 2017-02-23 13:52:07 UTC (rev 172) @@ -75,67 +75,6 @@ } } -anim.plasma <- function(width=480, height=480) { - ## animate relative metastabilities of plasma proteins, - ## as a function of chemical activities of H2 and O2 - ## start with 71 proteins; one protein is removed in - ## each successive frame - ## 20110804 jmd - # make sure we have an empty png directory - if(!"png" %in% dir()) stop("directory 'png' not present") - else if(length(dir("png")) > 0) stop("directory 'png' not empty") - # get list of proteins - f <- system.file("extdata/abundance/AA03.csv", package="CHNOSZ") - pdata <- read.csv(f, as.is=TRUE) - notna <- !is.na(pdata$name) - pname <- pdata$name[notna] - # set up the system; use O2 aq instead of gas - basis(c("CO2","NH3","H2S","H2","O2","H+")) - basis("O2","aq") - basis(c("CO2","NH3","H2S","H+"),c(-3,-3,-10,-7)) - species(pname,"HUMAN") - a <- affinity(H2=c(-20,0), O2=c(-80,-60)) - # start with all species - ispecies <- 1:length(pname) - # open plot file - png("png/plasma%03d.png",width=width, height=height) - # numbers of proteins for each frame - np <- length(pname):2 - # add some lead-in and lead-out frames - np <- c(rep(head(np,1),8),np,rep(tail(np,1),8)) - # now loop until we get to two proteins - for(i in 1:length(np)) { - d <- diagram(a, groups=as.list(ispecies), names=pname[ispecies], normalize=TRUE, cex=1.5) - # note that the darker colors go with higher abundances - # as reported by Anderson and Anderson, 2003 - # how many show up on the diagram? - nshow <- length(unique(as.numeric(d$predominant))) - title(main=paste(np[i]," human plasma proteins (",nshow, - " showing)",sep=""),cex.main=1) - if(c(0,diff(np))[i] != 0) { - # identify the protein with the greatest - # area on the diagram - imost <- which.max(tabulate(as.numeric(d$predominant))) - # take out that proteins - ispecies <- ispecies[-imost] - } - } - # close PNG plot device - dev.off() - # make animated GIF using ImageMagick - cat("anim.plasma: converting to animated GIF...\n") - outfile <- "plasma.gif" - syscmd <- paste("convert -loop 0 -delay 25 png/*.png png/", outfile, sep = "") - cat(paste(syscmd,"\n")) - if(.Platform$OS.type=="unix") sres <- system(syscmd) - else sres <- shell(syscmd) - if(sres==0) cat(paste("anim.plasma: animation is at png/",outfile,"\n",sep="")) - else { - cat("anim.plasma: error converting to animated GIF\n") - cat("anim.plasma: check that 'convert' tool from ImageMagick is in your PATH\n") - } -} - anim.carboxylase <- function(T=25:125,ntop=5,lcex=0.8,width=420,height=320) { # animate rank-activity diagrams over a temperature # and logaH2 gradient, or plot a single one for a single temperature @@ -261,5 +200,3 @@ } } } - - Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/R/examples.R 2017-02-23 13:52:07 UTC (rev 172) @@ -12,7 +12,7 @@ "util.seq", "util.units", "taxonomy", "info", "protein.info", "hkf", "water", "subcrt", "makeup", "basis", "swap.basis", "species", "affinity", "util.affinity", "equil.boltzmann", "diagram", "buffer", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr", - "objective", "revisit", "transfer", "anim", "EOSregress", "wjd") + "anim", "objective", "revisit", "transfer", "EOSregress", "wjd") plot.it <- FALSE if(is.character(do.png)) png(paste(do.png,"%d.png",sep=""),width=500,height=500,pointsize=12) Modified: pkg/CHNOSZ/demo/yeastgfp.R =================================================================== --- pkg/CHNOSZ/demo/yeastgfp.R 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/demo/yeastgfp.R 2017-02-23 13:52:07 UTC (rev 172) @@ -37,7 +37,7 @@ inames <- 1:length(names) for(i in 1:length(nloc)) { diagram(a, normalize=TRUE, names=names[inames], groups=as.list(inames), - fill=fill[inames], cex.axis=0.75, cex.names=1) + fill=fill[inames], cex.axis=0.75, cex.names=1.2) label.plot(letters[i], xfrac=0.95, yfrac=0.9, paren=TRUE, italic=TRUE) title(main=paste(length(inames), "locations")) # take out the stable species Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/inst/NEWS 2017-02-23 13:52:07 UTC (rev 172) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-61 (2017-02-23) +CHANGES IN CHNOSZ 1.0.8-62 (2017-02-23) --------------------------------------- DOCUMENTATION: Deleted: pkg/CHNOSZ/inst/extdata/abundance/AA03.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/abundance/AA03.csv 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/inst/extdata/abundance/AA03.csv 2017-02-23 13:52:07 UTC (rev 172) @@ -1,72 +0,0 @@ -type,description,log10(pg/ml),name,name2,note -hemoglobin,Hemoglobin,11.21,HBA,HBB, -plasma,Albumin,10.71,ALBU,, -plasma,"IgG Total",10.09,IGHG1,"IGHG2,IGHG3,IGHG4", -plasma,Transferrin,9.59,TRFE,, -plasma,Fibrinogen,9.52,FIBA,"FIBB,FIBG","Fibrinogen alpha chain" -plasma,"IgA Total",9.48,IGHA1,IGHA2, -plasma,Alpha-2-Macroglobulin,9.48,A2MG,, -plasma,"IgM Total",9.38,IGJ,,"Immunoglobulin J chain" -plasma,Alpha-1-Antitrypsin,9.31,A1AT,, -plasma,"C3 Complement",9.27,CO3,, -plasma,Haptoglobin,9.27,HPT,, -plasma,"Apolipoprotein A-1",9.21,APOA1,, -plasma,"Apolipoprotein B",9.1,APOB,,"Apolipoprotein B-100" -plasma,"Alpha-1-acid Glycoprotein",9.04,A1AG1,A1AG2, -plasma,Lipoprotein(a),8.93,APOA,,Apolipoprotein(a) -plasma,"Factor H",8.77,CFAH,,"Complement factor H" -plasma,Ceruloplasmin,8.77,CERU,, -plasma,"C4 Complement",8.72,CO4A,CO4B, -plasma,"Complement Factor B",8.6,CFAB,, -plasma,Prealbumin,8.6,TTHY,,Transthyretin -plasma,"C9 Complement",8.56,CO9,, -plasma,"C1q Complement",8.35,C1QA,"C1QB,C1QC", -plasma,"C8 Complement",8.24,CO8B,CO8G, -plasma,"C5 Complement",8.18,CO5,, -plasma,Plasminogen,8.18,PLMN,, -plasma,IgD,8.14,IGHD,,"Ig delta chain C region" -plasma,"C1 Inhibitor",8.03,IC1,, -plasma,"C6 Complement",8.03,CO6,, -plasma,"C7 Complement",7.93,CO7,, -plasma,"Complement Factor I",7.8,CFAI,, -plasma,"Retinol Binding Protein",7.8,RET4,"RET1,RET2,RET3,RET5", -plasma,iC3b,7.43,CO3.C3c,,"Complement C3c alpha' chain fragment 1?" -plasma,"Thyroxin Binding Globulin",7.43,THBG,,"Thyroxine-binding globulin" -plasma,"C2 Complement Protein",7.34,CO2,, -plasma,"Thrombus Precursor Protein",6.72,THRB,,Prothrombin? -plasma,"C-reactive Protein",6.68,CRP,, -plasma,"Bb Fragment",6.13,CFAB.Bb,, -tissue,"C3a Complement Protein",5.55,CO3.C3a,,"C3a anaphylatoxin" -tissue,Ferritin,5.45,FRIL,FRIH,"Ferritin light chain" -tissue,Rantes,5.45,CCL5,,"RANTES(3-68) cleaved from C-C motif chemokine 5" -tissue,"SC5-b9 Complex",5.38,VTNC,,"Vitronectin is 'S-protein'; C5b-9 is complement" -tissue,Myoglobin,4.86,MYG,, -tissue,Thyroglobulin,4.76,THYG,, -tissue,TPA,4.09,TPA,,"Tissue-type plasminogen activator" -tissue,"C5a Complement",4.05,CO5.C5a,,"C5a anaphylatoxin" -tissue,"Neuron-Specific Enolase",3.95,ENOG,,Gamma-enolase -tissue,C-Peptide,3.94,INS.C,,"propeptide in insulin" -tissue,Alpha-fetoprotein,3.74,FETA,, -tissue,"TNF-Binding Proteins",3.57,TNR1A,,"Tumor necrosis factor receptor superfamily member 1A" -tissue,"Prostate-Specific Antigen",3.57,KLK3,, -tissue,"Prostatic Acid Phosphatase",3.46,PPAP,, -tissue,CEA,3.42,CEAM5,,"Carcinoembryonic antigen-related cell adhesion molecule 5" -tissue,"Myelin Basic Protein",3.42,MBP,, -tissue,"Troponin I",3.25,TNNI1,TNNI2,"Troponin I, slow skeletal muscle" -interleukin,Interleukin-1ra,3.15,IL1RA,,"Interleukin-1 receptor antagonist protein" -interleukin,"MIP-1 beta",2.17,CCL4,,"cleaved from C-C motif chemokine 4" -interleukin,"Troponin T",1.92,TNNT1,, -interleukin,Interleukin-8,1.92,IL8,, -interleukin,"MIP-1 alpha",1.8,CCL3,,"cleaved from C-C motif chemokine 3" -interleukin,"Tissue Factor",1.75,TF,, -interleukin,GCSF,1.69,CSF3,,"Granulocyte colony-stimulating factor" -interleukin,"Interferon Alpha",1.59,IFNA1,"IFNA2,INFA4,IFNA8,INFA16","Interferon alpha-1/13" -interleukin,Interleukin-2,1.42,IL2,, -interleukin,Interleukin-4,1.42,IL4,, -interleukin,TNF-Alpha,1.21,TNFA,, -interleukin,"Interferon Gamma",1.21,IFNG,, -interleukin,"Interleukin-1 Beta",1.1,IL1B,, -interleukin,Interleukin-12,0.94,IL12A,IL12B, -interleukin,Interleukin-10,0.83,IL10,, -interleukin,Interleukin-5,0.83,IL5,, -interleukin,Interleukin-6,0.62,IL6,, Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd =================================================================== --- pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/man/CHNOSZ-package.Rd 2017-02-23 13:52:07 UTC (rev 172) @@ -23,7 +23,6 @@ By combining data taken from different sources, it is possible to build an inconsistent and/or nonsensical calculation. An attempt has been made to provide a primary database (OBIGT) that is internally consistent, but no guarantee can be made. If there is any doubt about the accuracy or suitability of data for a particular problem, please consult the primary sources (see \code{\link{thermo.refs}}). -Examples without a reference (and some with references) demonstrate experimental features of CHNOSZ. } \section{Overview}{ Modified: pkg/CHNOSZ/man/affinity.Rd =================================================================== --- pkg/CHNOSZ/man/affinity.Rd 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/man/affinity.Rd 2017-02-23 13:52:07 UTC (rev 172) @@ -3,7 +3,7 @@ \alias{affinity} \title{Chemical Affinities of Formation Reactions} \description{ - Calculate the chemical affinities of formation reactions of species. Do it for single values of temperature, pressure, ionic strength and chemical activities of the basis species, or as a function of one or more of these variables. Or, return other properties including standard molal Gibbs energies of basis species and species of interest, and standard molal Gibbs energies, equilibrium constants and activity products of formation reactions. +Calculate the chemical affinities of formation reactions of species. } \usage{ @@ -14,59 +14,55 @@ \arguments{ \item{...}{numeric, zero or more named arguments, used to identify the variables of interest in the calculations} \item{property}{character, denoting the property to be calculated. Default is \samp{A}, for chemical affinity of formation reactions of species of interest} - \item{sout}{list, output from subcrt function} - \item{exceed.Ttr}{logical, allow subcrt to compute properties for phases beyond their transition temperature?} - \item{return.buffer}{logical. If \code{TRUE}, and a \code{\link{buffer}} has been associated with one or more basis species in the system, return the values of the activities of the basis species calculated using the buffer (it is not necessary in this case to have defined any species of interest). Default is \code{FALSE}} - \item{balance}{character. This argument is passed to \code{\link{buffer}} to identify a conserved basis species (or \samp{PBB}) in a chemical activity buffer. Default is \samp{PBB}} + \item{sout}{list, output from \code{\link{subcrt}}} + \item{exceed.Ttr}{logical, allow \code{\link{subcrt}} to compute properties for phases beyond their transition temperature?} + \item{return.buffer}{logical. If \code{TRUE}, and a \code{\link{buffer}} has been associated with one or more basis species in the system, return the values of the activities of the basis species calculated using the buffer (it is not necessary in this case to have defined any species of interest). Default is \code{FALSE}.} + \item{balance}{character. This argument is passed to \code{\link{buffer}} to identify a conserved basis species (or \samp{PBB}) in a chemical activity buffer. Default is \samp{PBB}.} \item{iprotein}{numeric, indices of proteins in \code{\link{thermo}$protein} for which to calculate properties} \item{loga.protein}{numeric, logarithms of activities of proteins identified in \code{iprotein}} } \details{ \code{affinity} calculates the chemical affinities of reactions to form the species of interest from the basis species. +The equation used to calculate chemical affinity \emph{A} is \emph{A}=\eqn{RT\ln (K/Q)}{RT*ln(K/Q)}, where \eqn{K} denotes the equilibrium constant of the reaction and \eqn{Q} stands for the activity product of the species in the reaction. The calculation of chemical affinities relies on the current definitions of the \code{\link{basis}} species and \code{\link{species}} of interest. -It is possible to use the results of \code{affinity} to generate equilibrium activity diagrams using \code{\link{diagram}}. +Calculations are possible at single values of temperature, pressure, ionic strength and chemical activities of the basis species, or as a function of one or more of these variables. -The equation used to calculate chemical affinity \emph{\bold{A}} is \emph{\bold{A}}=\eqn{RT\ln (K/Q)}{RT*ln(K/Q)} (Kondepudi and Prigogine, 1998), where \eqn{K} denotes the equilibrium constant of the reaction and \eqn{Q} stands for the activity product of the species in the reaction. -(The equilibrium constant is related to standard Gibbs energy of reaction, \eqn{\Delta G^{\circ}_r}{DeltaG0r}, by \eqn{\Delta G^{\circ}_r = -2.303RT\log K}{DeltaG0r = -2.303*RT*logK}, where \eqn{R} and \eqn{T} stand for, respectively, the gas constant and temperature). -With the approach of a given reaction to a state of equilibrium, the chemical affinity tends toward zero, or \eqn{K = Q}. - -Valid properties are \samp{A} or NULL for chemical affinity, \samp{logK} or \samp{logQ} for logarithm of equilibrium constant and reaction activity product, or any of the properties available in \code{\link{subcrt}} except for \samp{rho}. -The properties returned are those of the formation reactions of the species of interest from the basis species. -It is also possible to calculate the properties of the species of interest themselves (not their formation reactions) by setting the \code{property} to \samp{G.species}, \samp{Cp.species}, etc. -Except for \samp{A}, the properties of proteins or their reactions calculated in this manner are restricted to nonionized proteins. - Zero, one, or more leading arguments to the function identify which of the chemical activities of basis species, temperature, pressure and/or ionic strength to vary. The names of each of these arguments may be the formula of any of the basis species of the system, or \samp{T}, \samp{P}, \samp{pe}, \samp{pH}, \samp{Eh}, or \samp{IS} (but names may not be repeated). -To use the names of charged basis species such as \samp{K+} and \samp{SO4-2} as the arguments, they should be enclosed in quotes (see the example for aluminum speciation in \code{\link{diagram}}). -The value of each argument is of the form \code{c(min,max)} or \code{c(min,max,res)} where \code{min} and \code{max} refer to the minimimum and maximum values of variable identified by the name of the argument, and \code{res} denotes the resolution, or number of points along which to do the calculations (this is assigned a default value of 128 if it is missing). -For any arguments that refer to basis species, the numerical values are the logarithms of the activities of that basis species, or logarithms of fugacities if it is a gas. -Unlike the \code{energy} function, the units of \samp{T} and \samp{P} in \code{affinity} are those the user has set using \code{\link{T.units}} and \code{\link{P.units} }(on program start-up these are \eqn{^{\circ}}{?}C and bar, respectively). +The names charged basis species such as \samp{K+} and \samp{SO4-2} should be quoted when used as arguments. +The value of each argument is of the form \code{c(min, max)} or \code{c(min, max, res)} where \code{min} and \code{max} refer to the minimimum and maximum values of variable identified by the name of the argument, and \code{res} denotes the resolution, or number of points along which to do the calculations; \code{red} is assigned a default value of 128 if it is missing. +For any arguments that refer to basis species, the numerical values are the logarithms of activity (or fugacity for gases) of that basis species. +The units of \samp{T} and \samp{P} in \code{affinity} are those the user has set using \code{\link{T.units}} and \code{\link{P.units} }(on program start-up these are \eqn{^{\circ}}{?}C and bar, respectively). If one or more buffers are assigned to the definition of \code{\link{basis}} species, \code{affinity} calls \code{\link{buffer}} to calculate the logarithms of activities of these basis species from the buffer. The \code{iprotein} and \code{loga.protein} arguments can be used to compute the chemical affinities of formation reactions of proteins that are not in the current \code{\link{species}} definition. -This approach can be utilized in order to calculate the properties of many proteins in a fraction of the time it would take to calculate them individually. -The appropriate \code{\link{basis}} species still must be defined prior to calling \code{affinity}. -\code{iprotein} contains indices of desired proteins in \code{\link{thermo}$protein}; \code{affinity} adds to the species list the amino acid residues and and terminal H2O group (indicated by \dQuote{RESIDUE} in \code{thermo$protein}) then calculates the properties of the reactions for the residues and terminal group, including ionization effects, and adds them together to get those of the indicated proteins. +\code{iprotein} contains the indices (rownumbers) of desired proteins in \code{\link{thermo}$protein}. +This uses some optimizations to calculate the properties of many proteins in a fraction of the time it would take to calculate them individually. -In CHNOSZ version 0.9, \code{energy} gained a new argument \samp{transect} which is set to TRUE by \code{energy.args} when the length(s) of the variables is(are) greater than three. +When the length(s) of the variables is(are) greater than 3, the function enters the \samp{transect} mode of operation (see \code{\link{energy}}). In this mode of operation, instead of performing the calculations on an \eqn{n}{n}-dimensional grid, the affinities are calculated on a transect of changing T, P, and/or chemical activity of basis species. + +The function can also be used to calculate other thermodynamic properties of formation reactions. +Valid properties are \samp{A} or NULL for chemical affinity, \samp{logK} or \samp{logQ} for logarithm of equilibrium constant and reaction activity product, or any of the properties available in \code{\link{subcrt}} except for \samp{rho}. +The properties returned are those of the formation reactions of the species of interest from the basis species. +It is also possible to calculate the properties of the species of interest themselves (not their formation reactions) by setting the \code{property} to \samp{G.species}, \samp{Cp.species}, etc. +Except for \samp{A}, the properties of proteins or their reactions calculated in this manner are restricted to nonionized proteins. } \value{ -For \code{affinity}, a list, elements of which are \code{sout} output from \code{\link{subcrt}}, \code{property} name of the calculated property (\samp{A} for chemical affinity), \code{basis} and \code{species} definition of basis species and species of interest in effect at runtime, \code{T} and \code{P} temperature and pressure, in the system units of Kelvin and bar, set to \code{numeric()} (length=0) if either one is a variable, \code{vars} the names of the variables, \code{vals} the values of the variables (a list, one element for each variable), \code{values} the result of the calculation (a list, one element for each species, with names taken from the species index in \code{\link{thermo}$obigt}). +A list, elements of which are \code{sout} output from \code{\link{subcrt}}, \code{property} name of the calculated property (\samp{A} for chemical affinity), \code{basis} and \code{species} definition of basis species and species of interest in effect at runtime, \code{T} and \code{P} temperature and pressure, in the system units of Kelvin and bar, set to \code{numeric()} (length=0) if either one is a variable, \code{vars} the names of the variables, \code{vals} the values of the variables (a list, one element for each variable), \code{values} the result of the calculation (a list, one element for each species, with names taken from the species index in \code{\link{thermo}$obigt}). The elements of the lists in \code{vals} and \code{values} are arrays of \eqn{n}{n} dimensions, where \eqn{n}{n} is the number of variables. -The values of chemical affinity of formation reactions of the species are returned in dimensionless units (for use with decimal logarithms, i.e., \emph{\strong{A}}/\eqn{2.303RT}). +The values of chemical affinity of formation reactions of the species are returned in dimensionless units (for use with decimal logarithms, i.e., \emph{A}/\eqn{2.303RT}). -Names other than \samp{T} or \samp{P} in \code{vars} generally refer to basis species, and the corresponding \code{vals} are the logarithms of activity or fugacity. However, if one or more of \code{pe}, \code{Eh} or \code{pH} is among the variables of interest, \code{vals} holds the values of the those variables as indicated. +Names other than \samp{T} or \samp{P} in \code{vars} generally refer to basis species, and the corresponding \code{vals} are the logarithms of activity or fugacity. +However, if one or more of \code{pe}, \code{Eh} or \code{pH} is among the variables of interest, \code{vals} holds the values of the those variables as indicated. } \seealso{ -Usually, \code{\link{equilibrate}} is the next step in calculations of chemical equilibrium. -The help for \code{\link{buffer}} has some examples of using chemical activity buffers. -The guts of the calculations provided by \code{affinity} involve \code{\link{energy.args}} and \code{\link{energy}}, which normally are not part of the user interaction. -Longer examples are in \code{demo{affinity}}. +\code{\link{equilibrate}} for calculating of equilibrium activities of species, and \code{\link{diagram}} for plotting the results. +The guts of the calculations involve \code{\link{energy.args}} and \code{\link{energy}}, which are not intended for normal user interaction. } \examples{ @@ -93,10 +89,7 @@ } \references{ - Helgeson, H. C., Richard, L, McKenzie, W. F., Norton, D. L. and Schmitt, A. (2009) A chemical and thermodynamic model of oil generation in hydrocarbon source rocks. \emph{Geochim. Cosmochim. Acta} \bold{73}, 594--695. \url{http://dx.doi.org/10.1016/j.gca.2008.03.004} - - Kondepudi, D. K. and Prigogine, I. (1998) \emph{Modern Thermodynamics: From Heat Engines to Dissipative Structures}, John Wiley & Sons, New York, 486 p. \url{http://www.worldcat.org/oclc/38055900} +Helgeson, H. C., Richard, L, McKenzie, W. F., Norton, D. L. and Schmitt, A. (2009) A chemical and thermodynamic model of oil generation in hydrocarbon source rocks. \emph{Geochim. Cosmochim. Acta} \bold{73}, 594--695. \url{http://dx.doi.org/10.1016/j.gca.2008.03.004} } - \concept{Primary thermodynamic modeling} Modified: pkg/CHNOSZ/man/anim.Rd =================================================================== --- pkg/CHNOSZ/man/anim.Rd 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/man/anim.Rd 2017-02-23 13:52:07 UTC (rev 172) @@ -2,7 +2,6 @@ \name{anim.TCA} \alias{anim} \alias{anim.TCA} -\alias{anim.plasma} \alias{anim.carboxylase} \title{Functions to Make Animations} \description{ @@ -12,7 +11,6 @@ \usage{ anim.TCA(redox = list(O2 = c(-95, -60)), high.T = FALSE, nframes = 100, pHlim = c(0,10), width = 420, height = 320) - anim.plasma(width=480, height=480) anim.carboxylase(T = 25:125, ntop = 5, lcex = 0.8, width = 420, height = 320) } @@ -29,16 +27,22 @@ } \details{ - These functions create a series of PNG figures that can be converted into an animated diagram. The PNG files are created in the \samp{png} directory within the current working directory; the functions stop with an error if either this directory is not present or it is present but not empty. After making the PNG files, they are converted to an animated GIF using the \samp{convert} tool from the ImageMagick software distribution (\url{http://www.imagemagick.org}), if it is available on the system. The system command is called using the \code{\link{system}} function on unix-alikes, and using \code{shell} on Windows platforms. When installing ImageMagick on Windows, be sure to leave the \sQuote{Add application directory to your system path} option checked; this will make the \samp{convert} command from ImageMagick available in the shell. +These functions create a series of PNG figures that can be converted into an animated diagram. +The PNG files are created in the \samp{png} directory within the current working directory; the functions stop with an error if either this directory is not present or it is present but not empty. +After making the PNG files, they are converted to an animated GIF using the \samp{convert} tool from the ImageMagick software distribution (\url{http://www.imagemagick.org}), if it is available on the system. +The system command is called using \code{\link{system}}, or \code{shell} on Windows platforms. +When installing ImageMagick on Windows, be sure to leave the \sQuote{Add application directory to your system path} option checked; this will make the \samp{convert} command from ImageMagick available in the shell. - To ensure the results described below, each function here does remove any existing system definition by calling \code{data(thermo)}. +To ensure the calculations are performed as intended, each function first removes any existing system definition by calling \code{data(thermo)}. - \code{anim.TCA} creates a series of figures showing how a logaH2O - logfO2 activity diagram for various species involved in the tricarboxylic acid (TCA) cycle changes as a function of pH. Alternatively, set \code{redox} to \code{list(H2=c(-20,0))} to draw a logaH2O - logaH2 diagram. The diagrams are made at 25 \eqn{^{\circ}}{?}C unless \code{high.T} is TRUE, in which case high-temperature (100 \eqn{^{\circ}}{?}C) stability fields are overlain. The number of frames to be used for the animation (as pH increases ranges between the values specified in \code{pHlim}) is given by \code{nframes}. +\code{anim.TCA} creates a series of figures showing how a logaH2O - logfO2 activity diagram for various species involved in the tricarboxylic acid (TCA) cycle changes as a function of pH. +Alternatively, set \code{redox} to \code{list(H2=c(-20,0))} to draw a logaH2O - logaH2 diagram. +The diagrams are made at 25 \eqn{^{\circ}}{?}C unless \code{high.T} is TRUE, in which case high-temperature (100 \eqn{^{\circ}}{?}C) stability fields are overlaid. - \code{anim.plasma} produces a series of equilibrium activity diagrams for proteins in human blood plasma, as a function of log aO2 and log aH2, at 25 \eqn{^{\circ}}{?}C. Unlike most other examples in CHNOSZ, the chemical potentials of hydrogen and oxygen in the system are represented by the activities of O2 and H2, and H2O is not used as a basis species. Therefore, the equilibrium activities of H2O vary by many orders of magnitude across these diagrams. The list of proteins is taken from Anderson and Anderson (2003); see the description for the data file AA03.csv in \code{\link{extdata}}. The first diagram shows the equilibrium predominance fields with all 71 listed proteins in the calculation. In each subsequent diagram, the protein whose predominance field occupies the greatest area on the diagram is removed. The range of \code{\link{heat.colors}} indicates the reported reference abundances of the proteins, with the deepest (reddest) colors corresponding to the highest abundances. - - \code{anim.carboxylase} animates equilibrium rank-activity diagrams along a combined temperature and logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single \code{temperature} is provided. The proteins in the calculation are 24 carboxylases from a variety of organisms. There are 12 ribulose phosphate carboxylase and 12 acetyl-coenzyme A carboxylase; 6 of each type are from nominally mesophilic organisms and 6 from nominally thermophilic organisms, shown as blue and red symbols on the diagrams. The activities of hydrogen at each temperature are calculated using \eqn{\log a_{\mathrm{H_{2}}_{\left(aq\right)}}=-11+3/\left(40\times T\left(^{\circ}C\right)\right)}{logaH2 = -11 + 3/40 * T(degC)}; this equation comes from a model of relative stabilities of proteins in a hot-spring environment (Dick and Shock, 2011). - +\code{anim.carboxylase} animates equilibrium rank-activity diagrams along a combined temperature and logaH2 gradient, or makes a single plot on the default device (without conversion to animated GIF) if a single \code{temperature} is provided. +The proteins in the calculation are 24 carboxylases from a variety of organisms. +There are 12 ribulose phosphate carboxylase and 12 acetyl-coenzyme A carboxylase; 6 of each type are from nominally mesophilic organisms and 6 from nominally thermophilic organisms, shown as blue and red symbols on the diagrams. +The activities of hydrogen at each temperature are calculated using \eqn{\log a_{\mathrm{H_{2}}_{\left(aq\right)}}=-11+3/\left(40\times T\left(^{\circ}C\right)\right)}{logaH2 = -11 + 3/40 * T(degC)}; this equation comes from a model of relative stabilities of proteins in a hot-spring environment (Dick and Shock, 2011). } \examples{\dontshow{data(thermo)} @@ -53,11 +57,7 @@ } \references{ - - Anderson, N. L. and Anderson, N. G. (2003) The human plasma proteome: History, character and diagnostic prospects (Vol. 1 (2002) 845-867). \emph{Molecular and Cellular Proteomics} \bold{2}, 50. \url{http://dx.doi.org/10.1074/mcp.A300001-MCP200} - - Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{http://dx.doi.org/10.1371/journal.pone.0022782} - +Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{http://dx.doi.org/10.1371/journal.pone.0022782} } \concept{Extra thermodynamic modeling} Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2017-02-23 11:45:38 UTC (rev 171) +++ pkg/CHNOSZ/man/extdata.Rd 2017-02-23 13:52:07 UTC (rev 172) @@ -13,7 +13,6 @@ Files in \code{abundance} contain protein abundance and microbial occurrence data: \itemize{ \item \code{stress} is a data frame listing proteins identified in selected proteomic stress response experiments. The names of proteins begin at row 3, and columns are all the same length (padded as necessary at the bottom by \code{NA}s). Names correspond to ordered locus names (for \samp{Sce}) or gene names (for \samp{Eco}). The column names identify the experiments, the first row contains the name of the organism (\samp{Sce} or \samp{Eco}) and the third row has the reference key for the source of the data (listed in \code{\link{thermo}$refs}). [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 172 From noreply at r-forge.r-project.org Fri Feb 24 03:07:50 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 24 Feb 2017 03:07:50 +0100 (CET) Subject: [CHNOSZ-commits] r173 - in pkg/CHNOSZ: . R data demo inst inst/extdata/abundance man Message-ID: <20170224020750.AB43C187C3E@r-forge.r-project.org> Author: jedick Date: 2017-02-24 03:07:50 +0100 (Fri, 24 Feb 2017) New Revision: 173 Added: pkg/CHNOSZ/inst/extdata/abundance/TBD+05.csv Removed: pkg/CHNOSZ/inst/extdata/abundance/stress.csv Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/read.expr.R pkg/CHNOSZ/R/util.data.R pkg/CHNOSZ/data/protein.csv pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/sources.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/read.expr.Rd Log: remove stress() and stress.csv Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-23 13:52:07 UTC (rev 172) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-24 02:07:50 UTC (rev 173) @@ -1,6 +1,6 @@ -Date: 2017-02-23 +Date: 2017-02-24 Package: CHNOSZ -Version: 1.0.8-62 +Version: 1.0.8-63 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/read.expr.R =================================================================== --- pkg/CHNOSZ/R/read.expr.R 2017-02-23 13:52:07 UTC (rev 172) +++ pkg/CHNOSZ/R/read.expr.R 2017-02-24 02:07:50 UTC (rev 173) @@ -1,25 +1,8 @@ # CHNOSZ/read.expr.R # protein abundance and localization data from experiments -# stress: protein identities from stress.csv # yeastgfp: protein localization and abundance from yeastgfp.csv # read.expr: protein abundance from other files (including in extdata/abundance) -stress <- function(condition, organism) { - # get names of proteins from a stress response experiment - # extracted from get.protein() 20120519 jmd - # read the data file - stressfile <- system.file("extdata/abundance/stress.csv", package="CHNOSZ") - stressdat <- read.csv(stressfile, check.names=FALSE, as.is=TRUE) - imatch <- which(colnames(stressdat) == condition & stressdat[1, ] == organism) - if(length(imatch)==0) stop("didn't find proteins for ", organism, " in ", condition) - protein <- stressdat[3:nrow(stressdat), imatch] - protein <- protein[!is.na(protein)] - # stressdat[2, ]: the literature source of the data - message("stress: found ", length(protein), " proteins for ", organism, " in ", condition, " from ", stressdat[2, imatch]) - out <- list(protein=protein, abundance=rep(1, length(protein))) - return(out) -} - yeastgfp <- function(location=NULL, exclusive=TRUE) { # return a list of ORFs and protein abundances for a subcellular location # using data from the YeastGFP project Modified: pkg/CHNOSZ/R/util.data.R =================================================================== --- pkg/CHNOSZ/R/util.data.R 2017-02-23 13:52:07 UTC (rev 172) +++ pkg/CHNOSZ/R/util.data.R 2017-02-24 02:07:50 UTC (rev 173) @@ -190,13 +190,8 @@ # count the times each source is listed in protein.csv npr <- sapply(x$key, function(x) length(which(thermo$protein$ref==x)) ) npr[npr==0] <- "" - # count the times each source is listed in stress.csv - stressfile <- system.file("extdata/abundance/stress.csv", package="CHNOSZ") - stressdat <- read.csv(stressfile, check.names=FALSE, as.is=TRUE) - nst <- sapply(x$key, function(x) length(which(stressdat[2,]==x)) ) - nst[nst==0] <- "" # append the counts to the table to be shown - x <- c(x,list(ns1=ns1,npr=npr,nst=nst)) + x <- c(x,list(ns1=ns1,npr=npr)) # title to display for web page title <- "Sources of Thermodynamic Data in CHNOSZ" ### the following is adapted from print.findFn in package 'sos' @@ -222,8 +217,7 @@ .cat("

Click on column headers to sort

") .cat("

Columns 'n..' give number of times each reference appears in data tables:

") .cat("ns1: 'ref1' and 'ref2' in data/OBIGT.csv
") - .cat("npr: 'ref' in data/protein.csv
") - .cat("nst: second row in data/stress.csv

") + .cat("npr: 'ref' in data/protein.csv

") ### start table and headers .cat("\n") .cat("") Modified: pkg/CHNOSZ/data/protein.csv =================================================================== --- pkg/CHNOSZ/data/protein.csv 2017-02-23 13:52:07 UTC (rev 172) +++ pkg/CHNOSZ/data/protein.csv 2017-02-24 02:07:50 UTC (rev 173) @@ -1,210 +1,209 @@ protein,organism,ref,abbrv,chains,Ala,Cys,Asp,Glu,Phe,Gly,His,Ile,Lys,Leu,Met,Asn,Pro,Gln,Arg,Ser,Thr,Val,Trp,Tyr -O08452,PYRFU,BBA+03,O08452,1,28,5,33,23,20,45,12,25,19,27,4,21,20,7,14,21,16,31,26,37 -AMY,BACSU,BBA+03,P00691,1,49,1,44,23,20,51,16,35,30,36,10,54,23,29,24,55,45,32,14,28 -AMYA,PYRFU,BBA+03,P49067,1,26,2,35,66,37,44,14,41,48,59,12,24,28,15,35,33,12,59,17,41 -BPT1,BOVIN,BBA+03,P00974,1,6,6,2,2,4,6,0,2,4,2,1,3,4,1,6,1,3,1,0,4 -CYC,BOVIN,BBA+03,P62894,1,6,2,3,9,4,14,3,6,18,6,2,5,4,3,2,1,8,3,1,4 -LYSC,CHICK,BBA+03,P00698,1,12,8,7,2,3,12,1,6,6,8,2,14,2,3,11,10,7,6,6,3 -MYG,PHYCA,BBA+03,P02185,1,17,0,7,14,6,11,12,9,19,18,2,1,4,5,4,6,5,8,2,3 -NUC,STAAU,BBA+03,P00644,1,14,0,8,12,3,10,4,5,23,11,4,6,6,6,5,5,10,9,1,7 -RNAS1,BOVIN,BBA+03,P61823,1,12,8,5,5,3,3,4,3,10,2,4,10,4,7,4,15,10,9,0,6 -RNBR,BACAM,BBA+03,P00648,1,8,0,9,3,4,10,2,8,8,7,0,6,3,4,6,9,9,4,3,7 -RNH,ECOLI,BBA+03,P0A7Y4,1,14,3,7,12,2,14,5,7,11,12,4,7,5,8,10,4,10,9,6,5 -RNH,THET8,BBA+03,P29253,1,19,4,5,15,6,14,8,1,12,17,3,6,12,3,15,4,9,6,5,2 -RNT1,ASPOR,BBA+03,P00651,1,7,4,6,6,4,12,3,2,1,3,0,9,4,3,1,15,6,8,1,9 -CSG,HALJP,BBA+03,Q9C4B4,1,61,0,122,86,20,78,4,47,4,47,0,51,29,21,19,74,79,66,2,18 -CSG,HALSA,BBA+03,Q9HM69,1,54,0,113,70,18,77,2,41,15,44,7,56,21,27,19,76,85,68,2,23 -CSG,HALVO,BBA+03,P25062,1,59,0,89,67,13,83,2,48,4,49,5,43,19,21,14,85,108,65,3,16 -CSG,METFE,BBA+03,P27373,1,24,8,23,31,15,56,1,77,41,23,6,71,19,6,16,35,46,31,8,34 -CSG,METJA,BBA+03,Q58232,1,46,2,78,36,10,36,3,25,54,46,12,31,13,3,4,21,28,55,4,23 -CSG,METSC,BBA+03,P27374,1,24,8,23,31,15,56,1,74,41,23,8,71,19,6,16,35,46,32,8,34 -CSG,METVO,BBA+03,Q50833,1,75,0,64,41,13,41,0,26,46,49,11,26,9,8,3,30,37,52,3,19 -CSG,METTL,BBA+03,Q8X235,1,60,0,65,35,10,38,0,34,48,42,7,27,9,9,7,32,29,59,3,16 -CSG,METBU1,SNR+06,ZP_00562202.1,1,40,0,96,53,31,49,2,53,25,39,14,20,17,13,12,45,56,62,9,18 -CSG,METBU,BBA+03,Q12YZ7,1,5,1,20,20,11,26,5,29,14,18,3,32,10,8,4,23,8,28,1,12 -SLAP1,BACAN,BBA+03,P49051,1,95,0,42,70,22,51,2,23,106,51,7,38,21,24,3,36,74,100,5,15 -SLAP,ACEKI,BBA+03,P22258,1,65,0,59,25,20,51,3,35,57,58,4,62,16,19,14,36,71,92,4,45 -SLAP,AERSA,BBA+03,P35823,1,57,0,30,19,25,43,4,24,25,45,2,39,12,19,14,26,47,41,4,5 -SLAP,BACCI,BBA+03,P35824,1,159,9,98,76,51,167,17,61,73,114,11,66,88,46,108,117,125,132,19,49 -SLAP,GEOSE,BBA+03,P35825,1,135,0,83,63,40,71,5,53,109,80,3,74,28,31,21,69,156,131,4,42 -SLAP,CAMFE,BBA+03,P35827,1,127,0,84,26,28,84,4,68,68,67,12,73,4,4,2,82,119,71,2,14 -SLAP,CAUCR,BBA+03,P35828,1,203,0,53,9,31,124,3,40,11,76,3,60,8,20,8,75,190,94,2,15 -SLAP,LACAC,BBA+03,P35829,1,56,0,20,8,9,23,3,15,36,13,1,51,8,8,7,33,54,52,0,23 -SLAP,LACBR,BBA+03,Q05044,1,60,0,24,6,8,41,2,6,36,20,4,21,6,9,8,37,81,33,4,29 -SLAP,LACHE,BBA+03,P38059,1,45,0,24,12,11,24,3,21,41,12,3,38,13,10,5,30,52,42,0,23 -SLAP2,BACAN,BBA+03,P94217,1,70,0,62,45,26,76,8,40,86,62,1,57,23,21,9,51,71,99,4,22 -SLAP,BACLI,BBA+03,P49052,1,80,0,63,54,29,79,9,45,89,50,2,51,23,17,15,41,78,95,4,20 -POLG.VP4,POL1M,BBA+03,P03300,1,7,0,4,2,2,4,1,4,5,2,1,6,3,4,2,9,5,3,0,4 -POLG.VP2,POL1M,BBA+03,P03300,1,21,9,10,12,8,18,5,11,5,25,8,20,18,10,13,22,24,14,8,10 -POLG.VP3,POL1M,BBA+03,P03300,1,15,5,14,10,10,13,5,14,10,23,12,8,18,7,9,21,20,13,3,8 -POLG.VP1,POL1M,BBA+03,P03300,1,23,2,17,11,12,17,7,12,15,20,5,14,21,9,15,24,32,26,4,16 -POLG.2A,POL1M,BBA+03,P03300,1,12,6,7,9,5,16,6,8,3,8,4,8,4,7,8,8,6,10,1,13 -POLG.P2B,POL1M,BBA+03,P03300,1,6,2,4,5,2,5,0,12,7,12,1,4,2,4,2,7,12,5,2,3 -POLG.P2C,POL1M,BBA+03,P03300,1,22,10,15,20,14,12,8,25,23,25,13,20,15,19,19,27,15,16,4,7 -POLG.P3A,POL1M,BBA+03,P03300,1,7,2,5,4,2,4,1,7,6,6,2,4,4,7,3,3,6,9,1,4 -POLG.VPg,POL1M,BBA+03,P03300,1,2,0,0,0,0,2,0,1,3,1,0,2,3,1,1,0,3,2,0,1 -POLG.3C,POL1M,BBA+03,P03300,1,15,3,8,9,8,18,4,13,9,11,5,9,8,7,9,9,19,13,0,5 -POLG.RNA,POL1M,BBA+03,P03300,1,31,5,32,30,19,28,12,26,38,46,17,18,22,7,18,30,26,24,7,25 -FLAB1,AERPE,BBA+03,Q9YAN8,1,20,2,8,14,7,18,0,13,8,20,4,6,8,3,5,18,13,25,1,4 -FLAB2,AERPE,BBA+03,Q9YAN6,1,27,2,18,15,6,20,0,17,6,26,3,6,14,2,7,16,22,23,0,10 -FLAB1,METJA,BBA+03,Q58301,1,27,1,11,6,8,18,2,19,8,17,4,10,6,9,1,16,17,18,1,6 -FLAB2,METJA,BBA+03,Q58302,1,28,1,7,8,5,18,1,21,8,19,3,12,6,9,2,13,21,17,1,5 -FLAB3,METJA,BBA+03,Q58303,1,21,0,8,11,8,19,3,26,6,11,3,15,7,6,6,12,17,20,1,5 -FLA,BACSU,BBA+03,P02968,1,39,0,22,17,5,19,4,22,15,29,8,27,2,24,14,24,18,14,0,1 -FLAA,AQUPY,BBA+03,P46210,1,54,0,37,19,10,37,2,48,23,45,8,34,9,25,20,34,48,28,2,18 -FLAA,AQUAE,BBA+03,O67803,1,57,0,33,18,16,39,1,38,16,46,7,46,7,30,18,38,54,37,0,17 -FLJJ,CAUCR,BBA+03,P02969,1,40,0,23,7,5,24,2,13,10,35,5,19,7,18,12,17,22,16,1,0 -PST1,YEAST,BBA+03,YDR055W,1,28,4,17,8,18,28,2,26,33,39,0,36,3,12,1,83,35,23,1,3 -TSA1,YEAST,BBA+03,YML028W,1,19,2,11,15,11,13,2,13,14,17,0,8,11,6,6,8,13,18,3,5 -PRX1,YEAST,BBA+03,YBL064C,1,17,3,20,11,18,11,3,20,25,17,2,12,15,11,11,17,18,21,4,5 -DOT5,YEAST,BBA+03,YIL010W,1,14,2,10,19,10,10,3,12,25,18,2,11,12,7,12,20,8,16,0,4 -MOD5.M,YEAST,BBA+03,P07884-1,1,15,7,29,30,12,20,11,31,46,35,10,22,16,21,25,20,29,22,9,18 -MOD5.N,YEAST,BBA+03,P07884-2,1,15,6,29,30,12,18,11,31,44,32,9,21,15,21,25,20,29,22,9,18 -COX1,YEAST,BBA+03,P00401,1,44,1,13,9,44,43,16,49,10,68,21,27,25,9,9,43,31,38,10,24 -COX2,YEAST,BBA+03,P00410,1,15,4,13,16,11,12,5,25,8,24,6,7,13,8,4,13,14,19,5,14 -COX3,YEAST,BBA+03,P00420,1,22,2,5,7,16,19,15,18,2,36,13,9,9,4,7,16,20,25,9,15 -COX4,YEAST,BBA+03,P04037,1,6,3,10,9,1,13,4,6,9,11,2,5,10,4,4,6,10,11,2,4 -COX5A,YEAST,BBA+03,P00424,1,13,0,5,8,3,10,1,3,11,11,4,6,6,11,5,13,4,9,6,4 -COX5B,YEAST,BBA+03,P00425,1,8,0,4,11,4,11,1,5,13,15,2,9,8,6,6,7,8,6,6,4 -COX6,YEAST,BBA+03,P00427,1,11,1,9,16,7,1,1,2,7,11,0,4,5,3,7,5,3,9,0,6 -COX7,YEAST,BBA+03,P10174,1,8,0,0,0,3,1,1,6,6,6,0,2,5,3,3,3,2,4,2,4 -COX8,YEAST,BBA+03,P04039,1,4,1,1,1,7,4,2,2,6,2,0,1,3,1,1,1,1,6,0,3 -COX9,YEAST,BBA+03,P07255,1,4,0,2,3,3,5,1,6,6,3,3,1,1,0,4,2,3,3,3,2 -KC11,YEAST,BBA+03,P23291,1,31,4,28,25,17,35,17,23,37,48,12,33,30,72,26,30,24,18,4,24 -KC12,YEAST,BBA+03,P23292,1,34,3,29,25,16,40,19,21,38,44,12,39,28,61,26,37,23,20,4,27 -KC13,YEAST,BBA+03,P39962,1,24,13,34,21,19,28,18,35,37,35,11,47,28,28,31,46,20,16,4,29 -HRR25,YEAST,BBA+03,P29295,1,21,5,24,27,22,28,14,26,33,47,13,31,29,43,32,35,20,17,4,23 -GAL83,YEAST,BBA+03,Q04739,1,24,1,37,21,12,23,15,18,18,29,15,32,31,33,11,33,26,20,4,14 -SIP1,YEAST,BBA+03,P32578,1,49,6,60,47,27,33,35,43,48,70,19,61,45,32,42,118,55,43,4,26 -SIP2,YEAST,BBA+03,P34164,1,17,4,32,27,10,21,8,21,27,26,9,18,32,24,22,44,34,23,3,12 -GLRX1,YEAST,BBA+03,P25373,1,8,2,5,12,2,6,3,9,8,14,2,8,4,5,3,3,5,7,0,4 -GLRX2.C,YEAST,BBA+03,P17695,1,7,2,4,10,3,7,2,6,12,12,1,6,4,6,0,7,6,10,0,3 -GLRX2,YEAST,BBA+03,P17695,1,9,2,5,11,7,7,2,13,14,15,3,8,5,6,2,10,10,11,0,3 -GLRX3,YEAST,BBA+03,Q03835,1,17,5,16,32,19,12,7,17,15,23,5,16,12,15,8,27,13,14,2,10 -GLRX4,YEAST,BBA+03,P32642,1,18,2,16,26,16,10,3,17,16,19,4,9,11,15,8,22,10,16,2,4 -GLRX5,YEAST,BBA+03,Q02784,1,12,2,6,18,9,9,0,10,9,15,4,5,11,4,9,8,7,7,1,4 -GSHR.M,YEAST,BBA+03,P41921,1,33,5,24,35,17,43,15,32,42,34,9,28,14,11,18,29,26,45,4,19 -GSHR.C,YEAST,BBA+03,P41921,1,32,5,24,35,16,43,15,31,41,32,8,28,14,9,16,27,23,45,4,19 -GPD1,YEAST,BBA+03,Q00055,1,32,10,17,33,15,34,12,27,22,32,5,19,14,13,13,24,17,35,6,10 -GPD2,YEAST,BBA+03,P41911,1,32,7,21,30,16,29,21,31,26,44,8,19,17,18,21,23,25,34,5,13 -TRX1,YEAST,BBA+03,P22217,1,16,2,7,6,6,4,0,5,10,6,3,4,5,6,0,4,4,10,1,3 -TRX2,YEAST,BBA+03,P22803,1,15,2,7,6,5,5,0,5,9,5,3,2,4,4,1,9,4,12,1,4 -TRX3,YEAST,BBA+03,P25372,1,7,4,8,5,6,6,1,10,13,12,6,4,8,5,5,5,9,8,1,4 -TRXB1,YEAST,BBA+03,P29509,1,36,4,15,24,11,29,5,22,24,24,8,10,13,8,10,19,28,17,2,9 -TRXB2,YEAST,BBA+03,P38816,1,35,4,14,24,14,28,7,26,20,23,10,14,14,9,16,26,24,23,2,9 -AMPM1,YEAST,BBA+03,YLR244C,1,20,14,20,25,9,26,14,22,33,24,7,20,25,11,15,21,27,22,4,18 -AMPM2,YEAST,BBA+03,YBL091C,1,29,4,32,35,12,31,14,22,37,31,10,22,17,14,21,19,24,27,2,18 -EXG1,YEAST,BBA+03,YLR300W,1,25,7,37,25,17,31,10,24,14,34,5,27,13,18,15,27,18,19,15,27 -CLPX,ECOLI,BBA+03,P0A6H1,1,35,7,29,36,10,35,7,31,33,45,4,11,17,20,19,23,19,31,0,11 -CLPP,ECOLI,BBA+03,P0A6G7,1,16,2,10,16,8,16,6,16,7,19,12,7,8,10,13,13,10,11,0,7 -CLPA,ECOLI,BBA+03,P0ABH9,1,69,3,44,64,27,50,21,46,44,78,15,32,25,36,50,42,38,60,3,11 -HSLU,ECOLI,BBA+03,P0A6H5,1,42,2,27,46,10,24,7,38,30,40,14,15,17,23,29,22,21,28,3,5 -HSLV,ECOLI,BBA+03,P0A7B8,1,24,1,10,13,5,15,5,12,10,18,3,8,2,4,10,5,12,13,1,4 -FTSH,ECOLI,BBA+03,P0AAI3,1,59,2,37,50,25,58,9,40,37,51,25,26,36,22,43,32,27,50,5,10 -LON,ECOLI,BBA+03,P0A9M0,1,62,6,51,68,10,51,14,51,61,84,30,26,37,28,49,38,32,63,3,20 -AMY1,HORVU,BBA+03,P25718,1,47,4,37,13,15,44,13,23,22,25,12,17,17,12,15,21,17,28,16,16 -AMYB,HORVU,BBA+03,P16098,1,41,5,31,31,23,56,14,22,22,41,18,26,35,28,27,22,21,37,10,25 -GUB2,HORVU,BBA+03,P12257,1,43,2,6,6,15,33,7,11,9,17,11,24,18,10,8,22,15,30,4,15 -ALEU,HORVU,BBA+03,P05167,1,18,1,4,8,7,7,2,3,2,10,2,4,3,2,17,15,7,5,1,3 -RPOE,ECOLI,BBA+03,P0AGB6,1,17,1,12,16,7,8,1,12,7,18,4,7,8,9,18,14,6,18,1,7 -FLIA,ECOLI,BBA+03,P0AEM6,1,18,0,14,25,2,13,5,9,6,36,5,9,5,17,24,12,11,17,3,8 -RP32,ECOLI,BBA+03,P0AGB3,1,33,0,23,22,8,12,6,12,16,29,11,13,6,14,23,16,9,18,6,7 -RPOS,ECOLI,BBA+03,P13445,1,24,0,23,41,9,19,4,19,12,44,5,13,8,15,34,13,17,20,3,7 -RP54,ECOLI,BBA+03,P24255,1,31,3,36,42,10,18,9,30,19,59,10,14,21,38,26,36,33,26,5,11 -RPOD,ECOLI,BBA+03,P00579,1,49,3,54,71,15,24,9,43,34,54,25,19,19,30,46,29,38,34,4,13 -AMY1,ECOLI,BBA+03,P25718,1,58,4,55,25,29,58,19,22,31,56,15,24,31,42,27,39,45,29,25,25 -AMPM,ECOLI,BBA+03,P0AE18,1,14,7,17,22,6,22,9,26,18,16,9,8,11,5,13,12,16,24,1,8 -AMPM,PYRFU,BBA+03,P56218,1,30,0,12,29,8,22,6,29,26,26,9,9,14,5,14,6,13,24,1,12 -ALBU,BOVIN,BBA+03,P02769,1,47,35,40,59,27,16,17,14,59,61,4,14,28,20,23,28,33,36,2,20 -OVAL,CHICK,BBA+03,P01012,1,35,6,14,33,20,19,7,25,20,32,16,17,14,15,15,38,15,31,3,10 -INS,BOVIN,BBA+03,P01317,1,3,6,0,4,3,4,2,1,1,6,0,3,1,3,1,3,1,5,0,4 -CTRA,BOVIN,BBA+03,P00766,1,22,10,9,5,6,23,2,10,14,19,2,13,9,10,3,27,22,23,8,4 -LACB,BOVIN,BBA+03,P02754,1,15,5,10,16,4,4,2,10,15,22,4,5,8,9,3,7,8,9,2,4 -MYG,HORSE,BBA+03,P68082,1,15,0,8,13,7,15,11,9,19,17,2,2,4,6,2,5,7,7,2,2 -A0FHA7,HORVU,BBA+03,A0FHA7,1,41,11,27,44,25,30,10,16,40,62,8,19,29,16,30,38,21,31,6,13 -CLPP,HORVU,BBA+03,P48883,1,15,3,15,17,11,14,5,20,7,16,12,3,13,3,12,9,12,15,5,9 -E13A,HORVU,BBA+03,P34742,1,41,2,15,8,14,30,2,13,9,24,5,24,20,7,16,16,21,26,3,14 -CSG,METMP,BBA+03,Q6M088,1,91,0,61,36,14,47,0,29,29,46,9,20,14,9,2,21,34,65,3,16 -HJA1,METJA,BBA+03,Q57632,1,15,0,1,11,1,1,1,4,10,7,1,0,2,0,4,1,1,6,0,1 -HJA2,METJA,BBA+03,Q58342,1,15,0,1,11,1,1,1,4,9,7,1,0,2,1,4,1,1,6,0,1 -HJA3,METJA,BBA+03,Q58655,1,14,1,2,7,1,3,1,3,9,6,1,0,2,1,5,2,1,7,0,1 -HJA4,METJA,BBA+03,Q60264,1,13,0,2,10,2,1,1,4,10,7,1,0,2,0,4,1,2,6,0,1 -HstA,METVO,BBA+03,Q6ZZY8,1,11,0,2,9,1,3,1,5,8,5,3,0,2,0,5,3,1,8,0,0 -HstB,METVO,BBA+03,Q6ZZY7,1,12,0,2,11,1,2,1,4,7,9,3,0,2,0,4,3,1,4,0,0 -HARA,PYRAB,BBA+03,P61881,1,12,0,2,9,1,3,1,5,8,5,1,0,2,1,5,2,1,7,0,2 -HARB,PYRAB,BBA+03,Q9V1F5,1,13,0,3,7,0,2,2,5,10,8,1,0,2,1,5,2,1,5,0,0 -HARA,PYRFU,BBA+03,P61882,1,12,0,2,9,1,3,1,5,8,5,1,0,2,1,5,2,1,7,0,2 -HARB,PYRFU,BBA+03,O59627,1,12,0,3,7,0,3,2,6,10,6,1,0,2,2,4,2,1,6,0,0 -HMmA,METMP,BBA+03,Q6M085,1,13,0,4,8,1,2,1,4,9,5,5,0,2,0,3,2,1,7,0,0 -Q6LXK3,METMP,BBA+03,Q6LXK3,1,15,0,4,7,0,2,1,2,7,7,4,0,2,0,4,3,1,7,0,0 -DN71,SULSO,BBA+03,P61991,1,3,0,3,6,2,7,0,3,14,3,3,0,1,3,2,3,3,5,1,2 -DN72,SULSO,BBA+03,P39476,1,3,0,3,7,2,7,0,3,14,3,2,0,1,2,2,3,3,5,1,2 -TPX,THIDA,BBA+03,Q3SMC0,1,23,2,11,7,7,11,1,8,13,15,4,9,9,1,3,8,10,19,0,2 -TPX,BACHD,BBA+03,Q9K813,1,21,2,12,12,6,9,2,6,11,16,2,9,6,3,6,9,11,18,1,4 -TPX,BACSU,BBA+03,P80864,1,17,2,11,14,7,12,2,9,12,12,2,7,6,4,6,9,10,18,1,5 -TPX,AQUAE,BBA+03,O66780,1,11,2,10,16,6,12,0,11,14,11,5,7,8,5,6,4,10,27,0,4 -TPX,ECOLI,BBA+03,P0A862,1,22,3,10,7,10,10,1,10,7,15,0,10,6,9,5,10,12,18,0,2 -H-NS,PHOPR,BBA+03,Q6LT83,1,14,0,9,19,2,5,1,2,14,19,3,2,4,4,9,8,7,5,1,3 +O08452,PYRFU,UniProt,O08452,1,28,5,33,23,20,45,12,25,19,27,4,21,20,7,14,21,16,31,26,37 +AMY,BACSU,UniProt,P00691,1,49,1,44,23,20,51,16,35,30,36,10,54,23,29,24,55,45,32,14,28 +AMYA,PYRFU,UniProt,P49067,1,26,2,35,66,37,44,14,41,48,59,12,24,28,15,35,33,12,59,17,41 +BPT1,BOVIN,UniProt,P00974,1,6,6,2,2,4,6,0,2,4,2,1,3,4,1,6,1,3,1,0,4 +CYC,BOVIN,UniProt,P62894,1,6,2,3,9,4,14,3,6,18,6,2,5,4,3,2,1,8,3,1,4 +LYSC,CHICK,UniProt,P00698,1,12,8,7,2,3,12,1,6,6,8,2,14,2,3,11,10,7,6,6,3 +MYG,PHYCA,UniProt,P02185,1,17,0,7,14,6,11,12,9,19,18,2,1,4,5,4,6,5,8,2,3 +NUC,STAAU,UniProt,P00644,1,14,0,8,12,3,10,4,5,23,11,4,6,6,6,5,5,10,9,1,7 +RNAS1,BOVIN,UniProt,P61823,1,12,8,5,5,3,3,4,3,10,2,4,10,4,7,4,15,10,9,0,6 +RNBR,BACAM,UniProt,P00648,1,8,0,9,3,4,10,2,8,8,7,0,6,3,4,6,9,9,4,3,7 +RNH,ECOLI,UniProt,P0A7Y4,1,14,3,7,12,2,14,5,7,11,12,4,7,5,8,10,4,10,9,6,5 +RNH,THET8,UniProt,P29253,1,19,4,5,15,6,14,8,1,12,17,3,6,12,3,15,4,9,6,5,2 +RNT1,ASPOR,UniProt,P00651,1,7,4,6,6,4,12,3,2,1,3,0,9,4,3,1,15,6,8,1,9 +CSG,HALJP,UniProt,Q9C4B4,1,61,0,122,86,20,78,4,47,4,47,0,51,29,21,19,74,79,66,2,18 +CSG,HALSA,UniProt,Q9HM69,1,54,0,113,70,18,77,2,41,15,44,7,56,21,27,19,76,85,68,2,23 +CSG,HALVO,UniProt,P25062,1,59,0,89,67,13,83,2,48,4,49,5,43,19,21,14,85,108,65,3,16 +CSG,METFE,UniProt,P27373,1,24,8,23,31,15,56,1,77,41,23,6,71,19,6,16,35,46,31,8,34 +CSG,METJA,UniProt,Q58232,1,46,2,78,36,10,36,3,25,54,46,12,31,13,3,4,21,28,55,4,23 +CSG,METSC,UniProt,P27374,1,24,8,23,31,15,56,1,74,41,23,8,71,19,6,16,35,46,32,8,34 +CSG,METVO,UniProt,Q50833,1,75,0,64,41,13,41,0,26,46,49,11,26,9,8,3,30,37,52,3,19 +CSG,METTL,UniProt,Q8X235,1,60,0,65,35,10,38,0,34,48,42,7,27,9,9,7,32,29,59,3,16 +CSG,METBU,UniProt,Q12YZ7,1,5,1,20,20,11,26,5,29,14,18,3,32,10,8,4,23,8,28,1,12 +SLAP1,BACAN,UniProt,P49051,1,95,0,42,70,22,51,2,23,106,51,7,38,21,24,3,36,74,100,5,15 +SLAP,ACEKI,UniProt,P22258,1,65,0,59,25,20,51,3,35,57,58,4,62,16,19,14,36,71,92,4,45 +SLAP,AERSA,UniProt,P35823,1,57,0,30,19,25,43,4,24,25,45,2,39,12,19,14,26,47,41,4,5 +SLAP,BACCI,UniProt,P35824,1,159,9,98,76,51,167,17,61,73,114,11,66,88,46,108,117,125,132,19,49 +SLAP,GEOSE,UniProt,P35825,1,135,0,83,63,40,71,5,53,109,80,3,74,28,31,21,69,156,131,4,42 +SLAP,CAMFE,UniProt,P35827,1,127,0,84,26,28,84,4,68,68,67,12,73,4,4,2,82,119,71,2,14 +SLAP,CAUCR,UniProt,P35828,1,203,0,53,9,31,124,3,40,11,76,3,60,8,20,8,75,190,94,2,15 +SLAP,LACAC,UniProt,P35829,1,56,0,20,8,9,23,3,15,36,13,1,51,8,8,7,33,54,52,0,23 +SLAP,LACBR,UniProt,Q05044,1,60,0,24,6,8,41,2,6,36,20,4,21,6,9,8,37,81,33,4,29 +SLAP,LACHE,UniProt,P38059,1,45,0,24,12,11,24,3,21,41,12,3,38,13,10,5,30,52,42,0,23 +SLAP2,BACAN,UniProt,P94217,1,70,0,62,45,26,76,8,40,86,62,1,57,23,21,9,51,71,99,4,22 +SLAP,BACLI,UniProt,P49052,1,80,0,63,54,29,79,9,45,89,50,2,51,23,17,15,41,78,95,4,20 +POLG.VP4,POL1M,UniProt,P03300,1,7,0,4,2,2,4,1,4,5,2,1,6,3,4,2,9,5,3,0,4 +POLG.VP2,POL1M,UniProt,P03300,1,21,9,10,12,8,18,5,11,5,25,8,20,18,10,13,22,24,14,8,10 +POLG.VP3,POL1M,UniProt,P03300,1,15,5,14,10,10,13,5,14,10,23,12,8,18,7,9,21,20,13,3,8 +POLG.VP1,POL1M,UniProt,P03300,1,23,2,17,11,12,17,7,12,15,20,5,14,21,9,15,24,32,26,4,16 +POLG.2A,POL1M,UniProt,P03300,1,12,6,7,9,5,16,6,8,3,8,4,8,4,7,8,8,6,10,1,13 +POLG.P2B,POL1M,UniProt,P03300,1,6,2,4,5,2,5,0,12,7,12,1,4,2,4,2,7,12,5,2,3 +POLG.P2C,POL1M,UniProt,P03300,1,22,10,15,20,14,12,8,25,23,25,13,20,15,19,19,27,15,16,4,7 +POLG.P3A,POL1M,UniProt,P03300,1,7,2,5,4,2,4,1,7,6,6,2,4,4,7,3,3,6,9,1,4 +POLG.VPg,POL1M,UniProt,P03300,1,2,0,0,0,0,2,0,1,3,1,0,2,3,1,1,0,3,2,0,1 +POLG.3C,POL1M,UniProt,P03300,1,15,3,8,9,8,18,4,13,9,11,5,9,8,7,9,9,19,13,0,5 +POLG.RNA,POL1M,UniProt,P03300,1,31,5,32,30,19,28,12,26,38,46,17,18,22,7,18,30,26,24,7,25 +FLAB1,AERPE,UniProt,Q9YAN8,1,20,2,8,14,7,18,0,13,8,20,4,6,8,3,5,18,13,25,1,4 +FLAB2,AERPE,UniProt,Q9YAN6,1,27,2,18,15,6,20,0,17,6,26,3,6,14,2,7,16,22,23,0,10 +FLAB1,METJA,UniProt,Q58301,1,27,1,11,6,8,18,2,19,8,17,4,10,6,9,1,16,17,18,1,6 +FLAB2,METJA,UniProt,Q58302,1,28,1,7,8,5,18,1,21,8,19,3,12,6,9,2,13,21,17,1,5 +FLAB3,METJA,UniProt,Q58303,1,21,0,8,11,8,19,3,26,6,11,3,15,7,6,6,12,17,20,1,5 +FLA,BACSU,UniProt,P02968,1,39,0,22,17,5,19,4,22,15,29,8,27,2,24,14,24,18,14,0,1 +FLAA,AQUPY,UniProt,P46210,1,54,0,37,19,10,37,2,48,23,45,8,34,9,25,20,34,48,28,2,18 +FLAA,AQUAE,UniProt,O67803,1,57,0,33,18,16,39,1,38,16,46,7,46,7,30,18,38,54,37,0,17 +FLJJ,CAUCR,UniProt,P02969,1,40,0,23,7,5,24,2,13,10,35,5,19,7,18,12,17,22,16,1,0 +PST1,YEAST,UniProt,YDR055W,1,28,4,17,8,18,28,2,26,33,39,0,36,3,12,1,83,35,23,1,3 +TSA1,YEAST,UniProt,YML028W,1,19,2,11,15,11,13,2,13,14,17,0,8,11,6,6,8,13,18,3,5 +PRX1,YEAST,UniProt,YBL064C,1,17,3,20,11,18,11,3,20,25,17,2,12,15,11,11,17,18,21,4,5 +DOT5,YEAST,UniProt,YIL010W,1,14,2,10,19,10,10,3,12,25,18,2,11,12,7,12,20,8,16,0,4 +MOD5.M,YEAST,UniProt,P07884-1,1,15,7,29,30,12,20,11,31,46,35,10,22,16,21,25,20,29,22,9,18 +MOD5.N,YEAST,UniProt,P07884-2,1,15,6,29,30,12,18,11,31,44,32,9,21,15,21,25,20,29,22,9,18 +COX1,YEAST,UniProt,P00401,1,44,1,13,9,44,43,16,49,10,68,21,27,25,9,9,43,31,38,10,24 +COX2,YEAST,UniProt,P00410,1,15,4,13,16,11,12,5,25,8,24,6,7,13,8,4,13,14,19,5,14 +COX3,YEAST,UniProt,P00420,1,22,2,5,7,16,19,15,18,2,36,13,9,9,4,7,16,20,25,9,15 +COX4,YEAST,UniProt,P04037,1,6,3,10,9,1,13,4,6,9,11,2,5,10,4,4,6,10,11,2,4 +COX5A,YEAST,UniProt,P00424,1,13,0,5,8,3,10,1,3,11,11,4,6,6,11,5,13,4,9,6,4 +COX5B,YEAST,UniProt,P00425,1,8,0,4,11,4,11,1,5,13,15,2,9,8,6,6,7,8,6,6,4 +COX6,YEAST,UniProt,P00427,1,11,1,9,16,7,1,1,2,7,11,0,4,5,3,7,5,3,9,0,6 +COX7,YEAST,UniProt,P10174,1,8,0,0,0,3,1,1,6,6,6,0,2,5,3,3,3,2,4,2,4 +COX8,YEAST,UniProt,P04039,1,4,1,1,1,7,4,2,2,6,2,0,1,3,1,1,1,1,6,0,3 +COX9,YEAST,UniProt,P07255,1,4,0,2,3,3,5,1,6,6,3,3,1,1,0,4,2,3,3,3,2 +KC11,YEAST,UniProt,P23291,1,31,4,28,25,17,35,17,23,37,48,12,33,30,72,26,30,24,18,4,24 +KC12,YEAST,UniProt,P23292,1,34,3,29,25,16,40,19,21,38,44,12,39,28,61,26,37,23,20,4,27 +KC13,YEAST,UniProt,P39962,1,24,13,34,21,19,28,18,35,37,35,11,47,28,28,31,46,20,16,4,29 +HRR25,YEAST,UniProt,P29295,1,21,5,24,27,22,28,14,26,33,47,13,31,29,43,32,35,20,17,4,23 +GAL83,YEAST,UniProt,Q04739,1,24,1,37,21,12,23,15,18,18,29,15,32,31,33,11,33,26,20,4,14 +SIP1,YEAST,UniProt,P32578,1,49,6,60,47,27,33,35,43,48,70,19,61,45,32,42,118,55,43,4,26 +SIP2,YEAST,UniProt,P34164,1,17,4,32,27,10,21,8,21,27,26,9,18,32,24,22,44,34,23,3,12 +GLRX1,YEAST,UniProt,P25373,1,8,2,5,12,2,6,3,9,8,14,2,8,4,5,3,3,5,7,0,4 +GLRX2.C,YEAST,UniProt,P17695,1,7,2,4,10,3,7,2,6,12,12,1,6,4,6,0,7,6,10,0,3 +GLRX2,YEAST,UniProt,P17695,1,9,2,5,11,7,7,2,13,14,15,3,8,5,6,2,10,10,11,0,3 +GLRX3,YEAST,UniProt,Q03835,1,17,5,16,32,19,12,7,17,15,23,5,16,12,15,8,27,13,14,2,10 +GLRX4,YEAST,UniProt,P32642,1,18,2,16,26,16,10,3,17,16,19,4,9,11,15,8,22,10,16,2,4 +GLRX5,YEAST,UniProt,Q02784,1,12,2,6,18,9,9,0,10,9,15,4,5,11,4,9,8,7,7,1,4 +GSHR.M,YEAST,UniProt,P41921,1,33,5,24,35,17,43,15,32,42,34,9,28,14,11,18,29,26,45,4,19 +GSHR.C,YEAST,UniProt,P41921,1,32,5,24,35,16,43,15,31,41,32,8,28,14,9,16,27,23,45,4,19 +GPD1,YEAST,UniProt,Q00055,1,32,10,17,33,15,34,12,27,22,32,5,19,14,13,13,24,17,35,6,10 +GPD2,YEAST,UniProt,P41911,1,32,7,21,30,16,29,21,31,26,44,8,19,17,18,21,23,25,34,5,13 +TRX1,YEAST,UniProt,P22217,1,16,2,7,6,6,4,0,5,10,6,3,4,5,6,0,4,4,10,1,3 +TRX2,YEAST,UniProt,P22803,1,15,2,7,6,5,5,0,5,9,5,3,2,4,4,1,9,4,12,1,4 +TRX3,YEAST,UniProt,P25372,1,7,4,8,5,6,6,1,10,13,12,6,4,8,5,5,5,9,8,1,4 +TRXB1,YEAST,UniProt,P29509,1,36,4,15,24,11,29,5,22,24,24,8,10,13,8,10,19,28,17,2,9 +TRXB2,YEAST,UniProt,P38816,1,35,4,14,24,14,28,7,26,20,23,10,14,14,9,16,26,24,23,2,9 +AMPM1,YEAST,UniProt,YLR244C,1,20,14,20,25,9,26,14,22,33,24,7,20,25,11,15,21,27,22,4,18 +AMPM2,YEAST,UniProt,YBL091C,1,29,4,32,35,12,31,14,22,37,31,10,22,17,14,21,19,24,27,2,18 +EXG1,YEAST,UniProt,YLR300W,1,25,7,37,25,17,31,10,24,14,34,5,27,13,18,15,27,18,19,15,27 +CLPX,ECOLI,UniProt,P0A6H1,1,35,7,29,36,10,35,7,31,33,45,4,11,17,20,19,23,19,31,0,11 +CLPP,ECOLI,UniProt,P0A6G7,1,16,2,10,16,8,16,6,16,7,19,12,7,8,10,13,13,10,11,0,7 +CLPA,ECOLI,UniProt,P0ABH9,1,69,3,44,64,27,50,21,46,44,78,15,32,25,36,50,42,38,60,3,11 +HSLU,ECOLI,UniProt,P0A6H5,1,42,2,27,46,10,24,7,38,30,40,14,15,17,23,29,22,21,28,3,5 +HSLV,ECOLI,UniProt,P0A7B8,1,24,1,10,13,5,15,5,12,10,18,3,8,2,4,10,5,12,13,1,4 +FTSH,ECOLI,UniProt,P0AAI3,1,59,2,37,50,25,58,9,40,37,51,25,26,36,22,43,32,27,50,5,10 +LON,ECOLI,UniProt,P0A9M0,1,62,6,51,68,10,51,14,51,61,84,30,26,37,28,49,38,32,63,3,20 +AMY1,HORVU,UniProt,P25718,1,47,4,37,13,15,44,13,23,22,25,12,17,17,12,15,21,17,28,16,16 +AMYB,HORVU,UniProt,P16098,1,41,5,31,31,23,56,14,22,22,41,18,26,35,28,27,22,21,37,10,25 +GUB2,HORVU,UniProt,P12257,1,43,2,6,6,15,33,7,11,9,17,11,24,18,10,8,22,15,30,4,15 +ALEU,HORVU,UniProt,P05167,1,18,1,4,8,7,7,2,3,2,10,2,4,3,2,17,15,7,5,1,3 +RPOE,ECOLI,UniProt,P0AGB6,1,17,1,12,16,7,8,1,12,7,18,4,7,8,9,18,14,6,18,1,7 +FLIA,ECOLI,UniProt,P0AEM6,1,18,0,14,25,2,13,5,9,6,36,5,9,5,17,24,12,11,17,3,8 +RP32,ECOLI,UniProt,P0AGB3,1,33,0,23,22,8,12,6,12,16,29,11,13,6,14,23,16,9,18,6,7 +RPOS,ECOLI,UniProt,P13445,1,24,0,23,41,9,19,4,19,12,44,5,13,8,15,34,13,17,20,3,7 +RP54,ECOLI,UniProt,P24255,1,31,3,36,42,10,18,9,30,19,59,10,14,21,38,26,36,33,26,5,11 +RPOD,ECOLI,UniProt,P00579,1,49,3,54,71,15,24,9,43,34,54,25,19,19,30,46,29,38,34,4,13 +AMY1,ECOLI,UniProt,P25718,1,58,4,55,25,29,58,19,22,31,56,15,24,31,42,27,39,45,29,25,25 +AMPM,ECOLI,UniProt,P0AE18,1,14,7,17,22,6,22,9,26,18,16,9,8,11,5,13,12,16,24,1,8 +AMPM,PYRFU,UniProt,P56218,1,30,0,12,29,8,22,6,29,26,26,9,9,14,5,14,6,13,24,1,12 +ALBU,BOVIN,UniProt,P02769,1,47,35,40,59,27,16,17,14,59,61,4,14,28,20,23,28,33,36,2,20 +OVAL,CHICK,UniProt,P01012,1,35,6,14,33,20,19,7,25,20,32,16,17,14,15,15,38,15,31,3,10 +INS,BOVIN,UniProt,P01317,1,3,6,0,4,3,4,2,1,1,6,0,3,1,3,1,3,1,5,0,4 +CTRA,BOVIN,UniProt,P00766,1,22,10,9,5,6,23,2,10,14,19,2,13,9,10,3,27,22,23,8,4 +LACB,BOVIN,UniProt,P02754,1,15,5,10,16,4,4,2,10,15,22,4,5,8,9,3,7,8,9,2,4 +MYG,HORSE,UniProt,P68082,1,15,0,8,13,7,15,11,9,19,17,2,2,4,6,2,5,7,7,2,2 +A0FHA7,HORVU,UniProt,A0FHA7,1,41,11,27,44,25,30,10,16,40,62,8,19,29,16,30,38,21,31,6,13 +CLPP,HORVU,UniProt,P48883,1,15,3,15,17,11,14,5,20,7,16,12,3,13,3,12,9,12,15,5,9 +E13A,HORVU,UniProt,P34742,1,41,2,15,8,14,30,2,13,9,24,5,24,20,7,16,16,21,26,3,14 +CSG,METMP,UniProt,Q6M088,1,91,0,61,36,14,47,0,29,29,46,9,20,14,9,2,21,34,65,3,16 +HJA1,METJA,UniProt,Q57632,1,15,0,1,11,1,1,1,4,10,7,1,0,2,0,4,1,1,6,0,1 +HJA2,METJA,UniProt,Q58342,1,15,0,1,11,1,1,1,4,9,7,1,0,2,1,4,1,1,6,0,1 +HJA3,METJA,UniProt,Q58655,1,14,1,2,7,1,3,1,3,9,6,1,0,2,1,5,2,1,7,0,1 +HJA4,METJA,UniProt,Q60264,1,13,0,2,10,2,1,1,4,10,7,1,0,2,0,4,1,2,6,0,1 +HstA,METVO,UniProt,Q6ZZY8,1,11,0,2,9,1,3,1,5,8,5,3,0,2,0,5,3,1,8,0,0 +HstB,METVO,UniProt,Q6ZZY7,1,12,0,2,11,1,2,1,4,7,9,3,0,2,0,4,3,1,4,0,0 +HARA,PYRAB,UniProt,P61881,1,12,0,2,9,1,3,1,5,8,5,1,0,2,1,5,2,1,7,0,2 +HARB,PYRAB,UniProt,Q9V1F5,1,13,0,3,7,0,2,2,5,10,8,1,0,2,1,5,2,1,5,0,0 +HARA,PYRFU,UniProt,P61882,1,12,0,2,9,1,3,1,5,8,5,1,0,2,1,5,2,1,7,0,2 +HARB,PYRFU,UniProt,O59627,1,12,0,3,7,0,3,2,6,10,6,1,0,2,2,4,2,1,6,0,0 +HMmA,METMP,UniProt,Q6M085,1,13,0,4,8,1,2,1,4,9,5,5,0,2,0,3,2,1,7,0,0 +Q6LXK3,METMP,UniProt,Q6LXK3,1,15,0,4,7,0,2,1,2,7,7,4,0,2,0,4,3,1,7,0,0 +DN71,SULSO,UniProt,P61991,1,3,0,3,6,2,7,0,3,14,3,3,0,1,3,2,3,3,5,1,2 +DN72,SULSO,UniProt,P39476,1,3,0,3,7,2,7,0,3,14,3,2,0,1,2,2,3,3,5,1,2 +TPX,THIDA,UniProt,Q3SMC0,1,23,2,11,7,7,11,1,8,13,15,4,9,9,1,3,8,10,19,0,2 +TPX,BACHD,UniProt,Q9K813,1,21,2,12,12,6,9,2,6,11,16,2,9,6,3,6,9,11,18,1,4 +TPX,BACSU,UniProt,P80864,1,17,2,11,14,7,12,2,9,12,12,2,7,6,4,6,9,10,18,1,5 +TPX,AQUAE,UniProt,O66780,1,11,2,10,16,6,12,0,11,14,11,5,7,8,5,6,4,10,27,0,4 +TPX,ECOLI,UniProt,P0A862,1,22,3,10,7,10,10,1,10,7,15,0,10,6,9,5,10,12,18,0,2 +H-NS,PHOPR,UniProt,Q6LT83,1,14,0,9,19,2,5,1,2,14,19,3,2,4,4,9,8,7,5,1,3 cell,ECOLI,Nei86,NA,1,488,87,229,250,176,582,90,276,326,428,146,229,210,250,281,205,241,402,54,131 -PPB,ECOLI,BBA+03,P00634,1,64,4,28,24,8,45,10,16,28,39,8,20,21,22,14,22,40,23,3,11 -SPTA2.SH3,CHICK,BBA+03,P07751,1,3,0,5,4,1,3,0,1,8,7,1,3,3,2,2,2,4,6,2,3 -BARS,BACAM,BBA+03,P11540,1,6,2,4,11,2,5,1,6,6,12,0,3,2,6,3,5,4,5,3,3 -TRY1,BOVIN,BBA+03,P00760,1,14,12,6,4,3,25,3,15,14,14,2,16,8,10,2,34,10,17,4,10 -CYB5.HEME,BOVIN,BBA+03,P00171,1,3,0,4,11,3,6,5,4,6,8,0,3,1,2,2,4,6,4,1,4 -LYS,BPT4,BBA+03,P00720,1,15,2,10,8,5,11,1,10,13,16,5,12,3,5,13,6,11,9,3,6 -RNT1.K25,ASPOR,BBA+03,P00651,1,7,4,6,6,4,12,3,2,2,3,0,9,4,2,1,15,6,8,1,9 -IOVO.3,MELGA,BBA+03,P68390,1,2,6,2,3,2,4,1,0,4,4,0,5,3,0,1,4,4,3,0,3 -PAP1,CARPA,BBA+03,P00784,1,14,7,6,10,4,28,2,12,10,11,0,13,10,10,12,13,8,18,5,19 -PRVB,ESOLU,BBA+03,P02619,1,20,1,14,6,10,7,1,4,12,9,2,1,1,2,1,8,2,5,0,1 -PEPA,PIG,BBA+03,P00791,1,16,6,29,13,14,35,1,25,1,26,4,13,15,13,2,44,26,22,5,16 -PLMN.K4,HUMAN,BBA+03,P00747,1,2,6,4,2,1,6,3,0,6,2,2,5,6,3,4,7,10,1,3,5 -SPG1.B1,STRSG,BBA+03,P06654,1,6,0,5,5,2,4,0,1,6,3,0,3,0,1,0,0,11,4,1,3 -SPG1.B2,STRSG,BBA+03,P06654,1,6,0,5,4,2,4,0,1,7,2,0,3,0,1,0,0,11,5,1,3 -DN71.d,SULAC,BBA+03,P13123,1,4,0,5,7,2,5,0,1,13,3,2,1,1,0,4,3,3,7,1,2 -SSI,STRAO|2,BBA+03,P01006,2,36,8,12,10,6,22,4,0,4,18,6,6,16,2,8,18,16,26,2,6 -SSI,STRAO,BBA+03,P01006,1,18,4,6,5,3,11,2,0,2,9,3,3,8,1,4,9,8,13,1,3 -TRPA,SALTY,BBA+03,P00929,1,40,3,13,16,12,20,5,18,8,28,5,11,17,10,15,16,7,17,0,7 -UBIQ,HUMAN,BBA+03,P62988,1,2,0,5,6,2,6,1,7,7,9,1,2,3,6,4,3,7,4,0,1 -CDC2,HUMAN,BBA+03,NA,1,12,1,19,18,11,18,8,22,24,36,8,10,15,10,15,21,13,18,4,14 -CDK2,HUMAN,BBA+03,NA,1,19,3,16,17,16,16,10,16,21,39,5,8,19,9,16,14,17,23,4,10 -CDK3,HUMAN,BBA+03,NA,1,16,2,14,21,15,18,9,17,20,41,7,6,19,13,19,17,16,19,4,12 -CDK4,HUMAN,BBA+03,NA,1,22,4,17,19,13,24,9,11,11,33,8,7,25,8,23,15,15,27,3,9 -CDK5,HUMAN,BBA+03,NA,1,16,8,21,17,15,16,7,11,23,40,4,13,19,9,16,14,12,18,3,10 -CDK6,HUMAN,BBA+03,NA,1,19,6,23,22,16,18,9,12,18,39,6,7,17,14,22,20,19,28,3,8 -CDK7,HUMAN,BBA+03,NA,1,24,5,20,18,17,23,10,20,24,50,8,14,21,13,18,15,18,15,4,9 -CDK8,HUMAN,BBA+03,NA,1,25,6,33,24,17,27,22,23,39,40,13,16,33,24,24,28,23,21,6,20 -CDK9,HUMAN,BBA+03,NA,1,22,7,21,23,14,19,8,19,29,45,11,18,18,17,23,19,18,22,5,14 -CDK10,HUMAN,BBA+03,NA,1,18,10,13,27,13,21,11,19,26,48,9,10,26,12,24,17,20,22,4,10 -CCNA1,HUMAN,BBA+03,NA,1,34,11,24,37,18,28,8,18,21,59,12,10,29,22,22,27,26,31,4,24 -CCNA2,HUMAN,BBA+03,NA,1,38,3,20,33,11,16,12,15,31,52,12,16,34,25,16,25,23,30,3,17 -CCNB1,HUMAN,BBA+03,NA,1,39,5,19,33,10,17,8,19,36,45,22,17,35,19,16,20,23,35,2,13 -CCNB2,HUMAN,BBA+03,NA,1,25,5,19,26,9,13,8,21,35,46,13,20,18,23,18,26,22,34,3,14 -CCNB3,HUMAN,BBA+03,NA,1,75,21,41,164,56,27,29,69,172,162,40,37,80,60,23,139,113,58,4,25 -CCNC,HUMAN,BBA+03,NA,1,18,7,12,20,15,7,5,15,19,35,10,9,15,18,13,17,10,17,6,15 -CCND1,HUMAN,BBA+03,NA,1,26,13,13,34,10,3,4,12,18,36,12,12,15,13,16,16,13,21,2,6 -CCND2,HUMAN,BBA+03,NA,1,21,12,20,24,8,7,5,13,17,41,8,7,13,19,16,14,16,18,3,7 -CCND3,HUMAN,BBA+03,NA,1,30,12,12,21,6,14,7,10,10,41,9,1,17,16,22,20,18,15,3,8 -CCNE1,HUMAN,BBA+03,NA,1,31,10,29,29,13,14,9,20,26,46,16,12,25,21,24,27,15,22,8,13 -CCNE2,HUMAN,BBA+03,NA,1,18,10,18,30,18,12,10,31,33,44,10,14,23,23,17,29,23,22,8,11 -CCNF,HUMAN,BBA+03,NA,1,59,32,41,57,24,40,22,25,34,97,7,15,40,41,50,74,42,55,12,19 -CCNG1,HUMAN,BBA+03,NA,1,15,11,9,22,13,8,7,17,23,43,6,10,9,17,18,22,17,18,3,7 -CCNG2,HUMAN,BBA+03,NA,1,19,19,14,36,16,11,10,18,24,50,4,14,14,8,13,31,16,18,2,7 -CCNH,HUMAN,BBA+03,NA,1,20,8,14,31,14,7,8,14,24,42,10,15,15,10,20,24,13,17,2,15 -CCNI,HUMAN,BBA+03,NA,1,25,11,17,21,16,11,14,14,23,52,11,12,24,18,18,36,16,26,4,8 -CCNJ,HUMAN,BBA+03,NA,1,26,12,12,20,12,12,16,15,13,52,9,10,19,32,17,31,22,19,6,17 -CCNJL,HUMAN,BBA+03,NA,1,34,17,17,17,16,14,21,10,16,60,9,8,37,20,18,43,32,25,5,16 -CCNK,HUMAN,BBA+03,NA,1,20,7,18,21,15,12,11,13,28,30,7,7,32,42,14,22,17,22,8,11 -CCNL1,HUMAN,BBA+03,NA,1,36,7,16,32,13,27,30,25,37,41,6,18,27,17,62,64,33,22,2,11 -CCNL2,HUMAN,BBA+03,NA,1,43,9,21,31,12,35,16,19,41,44,7,11,32,21,58,59,17,27,2,15 -CCNO,HUMAN,BBA+03,NA,1,37,17,14,17,14,17,11,8,11,49,4,6,30,19,25,32,16,18,1,4 -CCNT1,HUMAN,BBA+03,NA,1,48,7,29,44,20,31,39,24,52,62,16,32,52,38,30,90,53,36,8,15 -CCNT2,HUMAN,BBA+03,NA,1,37,9,32,37,15,33,46,34,56,59,17,26,41,41,26,113,46,37,7,18 -CCNY,HUMAN,BBA+03,NA,1,23,9,26,20,11,5,9,22,19,38,4,19,18,11,26,33,15,15,4,14 -CD5R1,HUMAN,BBA+03,NA,1,20,8,12,11,9,14,7,10,23,38,5,16,19,15,14,37,14,21,4,10 -MAT1,HUMAN,BBA+03,NA,1,13,8,15,35,11,13,7,11,27,39,6,15,16,21,17,14,13,18,1,9 -Q2RJF3,MOOTA,BBA+03,NA,1,34,5,28,37,16,32,13,32,30,50,10,20,18,10,23,19,15,27,3,26 -Q2RMD6,MOOTA,BBA+03,NA,1,146,18,60,72,48,93,25,68,80,91,27,40,56,43,42,64,62,80,11,45 -Q2RJ73,MOOTA,BBA+03,NA,1,54,10,46,59,35,64,11,63,42,52,26,21,43,17,39,23,40,47,9,28 +PPB,ECOLI,UniProt,P00634,1,64,4,28,24,8,45,10,16,28,39,8,20,21,22,14,22,40,23,3,11 +SPTA2.SH3,CHICK,UniProt,P07751,1,3,0,5,4,1,3,0,1,8,7,1,3,3,2,2,2,4,6,2,3 +BARS,BACAM,UniProt,P11540,1,6,2,4,11,2,5,1,6,6,12,0,3,2,6,3,5,4,5,3,3 +TRY1,BOVIN,UniProt,P00760,1,14,12,6,4,3,25,3,15,14,14,2,16,8,10,2,34,10,17,4,10 +CYB5.HEME,BOVIN,UniProt,P00171,1,3,0,4,11,3,6,5,4,6,8,0,3,1,2,2,4,6,4,1,4 +LYS,BPT4,UniProt,P00720,1,15,2,10,8,5,11,1,10,13,16,5,12,3,5,13,6,11,9,3,6 +RNT1.K25,ASPOR,UniProt,P00651,1,7,4,6,6,4,12,3,2,2,3,0,9,4,2,1,15,6,8,1,9 +IOVO.3,MELGA,UniProt,P68390,1,2,6,2,3,2,4,1,0,4,4,0,5,3,0,1,4,4,3,0,3 +PAP1,CARPA,UniProt,P00784,1,14,7,6,10,4,28,2,12,10,11,0,13,10,10,12,13,8,18,5,19 +PRVB,ESOLU,UniProt,P02619,1,20,1,14,6,10,7,1,4,12,9,2,1,1,2,1,8,2,5,0,1 +PEPA,PIG,UniProt,P00791,1,16,6,29,13,14,35,1,25,1,26,4,13,15,13,2,44,26,22,5,16 +PLMN.K4,HUMAN,UniProt,P00747,1,2,6,4,2,1,6,3,0,6,2,2,5,6,3,4,7,10,1,3,5 +SPG1.B1,STRSG,UniProt,P06654,1,6,0,5,5,2,4,0,1,6,3,0,3,0,1,0,0,11,4,1,3 +SPG1.B2,STRSG,UniProt,P06654,1,6,0,5,4,2,4,0,1,7,2,0,3,0,1,0,0,11,5,1,3 +DN71.d,SULAC,UniProt,P13123,1,4,0,5,7,2,5,0,1,13,3,2,1,1,0,4,3,3,7,1,2 +SSI,STRAO|2,UniProt,P01006,2,36,8,12,10,6,22,4,0,4,18,6,6,16,2,8,18,16,26,2,6 +SSI,STRAO,UniProt,P01006,1,18,4,6,5,3,11,2,0,2,9,3,3,8,1,4,9,8,13,1,3 +TRPA,SALTY,UniProt,P00929,1,40,3,13,16,12,20,5,18,8,28,5,11,17,10,15,16,7,17,0,7 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 173 From noreply at r-forge.r-project.org Fri Feb 24 07:46:29 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 24 Feb 2017 07:46:29 +0100 (CET) Subject: [CHNOSZ-commits] r174 - in pkg/CHNOSZ: . R data inst inst/extdata/thermo man tests/testthat vignettes Message-ID: <20170224064629.9A592188AA1@r-forge.r-project.org> Author: jedick Date: 2017-02-24 07:46:29 +0100 (Fri, 24 Feb 2017) New Revision: 174 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/add.protein.R pkg/CHNOSZ/R/protein.info.R pkg/CHNOSZ/data/protein.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/thermo/obigt_check.csv pkg/CHNOSZ/man/add.protein.Rd pkg/CHNOSZ/man/protein.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/man/util.fasta.Rd pkg/CHNOSZ/tests/testthat/test-add.protein.R pkg/CHNOSZ/tests/testthat/test-affinity.R pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/hotspring.Rnw pkg/CHNOSZ/vignettes/hotspring.lyx Log: remove read.aa() Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-24 06:46:29 UTC (rev 174) @@ -1,6 +1,6 @@ Date: 2017-02-24 Package: CHNOSZ -Version: 1.0.8-63 +Version: 1.0.8-64 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/add.protein.R =================================================================== --- pkg/CHNOSZ/R/add.protein.R 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/R/add.protein.R 2017-02-24 06:46:29 UTC (rev 174) @@ -5,7 +5,6 @@ # add.protein - add amino acid counts to thermo$protein (returns iprotein) # seq2aa - calculate amino acid counts from a sequence # aasum - combine amino acid counts (sum, average, or weighted sum by abundance) -# read.aa - read amino acid counts from a file seq2aa <- function(protein, sequence) { # remove newlines and whitespace @@ -55,21 +54,12 @@ return(out) } -read.aa <- function(file="protein.csv", ...) { - # 20090428 added colClasses here - # 20140128 added as.is=TRUE (in case numeric values are stored in ref or abbrv column) - aa <- read.csv(file, colClasses=c(rep("character", 2), NA, NA, rep("numeric", 21)), as.is=TRUE, ...) - if(!identical(colnames(aa), colnames(get("thermo")$protein))) - stop(paste("format of", file, "is incompatible with thermo$protein")) - return(aa) -} - add.protein <- function(aa) { # add a properly constructed data frame of # amino acid counts to thermo$protein thermo <- get("thermo") if(!identical(colnames(aa), colnames(thermo$protein))) - stop("the value of 'aa' is not a data frame with the same columns as thermo$protein") + stop("'aa' does not have the same columns as thermo$protein") # find any protein IDs that are duplicated po <- paste(aa$protein, aa$organism, sep="_") ip <- pinfo(po) Modified: pkg/CHNOSZ/R/protein.info.R =================================================================== --- pkg/CHNOSZ/R/protein.info.R 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/R/protein.info.R 2017-02-24 06:46:29 UTC (rev 174) @@ -8,7 +8,7 @@ # protein.basis: coefficients of basis species in formation reactions of [ionized] proteins [residues] # protein.equil: step-by-step example of protein equilibrium calculation -pinfo <- function(protein, organism=NULL, residue=FALSE) { +pinfo <- function(protein, organism=NULL, residue=FALSE, regexp=FALSE) { # return the `protein` (possibly per residue) for: # dataframe `protein` # return the rownumber(s) of thermo$protein for: @@ -29,11 +29,19 @@ # compute per-residue counts if requested if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25]) } else { - # search for protein or protein_organism in thermo$protein - t_p_names <- paste(t_p$protein, t_p$organism, sep="_") - if(is.null(organism)) my_names <- protein - else my_names <- paste(protein, organism, sep="_") - iprotein <- match(my_names, t_p_names) + # search for protein by regular expression + if(regexp) { + iprotein <- grepl(protein, t_p$protein) + iorganism <- iprotein + if(!is.null(organism)) iorganism <- grepl(organism, t_p$organism) + iprotein <- which(iprotein & iorganism) + } else { + # search for protein or protein_organism in thermo$protein + t_p_names <- paste(t_p$protein, t_p$organism, sep="_") + if(is.null(organism)) my_names <- protein + else my_names <- paste(protein, organism, sep="_") + iprotein <- match(my_names, t_p_names) + } out <- iprotein } out Modified: pkg/CHNOSZ/data/protein.csv =================================================================== --- pkg/CHNOSZ/data/protein.csv 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/data/protein.csv 2017-02-24 06:46:29 UTC (rev 174) @@ -468,3 +468,41 @@ PTC1,HUMAN,UniProt,Q13635,1,116,27,63,78,64,101,42,62,50,153,31,49,102,57,79,105,83,108,21,56 SMO,HUMAN,UniProt,Q99835,1,70,26,28,36,37,57,15,33,29,71,14,25,61,26,47,52,43,53,19,18 GLI3R,HUMAN,UniProt,P10071,1,10,0,6,4,5,5,12,7,0,7,5,3,26,0,7,17,6,3,0,8 +HXA1,HUMAN,UniProt,P49639,1,25,7,9,17,9,26,24,7,14,19,5,16,25,20,14,46,20,14,2,16 +HXA2,HUMAN,UniProt,O43364,1,31,8,16,29,16,22,10,9,20,38,4,18,30,23,15,42,24,13,2,6 +HXA3,HUMAN,UniProt,O43365,1,49,5,8,15,8,44,18,6,19,28,8,17,75,27,15,49,20,9,2,21 +HXA4,HUMAN,UniProt,Q00056,1,37,3,4,14,6,28,15,7,16,21,5,8,52,19,20,24,14,10,3,14 +HXA5,HUMAN,UniProt,P20719,1,30,3,10,14,8,25,12,8,10,11,7,10,20,11,21,41,8,5,3,13 +HXA6,HUMAN,UniProt,P31267,1,16,5,10,12,10,20,4,5,13,16,4,9,15,15,17,28,10,4,3,17 +HXA7,HUMAN,UniProt,P31268,1,33,5,13,20,9,18,4,6,11,14,3,10,12,8,15,18,11,4,3,13 +HXA9,HUMAN,UniProt,P31269,1,33,4,14,15,9,17,12,4,14,21,5,13,26,8,19,17,15,11,4,11 +HXA10,HUMAN,UniProt,P31260,1,43,9,14,22,12,59,5,6,19,32,6,13,51,16,22,43,14,7,3,14 +HXA11,HUMAN,UniProt,P31270,1,32,6,12,21,12,20,6,5,15,18,5,12,25,12,24,39,18,13,2,16 +HXA13,HUMAN,UniProt,P31271,1,93,6,8,17,10,35,11,6,19,19,10,13,37,13,16,29,12,13,5,16 +HXB1,HUMAN,UniProt,P14653,1,29,5,9,19,11,29,4,2,12,16,4,11,39,15,15,37,17,8,2,17 +HXB2,HUMAN,UniProt,P14652,1,39,9,14,29,19,27,4,7,12,35,3,6,53,16,20,33,14,11,3,2 +HXB3,HUMAN,UniProt,P14651,1,42,7,8,15,10,64,15,4,22,28,10,20,60,21,13,46,19,6,2,19 +HXB4,HUMAN,UniProt,P17483,1,22,7,5,13,6,19,7,5,11,13,4,9,46,10,23,21,6,10,3,11 +HXB5,HUMAN,UniProt,P09067,1,30,3,9,15,11,16,7,7,10,16,8,11,19,12,19,46,13,3,3,11 +HXB6,HUMAN,UniProt,P17509,1,18,6,6,20,10,17,4,4,12,14,4,5,19,13,17,23,10,4,3,15 +HXB7,HUMAN,UniProt,P09629,1,26,4,5,18,10,22,3,5,10,11,6,8,10,11,17,20,13,3,3,12 +HXB9,HUMAN,UniProt,P17482,1,21,3,6,22,7,17,7,6,16,20,5,8,24,14,17,26,8,8,4,11 +HXB13,HUMAN,UniProt,Q92826,1,33,7,9,14,8,26,5,6,16,19,4,8,33,13,16,22,14,12,4,15 +HXC4,HUMAN,UniProt,P09017,1,20,5,6,18,4,12,14,10,12,13,5,9,35,16,20,31,12,5,3,14 +HXC5,HUMAN,UniProt,Q00444,1,25,4,6,14,5,12,6,8,14,13,8,12,20,12,17,20,9,3,3,11 +HXC6,HUMAN,UniProt,P09630,1,14,3,8,17,9,18,5,9,11,14,5,15,8,17,20,24,15,7,3,13 +HXC8,HUMAN,UniProt,P31273,1,13,4,7,26,11,19,10,3,16,15,4,13,14,15,15,26,6,9,3,13 +HXC9,HUMAN,UniProt,P31274,1,24,4,15,14,9,15,7,4,16,18,7,8,27,7,20,24,12,11,4,14 +HXC10,HUMAN,UniProt,Q9NYD6,1,25,9,11,32,9,20,5,6,24,26,8,18,30,10,23,42,18,9,3,14 +HXC11,HUMAN,UniProt,O43248,1,28,8,7,25,15,21,8,5,17,19,6,17,28,9,21,35,8,11,2,14 +HXC12,HUMAN,UniProt,P31275,1,18,5,11,17,11,42,3,4,12,32,2,14,30,9,21,26,4,8,3,10 +HXC13,HUMAN,UniProt,P31276,1,28,7,11,16,7,37,11,7,19,23,4,5,36,13,17,37,12,18,5,17 +HXD1,HUMAN,UniProt,Q9GZZ0,1,48,6,10,13,17,33,5,6,17,25,3,8,36,12,14,34,14,14,2,11 +HXD3,HUMAN,UniProt,P31249,1,44,9,9,19,11,42,15,7,22,29,9,18,59,26,15,48,18,11,2,19 +HXD4,HUMAN,UniProt,P09016,1,18,4,8,12,7,27,9,4,15,15,6,7,33,15,15,24,10,10,3,13 +HXD8,HUMAN,UniProt,P13378,1,36,5,8,21,12,24,11,6,15,14,4,11,37,18,18,17,10,7,3,13 +HXD9,HUMAN,UniProt,P28356,1,43,7,7,20,11,46,6,7,17,17,8,9,36,13,21,43,17,10,4,10 +HXD10,HUMAN,UniProt,P28358,1,16,9,8,30,9,12,3,9,23,24,14,20,27,19,20,41,22,20,3,11 +HXD11,HUMAN,UniProt,P31277,1,48,6,11,19,16,50,2,4,16,16,6,10,41,15,21,23,7,10,2,15 +HXD12,HUMAN,UniProt,P35452,1,39,4,7,13,10,24,0,4,16,28,3,11,28,15,19,17,10,9,3,10 +HXD13,HUMAN,UniProt,P35453,1,54,5,11,13,11,32,7,7,18,14,7,11,23,13,19,45,12,20,5,16 Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/inst/NEWS 2017-02-24 06:46:29 UTC (rev 174) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-63 (2017-02-24) +CHANGES IN CHNOSZ 1.0.8-64 (2017-02-24) --------------------------------------- DOCUMENTATION: @@ -64,9 +64,6 @@ marks and lines; this is used in diagram() to redraw the axes on filled diagrams. -- Add `...` argument to read.aa() (additional arguments for - read.csv()). - - seq2aa() removes newlines and whitespace before counting the letters in the sequence. @@ -136,7 +133,8 @@ summary table). - New function pinfo() merges functionality of old iprotein() and - ip2aa(), which have been removed (along with protein.info()). + ip2aa(). Add `regexp` argument to control whether matches are made + using a regular expression. - Rename aa2eos() to protein.obigt(). @@ -145,6 +143,8 @@ - Remove stress() and stress.csv; move data from Tai et al., 2005 (used in an example in ?read.expr) to TBD+05.csv. +- Remove read.aa() - replaced by read.csv() with as.is=TRUE. + CHANGES IN CHNOSZ 1.0.8 (2016-05-28) ------------------------------------ Modified: pkg/CHNOSZ/inst/extdata/thermo/obigt_check.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/thermo/obigt_check.csv 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/inst/extdata/thermo/obigt_check.csv 2017-02-24 06:46:29 UTC (rev 174) @@ -210,34 +210,34 @@ "OBIGT",1793,"Gly-Tyr-Gly","aq",,-190.24, "OBIGT",1794,"Gly-Val-Gly","aq",,-155.72, "OBIGT",1795,"[GXGBB]","aq",,-98.93, -"OBIGT",1833,"methyldiethanolamine","aq",1.61,, -"OBIGT",1865,"MgAsO4-","aq",1.3,, -"OBIGT",1868,"MnAsO4-","aq",-1.45,, -"OBIGT",1964,"antigorite","cr1",,,812 -"OBIGT",1998,"clinochlore,7a","cr1",,,666 -"OBIGT",2017,"daphnite,14a","cr",,,-836 -"OBIGT",2042,"ferrosilite","cr1",,,694 -"OBIGT",2043,"ferrosilite","cr2",,,694 -"OBIGT",2058,"greenalite","cr",,,142507 -"OBIGT",2073,"hydromagnesite","cr",,,-2569 -"OBIGT",2204,"n-octadecane","cr",-2.63,, -"OBIGT",2205,"n-nonadecane","cr",-13.32,, -"OBIGT",2206,"n-eicosane","cr",-2.79,, -"OBIGT",2207,"n-heneicosane","cr",-8.61,, -"OBIGT",2208,"n-docosane","cr",-2.63,, -"OBIGT",2209,"n-tricosane","cr",-5.22,, -"OBIGT",2210,"n-tetracosane","cr",-2.02,, -"OBIGT",2211,"n-pentacosane","cr",-2.93,, -"OBIGT",2212,"n-hexacosane","cr",-1.29,, -"OBIGT",2213,"n-heptacosane","cr",-1.23,, -"OBIGT",2265,"carbazole","cr",-43.39,, -"OBIGT",2306,"triphenylene","cr",,,541 -"OBIGT",2619,"deoxyadenosine","cr",,,-2977 -"OBIGT",2626,"acetamide","cr",-67.91,, -"OBIGT",2671,"jarosite","cr",,,20697 -"OBIGT",2672,"natrojarosite","cr",,,17554 -"OBIGT",2744,"n-nonacontane","liq",,,635 -"OBIGT",2751,"2-methyloctane","liq",10,, -"OBIGT",3164,"5,6-dithiadecane","liq",2,, -"OBIGT",3239,"ethylene","gas",-4.59,, -"OBIGT",3249,"3,5-dimethylphenol","gas",,,628 +"OBIGT",1839,"methyldiethanolamine","aq",1.61,, +"OBIGT",1871,"MgAsO4-","aq",1.3,, +"OBIGT",1874,"MnAsO4-","aq",-1.45,, +"OBIGT",1970,"antigorite","cr1",,,812 +"OBIGT",2004,"clinochlore,7a","cr1",,,666 +"OBIGT",2023,"daphnite,14a","cr",,,-836 +"OBIGT",2048,"ferrosilite","cr1",,,694 +"OBIGT",2049,"ferrosilite","cr2",,,694 +"OBIGT",2064,"greenalite","cr",,,142507 +"OBIGT",2079,"hydromagnesite","cr",,,-2569 +"OBIGT",2210,"n-octadecane","cr",-2.63,, +"OBIGT",2211,"n-nonadecane","cr",-13.32,, +"OBIGT",2212,"n-eicosane","cr",-2.79,, +"OBIGT",2213,"n-heneicosane","cr",-8.61,, +"OBIGT",2214,"n-docosane","cr",-2.63,, +"OBIGT",2215,"n-tricosane","cr",-5.22,, +"OBIGT",2216,"n-tetracosane","cr",-2.02,, +"OBIGT",2217,"n-pentacosane","cr",-2.93,, +"OBIGT",2218,"n-hexacosane","cr",-1.29,, +"OBIGT",2219,"n-heptacosane","cr",-1.23,, +"OBIGT",2271,"carbazole","cr",-43.39,, +"OBIGT",2312,"triphenylene","cr",,,541 +"OBIGT",2625,"deoxyadenosine","cr",,,-2977 +"OBIGT",2632,"acetamide","cr",-67.91,, +"OBIGT",2677,"jarosite","cr",,,20697 +"OBIGT",2678,"natrojarosite","cr",,,17554 +"OBIGT",2750,"n-nonacontane","liq",,,635 +"OBIGT",2757,"2-methyloctane","liq",10,, +"OBIGT",3170,"5,6-dithiadecane","liq",2,, +"OBIGT",3245,"ethylene","gas",-4.59,, +"OBIGT",3255,"3,5-dimethylphenol","gas",,,628 Modified: pkg/CHNOSZ/man/add.protein.Rd =================================================================== --- pkg/CHNOSZ/man/add.protein.Rd 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/man/add.protein.Rd 2017-02-24 06:46:29 UTC (rev 174) @@ -1,7 +1,6 @@ \name{add.protein} \alias{add.protein} \alias{seq2aa} -\alias{read.aa} \alias{aasum} \title{Amino Acid Compositions of Proteins} \description{ @@ -11,7 +10,6 @@ \usage{ add.protein(aa) seq2aa(protein, sequence) - read.aa(file = "protein.csv", ...) aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) } @@ -19,7 +17,6 @@ \item{aa}{data frame, amino acid composition in the format of \code{thermo$protein}} \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}$protein})} \item{sequence}{character, protein sequence} - \item{file}{character, path to file with amino acid compositions} \item{...}{additional arguments passed to \code{\link{read.csv}}} \item{abundance}{numeric, abundances of proteins} \item{average}{logical, return the weighted average of amino acid counts?} @@ -41,8 +38,6 @@ If \code{average} is TRUE the final sum is divided by the number of input compositions. The name used in the output is taken from the first row of \code{aa} or from \code{protein} and \code{organism} if they are specified. -\code{read.aa} returns a data frame of amino acid composition based on the contents of the indicated \code{file}, which should be a CSV file with the same column names as \code{thermo$protein}. - Given amino acid composition returned by the \code{*aa} functions described above, \code{add.protein} adds them to \code{thermo$protein} for use by other functions in CHNOSZ. The amino acid compositions of proteins in \code{aa} with the same name as one in \code{thermo$protein} are replaced. The value returned by this function is the rownumbers of \code{thermo$protein} that are added and/or replaced. Modified: pkg/CHNOSZ/man/protein.Rd =================================================================== --- pkg/CHNOSZ/man/protein.Rd 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/man/protein.Rd 2017-02-24 06:46:29 UTC (rev 174) @@ -18,7 +18,8 @@ ## logfO2-pH potential diagram # with a charged basis, we calculate properties of ionized proteins basis("CHNOS+") -aa <- read.aa(system.file("extdata/protein/DS11.csv", package = "CHNOSZ")) +file <- system.file("extdata/protein/DS11.csv", package = "CHNOSZ") +aa <- read.csv(file, as.is=TRUE) aa <- aa[grep("transferase", aa$protein), ] ip <- add.protein(aa) a <- affinity(pH=c(0, 14), O2=c(-64, -61), T=75, iprotein=ip) Modified: pkg/CHNOSZ/man/protein.info.Rd =================================================================== --- pkg/CHNOSZ/man/protein.info.Rd 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/man/protein.info.Rd 2017-02-24 06:46:29 UTC (rev 174) @@ -14,7 +14,7 @@ } \usage{ - pinfo(protein, organism=NULL, residue=FALSE) + pinfo(protein, organism=NULL, residue=FALSE, regexp=FALSE) protein.length(protein, organism = NULL) protein.formula(protein, organism = NULL, residue = FALSE) protein.obigt(protein, organism = NULL, state=get("thermo")$opt$state) @@ -26,6 +26,7 @@ \item{protein}{character, names of proteins; numeric, species index of proteins; data frame; amino acid composition of proteins} \item{organism}{character, names of organisms} \item{residue}{logical, return per-residue values (those of the proteins divided by their lengths)?} + \item{regexp}{logical, find matches using regular expressions?} \item{normalize}{logical, return per-residue values (those of the proteins divided by their lengths)?} \item{state}{character, physical state} \item{T}{numeric, temperature in \eqn{^{\circ}}{?}C} @@ -38,6 +39,9 @@ The names can be supplied in the single \code{protein} argument (with an underscore, denoting protein_organism) or as pairs of \code{protein}s and \code{organism}s. NA is returned for any unmatched proteins, including those for which no \code{organism} is given or that do not have an underscore in \code{protein}. +Alternatively, if \code{regexp} is TRUE, the \code{protein} argument is used as a pattern (regular expression); rownumbers of all matches of \code{thermo$protein$protein} to this pattern are returned. +When using \code{regexp}, the \code{organism} can optionally be provided to return only those entries that also match \code{thermo$protein$organism}. + For numeric \code{protein}, \code{pinfo} returns the corresponding row(s) of \code{thermo$protein}. Set \code{residue} to TRUE to return the per-residue composition (i.e. amino acid composition of the protein divided by total number of residues). @@ -115,7 +119,7 @@ # get amino acid compositions of microbial proteins # generated from the RefSeq database file <- system.file("extdata/refseq/protein_refseq.csv.xz", package="CHNOSZ") -ip <- add.protein(read.aa(file)) +ip <- add.protein(read.csv(file, as.is=TRUE)) # only use those organisms with a certain # number of sequenced bases ip <- ip[as.numeric(thermo$protein$abbrv[ip]) > 50000] @@ -139,7 +143,42 @@ axis(1, 1:15, terms, las=2) title(main=paste("Average oxidation state of carbon in proteins", "by taxID in NCBI RefSeq (after Dick, 2014)", sep="\n")) + +\dontshow{opar <- par(no.readonly=TRUE)} +# using pinfo() with regexp=TRUE: +# plot ZC and nH2O/residue of HOX proteins +# basis species: glutamine-glutamic acid-cysteine-O2-H2O +basis("QEC") +# device setup +par(mfrow=c(2, 2)) +# a red-blue scale from 1-13 +col <- ZC.col(1:13) +# axis labels +ZClab <- axis.label("ZC") +nH2Olab <- expression(bar(italic(n))[H[2]*O]) +# loop over HOX gene clusters +for(cluster in c("A", "B", "C", "D")) { + # get protein indices + pattern <- paste0("^HX", cluster) + ip <- pinfo(pattern, "HUMAN", regexp=TRUE) + # calculate ZC and nH2O/residue + thisZC <- ZC(protein.formula(ip)) + thisH2O <- protein.basis(ip)[, "H2O"] / protein.length(ip) + # plot lines + plot(thisZC, thisH2O, type="l", xlab=ZClab, ylab=nH2Olab) + # the number of the HOX gene + pname <- pinfo(ip)$protein + nHOX <- as.numeric(gsub("[A-Za-z]*", "", pname)) + # plot colored points + points(thisZC, thisH2O, pch=19, col=col[nHOX], cex=3.5) + points(thisZC, thisH2O, pch=19, col="white", cex=2.5) + # plot the number of the HOX gene + text(thisZC, thisH2O, nHOX) + # add title + title(main=paste0("HOX", cluster)) } +\dontshow{par(opar)} +} \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. \emph{Biogeosciences} \bold{3}, 311--336. \url{http://dx.doi.org/10.5194/bg-3-311-2006} Modified: pkg/CHNOSZ/man/util.fasta.Rd =================================================================== --- pkg/CHNOSZ/man/util.fasta.Rd 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/man/util.fasta.Rd 2017-02-24 06:46:29 UTC (rev 174) @@ -105,7 +105,7 @@ # the amino acid composition can be saved for future use write.csv(aa, "saved.aa.csv", row.names=FALSE) # in another R session, the protein can be loaded without using uniprot.aa() -aa <- read.aa("saved.aa.csv") +aa <- read.csv("saved.aa.csv", as.is=TRUE) add.protein(aa) ## count amino acids in a sequence Modified: pkg/CHNOSZ/tests/testthat/test-add.protein.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-add.protein.R 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/tests/testthat/test-add.protein.R 2017-02-24 06:46:29 UTC (rev 174) @@ -11,12 +11,12 @@ ip <- add.protein(aa) # the replaces the proteins (with the same ones) expect_error(ip <- add.protein(aa), "converting factors causes problems replacing protein data") - # ... should use read.csv(file, stringsAsFactors=FALSE) + # ... should use read.csv(file, as.is=TRUE) }) test_that("errors and messages occur in some circumstances", { expect_error(seq2aa("LYS_CHICK", "XXX"), "no characters match an amino acid") - expect_error(add.protein(count.aa("AAA")), "not a data frame with the same columns as thermo\\$protein") + expect_error(add.protein(count.aa("AAA")), "does not have the same columns as thermo\\$protein") expect_message(add.protein(pinfo(pinfo("CYC_BOVIN"))), "replaced 1 existing protein\\(s\\)") }) Modified: pkg/CHNOSZ/tests/testthat/test-affinity.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-affinity.R 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/tests/testthat/test-affinity.R 2017-02-24 06:46:29 UTC (rev 174) @@ -101,7 +101,8 @@ basis(c("HCO3-", "H2O", "NH3", "HS-", "H2", "H+"), "aq", c(-3, 0, -4, -7, 999, 999)) sites <- c("N", "S", "R", "Q", "P") - aa <- read.aa(system.file("extdata/protein/DS11.csv", package="CHNOSZ")) + file <- system.file("extdata/protein/DS11.csv", package="CHNOSZ") + aa <- read.csv(file, as.is=TRUE) ip <- add.protein(aa[1:5, ]) # to reproduce, we need use the "old" parameters for [Met] from Dick et al., 2006 mod.obigt("[Met]", G=-35245, H=-59310) Modified: pkg/CHNOSZ/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2017-02-24 06:46:29 UTC (rev 174) @@ -1350,22 +1350,23 @@ In the Rubisco example above, we saw the use of `read.fasta()` to read amino acid sequences from a FASTA file. There are several other methods for inputting amino acid compositions. +R's `read.csv()` can be used to read amino acid compositions from a CSV file with the same columns that are present in `thermo$protein`. +Note the use of `as.is = TRUE` to prevent reading character data as factors. +The `nrows` argument can be added to read that number of rows: +```{r read_csv} +file <- system.file("extdata/protein/DS11.csv", package = "CHNOSZ") +aa_bison <- read.csv(file, as.is = TRUE, nrows = 5) +``` `more.aa()` retrieves amino acid composition of proteins in *Saccharomyces cerevisiae* and *Escherichia coli* from data files that are included with CHNOSZ: ```{r more_aa} aa_YML020W <- more.aa("YML020W", "Sce") aa_ILVE <- more.aa("ILVE", "Eco") ``` -`read.aa()` is used to read amino acid compositions from a CSV file with the same columns that are present in `thermo$protein`. -The `nrows` argument can be added to read that number of rows: -```{r read_aa} -aa_bison <- read.aa(system.file("extdata/protein/DS11.csv", - package = "CHNOSZ"), nrows = 5) -``` `read.fasta()` reads a FASTA file and returns the amino acid compositions of the sequences. The `iseq` argument can be used to read those sequences from the file: ```{r read_fasta, message=FALSE} -aa_Ef <- read.fasta(system.file("extdata/fasta/EF-Tu.aln", - package = "CHNOSZ"), iseq = 1:2) +file <- system.file("extdata/fasta/EF-Tu.aln", package = "CHNOSZ") +aa_Ef <- read.fasta(file, iseq = 1:2) ``` `seq2aa()` counts the amino acids in a user-supplied sequence and generates a data frame of the amino acid composition: ```{marginfigure} @@ -1476,7 +1477,8 @@ Then we add the proteins and get their indices using `add.protein()`, set the basis, calculate the affinities, and make a potential diagram with temperature and activity of dissolved hydrogen as variables: ```{r bison_transferase, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, dpi=dpi, out.width="100%", echo=FALSE, results="hide", message=FALSE, fig.cap='Potential diagram for metagenomically identified sequences of transferases in Bison Pool hot spring. See also the vignette [*Hot-spring proteins in CHNOSZ*](hotspring.pdf).', cache=TRUE, pngquant=pngquant, timeit=timeit} -aa <- read.aa(system.file("extdata/protein/DS11.csv", package = "CHNOSZ")) +file <- system.file("extdata/protein/DS11.csv", package = "CHNOSZ") +aa <- read.csv(file, as.is = TRUE) aa <- aa[grep("transferase", aa$protein), ] ip <- add.protein(aa) bspecies <- c("HCO3-", "H2O", "NH3", "HS-", "H2", "H+") @@ -1492,12 +1494,12 @@ lines(T, logaH2, lty = 2, lwd = 2) points(T, logaH2, pch = 21, bg = "white", cex = 1.5) ``` -```{r bison_transferase, eval=FALSE, echo=1:11} +```{r bison_transferase, eval=FALSE, echo=1:12} ``` Site numbers 1--5 correspond to a cooling gradient along the outflow channel of the hot spring. The colors represent the relative `r zc` of the proteins (red is more reduced). The points indicate the *T* and log*a*H2 that optimize a thermodynamic model for relative abundances of phyla that were estimated by taxonomic classification of metagenomic sequences [@DS13]: -```{r bison_transferase, eval=FALSE, echo=12:15} +```{r bison_transferase, eval=FALSE, echo=13:16} ``` # Experimental features Modified: pkg/CHNOSZ/vignettes/hotspring.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/hotspring.Rnw 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/vignettes/hotspring.Rnw 2017-02-24 06:46:29 UTC (rev 174) @@ -132,8 +132,8 @@ <>= # read the amino acid compositions -aa.annot <- read.aa(system.file("extdata/protein/DS11.csv", package="CHNOSZ")) -aa.phyla <- read.aa(system.file("extdata/protein/DS13.csv", package="CHNOSZ")) +aa.annot <- read.csv(system.file("extdata/protein/DS11.csv", package="CHNOSZ"), as.is=TRUE) +aa.phyla <- read.csv(system.file("extdata/protein/DS13.csv", package="CHNOSZ"), as.is=TRUE) @ Here are the site names for the sampling locations (also referred Modified: pkg/CHNOSZ/vignettes/hotspring.lyx =================================================================== --- pkg/CHNOSZ/vignettes/hotspring.lyx 2017-02-24 02:07:50 UTC (rev 173) +++ pkg/CHNOSZ/vignettes/hotspring.lyx 2017-02-24 06:46:29 UTC (rev 174) @@ -482,12 +482,14 @@ \begin_layout Plain Layout -aa.annot <- read.aa(system.file("extdata/protein/DS11.csv", package="CHNOSZ")) +aa.annot <- read.csv(system.file("extdata/protein/DS11.csv", package="CHNOSZ"), + as.is=TRUE) \end_layout \begin_layout Plain Layout -aa.phyla <- read.aa(system.file("extdata/protein/DS13.csv", package="CHNOSZ")) +aa.phyla <- read.csv(system.file("extdata/protein/DS13.csv", package="CHNOSZ"), + as.is=TRUE) \end_layout \begin_layout Plain Layout From noreply at r-forge.r-project.org Fri Feb 24 14:00:08 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 24 Feb 2017 14:00:08 +0100 (CET) Subject: [CHNOSZ-commits] r175 - in pkg/CHNOSZ: . R demo inst man vignettes Message-ID: <20170224130008.7D4E11889E1@r-forge.r-project.org> Author: jedick Date: 2017-02-24 14:00:08 +0100 (Fri, 24 Feb 2017) New Revision: 175 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/affinity.R pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/demo/findit.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/species.Rd pkg/CHNOSZ/man/swap.basis.Rd pkg/CHNOSZ/man/util.affinity.Rd pkg/CHNOSZ/man/util.args.Rd pkg/CHNOSZ/man/util.array.Rd pkg/CHNOSZ/man/util.character.Rd pkg/CHNOSZ/man/util.program.Rd pkg/CHNOSZ/man/util.units.Rd pkg/CHNOSZ/man/util.water.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: export explicitly in NAMESPACE Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-24 13:00:08 UTC (rev 175) @@ -1,6 +1,6 @@ Date: 2017-02-24 Package: CHNOSZ -Version: 1.0.8-64 +Version: 1.0.8-65 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/NAMESPACE 2017-02-24 13:00:08 UTC (rev 175) @@ -1,7 +1,54 @@ -# Export all names except those beginning with F_ -# (so we don't export F_h2o92 created below) -exportPattern("^([^F]|F($|[^_])).*") +## Export all names except those beginning with F_ +## (so we don't export F_h2o92 created below) +#exportPattern("^([^F]|F($|[^_])).*") +# exports starting with functions used in vignettes, examples, demos, tests 20170224 +export( +# anintro vignette + "info", "makeup", "as.chemical.formula", "ZC", + "subcrt", "T.units", "P.units", "E.units", "convert", + "axis.label", "expr.species", "basis", "describe.reaction", + "species", "affinity", "swap.basis", "diagram", "mosaic", + "water.lines", "mod.buffer", "thermo.plot.new", + "describe.property", "describe.basis", "equilibrate", + "aminoacids", "ZC.col", + "pinfo", "protein.length", "protein.formula", + "read.fasta", "protein.basis", "yeastgfp", "more.aa", "add.protein", + "unitize", "revisit", "seq2aa", "findit", + "thermo.refs", "mod.obigt", "today", +# examples + "examples", "demos", "mtitle", + "list2array", "slice", "dimSums", "slice.affinity", + "def2gi", "read.blast", "id.blast", + "add.obigt", "RH2obigt", + "expr.property", "expr.units", + "mass", "entropy", "get.formula", "GHS", "water", + "i2A", "invertible.combs", + "dPdTtr", "Ttr", + "count.aa", "nucleic.complement", "nucleic.formula", + "rho.IAPWS95", "IAPWS95", "water.AW90", "WP02.auxiliary", "water.IAPWS95", + "getrank", "parent", "sciname", "allparents", "getnodes", "getnames", + "protein.obigt", "hkf", "cgl", "which.pmax", + "equil.boltzmann", "equil.reaction", "find.TP", + "ionize.aa", "MP90.cp", "aasum", "read.expr", + "anim.carboxylase", + "qqr", "RMSD", "CVRMSD", "spearman", "DGmix", "DDGmix", "DGtr", + "ratlab", "transfer", "draw.transfer", + "EOSregress", "EOScoeffs", "EOSplot", "EOSvar", + "wjd", "element.potentials", "is.near.equil", "guess", "run.wjd", +# demos + "protein.equil", "palply", + "label.plot", + "equil.potentials", "basis.logact", + "label.figure", "syslab", +# equilibrium vignette + "usrfig", +# hotspring vignette + "strip" +# no other functions used in tests +# co-documented with above +) + # Load shared objects useDynLib(CHNOSZ, .registration = TRUE, .fixes = "F_") Modified: pkg/CHNOSZ/R/affinity.R =================================================================== --- pkg/CHNOSZ/R/affinity.R 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/R/affinity.R 2017-02-24 13:00:08 UTC (rev 175) @@ -154,7 +154,7 @@ loga.protein <- rep(loga.protein,length.out=length(iprotein)) protein.fun <- function(ip) { tpext <- as.numeric(thermo$protein[iprotein[ip],5:25]) - return(Reduce("+", CHNOSZ::pprod(a[ires],tpext)) - loga.protein[ip]) + return(Reduce("+", pprod(a[ires],tpext)) - loga.protein[ip]) } # use another level of indexing to let the function # report on its progress Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/R/basis.R 2017-02-24 13:00:08 UTC (rev 175) @@ -1,8 +1,92 @@ # CHNOSZ/basis.R -# set up the basis species of a chemical system +# set up the basis species of a thermodynamic system -## various functions to work with basis species +basis <- function(species=NULL, state=NULL, logact=NULL, delete=FALSE) { + thermo <- get("thermo") + ## delete the basis species if requested + oldbasis <- thermo$basis + if(delete) { + thermo$basis <- NULL + assign("thermo", thermo, "CHNOSZ") + } + ## return the basis definition if requested + if(is.null(species)) return(oldbasis) + ## from now on we need something to work with + if(length(species)==0) stop("species argument is empty") + # is the species one of the preset keywords? + if(species[1] %in% preset.basis()) return(preset.basis(species[1])) + # the species names/formulas have to be unique + if(!length(unique(species))==length(species)) stop("species names are not unique") + ## processing 'state' and 'logact' arguments + # they should be same length as species + if(!is.null(state)) state <- rep(state, length.out=length(species)) + if(!is.null(logact)) logact <- rep(logact, length.out=length(species)) + # results should be identical for + # basis(c('H2O','CO2','H2'), rep('aq',3), c(0,-3,-3)) + # basis(c('H2O','CO2','H2'), c(0,-3,-3), rep('aq',3)) + # first of all, do we have a third argument? + if(!is.null(logact)) { + # does the 3rd argument look like states? + if(is.character(logact[1])) { + # swap the arguments into their correct places + tmp <- logact + logact <- state + state <- tmp + } + } else { + # if the second argument is numeric, treat it like logacts + if(is.numeric(state[1])) { + logact <- state + state <- NULL + } + } + ## processing 'species' argument + # pH transformation + if("pH" %in% species) { + logact[species=="pH"] <- -logact[species=="pH"] + if(!is.null(logact)) species[species=="pH"] <- "H+" + } + # Eh and pe transformations + if("pe" %in% species) { + logact[species=="pe"] <- -logact[species=="pe"] + if(!is.null(logact)) species[species=="pe"] <- "e-" + } + if("Eh" %in% species) { + # 20090209 should be careful with this conversion as it's only for 25 deg C + # to be sure, just don't call species("Eh") + if(!is.null(logact)) logact[species=="Eh"] <- -convert(logact[species=="Eh"],"pe") + species[species=="Eh"] <- "e-" + } + ## if all species are in the existing basis definition, + ## *and* at least one of state or logact is not NULL + ## modify the states and/or logacts of the existing basis species + if(all(species %in% rownames(oldbasis)) | all(species %in% oldbasis$ispecies)) + if(!is.null(state) | !is.null(logact)) + return(mod.basis(species, state, logact)) + ## we're on to making a new basis definition + # use default logacts if they aren't present + if(is.null(logact)) logact <- rep(0, length(species)) + # if species argument is numeric, it's species indices + if(is.numeric(species[1])) { + ispecies <- species + ina <- ispecies > nrow(thermo$obigt) + } else { + # get species indices using states from the argument, or default states + if(!is.null(state)) ispecies <- suppressMessages(info(species, state, check.it=FALSE)) + else ispecies <- suppressMessages(info(species, check.it=FALSE)) + # check if we got all the species + ina <- is.na(ispecies) + # info() returns a list if any of the species had multiple approximate matches + # we don't accept any of those + if(is.list(ispecies)) ina <- ina | sapply(ispecies,length) > 1 + } + if(any(ina)) stop(paste("species not available:", paste(species[ina], "(", state[ina], ")", sep="", collapse=" "))) + # load new basis species + return(put.basis(ispecies, logact)) +} +## non-exported functions + # to add the basis to thermo$obigt put.basis <- function(ispecies, logact = rep(NA, length(ispecies))) { thermo <- get("thermo") @@ -128,91 +212,3 @@ logact[is.na(logact)] <- -3 return(logact) } - -## the actual basis() function -## delete, retrieve, define or modify the basis species of a thermodynamic system -basis <- function(species=NULL, state=NULL, logact=NULL, delete=FALSE) { - thermo <- get("thermo") - ## delete the basis species if requested - oldbasis <- thermo$basis - if(delete) { - thermo$basis <- NULL - assign("thermo", thermo, "CHNOSZ") - } - ## return the basis definition if requested - if(is.null(species)) return(oldbasis) - ## from now on we need something to work with - if(length(species)==0) stop("species argument is empty") - # is the species one of the preset keywords? - if(species[1] %in% preset.basis()) return(preset.basis(species[1])) - # the species names/formulas have to be unique - if(!length(unique(species))==length(species)) stop("species names are not unique") - ## processing 'state' and 'logact' arguments - # they should be same length as species - if(!is.null(state)) state <- rep(state, length.out=length(species)) - if(!is.null(logact)) logact <- rep(logact, length.out=length(species)) - # results should be identical for - # basis(c('H2O','CO2','H2'), rep('aq',3), c(0,-3,-3)) - # basis(c('H2O','CO2','H2'), c(0,-3,-3), rep('aq',3)) - # first of all, do we have a third argument? - if(!is.null(logact)) { - # does the 3rd argument look like states? - if(is.character(logact[1])) { - # swap the arguments into their correct places - tmp <- logact - logact <- state - state <- tmp - } - } else { - # if the second argument is numeric, treat it like logacts - if(is.numeric(state[1])) { - logact <- state - state <- NULL - } - } - ## processing 'species' argument - # pH transformation - if("pH" %in% species) { - logact[species=="pH"] <- -logact[species=="pH"] - if(!is.null(logact)) species[species=="pH"] <- "H+" - } - # Eh and pe transformations - if("pe" %in% species) { - logact[species=="pe"] <- -logact[species=="pe"] - if(!is.null(logact)) species[species=="pe"] <- "e-" - } - if("Eh" %in% species) { - # 20090209 should be careful with this conversion as it's only for 25 deg C - # to be sure, just don't call species("Eh") - if(!is.null(logact)) logact[species=="Eh"] <- -convert(logact[species=="Eh"],"pe") - species[species=="Eh"] <- "e-" - } - ## if all species are in the existing basis definition, - ## *and* at least one of state or logact is not NULL - ## modify the states and/or logacts of the existing basis species - if(all(species %in% rownames(oldbasis)) | all(species %in% oldbasis$ispecies)) - if(!is.null(state) | !is.null(logact)) - return(mod.basis(species, state, logact)) - ## we're on to making a new basis definition - # use default logacts if they aren't present - if(is.null(logact)) logact <- rep(0, length(species)) - # if species argument is numeric, it's species indices - if(is.numeric(species[1])) { - ispecies <- species - ina <- ispecies > nrow(thermo$obigt) - } else { - # get species indices using states from the argument, or default states - if(!is.null(state)) ispecies <- suppressMessages(info(species, state, check.it=FALSE)) - else ispecies <- suppressMessages(info(species, check.it=FALSE)) - # check if we got all the species - ina <- is.na(ispecies) - # info() returns a list if any of the species had multiple approximate matches - # we don't accept any of those - if(is.list(ispecies)) ina <- ina | sapply(ispecies,length) > 1 - } - if(any(ina)) stop(paste("species not available:", paste(species[ina], "(", state[ina], ")", sep="", collapse=" "))) - # load new basis species - return(put.basis(ispecies, logact)) -} - - Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/R/diagram.R 2017-02-24 13:00:08 UTC (rev 175) @@ -565,7 +565,7 @@ } } -find.tp <- function(x) { +find.TP <- function(x) { # find triple points in an matrix of integers 20120525 jmd # these are the locations closest to the greatest number of different values # rearrange the matrix in the same way that diagram() does for 2-D predominance diagrams Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/R/examples.R 2017-02-24 13:00:08 UTC (rev 175) @@ -6,12 +6,11 @@ # run all the examples in CHNOSZ documentation .ptime <- proc.time() topics <- c("thermo", "sideeffects", "examples", - "util.args", "util.array", "util.blast", "util.character", - "util.data", "util.expression", "util.fasta", "util.formula", "util.matrix", - "util.misc", "util.program", - "util.seq", "util.units", "taxonomy", "info", "protein.info", "hkf", "water", "subcrt", + "util.args", "util.array", "util.blast", "util.character", "util.data", "util.expression", + "util.fasta", "util.formula", "util.matrix", "util.misc", "util.program", "util.seq", "util.units", + "util.water", "taxonomy", "info", "protein.info", "hkf", "water", "IAPWS95", "subcrt", "makeup", "basis", "swap.basis", "species", "affinity", "util.affinity", "equil.boltzmann", - "diagram", "buffer", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr", + "diagram", "buffer", "nonideal", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr", "anim", "objective", "revisit", "transfer", "EOSregress", "wjd") plot.it <- FALSE if(is.character(do.png)) Modified: pkg/CHNOSZ/demo/findit.R =================================================================== --- pkg/CHNOSZ/demo/findit.R 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/demo/findit.R 2017-02-24 13:00:08 UTC (rev 175) @@ -15,7 +15,7 @@ f2 <- findit(vars[1:2], objective, T=325, P=350, res=16, niter=5) title("S.D. of equilibrium log activities of sulfur species") # optimize logfO2, pH and T (at constant P ...) -f3 <- findit(vars, objective, P=350, res=10, niter=10) +f3 <- findit(vars, objective, P=350, res=10, niter=5, rat=0.5) title("S.D. of equilibrium log activities of sulfur species") # the results print(f1.out <- sapply(f1$value, tail, 1)) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/inst/NEWS 2017-02-24 13:00:08 UTC (rev 175) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.8-64 (2017-02-24) +CHANGES IN CHNOSZ 1.0.8-65 (2017-02-24) --------------------------------------- DOCUMENTATION: Modified: pkg/CHNOSZ/man/basis.Rd =================================================================== --- pkg/CHNOSZ/man/basis.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/basis.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -6,7 +6,9 @@ \alias{preset.logact} \title{Define Basis Species} \description{ - Define the basis species of a chemical system. Change their physical states or chemical activities or fugacities. Get the stoichiometries of the basis species in selected species of interest. +Define the basis species of a chemical system. +Change their physical states or chemical activities or fugacities. +Get the reaction coefficients of basis species in formation reactions of species. } \usage{ @@ -27,21 +29,32 @@ } \details{ - \code{basis} is used to define the basis species in a system of interest, and in many workflows is followed by calls to \code{\link{species}}, \code{\link{affinity}} and \code{\link{diagram}} for making equilibrium chemical activity diagrams. The other functions documented here are supporting functions for \code{basis} and generally are not intended to be called by the user. +\code{basis} is used to define the basis species in a thermodynamic system. - The basis species represent the possible range of chemical compositions for all the species of interest. Any valid set of basis species used here must meet two conditions: 1) the number of basis species is the same as the number of chemical elements (including charge) in those species and 2) the square matrix representing the elemental stoichiometries of the basis species has a real inverse. Basis species might, but do not always (and not if a charged basis species is present), correspond to the thermodynamic components of a system. +The basis species represent the possible range of chemical compositions for all the species of interest. +Any valid set of basis species used here must meet two conditions: 1) the number of basis species is the same as the number of chemical elements (including charge) in those species and 2) the square matrix representing the elemental stoichiometries of the basis species has a real inverse. - To create a basis definition, call \code{basis} with the names or formulas of the basis species in the first argument. Alternatively, the first argument may consist of numeric values indicating the species indices (rownumbers in \code{\link{thermo}$obigt}), but a mixture of character and numeric values will generate an error. The special names \samp{pH}, \samp{pe} and \samp{Eh} can be included in the \code{species} argument; they get translated into the names of the proton (\samp{H+}) and electron (\samp{e-}) as appropriate. +To create a basis definition, call \code{basis} with the names or formulas of the basis species in the first argument. +Alternatively, the first argument may consist of numeric values indicating the species indices (rownumbers in \code{\link{thermo}$obigt}), but a mixture of character and numeric values will generate an error. +The special names \samp{pH}, \samp{pe} and \samp{Eh} can be included in the \code{species} argument; they get translated into the names of the proton (\samp{H+}) and electron (\samp{e-}) as appropriate. - If the new basis definition meets all requirements, it is stored in \code{\link{thermo}$basis}, replacing any previous basis definition; \code{put.basis} does the actual storing of the basis definition. - The physical states or logarithms of activities of species in the basis definition can be changed directly using \code{mod.basis} but usually more conveniently by calling \code{basis} with the formulas of species that are in the basis set, or their species indices. If either of the second or third arguments to \code{basis} is of type character, it refers to the name of a state (if present in \code{thermo$obigt$state}) or to the name of a chemical activity \code{\link{buffer}} (if present in \code{thermo$buffers$name}). If either of these arguments is numeric it specifies the logarithms of activities (or fugacities for gases) of the basis species. In case \samp{pH}, \samp{pe} or \samp{Eh} are named, the logarithm of activity of the basis species is converted from these values. (For example, a value of 7 for pH is stored as a logarithm of activity of -7). +The physical states or logarithms of activities of species in the basis definition can be changed by calling \code{basis} with the formulas of species that are in the basis set, or their species indices. +If either of the second or third arguments to \code{basis} is of type character, it refers to the name of a state (if present in \code{thermo$obigt$state}) or to the name of a chemical activity \code{\link{buffer}} (if present in \code{thermo$buffers$name}). +If either of these arguments is numeric it specifies the logarithms of activities (or fugacities for gases) of the basis species. +In case \samp{pH}, \samp{pe} or \samp{Eh} is named, the logarithm of activity of the basis species is converted from these values. +For example, a value of 7 for pH is stored as a logarithm of activity of -7. - Whenever \code{basis} is called with NULL values of both \code{state} and \code{logact}, the new set of species, if they are a valid basis set, completely replaces any existing basis definition. If this occurs, any existing species definition (created by the \code{species} function) is deleted. However, \code{\link{swap.basis}} can be used to change the species (the compositions and/or physical states thereof) in the basis set while maintaining the list of species of interest, with the added benefit of equivalence of the chemical potentials of the elements before and after the swap. +Whenever \code{basis} is called with NULL values of both \code{state} and \code{logact}, the new set of species, if they are a valid basis set, completely replaces any existing basis definition. +If this occurs, any existing species definition (created by the \code{species} function) is deleted. +However, \code{\link{swap.basis}} can be used to change the species (the compositions and/or physical states thereof) in the basis set while maintaining the list of species of interest, with the added benefit of equivalence of the chemical potentials of the elements before and after the swap. - Call \code{basis} with \code{delete} set to TRUE to clear the basis definition. Any current basis definition (before being deleted) is returned by this call or by calling \code{basis} with all default arguments. +Call \code{basis} with \code{delete} set to TRUE to clear the basis definition. +Any current basis definition (before being deleted) is returned by this call or by calling \code{basis} with all default arguments. - If the value of \code{basis} is one of the keywords in the following table, the corresponding set of basis species is loaded (defined in \code{preset.basis}), and their activities set to reference values (defined in \code{preset.logact}). This approach is used by many of the examples in the package. The basis species identified by these keywords are aqueous except for \eqn{\mathrm{H_2O}}{H2O} (liq), \eqn{\mathrm{O_2}}{O2} (gas) and \eqn{\mathrm{Fe_2O_3}}{Fe2O3} (hematite, cr1). +If the value of \code{basis} is one of the keywords in the following table, the corresponding set of basis species is loaded (defined in \code{preset.basis}), and their activities set to reference values (defined in \code{preset.logact}). +This approach is used by many of the examples in the package. +The basis species identified by these keywords are aqueous except for \eqn{\mathrm{H_2O}}{H2O} (liq), \eqn{\mathrm{O_2}}{O2} (gas) and \eqn{\mathrm{Fe_2O_3}}{Fe2O3} (hematite, cr1). \tabular{ll}{ \code{CHNOS} \tab \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{NH_3}}{NH3}, @@ -65,16 +78,18 @@ } \value{ - \code{basis} returns the value of \code{thermo$basis} after any modifications; or, if \code{delete} is TRUE, its value before deletion. +\code{basis} returns the value of \code{thermo$basis} after any modifications; or, if \code{delete} is TRUE, its value before deletion. +} - +\section{Side Effects}{ +If the new basis definition meets all requirements, it is stored in \code{\link{thermo}$basis}, replacing any previous basis definition. } \seealso{ \code{\link{info}} to query the thermodynamic database in order to find what species are available. \code{\link{makeup}} is used by \code{basis} to generate the stoichiometric matrix from chemical formulas. - \code{\link{species}} is the usual next step after \code{basis}. \code{\link{swap.basis}} is used to change the chemical compounds (species formulas) used in the basis definition while keeping the chemical potentials of the elements unaltered. + \code{\link{species}} for setting up the formation reactions from basis species. } \examples{ Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/diagram.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -1,7 +1,7 @@ \name{diagram} \alias{diagram} \alias{strip} -\alias{find.tp} +\alias{find.TP} \title{Equilibrium Chemical Activity Diagrams} \description{ Plot equilibrium chemical activity (1-D speciation) or equal-activity (2-D predominance) diagrams as a function of chemical activities of basis speecies, temperature and/or pressure. @@ -19,7 +19,7 @@ add=FALSE, plot.it=TRUE, tplot=TRUE, ...) strip(affinity, ispecies = NULL, col = NULL, ns = NULL, xticks = NULL, ymin = -0.2, xpad = 1, cex.names = 0.7) - find.tp(x) + find.TP(x) } \arguments{ @@ -128,7 +128,7 @@ An inset dot-and-line plot is created below each strip if \code{ns} is given. This argument has the same format as \code{ispecies}, and can be used e.g. to display the relative numbers of species for comparison with the stability calculations. -\code{find.tp} finds the locations in a matrix of integers that are surrounded by the greatest number of different values. +\code{find.TP} finds the locations in a matrix of integers that are surrounded by the greatest number of different values. The function counts the unique values in a 3x3 grid around each point and returns a matrix of indices (similar to \code{\link{which}(..., arr.ind = TRUE)}) for the maximum count (ties result in more than one pair of indices). It can be used with the output from \code{diagram} for calculations in 2 dimensions to approximately locate the triple points on the diagram. @@ -230,7 +230,7 @@ btext <- substitute(Al2O3 - SiO2 - H2O, unlist(bexpr)) mtitle(c(as.expression(btext), "after Helgeson et al., 1978")) # find the approximate position of the triple point -tp <- find.tp(d$predominant) +tp <- find.TP(d$predominant) Ttp <- a$vals[[1]][tp[1, 2]] Ptp <- rev(a$vals[[2]])[tp[1, 1]] points(Ttp, Ptp, pch=10, cex=5) Modified: pkg/CHNOSZ/man/nonideal.Rd =================================================================== --- pkg/CHNOSZ/man/nonideal.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/nonideal.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -72,10 +72,7 @@ # cf Eq. 5.1-33: basis composition species(c("ATP-4", "H+", "H2O", "HPO4-2", "ADP-3", "HATP-3", "HADP-2", "H2PO4-")) -# cf Eq. 5.1-32: elemental composition -species.basis() \%*\% basis.elements() - ### A different example # speciation of phosphate as a function of ionic strength Modified: pkg/CHNOSZ/man/species.Rd =================================================================== --- pkg/CHNOSZ/man/species.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/species.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -41,9 +41,9 @@ \examples{\dontshow{data(thermo)} # set up the basis species basis("CHNOS") -# show the formation reactions of some species -ispecies <- info(c("glutamic acid","phenylalanine")) -species.basis(ispecies) +## show the formation reactions of some species +#ispecies <- info(c("glutamic acid","phenylalanine")) +#species.basis(ispecies) # add, modify, delete species species(c("CO2","NH3")) # aqueous species species(c("CO2","NH3"),"gas") # gases Modified: pkg/CHNOSZ/man/swap.basis.Rd =================================================================== --- pkg/CHNOSZ/man/swap.basis.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/swap.basis.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -63,18 +63,18 @@ ## demonstrating the interconvertibility between ## chemical potentials of elements and logarithms ## of activities of basis species at high temperature -basis("CHNOS+") -bl1 <- basis()$logact -emu <- element.mu(T=100) -bl2 <- basis.logact(emu, T=100) -# note that basis.logact produces a named array -stopifnot(all.equal(bl1, as.numeric(bl2))) +#basis("CHNOS+") +#bl1 <- basis()$logact +#emu <- element.mu(T=100) +#bl2 <- basis.logact(emu, T=100) +## note that basis.logact produces a named array +#stopifnot(all.equal(bl1, as.numeric(bl2))) ## swapping basis species while species are defined ## and using numeric species indices basis("MgCHNOPS+") -# load species whose names contain "ATP" -species(info.approx("ATP ")) +# load some Mg-ATP species +species(c("MgATP-2", "MgHATP-", "MgH2ATP", "Mg2ATP")) # swap in CO2(g) for CO2(aq) iCO2g <- info("CO2", "gas") swap.basis("CO2", iCO2g) Modified: pkg/CHNOSZ/man/util.affinity.Rd =================================================================== --- pkg/CHNOSZ/man/util.affinity.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.affinity.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -60,8 +60,8 @@ \examples{\dontshow{data(thermo)} basis("CHNOS") species("acetic acid") -eargs <- energy.args(list(O2=c(-90, -60, 5), T=c(0, 100, 5))) -ea <- do.call(energy, eargs) +#eargs <- energy.args(list(O2=c(-90, -60, 5), T=c(0, 100, 5))) +#ea <- do.call(energy, eargs) } \keyword{utilities} Modified: pkg/CHNOSZ/man/util.args.Rd =================================================================== --- pkg/CHNOSZ/man/util.args.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.args.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -32,18 +32,18 @@ } \examples{\dontshow{data(thermo)} -## argument processing -eos.args("hkf",c("g","H","S","cP","V","kT","e")) -## produces an error because "Q" is not allowed in water.SUPCRT92 -\dontrun{ - eos.args("hkf",c("G","H","S","Cp","V","kT","E","Q")) } - thermo$opt$water <<- "IAPWS" # needed for p and n in next line - eos.args("water",c("p","u","cv","psat","rho","n","q","x","y","epsilon")) - TP.args(c(273.15,373.15)) - TP.args(c(273.15,373.15),"Psat") - TP.args(c(273.15,373.15),c(100,100,200,200)) - state.args(c("AQ","GAS")) - state.args(c("a","l","liq")) +### argument processing +#eos.args("hkf",c("g","H","S","cP","V","kT","e")) +### produces an error because "Q" is not allowed in water.SUPCRT92 +#\dontrun{ +# eos.args("hkf",c("G","H","S","Cp","V","kT","E","Q")) } +# thermo$opt$water <<- "IAPWS" # needed for p and n in next line +# eos.args("water",c("p","u","cv","psat","rho","n","q","x","y","epsilon")) +# TP.args(c(273.15,373.15)) +# TP.args(c(273.15,373.15),"Psat") +# TP.args(c(273.15,373.15),c(100,100,200,200)) +# state.args(c("AQ","GAS")) +# state.args(c("a","l","liq")) } \keyword{utilities} Modified: pkg/CHNOSZ/man/util.array.Rd =================================================================== --- pkg/CHNOSZ/man/util.array.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.array.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -30,7 +30,7 @@ \code{slice} extracts or assigns values from/to the \code{i}th slice(s) in the \code{d}th dimension of an array. Values are assigned to an array if \code{value} is not NULL. This function works by building an expression containing the extraction operator (\code{\link{[}}). - \code{slice.affinity} performs a slice operation on the \samp{values} element of the \samp{affinity} variable (which should be the output of \code{\link{affinity}}). This function is used e.g. by \code{\link{anim.TCA}} to extract slices that are the basis for frames of an animated stability diagram. + \code{slice.affinity} performs a slice operation on the \samp{values} element of the \samp{affinity} variable (which should be the output of \code{\link{affinity}}). This function is used e.g. by \code{\link{anim.TCA}} to extract slices that are the used to make frames of an animated stability diagram. \code{dimSums} sums an array along the \code{d}th dimension using only the \code{i}th slices in that dimension. If \code{i} is NULL, all slices in that dimension are summed together. For matrices, \code{dimSums(x,1)} has the same result as \code{\link{colSums}(x)} and \code{dimSums(x,2)} has the same result as \code{\link{rowSums}(x)}. Modified: pkg/CHNOSZ/man/util.character.Rd =================================================================== --- pkg/CHNOSZ/man/util.character.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.character.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -32,13 +32,13 @@ } \examples{\dontshow{data(thermo)} -## string to character -s2c("hello world") -s2c("hello world",sep=" ",keep.sep=FALSE) -s2c("3.141592",sep=c(".","9")) -# character to string -c2s(aminoacids()) -c2s(aminoacids(),sep=".") +### string to character +#s2c("hello world") +#s2c("hello world",sep=" ",keep.sep=FALSE) +#s2c("3.141592",sep=c(".","9")) +## character to string +#c2s(aminoacids()) +#c2s(aminoacids(),sep=".") } \keyword{utilities} Modified: pkg/CHNOSZ/man/util.program.Rd =================================================================== --- pkg/CHNOSZ/man/util.program.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.program.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -38,11 +38,11 @@ \examples{ -caller.name() # character(0) -afun <- function() caller.name() -afun() # character(0) -bfun <- function() afun() -bfun() # "bfun" +#caller.name() # character(0) +#afun <- function() caller.name() +#afun() # character(0) +#bfun <- function() afun() +#bfun() # "bfun" } \keyword{utilities} Modified: pkg/CHNOSZ/man/util.units.Rd =================================================================== --- pkg/CHNOSZ/man/util.units.Rd 2017-02-24 06:46:29 UTC (rev 174) +++ pkg/CHNOSZ/man/util.units.Rd 2017-02-24 13:00:08 UTC (rev 175) @@ -84,18 +84,18 @@ # cm3bar to calories convert(10, "calories") -## examples showing unit settings -T.units("C") -T1in <- envert(25, "C") # no convertion -T1out <- outvert(313.15, "K") # K to C -T.units("K") -T2in <- envert(298.15, "C") # K to C -T2out <- outvert(-233.15, "C") # C to K -# these are the same temperature (25 deg C) -stopifnot(all.equal(T1in, T2in)) -# these are numerically equivalent (40 deg C / 40 K) -stopifnot(all.equal(T1out, T2out)) -T.units("C") # return to default +### examples showing unit settings +#T.units("C") +#T1in <- envert(25, "C") # no convertion +#T1out <- outvert(313.15, "K") # K to C [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 175 From noreply at r-forge.r-project.org Sat Feb 25 03:08:43 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 25 Feb 2017 03:08:43 +0100 (CET) Subject: [CHNOSZ-commits] r176 - in pkg/CHNOSZ: . R data inst man Message-ID: <20170225020843.72849188AC5@r-forge.r-project.org> Author: jedick Date: 2017-02-25 03:08:42 +0100 (Sat, 25 Feb 2017) New Revision: 176 Removed: pkg/CHNOSZ/man/util.affinity.Rd pkg/CHNOSZ/man/util.args.Rd pkg/CHNOSZ/man/util.character.Rd Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/NAMESPACE pkg/CHNOSZ/R/IAPWS95.R pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/R/buffer.R pkg/CHNOSZ/R/diagram.R pkg/CHNOSZ/R/equilibrate.R pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/hkf.R pkg/CHNOSZ/R/info.R pkg/CHNOSZ/R/makeup.R pkg/CHNOSZ/R/objective.R pkg/CHNOSZ/R/revisit.R pkg/CHNOSZ/R/species.R pkg/CHNOSZ/R/util.affinity.R pkg/CHNOSZ/R/util.args.R pkg/CHNOSZ/R/util.character.R pkg/CHNOSZ/R/util.data.R pkg/CHNOSZ/R/util.fasta.R pkg/CHNOSZ/R/util.formula.R pkg/CHNOSZ/R/util.list.R pkg/CHNOSZ/R/util.misc.R pkg/CHNOSZ/R/util.plot.R pkg/CHNOSZ/R/util.program.R pkg/CHNOSZ/R/util.protein.R pkg/CHNOSZ/R/util.units.R pkg/CHNOSZ/data/thermo.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/EOSregress.Rd pkg/CHNOSZ/man/IAPWS95.Rd pkg/CHNOSZ/man/affinity.Rd pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/buffer.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/eos.Rd pkg/CHNOSZ/man/equilibrate.Rd pkg/CHNOSZ/man/findit.Rd pkg/CHNOSZ/man/info.Rd pkg/CHNOSZ/man/ionize.aa.Rd pkg/CHNOSZ/man/makeup.Rd pkg/CHNOSZ/man/nonideal.Rd pkg/CHNOSZ/man/objective.Rd pkg/CHNOSZ/man/revisit.Rd pkg/CHNOSZ/man/species.Rd pkg/CHNOSZ/man/swap.basis.Rd pkg/CHNOSZ/man/util.blast.Rd pkg/CHNOSZ/man/util.data.Rd pkg/CHNOSZ/man/util.fasta.Rd pkg/CHNOSZ/man/util.formula.Rd pkg/CHNOSZ/man/util.list.Rd pkg/CHNOSZ/man/util.misc.Rd pkg/CHNOSZ/man/util.plot.Rd pkg/CHNOSZ/man/util.program.Rd pkg/CHNOSZ/man/util.units.Rd pkg/CHNOSZ/man/water.Rd pkg/CHNOSZ/man/wjd.Rd Log: undocument unexported functions Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-25 02:08:42 UTC (rev 176) @@ -1,6 +1,6 @@ -Date: 2017-02-24 +Date: 2017-02-25 Package: CHNOSZ -Version: 1.0.8-65 +Version: 1.0.8-66 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/NAMESPACE =================================================================== --- pkg/CHNOSZ/NAMESPACE 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/NAMESPACE 2017-02-25 02:08:42 UTC (rev 176) @@ -22,14 +22,14 @@ "def2gi", "read.blast", "id.blast", "add.obigt", "RH2obigt", "expr.property", "expr.units", - "mass", "entropy", "get.formula", "GHS", "water", + "mass", "entropy", "GHS", "water", "i2A", "invertible.combs", "dPdTtr", "Ttr", "count.aa", "nucleic.complement", "nucleic.formula", "rho.IAPWS95", "IAPWS95", "water.AW90", "WP02.auxiliary", "water.IAPWS95", "getrank", "parent", "sciname", "allparents", "getnodes", "getnames", "protein.obigt", "hkf", "cgl", "which.pmax", - "equil.boltzmann", "equil.reaction", "find.TP", + "equil.boltzmann", "equil.reaction", "find.tp", "ionize.aa", "MP90.cp", "aasum", "read.expr", "anim.carboxylase", "qqr", "RMSD", "CVRMSD", "spearman", "DGmix", "DDGmix", "DGtr", @@ -44,9 +44,18 @@ # equilibrium vignette "usrfig", # hotspring vignette - "strip" -# no other functions used in tests -# co-documented with above + "strip", +# ecipex package + "count.elements", +# (no other functions are used in the tests) +# other exported functions that are not used above + "write.blast", "checkEOS", "checkGHS", "check.obigt", + "V_s_var", "Cp_s_var", + "DGinf", "SD", "pearson", "shannon", "CV", "logact", + "feldspar", "apc", "EOSlab", "EOScalc", + "basis.elements", "element.mu", "ibasis", + "water.SUPCRT92", "water.props", "eqdata", "plot_findit", + "nonideal", "anim.TCA", "uniprot.aa", "run.guess" ) # Load shared objects Modified: pkg/CHNOSZ/R/IAPWS95.R =================================================================== --- pkg/CHNOSZ/R/IAPWS95.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/IAPWS95.R 2017-02-25 02:08:42 UTC (rev 176) @@ -1,6 +1,116 @@ # functions for properties of water using # the IAPWS-95 formulation (Wagner and Pruss, 2002) +IAPWS95 <- function(property,T=298.15,rho=1000) { + ## the IAPWS-95 formulation for ordinary water substance + ## Wagner and Pruss, 2002 + property <- tolower(property) + # triple point + T.triple <- 273.16 # K + P.triple <- 611.657 # Pa + rho.triple.liquid <- 999.793 + rho.triple.vapor <- 0.00485458 + # normal boiling point + T.boiling <- 373.124 + P.boiling <- 0.101325 + rho.boiling.liquid <- 958.367 + rho.boiling.vapor <- 0.597657 + # critical point constants + T.critical <- 647.096 # K + rho.critical <- 322 # kg m-3 + # specific and molar gas constants + R <- 0.46151805 # kJ kg-1 K-1 + # R.M <- 8.314472 # J mol-1 K-1 + # molar mass + M <- 18.015268 # g mol-1 + ## define functions idealgas and residual, supplying arguments delta and tau + idealgas <- function(p) IAPWS95.idealgas(p, delta, tau) + residual <- function(p) IAPWS95.residual(p, delta, tau) + ## relation of thermodynamic properties to Helmholtz free energy + a <- function() { + x <- idealgas('phi')+residual('phi') + return(x*R*T) + } + # Table 6.3 + p <- function() { + x <- 1 + delta*residual('phi.delta') + return(x*rho*R*T/1000) # for MPa + } + s <- function() { + x <- tau * (idealgas('phi.tau')+residual('phi.tau'))-idealgas('phi')-residual('phi') + return(x*R) + } + u <- function() { + x <- tau * (idealgas('phi.tau')+residual('phi.tau')) + return(x*R*T) + } + h <- function() { + x <- 1 + tau * (idealgas('phi.tau')+residual('phi.tau')) + delta*residual('phi.delta') + return(x*R*T) + } + g <- function() { + x <- 1 + idealgas('phi') + residual('phi') + delta*residual('phi.delta') + return(x*R*T) + } + cv <- function() { + x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + return(x*R) + } + cp <- function() { + x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + + (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / + (1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) + return(x*R) + } +# 20090420 speed of sound calculation is incomplete +# (delta.liquid and drhos.dT not visible) +# cs <- function() { +# x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + +# (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / +# (1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) * +# ((1+delta.liquid*residual('phi.delta')-delta.liquid*tau*residual('phi.tau.tau'))-rho.critical/(R*delta.liquid)*drhos.dT) +# return(x*R) +# } + w <- function() { + x <- 1 + 2*delta*residual('phi.delta') + delta^2*residual('phi.delta.delta') - + (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / + tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + return(sqrt(x*R*T)) + } + mu <- function() { + x <- -(delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')+delta*tau*residual('phi.delta.tau')) / + ( ( 1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau')^2 ) - tau^2 * + (idealgas('phi.tau.tau')+residual('phi.tau.tau'))*(1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) ) + return(x/(R*rho)) + } + ## run the calculations + ww <- NULL + my.T <- T + my.rho <- rho + for(j in 1:length(property)) { + t <- numeric() + for(i in 1:length(my.T)) { + T <- my.T[i] + rho <- my.rho[i] + # Equation 6.4 + delta <- rho / rho.critical + tau <- T.critical / T + t <- c(t,get(property[j])()) + } + t <- data.frame(t) + if(j==1) ww <- t else ww <- cbind(ww,t) + } + colnames(ww) <- property + return(ww) +} + +### unexported functions ### + +# IAPWS95.idealgas and IAPWS95.residual are supporting functions to IAPWS95 for calculating +# the ideal-gas and residual parts in the IAPWS-95 formulation. +# The value of p can be one of phi, phi.delta, phi.delta.delta, phi.tau, phi.tau.tau, or phi.delta.tau, +# to calculate the specific dimensionless Helmholtz free energy (phi) or one of its derivatives. + IAPWS95.idealgas <- function(p, delta, tau) { ## the ideal gas part in the IAPWS-95 formulation # from Table 6.1 of Wagner and Pruss, 2002 @@ -142,107 +252,3 @@ } return(get(p)()) } - -IAPWS95 <- function(property,T=298.15,rho=1000) { - ## the IAPWS-95 formulation for ordinary water substance - ## Wagner and Pruss, 2002 - property <- tolower(property) - # triple point - T.triple <- 273.16 # K - P.triple <- 611.657 # Pa - rho.triple.liquid <- 999.793 - rho.triple.vapor <- 0.00485458 - # normal boiling point - T.boiling <- 373.124 - P.boiling <- 0.101325 - rho.boiling.liquid <- 958.367 - rho.boiling.vapor <- 0.597657 - # critical point constants - T.critical <- 647.096 # K - rho.critical <- 322 # kg m-3 - # specific and molar gas constants - R <- 0.46151805 # kJ kg-1 K-1 - # R.M <- 8.314472 # J mol-1 K-1 - # molar mass - M <- 18.015268 # g mol-1 - ## define functions idealgas and residual, supplying arguments delta and tau - idealgas <- function(p) IAPWS95.idealgas(p, delta, tau) - residual <- function(p) IAPWS95.residual(p, delta, tau) - ## relation of thermodynamic properties to Helmholtz free energy - a <- function() { - x <- idealgas('phi')+residual('phi') - return(x*R*T) - } - # Table 6.3 - p <- function() { - x <- 1 + delta*residual('phi.delta') - return(x*rho*R*T/1000) # for MPa - } - s <- function() { - x <- tau * (idealgas('phi.tau')+residual('phi.tau'))-idealgas('phi')-residual('phi') - return(x*R) - } - u <- function() { - x <- tau * (idealgas('phi.tau')+residual('phi.tau')) - return(x*R*T) - } - h <- function() { - x <- 1 + tau * (idealgas('phi.tau')+residual('phi.tau')) + delta*residual('phi.delta') - return(x*R*T) - } - g <- function() { - x <- 1 + idealgas('phi') + residual('phi') + delta*residual('phi.delta') - return(x*R*T) - } - cv <- function() { - x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) - return(x*R) - } - cp <- function() { - x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + - (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / - (1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) - return(x*R) - } -# 20090420 speed of sound calculation is incomplete -# (delta.liquid and drhos.dT not visible) -# cs <- function() { -# x <- -tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) + -# (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / -# (1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) * -# ((1+delta.liquid*residual('phi.delta')-delta.liquid*tau*residual('phi.tau.tau'))-rho.critical/(R*delta.liquid)*drhos.dT) -# return(x*R) -# } - w <- function() { - x <- 1 + 2*delta*residual('phi.delta') + delta^2*residual('phi.delta.delta') - - (1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau'))^2 / - tau^2*(idealgas('phi.tau.tau')+residual('phi.tau.tau')) - return(sqrt(x*R*T)) - } - mu <- function() { - x <- -(delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')+delta*tau*residual('phi.delta.tau')) / - ( ( 1+delta*residual('phi.delta')-delta*tau*residual('phi.delta.tau')^2 ) - tau^2 * - (idealgas('phi.tau.tau')+residual('phi.tau.tau'))*(1+2*delta*residual('phi.delta')+delta^2*residual('phi.delta.delta')) ) - return(x/(R*rho)) - } - ## run the calculations - ww <- NULL - my.T <- T - my.rho <- rho - for(j in 1:length(property)) { - t <- numeric() - for(i in 1:length(my.T)) { - T <- my.T[i] - rho <- my.rho[i] - # Equation 6.4 - delta <- rho / rho.critical - tau <- T.critical / T - t <- c(t,get(property[j])()) - } - t <- data.frame(t) - if(j==1) ww <- t else ww <- cbind(ww,t) - } - colnames(ww) <- property - return(ww) -} - Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/basis.R 2017-02-25 02:08:42 UTC (rev 176) @@ -85,7 +85,7 @@ return(put.basis(ispecies, logact)) } -## non-exported functions +### unexported functions ### # to add the basis to thermo$obigt put.basis <- function(ispecies, logact = rep(NA, length(ispecies))) { @@ -212,3 +212,4 @@ logact[is.na(logact)] <- -3 return(logact) } + Modified: pkg/CHNOSZ/R/buffer.R =================================================================== --- pkg/CHNOSZ/R/buffer.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/buffer.R 2017-02-25 02:08:42 UTC (rev 176) @@ -56,6 +56,8 @@ return(invisible(thermo$buffers[thermo$buffers$name %in% name,])) } +### unexported functions ### + buffer <- function(logK=NULL,ibasis=NULL,logact.basis=NULL,is.buffer=NULL,balance='PBB') { thermo <- get("thermo") # if logK is NULL load the buffer species Modified: pkg/CHNOSZ/R/diagram.R =================================================================== --- pkg/CHNOSZ/R/diagram.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/diagram.R 2017-02-25 02:08:42 UTC (rev 176) @@ -565,7 +565,7 @@ } } -find.TP <- function(x) { +find.tp <- function(x) { # find triple points in an matrix of integers 20120525 jmd # these are the locations closest to the greatest number of different values # rearrange the matrix in the same way that diagram() does for 2-D predominance diagrams Modified: pkg/CHNOSZ/R/equilibrate.R =================================================================== --- pkg/CHNOSZ/R/equilibrate.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/equilibrate.R 2017-02-25 02:08:42 UTC (rev 176) @@ -228,6 +228,9 @@ return(logact) } +### unexported functions ### + +# return a list containing the balancing coefficients (n) and a textual description (description) balance <- function(aout, balance=NULL) { ## generate n.balance from user-given or automatically identified basis species ## extracted from equilibrate() 20120929 Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/examples.R 2017-02-25 02:08:42 UTC (rev 176) @@ -6,10 +6,10 @@ # run all the examples in CHNOSZ documentation .ptime <- proc.time() topics <- c("thermo", "sideeffects", "examples", - "util.args", "util.array", "util.blast", "util.character", "util.data", "util.expression", - "util.fasta", "util.formula", "util.matrix", "util.misc", "util.program", "util.seq", "util.units", + "util.array", "util.blast", "util.data", "util.expression", + "util.fasta", "util.formula", "util.matrix", "util.misc", "util.seq", "util.units", "util.water", "taxonomy", "info", "protein.info", "hkf", "water", "IAPWS95", "subcrt", - "makeup", "basis", "swap.basis", "species", "affinity", "util.affinity", "equil.boltzmann", + "makeup", "basis", "swap.basis", "species", "affinity", "equil.boltzmann", "diagram", "buffer", "nonideal", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr", "anim", "objective", "revisit", "transfer", "EOSregress", "wjd") plot.it <- FALSE @@ -46,3 +46,4 @@ } return(invisible(out)) } + Modified: pkg/CHNOSZ/R/hkf.R =================================================================== --- pkg/CHNOSZ/R/hkf.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/hkf.R 2017-02-25 02:08:42 UTC (rev 176) @@ -175,6 +175,8 @@ return(x) } +### unexported functions ### + gfun <- function(rhohat, Tc, P, alpha, daldT, beta) { ## g and f functions for describing effective electrostatic radii of ions ## split from hkf() 20120123 jmd Modified: pkg/CHNOSZ/R/info.R =================================================================== --- pkg/CHNOSZ/R/info.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/info.R 2017-02-25 02:08:42 UTC (rev 176) @@ -6,6 +6,62 @@ # these functions expect arguments of length 1; # info() handles longer arguments +info <- function(species=NULL, state=NULL, check.it=TRUE) { + ## return information for one or more species in thermo$obigt + ## if no species are requested, summarize the available data 20101129 + thermo <- get("thermo") + if(is.null(species)) { + message("info: 'species' is NULL; summarizing information about thermodynamic data...") + message(paste("thermo$obigt has", nrow(thermo$obigt[thermo$obigt$state=="aq", ]), "aqueous,", + nrow(thermo$obigt), "total species")) + message(paste("number of literature sources: ", nrow(thermo$refs), ", elements: ", + nrow(thermo$element), ", buffers: ", length(unique(thermo$buffers$name)), sep="")) + message(paste("number of proteins in thermo$protein is", nrow(thermo$protein), "from", + length(unique(thermo$protein$organism)), "organisms")) + # print information about SGD.csv, ECO.csv, HUM.csv + more.aa(organism="Sce") + more.aa(organism="Eco") + #pdata.aa(organism="HUM") + # print information about yeastgfp.csv + yeastgfp() + return() + } + ## run info.numeric or info.character depending on the input type + if(is.numeric(species)) { + out <- lapply(species, info.numeric, check.it) + # if we different states the column names could be different + if(length(unique(unlist(lapply(out, names)))) > ncol(thermo$obigt)) { + # make them the same as thermo$obigt + out <- lapply(out, function(row) { + colnames(row) <- colnames(thermo$obigt); return(row) + }) + } + # turn the list into a data frame + out <- do.call(rbind, out) + } else { + # state and species should be same length + if(!is.null(state)) { + lmax <- max(length(species), length(state)) + state <- rep(state, length.out=lmax) + species <- rep(species, length.out=lmax) + } + # loop over the species + out <- sapply(seq_along(species), function(i) { + # first look for exact match + ispecies <- info.character(species[i], state[i]) + # if no exact match and it's not a protein, show approximate matches (side effect of info.approx) + if(identical(ispecies, NA) & !grepl("_", species[i])) ispecies.notused <- info.approx(species[i], state[i]) + # do not accept multiple matches + if(length(ispecies) > 1) ispecies <- NA + return(ispecies) + }) + } + ## all done! + return(out) +} + +### unexported functions ### + info.text <- function(ispecies) { # a textual description of species name, formula, source, e.g. # CO2 [CO2(aq)] (SSW01, SHS89, 11.Oct.07) @@ -173,57 +229,3 @@ return(NA) } -info <- function(species=NULL, state=NULL, check.it=TRUE) { - ## return information for one or more species in thermo$obigt - ## if no species are requested, summarize the available data 20101129 - thermo <- get("thermo") - if(is.null(species)) { - message("info: 'species' is NULL; summarizing information about thermodynamic data...") - message(paste("thermo$obigt has", nrow(thermo$obigt[thermo$obigt$state=="aq", ]), "aqueous,", - nrow(thermo$obigt), "total species")) - message(paste("number of literature sources: ", nrow(thermo$refs), ", elements: ", - nrow(thermo$element), ", buffers: ", length(unique(thermo$buffers$name)), sep="")) - message(paste("number of proteins in thermo$protein is", nrow(thermo$protein), "from", - length(unique(thermo$protein$organism)), "organisms")) - # print information about SGD.csv, ECO.csv, HUM.csv - more.aa(organism="Sce") - more.aa(organism="Eco") - #pdata.aa(organism="HUM") - # print information about yeastgfp.csv - yeastgfp() - return() - } - ## run info.numeric or info.character depending on the input type - if(is.numeric(species)) { - out <- lapply(species, info.numeric, check.it) - # if we different states the column names could be different - if(length(unique(unlist(lapply(out, names)))) > ncol(thermo$obigt)) { - # make them the same as thermo$obigt - out <- lapply(out, function(row) { - colnames(row) <- colnames(thermo$obigt); return(row) - }) - } - # turn the list into a data frame - out <- do.call(rbind, out) - } else { - # state and species should be same length - if(!is.null(state)) { - lmax <- max(length(species), length(state)) - state <- rep(state, length.out=lmax) - species <- rep(species, length.out=lmax) - } - # loop over the species - out <- sapply(seq_along(species), function(i) { - # first look for exact match - ispecies <- info.character(species[i], state[i]) - # if no exact match and it's not a protein, show approximate matches (side effect of info.approx) - if(identical(ispecies, NA) & !grepl("_", species[i])) ispecies.notused <- info.approx(species[i], state[i]) - # do not accept multiple matches - if(length(ispecies) > 1) ispecies <- NA - return(ispecies) - }) - } - ## all done! - return(out) -} - Modified: pkg/CHNOSZ/R/makeup.R =================================================================== --- pkg/CHNOSZ/R/makeup.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/makeup.R 2017-02-25 02:08:42 UTC (rev 176) @@ -1,3 +1,139 @@ +# CHNOSZ/makeup.R + +makeup <- function(formula, multiplier=1, sum=FALSE, count.zero=FALSE) { + # return the elemental makeup (counts) of a chemical formula + # that may contain suffixed and/or parenthetical subformulas and/or charge + # and negative or positive, fractional coefficients + # a matrix is processed by rows + if(is.matrix(formula)) + return(lapply(seq_len(nrow(formula)), + function(i) makeup(formula[i, ]))) + # a named object or list of named objects is returned untouched + if(!is.null(names(formula))) return(formula) + if(is.list(formula) & !is.null(names(formula[[1]]))) return(formula) + # prepare to multiply the formula by the multiplier, if given + if(length(multiplier) > 1 & length(multiplier) != length(formula)) + stop("multiplier does not have length = 1 or length = number of formulas") + multiplier <- rep(multiplier, length(formula)) + # if the formula argument has length > 1, apply the function over each formula + if(length(formula) > 1) { + # get formulas for any species indices in the argument + formula <- get.formula(formula) + out <- lapply(seq_along(formula), function(i) { + makeup(formula[i], multiplier[i]) + }) + # if sum is TRUE, take the sum of all formulas + if(sum) { + out <- unlist(out) + out <- tapply(out, names(out), sum) + } else if(count.zero) { + # if count.zero is TRUE, all elements appearing in any + # of the formulas are counted for each species + # first construct elemental makeup showing zero of each element + em0 <- unlist(out) + em0 <- tapply(em0, names(em0), sum) + em0[] <- 0 + # then sum each formula and the zero vector, + # using tapply to group the elements + out <- lapply(out, function(x) { + xem <- c(x, em0) + tapply(xem, names(xem), sum) + }) + } + return(out) + } + # if the formula argument is numeric, + # and if the thermo object is available, + # get the formula of that numbered species from thermo$obigt + if("CHNOSZ" %in% search()) { + thermo <- get("thermo", "CHNOSZ") + if(is.numeric(formula)) formula <- thermo$obigt$formula[formula] + } + # first deal with charge + cc <- count.charge(formula) + # count.elements doesn't know about charge so we need + # to explicate the elemental symbol for it + formula <- cc$uncharged + if(cc$Z != 0 ) formula <- paste(formula, "Z", cc$Z, sep="") + # now "Z" will be counted + # if there are no subformulas, just use count.elements + if(length(grep("(\\(|\\)|\\*|\\:)", formula))==0) { + out <- count.elements(formula) + } else { + # count the subformulas + cf <- count.formulas(formula) + # count the elements in each subformula + ce <- lapply(names(cf), count.elements) + # multiply elemental counts by respective subformula counts + mcc <- lapply(seq_along(cf), function(i) ce[[i]]*cf[i]) + # unlist the subformula counts and sum them together by element + um <- unlist(mcc) + out <- tapply(um, names(um), sum) + } + # all done with the counting, now apply the multiplier + out <- out * multiplier + # complain if there are any elements that look strange + if("CHNOSZ" %in% search()) { + are.elements <- names(out) %in% thermo$element$element + if(!all(are.elements)) warning(paste("element(s) not in thermo$element:", + paste(rownames(out)[!are.elements], collapse=" ") )) + } + # done! + return(out) +} + +count.elements <- function(formula) { + # count the elements in a chemical formula 20120111 jmd + # this function expects a simple formula, + # no charge or parenthetical or suffixed subformulas + # regular expressions inspired by an answer on + # http://stackoverflow.com/questions/4116786/parsing-a-chemical-formula-from-a-string-in-c + #elementRegex <- "([A-Z][a-z]*)([0-9]*)" + elementSymbol <- "([A-Z][a-z]*)" + # here, element coefficients can be signed (+ or -) and have a decimal point + elementCoeff <- "((\\+|-|\\.|[0-9])*)" + elementRegex <- paste(elementSymbol, elementCoeff, sep="") + # stop if it doesn't look like a chemical formula + validateRegex <- paste("^(", elementRegex, ")+$", sep="") + if(length(grep(validateRegex, formula)) == 0) + stop(paste("'",formula,"' is not a simple chemical formula", sep="", collapse="\n")) + # where to put the output + element <- character() + count <- numeric() + # from now use "f" for formula to make writing the code easier + f <- formula + # we want to find the starting positions of all the elemental symbols + # make substrings, starting at every position in the formula + fsub <- sapply(1:nchar(f), function(i) substr(f, i, nchar(f))) + # get the numbers (positions) that start with an elemental symbol + # i.e. an uppercase letter + ielem <- grep("^[A-Z]", fsub) + # for each elemental symbol, j is the position before the start of the next + # symbol (or the position of the last character of the formula) + jelem <- c(tail(ielem - 1, -1), nchar(f)) + # assemble the stuff: each symbol-coefficient combination + ec <- sapply(seq_along(ielem), function(i) substr(f, ielem[i], jelem[i])) + # get the individual element symbols and coefficients + myelement <- gsub(elementCoeff, "", ec) + mycount <- as.numeric(gsub(elementSymbol, "", ec)) + # any missing coefficients are unity + mycount[is.na(mycount)] <- 1 + # append to the output + element <- c(element, myelement) + count <- c(count, mycount) + # in case there are repeated elements, sum all of their counts + # (tapply hint from https://stat.ethz.ch/pipermail/r-help/2011-January/265341.html) + out <- tapply(count, element, sum) + # tapply returns alphabetical sorted list. keep the order appearing in the formula + out <- out[match(unique(element), names(out))] + return(out) +} + +### unexported functions ### + +# returns a list with named elements +# `Z` - the numeric value of the charge +# `uncharged` - the original formula string excluding the charge count.charge <- function(formula) { # count the charge in a chemical formula 20120113 jmd # everything else is counted as the uncharged part of the formula @@ -34,6 +170,7 @@ return(out) } +# returns a numeric vector with names refering to each of the subformulas or the whole formula if there are no subformulas count.formulas <- function(formula) { # count the subformulas in a chemical formula 20120112 jmd # the formula may include multiple unnested parenthetical subformulas @@ -131,131 +268,3 @@ return(out) } -count.elements <- function(formula) { - # count the elements in a chemical formula 20120111 jmd - # this function expects a simple formula, - # no charge or parenthetical or suffixed subformulas - # regular expressions inspired by an answer on - # http://stackoverflow.com/questions/4116786/parsing-a-chemical-formula-from-a-string-in-c - #elementRegex <- "([A-Z][a-z]*)([0-9]*)" - elementSymbol <- "([A-Z][a-z]*)" - # here, element coefficients can be signed (+ or -) and have a decimal point - elementCoeff <- "((\\+|-|\\.|[0-9])*)" - elementRegex <- paste(elementSymbol, elementCoeff, sep="") - # stop if it doesn't look like a chemical formula - validateRegex <- paste("^(", elementRegex, ")+$", sep="") - if(length(grep(validateRegex, formula)) == 0) - stop(paste("'",formula,"' is not a simple chemical formula", sep="", collapse="\n")) - # where to put the output - element <- character() - count <- numeric() - # from now use "f" for formula to make writing the code easier - f <- formula - # we want to find the starting positions of all the elemental symbols - # make substrings, starting at every position in the formula - fsub <- sapply(1:nchar(f), function(i) substr(f, i, nchar(f))) - # get the numbers (positions) that start with an elemental symbol - # i.e. an uppercase letter - ielem <- grep("^[A-Z]", fsub) - # for each elemental symbol, j is the position before the start of the next - # symbol (or the position of the last character of the formula) - jelem <- c(tail(ielem - 1, -1), nchar(f)) - # assemble the stuff: each symbol-coefficient combination - ec <- sapply(seq_along(ielem), function(i) substr(f, ielem[i], jelem[i])) - # get the individual element symbols and coefficients - myelement <- gsub(elementCoeff, "", ec) - mycount <- as.numeric(gsub(elementSymbol, "", ec)) - # any missing coefficients are unity - mycount[is.na(mycount)] <- 1 - # append to the output - element <- c(element, myelement) - count <- c(count, mycount) - # in case there are repeated elements, sum all of their counts - # (tapply hint from https://stat.ethz.ch/pipermail/r-help/2011-January/265341.html) - out <- tapply(count, element, sum) - # tapply returns alphabetical sorted list. keep the order appearing in the formula - out <- out[match(unique(element), names(out))] - return(out) -} - -makeup <- function(formula, multiplier=1, sum=FALSE, count.zero=FALSE) { - # return the elemental makeup (counts) of a chemical formula - # that may contain suffixed and/or parenthetical subformulas and/or charge - # and negative or positive, fractional coefficients - # a matrix is processed by rows - if(is.matrix(formula)) - return(lapply(seq_len(nrow(formula)), - function(i) makeup(formula[i, ]))) - # a named object or list of named objects is returned untouched - if(!is.null(names(formula))) return(formula) - if(is.list(formula) & !is.null(names(formula[[1]]))) return(formula) - # prepare to multiply the formula by the multiplier, if given - if(length(multiplier) > 1 & length(multiplier) != length(formula)) - stop("multiplier does not have length = 1 or length = number of formulas") - multiplier <- rep(multiplier, length(formula)) - # if the formula argument has length > 1, apply the function over each formula - if(length(formula) > 1) { - # get formulas for any species indices in the argument - formula <- get.formula(formula) - out <- lapply(seq_along(formula), function(i) { - makeup(formula[i], multiplier[i]) - }) - # if sum is TRUE, take the sum of all formulas - if(sum) { - out <- unlist(out) - out <- tapply(out, names(out), sum) - } else if(count.zero) { - # if count.zero is TRUE, all elements appearing in any - # of the formulas are counted for each species - # first construct elemental makeup showing zero of each element - em0 <- unlist(out) - em0 <- tapply(em0, names(em0), sum) - em0[] <- 0 - # then sum each formula and the zero vector, - # using tapply to group the elements - out <- lapply(out, function(x) { - xem <- c(x, em0) - tapply(xem, names(xem), sum) - }) - } - return(out) - } - # if the formula argument is numeric, - # and if the thermo object is available, - # get the formula of that numbered species from thermo$obigt - if("CHNOSZ" %in% search()) { - thermo <- get("thermo", "CHNOSZ") - if(is.numeric(formula)) formula <- thermo$obigt$formula[formula] - } - # first deal with charge - cc <- count.charge(formula) - # count.elements doesn't know about charge so we need - # to explicate the elemental symbol for it - formula <- cc$uncharged - if(cc$Z != 0 ) formula <- paste(formula, "Z", cc$Z, sep="") - # now "Z" will be counted - # if there are no subformulas, just use count.elements - if(length(grep("(\\(|\\)|\\*|\\:)", formula))==0) { - out <- count.elements(formula) - } else { - # count the subformulas - cf <- count.formulas(formula) - # count the elements in each subformula - ce <- lapply(names(cf), count.elements) - # multiply elemental counts by respective subformula counts - mcc <- lapply(seq_along(cf), function(i) ce[[i]]*cf[i]) - # unlist the subformula counts and sum them together by element - um <- unlist(mcc) - out <- tapply(um, names(um), sum) - } - # all done with the counting, now apply the multiplier - out <- out * multiplier - # complain if there are any elements that look strange - if("CHNOSZ" %in% search()) { - are.elements <- names(out) %in% thermo$element$element - if(!all(are.elements)) warning(paste("element(s) not in thermo$element:", - paste(rownames(out)[!are.elements], collapse=" ") )) - } - # done! - return(out) -} Modified: pkg/CHNOSZ/R/objective.R =================================================================== --- pkg/CHNOSZ/R/objective.R 2017-02-24 13:00:08 UTC (rev 175) +++ pkg/CHNOSZ/R/objective.R 2017-02-25 02:08:42 UTC (rev 176) @@ -2,16 +2,6 @@ # objective functions for revisit(), findit() # all objective functions in one file, added attributes 20121009 jmd -get.objfun <- function(objective) { - # get the function with the name given in 'objective' - objfun <- get(objective) - # perform a check on its usability - if(!"optimum" %in% names(attributes(objfun))) - stop(paste(objective, "is not a function with an attribute named 'optimum'")) - # return the function - return(objfun) -} - # input: a1 or loga1 is matrix with a column for each species and a row for each condition # output: vector with length equal to number of rows of a1 or loga1 # attributes: @@ -193,3 +183,17 @@ }, optimum="minimal" ) + +### unexported functions ### + +# return the objective function named in objective, +# or produce an error if the function has no optimum attribute +get.objfun <- function(objective) { + # get the function with the name given in 'objective' + objfun <- get(objective) + # perform a check on its usability + if(!"optimum" %in% names(attributes(objfun))) + stop(paste(objective, "is not a function with an attribute named 'optimum'")) + # return the function + return(objfun) +} Modified: pkg/CHNOSZ/R/revisit.R =================================================================== [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 176 From noreply at r-forge.r-project.org Mon Feb 27 12:09:54 2017 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 27 Feb 2017 12:09:54 +0100 (CET) Subject: [CHNOSZ-commits] r177 - in pkg/CHNOSZ: . R data demo inst inst/extdata/OBIGT man vignettes Message-ID: <20170227110954.F2FB5180C09@r-forge.r-project.org> Author: jedick Date: 2017-02-27 12:09:54 +0100 (Mon, 27 Feb 2017) New Revision: 177 Added: pkg/CHNOSZ/vignettes/obigt.Rmd pkg/CHNOSZ/vignettes/obigt.bib pkg/CHNOSZ/vignettes/obigt.css Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/basis.R pkg/CHNOSZ/data/refs.csv pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/extdata/OBIGT/Amend_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Helgeson_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/LaRowe_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/LaRowe_liq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Other_gas.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_gas.csv pkg/CHNOSZ/inst/extdata/OBIGT/Richard_liq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_aq.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_cr.csv pkg/CHNOSZ/inst/extdata/OBIGT/Shock_gas.csv pkg/CHNOSZ/man/basis.Rd pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/examples.Rd pkg/CHNOSZ/vignettes/anintro.Rmd Log: add obigt.Rmd Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/DESCRIPTION 2017-02-27 11:09:54 UTC (rev 177) @@ -1,6 +1,6 @@ -Date: 2017-02-25 +Date: 2017-02-27 Package: CHNOSZ -Version: 1.0.8-66 +Version: 1.0.8-67 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/basis.R =================================================================== --- pkg/CHNOSZ/R/basis.R 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/R/basis.R 2017-02-27 11:09:54 UTC (rev 177) @@ -203,9 +203,10 @@ # logarithms of activities for preset basis definitions preset.logact <- function(species) { bases <- c("H2O", "CO2", "NH3", "H2S", "oxygen", "H+", "e-", "Fe2O3", - "cysteine", "glutamic acid", "glutamine") + "glutamine", "glutamic acid", "cysteine") + # values for QEC amino acids from Dick, 2017 (http://doi.org/10.1101/097667) logact <- c(0, -3, -4, -7, -80, -7, -7, 0, - -4, -4, -4) + -3.2, -4.5, -3.6) ibase <- match(species, bases) logact <- logact[ibase] # any unmatched species gets a logarithm of activity of -3 Modified: pkg/CHNOSZ/data/refs.csv =================================================================== --- pkg/CHNOSZ/data/refs.csv 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/data/refs.csv 2017-02-27 11:09:54 UTC (rev 177) @@ -1,71 +1,87 @@ -key,author,year,citation,URL -AH97b,"J. P. Amend and H. C. Helgeson",1997,"J. Chem. Soc., Faraday Trans. 93, 1927-1941",http://dx.doi.org/10.1039/A608126F -AML10,"M. Accornero, L. Marini and M. Lelli",2010,"Appl. Geochem. 25, 242-260",http://dx.doi.org/10.1016/j.apgeochem.2009.11.010 -AP01,"J. P. Amend and A. V. Plyasunov",2001,"Geochim. Cosmochim. Acta 65, 3901-3917",http://dx.doi.org/10.1016/S0016-7037(01)00707-4 -AS01,"J. P. Amend and E. L. Shock",2001,"FEMS Microbiol. Rev. 25, 175-243",http://dx.doi.org/10.1016/S0168-6445(00)00062-0 -BH83a,"T. S. Bowers and H. C. Helgeson",1983,"Geochim. Cosmochim. Acta 47, 1247-1275",http://dx.doi.org/10.1016/0016-7037(83)90066-2 -CHNOSZ,"J. M. Dick",2007,"CHNOSZ package documentation",http://chnosz.net -CS16,"P. A. Canovas III and E. L. Shock",2016,"Geochim. Cosmochim. Acta 195, 293-322",http://dx.doi.org/10.1016/j.gca.2016.08.028 -CWM89,"J. D. Cox, D. D. Wagman and V. A. Medvedev, eds.",1989,"CODATA Key Values for Thermodynamics",http://www.worldcat.org/oclc/18559968 -DEH+13,"J. M. Dick, K. A. Evans et al.",2013,"Geochim. Cosmochim. Acta 122, 247-266",http://dx.doi.org/10.1016/j.gca.2013.08.020 -DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 -DSM+97,"J. D. Dale, E. L. Shock et al.",1997,"Geochim. Cosmochim. Acta 61, 4017-4024",http://dx.doi.org/10.1016/S0016-7037(97)00212-3 -Dic07,"J. M. Dick",2007,"Ph.D. Dissertation, U.C. Berkeley", -GM09,"K.-D. Grevel and J. Majzlan",2009,"Geochim. Cosmochim. Acta 73, 6805 - 6815",http://dx.doi.org/10.1016/j.gca.2009.08.005 -Gur96,"S. Gurrieri",1996,"personal communication", -HDN+78,"H. C. Helgeson, J. M. Delany et al.",1978,"Am. J. Sci. 278A, 1-229",http://www.worldcat.org/oclc/13594862 -Hel85b,"H. C. Helgeson",1985,"Am. J. Sci. 285, 845-855",http://dx.doi.org/10.2475/ajs.285.9.845 -HOK+98,"H. C. Helgeson, C. E. Owens et al.",1998,"Geochim. Cosmochim. Acta 62, 985-1081",http://dx.doi.org/10.1016/S0016-7037(97)00219-6 -HPT06,"B. Hawrylak, R. Palepu and P. R. Tremaine",2006,"J. Chem. Thermodynamics 38, 988-1007",http://dx.doi.org.ezproxy1.lib.asu.edu/10.1016/j.jct.2005.10.013 -HRM+09,"H. C. Helgeson, L. Richard et al.",2009,"Geochim. Cosmochim. Acta 73, 594-695",http://dx.doi.org/10.1016/j.gca.2008.03.004 -HS99,"J. R. Haas and E. L. Shock",1998,"Geochim. Cosmochim. Acta 63, 3429-3441",http://dx.doi.org/10.1016/S0016-7037(99)00276-8 -HSS95,"J. R. Haas, E. L. Shock and D. C. Sassani",1995,"Geochim. Cosmochim. Acta 59, 4329-4350",http://dx.doi.org/10.1016/0016-7037(95)00314-P -JH85b,"K. J. Jackson and H. C. Helgeson",1985,"Econ. Geol. 80, 1365-1378",http://dx.doi.org/10.2113/gsecongeo.80.5.1365 -Joh92,"J. W. Johnson",1992,"personal communication", -Kel60,"K. K. Kelley",1960,"U. S. Bureau of Mines Bull. 584",http://www.worldcat.org/oclc/693388901 -LD12,"D. E. LaRowe and J. M. Dick",2012,"Geochim. Cosmochim. Acta 80, 70-91",http://10.1016/j.gca.2011.11.041 -LH06a,"D. E. LaRowe and H. C. Helgeson",2006,"Geochim. Cosmochim. Acta 70, 4680-4724",http://dx.doi.org/10.1016/j.gca.2006.04.010 -LH06b,"D. E. LaRowe and H. C. Helgeson",2006,"Thermochim. Acta 448, 82-106",http://dx.doi.org/10.1016/j.tca.2006.06.008 -MA07,"L. Marini and M. Accornero",2007,"Environ. Geol. 52, 1343-1363",http://dx.doi.org/10.1007/s00254-006-0578-5 -MA10,"L. Marini and M. Accornero",2010,"Environ. Earth Sci. 59, 1601-1606",http://dx.doi.org/10.1007/s12665-009-0369-x -MGN03,"J. Majzlan, K.-D. Grevel and A. Navrotsky",2003,"Am. Mineral. 88, 855-859",http://dx.doi.org/10.2138/am-2003-5-614 -MLS+03,"J. Majzlan, B. E. Lang et al.",2003,"Am. Mineral. 88, 846-854",http://dx.doi.org/10.2138/am-2003-5-613 -MNM+06,"J. Majzlan, A. Navrotsky et al.",2006,"Eur. J. Mineral. 18, 175-186",http://dx.doi.org/10.1127/0935-1221/2006/0018-0175 -MS97,"T. M. McCollom and E. L. Shock",1997,"Geochim. Cosmochim. Acta 61, 4375-4391",http://dx.doi.org/10.1016/S0016-7037(97)00241-X -MSB+04,"J. Majzlan, R. Stevens et al.",2004,"Phys. Chem. Mineral. 31, 518-531",http://dx.doi.org/10.1007/s00269-004-0405-z -MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"Appl. Geochem. 16, 161-181",http://dx.doi.org/10.1016/S0883-2927(00)00025-1 -Nei86,"F. C. Neidhardt",1986,"Escherichia coli and Salmonella typhimurium, 3-5",http://www.worldcat.org/oclc/15280827 -Pan70,"L. B. Pankratz",1970,"U. S. Bureau of Mines Report of Investigations 7430",http://www.worldcat.org/oclc/14154245 -PB82,"L. N. Plummer and E. Busenberg",1982,"Geochim. Cosmochim. Acta 46, 1011-1040",http://dx.doi.org/10.1016/0016-7037(82)90056-4 -PK70,"L. B. Pankratz and E. G. King",1970,"U. S. Bureau of Mines Report of Investigations 7435",http://www.worldcat.org/oclc/14154292 -PK95,"V. B. Parker and I. L. Khodakovskii",1995,"J. Phys. Chem. Ref. Data 24, 1699-1745",http://dx.doi.org/10.1063/1.555964 -PS01,"A. V. Plyasunov and E. L. Shock",2001,"Geochim. Cosmochim. Acta 65, 3879-3900",http://dx.doi.org/10.1016/S0016-7037(01)00678-0 -PSK99,"P. Prapaipong, E. L. Shock and C. M. Koretsky",1999,"Geochim. Cosmochim. Acta 63, 2547-2577",http://dx.doi.org/10.1016/S0016-7037(99)00146-5 -RG11,"L. Richard and X. Gaona",2011,"Geochim. Cosmochim. Acta 75, 7304-7350",http://dx.doi.org/10.1016/j.gca.2011.07.030 -RH95,"R. A. Robie and B. S. Hemingway",1995,"U. S. Geological Survey Bull. 2131",http://pubs.er.usgs.gov/publication/b2131 -RH98,"L. Richard and H. C. Helgeson",1998,"Geochim. Cosmochim. Acta 62, 3591-3636",http://dx.doi.org/10.1016/S0016-7037(97)00345-1 -RHF79,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"U. S. Geological Survey Bull. 1452",http://pubs.er.usgs.gov/publication/b1452 -Ric01,"L. Richard",2001,"Geochim. Cosmochim. Acta 65, 3827-3877",http://dx.doi.org/10.1016/S0016-7037(01)00761-X -Ric08,"L. Richard",2008,"personal communication", -SAJ00,"R. E. Stoffregen, C. N. Alpers and J. L. Jambor",2000,"Rev. Mineral. Geochem. 40, 453-479",http://dx.doi.org/10.2138/rmg.2000.40.9 -Sch10,"M. Schulte",2010,"Aquat. Geochem. 16, 621-637",http://dx.doi.org/10.1007/s10498-010-9102-3 -SH88,"E. L. Shock and H. C. Helgeson",1988,"Geochim. Cosmochim. Acta 52, 2009-2036",http://dx.doi.org/10.1016/0016-7037(88)90181-0 -SH90,"E. L. Shock and H. C. Helgeson",1990,"Geochim. Cosmochim. Acta 54, 915-945",http://dx.doi.org/10.1016/0016-7037(90)90429-O -Sho92,"E. L. Shock",1992,"Geochim. Cosmochim. Acta 56, 3481-3491",http://dx.doi.org/10.1016/0016-7037(92)90392-V -Sho93,"E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3341-3349",http://dx.doi.org/10.1016/0016-7037(93)90542-5 -Sho95,"E. L. Shock",1990,"Am. J. Sci. 295, 496-580",http://dx.doi.org/10.2475/ajs.295.5.496 -SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"Geochim. Cosmochim. Acta 53, 2157-2183",http://dx.doi.org/10.1016/0016-7037(89)90341-4 -SK93,"E. L. Shock and C. M. Koretsky",1993,"Geochim. Cosmochim. Acta 57, 4899-4922",http://dx.doi.org/10.1016/0016-7037(93)90128-J -SK95,"E. L. Shock and C. M. Koretsky",1995,"Geochim. Cosmochim. Acta 59, 1497-1532",http://dx.doi.org/10.1016/0016-7037(95)00058-8 -SLOP98,"E. L. Shock et al.",1998,"slop98.dat computer data file",http://geopig.asu.edu/?q=tools -SM93,"E. L. Shock and W. B. McKinnon",1993,"Icarus 106, 464-477",http://dx.doi.org/10.1006/icar.1993.1185 -SR04,"M. D. Schulte and K. L. Rogers",2004,"Geochim. Cosmochim. Acta 68, 1087-1097",http://dx.doi.org/10.1016/j.gca.2003.06.001 -SS93,"M. D. Schulte and E. L. Shock",1993,"Geochim. Cosmochim. Acta 57, 3835-3846",http://dx.doi.org/10.1016/0016-7037(93)90337-V -SS98,"D. C. Sassani and E. L. Shock",1998,"Geochim. Cosmochim. Acta 62, 2643-2671",http://dx.doi.org/10.1016/S0016-7037(98)00049-0 -SSB97,"E. L. Shock, D. C. Sassani and H. Betz",1997,"Geochim. Cosmochim. Acta 61, 4245-4266",http://dx.doi.org/10.1016/S0016-7037(97)00240-8 -SSH97,"D. A. Sverjensky, E. L. Shock and H. C. Helgeson",1997,"Geochim. Cosmochim. Acta 61, 1359-1412",http://dx.doi.org/10.1016/S0016-7037(97)00009-4 -SSW+97,"E. L. Shock, D. C. Sassani et al.",1997,"Geochim. Cosmochim. Acta 61, 907-950",http://dx.doi.org/10.1016/S0016-7037(96)00339-0 -SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"Geochim. Cosmochim. Acta 65, 3919-3930",http://dx.doi.org/10.1016/S0016-7037(01)00717-7 -TSD97,"Y. Tardy, R. Schaul, J. Duplay",1997,"C. R. Acad. Sci. Paris 324, 969-976",http://dx.doi.org/10.1016/S1251-8050(97)83981-X -UniProt,"The UniProt Consortium",2017,"The UniProt knowledgebase",http://www.uniprot.org/ -WEP+82,"D. D. Wagman, W. H. Evans et al.",1982,"J. Phys. Chem. Ref. Data 11, 1-392",http://dx.doi.org/10.1063/1.555661 +key,author,year,note,citation,URL +Kel60,"K. K. Kelley",1960,"gases Cp","U. S. Bureau of Mines Bull. 584",http://www.worldcat.org/oclc/693388901 +Kel60.1,"K. K. Kelley",1960,larnite,"U. S. Bureau of Mines Bull. 584",http://www.worldcat.org/oclc/693388901 +Kel60.2,"K. K. Kelley",1960,"gypsum Cp","U. S. Bureau of Mines Bull. 584",http://www.worldcat.org/oclc/693388901 +Pan70,"L. B. Pankratz",1970,chlorargyrite,"U. S. Bureau of Mines Report of Investigations 7430",http://www.worldcat.org/oclc/14154245 +PK70,"L. B. Pankratz and E. G. King",1970,"bornite and chalcopyrite","U. S. Bureau of Mines Report of Investigations 7435",http://www.worldcat.org/oclc/14154292 +HDNB78,"H. C. Helgeson, J. M. Delany et al.",1978,minerals,"Am. J. Sci. 278A, 1-229",http://www.worldcat.org/oclc/13594862 +RHF79,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"chlorargyrite, rutile, and titanite","U. S. Geological Survey Bull. 1452",http://pubs.er.usgs.gov/publication/b1452 +RHF79.1,"R. A. Robie, B. S. Hemingway and J. R. Fisher",1979,"dickite, fluorphlogopite, halloysite, and pyrope","U. S. Geological Survey Bull. 1452",http://pubs.er.usgs.gov/publication/b1452 +PB82,"L. N. Plummer and E. Busenberg",1982,"aragonite and calcite","Geochim. Cosmochim. Acta 46, 1011-1040",http://dx.doi.org/10.1016/0016-7037(82)90056-4 +WEP+82,"D. D. Wagman, W. H. Evans et al.",1982,"gases GHS","J. Phys. Chem. Ref. Data 11, 1-392",http://dx.doi.org/10.1063/1.555661 +WEP+82.1,"D. D. Wagman, W. H. Evans et al.",1982,manganosite,"J. Phys. Chem. Ref. Data 11, 1-392",http://dx.doi.org/10.1063/1.555661 +WEP+82.2,"D. D. Wagman, W. H. Evans et al.",1982,MgSO4,"J. Phys. Chem. Ref. Data 11, 1-392",http://dx.doi.org/10.1063/1.555661 +BH83,"T. S. Bowers and H. C. Helgeson",1983,rutile,"Geochim. Cosmochim. Acta 47, 1247-1275",http://dx.doi.org/10.1016/0016-7037(83)90066-2 +Hel85,"H. C. Helgeson",1985,"ferrosilite and siderite","Am. J. Sci. 285, 845-855",http://dx.doi.org/10.2475/ajs.285.9.845 +JH85,"K. J. Jackson and H. C. Helgeson",1985,"Sn minerals","Econ. Geol. 80, 1365-1378",http://dx.doi.org/10.2113/gsecongeo.80.5.1365 +Nei86,"F. C. Neidhardt",1986,,"Escherichia coli and Salmonella typhimurium, 3-5",http://www.worldcat.org/oclc/15280827 +SH88,"E. L. Shock and H. C. Helgeson",1988,"ionic species","Geochim. Cosmochim. Acta 52, 2009-2036",http://dx.doi.org/10.1016/0016-7037(88)90181-0 +SH88.1,"E. L. Shock and H. C. Helgeson",1988,"corrections for Ca-bearing minerals","Geochim. Cosmochim. Acta 52, 2009-2036",http://dx.doi.org/10.1016/0016-7037(88)90181-0 +SH88.2,"E. L. Shock and H. C. Helgeson",1988,titanite,"Geochim. Cosmochim. Acta 52, 2009-2036",http://dx.doi.org/10.1016/0016-7037(88)90181-0 +CWM89,"J. D. Cox, D. D. Wagman and V. A. Medvedev, eds.",1989,,"CODATA Key Values for Thermodynamics",http://www.worldcat.org/oclc/18559968 +SHS89,"E. L. Shock, H. C. Helgeson and D. A. Sverjensky",1989,"inorganic neutral species","Geochim. Cosmochim. Acta 53, 2157-2183",http://dx.doi.org/10.1016/0016-7037(89)90341-4 +SH90,"E. L. Shock and H. C. Helgeson",1990,"organic species","Geochim. Cosmochim. Acta 54, 915-945",http://dx.doi.org/10.1016/0016-7037(90)90429-O +Joh92a,"J. W. Johnson",1992,"steam, Cp represented by Maier-Kelley equation","personal communication", +Sho92,"E. L. Shock",1992,dipeptides,"Geochim. Cosmochim. Acta 56, 3481-3491",http://dx.doi.org/10.1016/0016-7037(92)90392-V +Sho93,"E. L. Shock",1993,ethylacetate,"Geochim. Cosmochim. Acta 57, 3341-3349",http://dx.doi.org/10.1016/0016-7037(93)90542-5 +Sho93.1,"E. L. Shock",1993,"carbon monoxide and ethylene","Geochim. Cosmochim. Acta 57, 3341-3349",http://dx.doi.org/10.1016/0016-7037(93)90542-5 +SK93,"E. L. Shock and C. M. Koretsky",1993,"metal-acetate complexes","Geochim. Cosmochim. Acta 57, 4899-4922",http://dx.doi.org/10.1016/0016-7037(93)90128-J +SM93,"E. L. Shock and W. B. McKinnon",1993,"CO, HCN, urea","Icarus 106, 464-477",http://dx.doi.org/10.1006/icar.1993.1185 +SS93,"M. D. Schulte and E. L. Shock",1993,aldehydes,"Geochim. Cosmochim. Acta 57, 3835-3846",http://dx.doi.org/10.1016/0016-7037(93)90337-V +HSS95,"J. R. Haas, E. L. Shock and D. C. Sassani",1995,"REE complexes","Geochim. Cosmochim. Acta 59, 4329-4350",http://dx.doi.org/10.1016/0016-7037(95)00314-P +PK95,"V. B. Parker and I. L. Khodakovskii",1995,melanterite,"J. Phys. Chem. Ref. Data 24, 1699-1745",http://dx.doi.org/10.1063/1.555964 +RH95,"R. A. Robie and B. S. Hemingway",1995,"gypsum GHS","U. S. Geological Survey Bull. 2131",http://pubs.er.usgs.gov/publication/b2131 +RH95.1,"R. A. Robie and B. S. Hemingway",1995,iron,"U. S. Geological Survey Bull. 2131",http://pubs.er.usgs.gov/publication/b2131 +SK95,"E. L. Shock and C. M. Koretsky",1995,"metal-organic acid complexes","Geochim. Cosmochim. Acta 59, 1497-1532",http://dx.doi.org/10.1016/0016-7037(95)00058-8 +Sho95,"E. L. Shock",1995,"carboxylic acids","Am. J. Sci. 295, 496-580",http://dx.doi.org/10.2475/ajs.295.5.496 +Gur96,"S. Gurrieri",1996,sulfur,"personal communication", +AH97b,"J. P. Amend and H. C. Helgeson",1997,"amino acids GHS","J. Chem. Soc., Faraday Trans. 93, 1927-1941",http://dx.doi.org/10.1039/A608126F +DSM+97,"J. D. Dale, E. L. Shock et al.",1997,alkylphenols,"Geochim. Cosmochim. Acta 61, 4017-4024",http://dx.doi.org/10.1016/S0016-7037(97)00212-3 +MS97,"T. M. McCollom and E. L. Shock",1997,"MgSO4, NaSO4-, and HCl","Geochim. Cosmochim. Acta 61, 4375-4391",http://dx.doi.org/10.1016/S0016-7037(97)00241-X +SSB97,"E. L. Shock, D. C. Sassani and H. Betz",1997,"uranium species","Geochim. Cosmochim. Acta 61, 4245-4266",http://dx.doi.org/10.1016/S0016-7037(97)00240-8 +SSH97,"D. A. Sverjensky, E. L. Shock and H. C. Helgeson",1997,"metal complexes","Geochim. Cosmochim. Acta 61, 1359-1412",http://dx.doi.org/10.1016/S0016-7037(97)00009-4 +SSW+97,"E. L. Shock, D. C. Sassani et al.",1997,"inorganic ions and hydroxide complexes","Geochim. Cosmochim. Acta 61, 907-950",http://dx.doi.org/10.1016/S0016-7037(96)00339-0 +TSD97,"Y. Tardy, R. Schaul, J. Duplay",1997,"humic acid, microflora, and plants","C. R. Acad. Sci. Paris 324, 969-976",http://dx.doi.org/10.1016/S1251-8050(97)83981-X +HOKR98,"H. C. Helgeson, C. E. Owens et al.",1998,"organic molecules and groups","Geochim. Cosmochim. Acta 62, 985-1081",http://dx.doi.org/10.1016/S0016-7037(97)00219-6 +HS99,"J. R. Haas and E. L. Shock",1998,"chloroethylene species","Geochim. Cosmochim. Acta 63, 3429-3441",http://dx.doi.org/10.1016/S0016-7037(99)00276-8 +RH98,"L. Richard and H. C. Helgeson",1998,"organic molecules and groups","Geochim. Cosmochim. Acta 62, 3591-3636",http://dx.doi.org/10.1016/S0016-7037(97)00345-1 +SLOP98,"E. L. Shock et al.",1998,,"slop98.dat computer data file",http://geopig.asu.edu/?q=tools +SS98a,"D. C. Sassani and E. L. Shock",1998,"platinum-group solids","Geochim. Cosmochim. Acta 62, 2643-2671",http://dx.doi.org/10.1016/S0016-7037(98)00049-0 +PSK99,"P. Prapaipong, E. L. Shock and C. M. Koretsky",1999,"metal-dicarboxylate complexes","Geochim. Cosmochim. Acta 63, 2547-2577",http://dx.doi.org/10.1016/S0016-7037(99)00146-5 +SAJ00,"R. E. Stoffregen, C. N. Alpers and J. L. Jambor",2000,"jarosite, natroalunite, and natrojarosite","Rev. Mineral. Geochem. 40, 453-479",http://dx.doi.org/10.2138/rmg.2000.40.9 +AP01,"J. P. Amend and A. V. Plyasunov",2001,carbohydrates,"Geochim. Cosmochim. Acta 65, 3901-3917",http://dx.doi.org/10.1016/S0016-7037(01)00707-4 +AS01,"J. P. Amend and E. L. Shock",2001,"NO and N2O","FEMS Microbiol. Rev. 25, 175-243",http://dx.doi.org/10.1016/S0168-6445(00)00062-0 +MVT01,"L. Mercury, P. Vieillard. and Y. Tardy",2001,"ice polymorphs","Appl. Geochem. 16, 161-181",http://dx.doi.org/10.1016/S0883-2927(00)00025-1 +PS01,"A. V. Plyasunov and E. L. Shock",2001,cyclohexane,"Geochim. Cosmochim. Acta 65, 3879-3900",http://dx.doi.org/10.1016/S0016-7037(01)00678-0 +Ric01,"L. Richard",2001,"organic sulfur compounds","Geochim. Cosmochim. Acta 65, 3827-3877",http://dx.doi.org/10.1016/S0016-7037(01)00761-X +SSW01,"M. D. Schulte, E. L. Shock and R. H. Wood",2001,"nonelectrolytes HKF heat capacity parameters","Geochim. Cosmochim. Acta 65, 3919-3930",http://dx.doi.org/10.1016/S0016-7037(01)00717-7 +MGN03,"J. Majzlan, K.-D. Grevel and A. Navrotsky",2003,"goethite, lepidocrocite, and maghemite GHS","Am. Mineral. 88, 855-859",http://dx.doi.org/10.2138/am-2003-5-614 +MLS+03,"J. Majzlan, B. E. Lang et al.",2003,"goethite, lepidocrocite, and maghemite Cp","Am. Mineral. 88, 846-854",http://dx.doi.org/10.2138/am-2003-5-613 +MSB+04,"J. Majzlan, R. Stevens et al.",2004,"hydronium jarosite","Phys. Chem. Mineral. 31, 518-531",http://dx.doi.org/10.1007/s00269-004-0405-z +SR04,"M. D. Schulte and K. L. Rogers",2004,"alkane thiols","Geochim. Cosmochim. Acta 68, 1087-1097",http://dx.doi.org/10.1016/j.gca.2003.06.001 +DLH06,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"amino acid, protein, and organic groups","Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 +DLH06.1,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"amino acids HKF parameters","Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 +DLH06.2,"J. M. Dick, D. E. LaRowe and H. C. Helgeson",2006,"Gly-X-Gly tripeptides","Biogeosciences 3, 311-336",http://dx.doi.org/10.5194/bg-3-311-2006 +HPT06,"B. Hawrylak, R. Palepu and P. R. Tremaine",2006,"methyldiethanolamine and methyldiethanolammonium chloride","J. Chem. Thermodynamics 38, 988-1007",http://dx.doi.org.ezproxy1.lib.asu.edu/10.1016/j.jct.2005.10.013 +LH06a,"D. E. LaRowe and H. C. Helgeson",2006,"nucleic-acid bases, nucleosides, and nucleotides","Geochim. Cosmochim. Acta 70, 4680-4724",http://dx.doi.org/10.1016/j.gca.2006.04.010 +LH06b,"D. E. LaRowe and H. C. Helgeson",2006,"Mg-complexed adenosine nucleotides (ATP), NAD, and NADP","Thermochim. Acta 448, 82-106",http://dx.doi.org/10.1016/j.tca.2006.06.008 +LH06b.1,"D. E. LaRowe and H. C. Helgeson",2006,"pyridine and piperidine","Thermochim. Acta 448, 82-106",http://dx.doi.org/10.1016/j.tca.2006.06.008 +MNM+06,"J. Majzlan, A. Navrotsky et al.",2006,"coquimbite, ferricopiapite, rhomboclase","Eur. J. Mineral. 18, 175-186",http://dx.doi.org/10.1127/0935-1221/2006/0018-0175 +CHNOSZ.1,"J. M. Dick",2007,"recalculated GHS","CHNOSZ package documentation",http://chnosz.net +CHNOSZ.2,"J. M. Dick",2007,"calculated Cp coefficients","CHNOSZ package documentation",http://chnosz.net +CHNOSZ.3,"J. M. Dick",2007,pseudo-H4SiO4,"CHNOSZ package documentation",http://chnosz.net +Dic07,"J. M. Dick",2007,"glutathione, cystine, and cystine sidechain","Ph.D. Dissertation, U.C. Berkeley", +MA07,"L. Marini and M. Accornero",2007,"metal-arsenate and metal-arsenite complexes","Environ. Geol. 52, 1343-1363",http://dx.doi.org/10.1007/s00254-006-0578-5 +Ric08,"L. Richard",2008,alkenes,"personal communication", +GM09,"K.-D. Grevel and J. Majzlan",2009,"kieserite, starkeyite, hexahydrite, and epsomite","Geochim. Cosmochim. Acta 73, 6805 - 6815",http://dx.doi.org/10.1016/j.gca.2009.08.005 +HRMNS09,"H. C. Helgeson, L. Richard et al.",2009,kerogens,"Geochim. Cosmochim. Acta 73, 594-695",http://dx.doi.org/10.1016/j.gca.2008.03.004 +AML10,"M. Accornero, L. Marini and M. Lelli",2010,"metal-chromate complexes","Appl. Geochem. 25, 242-260",http://dx.doi.org/10.1016/j.apgeochem.2009.11.010 +MA10,"L. Marini and M. Accornero",2010,"corrected values","Environ. Earth Sci. 59, 1601-1606",http://dx.doi.org/10.1007/s12665-009-0369-x +Sch10,"M. Schulte",2010,"organic sulfides","Aquat. Geochem. 16, 621-637",http://dx.doi.org/10.1007/s10498-010-9102-3 +RG11,"L. Richard and X. Gaona",2011,"organic iodine compounds","Geochim. Cosmochim. Acta 75, 7304-7350",http://dx.doi.org/10.1016/j.gca.2011.07.030 +LD12,"D. E. LaRowe and J. M. Dick",2012,"amino acids and protein groups","Geochim. Cosmochim. Acta 80, 70-91",http://10.1016/j.gca.2011.11.041 +LD12.1,"D. E. LaRowe and J. M. Dick",2012,"methionine and methionine sidechain GHS","Geochim. Cosmochim. Acta 80, 70-91",http://10.1016/j.gca.2011.11.041 +DEH+13,"J. M. Dick, K. A. Evans et al.",2013,"phenanthrene and isomers of methylphenanthrene","Geochim. Cosmochim. Acta 122, 247-266",http://dx.doi.org/10.1016/j.gca.2013.08.020 +CS16,"P. A. Canovas III and E. L. Shock",2016,"citric acid cycle metabolites","Geochim. Cosmochim. Acta 195, 293-322",http://dx.doi.org/10.1016/j.gca.2016.08.028 +CS16.1,"P. A. Canovas III and E. L. Shock",2016,"citric acid species HKF a1-a4 parameters and corrected Cp and V","Geochim. Cosmochim. Acta 195, 293-322",http://dx.doi.org/10.1016/j.gca.2016.08.028 +UniProt,"The UniProt Consortium",2017,,"The UniProt knowledgebase",http://www.uniprot.org/ Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/demo/00Index 2017-02-27 11:09:54 UTC (rev 177) @@ -3,13 +3,13 @@ affinity affinities of metabolic reactions and amino acid synthesis NaCl equilibrium constant for aqueous NaCl dissociation density density of H2O, inverted from IAPWS-95 equations -ORP oxidation-reduction potential of redox standards as a function of temperature +ORP temperature dependence of oxidation-reduction potential for redox standards revisit coefficient of variation of metastable equilibrium activities of proteins findit minimize the standard deviation of logarithms of activities of sulfur species ionize ionize.aa(): contour plots of net charge and ionization properties of LYSC_CHICK buffer minerals and aqueous species as buffers of hydrogen fugacity protbuff chemical activities buffered by thiol peroxidases or sigma factors -yeastgfp YeastGFP locations: log fO2 - log aH2O and log a - log fO2 diagrams +yeastgfp subcellular locations: log fO2 - log aH2O and log a - log fO2 diagrams mosaic Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species copper another example of mosaic(): complexation of copper with glycine species solubility solubility of calcite or CO2(gas) as a function of pH Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/inst/NEWS 2017-02-27 11:09:54 UTC (rev 177) @@ -1,11 +1,13 @@ -CHANGES IN CHNOSZ 1.0.8-66 (2017-02-25) +CHANGES IN CHNOSZ 1.0.8-67 (2017-02-27) --------------------------------------- DOCUMENTATION: -- Replace anintro.Rnw (using Sweave) with rewritten anintro.Rmd (using - knitr with Tufte style). +- Replace anintro.Rnw (Sweave) with rewritten anintro.Rmd (using knitr + with Tufte style). +- Add obigt.Rmd (Thermodynamic data in CHNOSZ). + - Add eos-regress.Rmd (Regressing thermodynamic data), including section on Making a pseudospecies: H4SiO4. Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Amend_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/Amend_aq.csv 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/inst/extdata/OBIGT/Amend_aq.csv 2017-02-27 11:09:54 UTC (rev 177) @@ -1,4 +1,33 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T +alanine,Ala,C3H7NO2,aq,AH97b,DLH06.1,25.Aug.06,-88810,-132500,38.83,33.6,60.4,14.9,1.74,7.16,-3.69,49.5,-7,0.18,0 +arginine,Arg,C6H14N4O2,aq,AH97b,DLH06.1,25.Aug.06,-57360,-143060,80.06,67.4,123.9,28.83,8.21,7.2,-5.95,94.8,-12.5,0.22,0 +argininium,Arg+,C6H15N4O2+,aq,AH97b,DLH06.1,25.Aug.06,-69930,-154880,82.57,77.6,122.5,31.72,0.22,5.46,-5.15,103.8,-9.6,0.73,0 +argininate,Arg-,C6H13N4O2-,aq,AH97b,DLH06.1,25.Aug.06,-40340,-129420,68.72,81.1,143,31.28,13.76,32.12,-9.94,141.9,-19.6,2.3,0 +asparagine,Asn,C4H8N2O3,aq,AH97b,DLH06.1,25.Aug.06,-125490,-182700,57.88,30.8,77.4,19.83,2.37,3.76,-4.81,56.5,-11.7,0.21,0 +"aspartic acid",Asp,C4H7NO4,aq,AH97b,DLH06.1,25.Aug.06,-172510,-226340,55.22,32.4,74.7,18.96,3.05,-6.62,-2.23,58.1,-11.9,0.17,0 +aspartate,Asp-,C4H6NO4-,aq,AH97b,DLH06.1,25.Aug.06,-167170,-224540,43.34,2.7,64.8,16.96,5.77,10.11,-6.37,56.3,-15.3,2.47,0 +cysteine,Cys,C3H7NO2S,aq,AH97b,DLH06.1,25.Aug.06,-80330,-124070,46.32,47.1,73.5,18.14,2.4,9.31,-4.97,59.8,-5.6,0.15,0 +cysteinate,Cys-,C3H6NO2S-,aq,AH97b,DLH06.1,25.Aug.06,-68920,-115440,37.01,19.1,60.6,14.43,5.11,12.35,-3.71,61,-9.5,2.48,0 +glutamine,Gln,C5H10N2O3,aq,AH97b,DLH06.1,25.Aug.06,-126280,-191860,62.41,43.8,93.7,23.22,3.58,5.44,-5.23,68.6,-11.4,0.18,0 +"glutamic acid",Glu,C5H9NO4,aq,AH97b,DLH06.1,25.Aug.06,-173050,-234820,61.2,43.5,90.2,22.3,4.23,6.55,-5.84,65.2,-10,0.15,0 +glutamate,Glu-,C5H8NO4-,aq,AH97b,DLH06.1,25.Aug.06,-167210,-234150,43.86,7.6,80,20.49,6.96,10.86,-7.02,47.6,-7.8,2.65,0 +glycine,Gly,C2H5NO2,aq,AH97b,DLH06.1,25.Aug.06,-90950,-124780,39.29,9.3,43.2,11.3,0.71,3.99,-3.04,28.5,-8.4,0.23,0 +glycinium,Gly+,C2H6NO2+,aq,AH97b,DLH06.1,25.Aug.06,-94160,-125720,46.91,40,56.4,19.57,-7.58,-40.35,5.41,49,-1.8,0.59,0 +histidine,His,C6H9N3O2,aq,AH97b,DLH06.1,25.Aug.06,-48420,-108200,66,56.2,99.3,24.32,4.8,7.52,-6.05,81.6,-11.3,0.27,0 +histidinium,His+,C6H10N3O2+,aq,AH97b,DLH06.1,25.Aug.06,-56700,-115250,70.13,59.1,97,26.64,-3.4,-0.88,-3.07,88,-12,0.5,0 +isoleucine,Ile,C6H13NO2,aq,AH97b,DLH06.1,25.Aug.06,-81990,-151600,49.7,91.6,105.8,24.49,6.55,18.16,-7.76,99.7,-3.6,0.09,0 +leucine,Leu,C6H13NO2,aq,AH97b,DLH06.1,25.Aug.06,-84200,-153600,50.41,95.2,107.8,24.68,7.51,19.93,-8.37,102.7,-3.3,0.09,0 +lysine,Lys,C6H14N2O2,aq,AH97b,DLH06.1,25.Aug.06,-80680,-159330,57.91,63.8,108.6,24.56,8.3,24.43,-9.53,86.6,-10.9,0.07,0 +lysinium,Lys+,C6H15N2O2+,aq,AH97b,DLH06.1,25.Aug.06,-92890,-170370,61.82,67.9,107.5,28.62,-1.51,4.47,-3.99,95.2,-8,1.21,0 +lysinate,Lys-,C6H13N2O2-,aq,AH97b,DLH06.1,25.Aug.06,-66310,-146340,53.27,72.8,112.2,28.29,10.53,2.97,-7.61,133.7,-18,2.67,0 +phenylalanine,Phe,C9H11NO2,aq,AH97b,DLH06.1,25.Aug.06,-49430,-108900,56.6,93.8,122.1,28.27,8.8,19.34,-9.38,108.1,-6.5,0.12,0 +proline,Pro,C5H9NO2,aq,AH97b,DLH06.1,25.Aug.06,-73560,-124100,49.83,43,82.6,19.39,4.87,11.88,-5.68,63.6,-9.5,0.14,0 +serine,Ser,C3H7NO3,aq,AH97b,DLH06.1,25.Aug.06,-123930,-172420,47.24,27.8,60.6,15.69,0.73,3.87,-3.49,48.5,-9.4,0.18,0 +threonine,Thr,C4H9NO3,aq,AH97b,DLH06.1,25.Aug.06,-119830,-178940,44.23,50.1,77.6,18.94,2.83,8.87,-4.87,65.5,-7.1,0.11,0 +tryptophan,Trp,C11H12N2O2,aq,AH97b,DLH06.1,25.Aug.06,-26820,-97590,59.96,99.6,143.6,33.91,9.21,14.78,-9.36,116.8,-7.8,0.15,0 +tyrosine,Tyr,C9H11NO3,aq,AH97b,DLH06.1,25.Aug.06,-91800,-157740,59.41,80.2,124.5,30.06,8.49,8.36,-8.58,106.2,-12.4,0.09,0 +tyrosinate,Tyr-,C9H10NO3-,aq,AH97b,DLH06.1,25.Aug.06,-79380,-149420,45.66,51.2,111.8,26.34,10.49,16.42,-7.59,109,-16,2.78,0 +valine,Val,C5H11NO2,aq,AH97b,DLH06.1,25.Aug.06,-85330,-146420,45.68,74,90.9,21.35,4.48,14.58,-6.12,83.8,-4.3,0.12,0 xylose,xylose,C5H10O5,aq,AP01,NA,24.Aug.06,-179371.414913958,-249937.858508604,48.7332695984704,65.9655831739962,95.7,22.5860420650096,0.90822179732314,4.78011472275335,-2.77246653919694,90.9177820267686,-17.5908221797323,-1.31453154875717,0 arabinose,arabinose,C5H10O5,aq,AP01,NA,24.Aug.06,-177397.227533461,-249471.797323136,43.6663479923518,67.1606118546845,93.3,22.538240917782,0.81261950286807,3.99139579349904,-3.48948374760994,93.7619502868069,-18.4034416826004,-1.31453154875717,0 lyxose,lyxose,C5H10O5,aq,AP01,NA,24.Aug.06,-179048.757170172,-250164.913957935,47.0841300191205,67.3996175908222,94.2,22.6577437858509,1.2906309751434,1.7925430210325,-3.10707456978967,93.9292543021032,-18.4034416826004,-1.31453154875717,0 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_aq.csv 2017-02-27 11:09:54 UTC (rev 177) @@ -1,2 +1,2 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -pseudo-H4SiO4,NA,H4SiO4,aq,CHNOSZ,NA,18.Feb.17,-312565,-346409,51.4246,-40.0964,52.1998,89.2031,-176.5071,-452.1431,101.36051,67.0854,-52.0776,0.1215745,0 +pseudo-H4SiO4,NA,H4SiO4,aq,CHNOSZ.3,NA,18.Feb.17,-312565,-346409,51.4246,-40.0964,52.1998,89.2031,-176.5071,-452.1431,101.36051,67.0854,-52.0776,0.1215745,0 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_cr.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_cr.csv 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/inst/extdata/OBIGT/CHNOSZ_cr.csv 2017-02-27 11:09:54 UTC (rev 177) @@ -1,5 +1,5 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -Fe,iron,Fe,cr1,RH95,CHNOSZ,05.Aug.07,0,0,6.475,5.994,7.092,7.162,-6.9682,0,0,1.2294,0,0,1043 -Fe,iron,Fe,cr2,RH95,CHNOSZ,05.Aug.07,-32284.5,-87223.4,-177.791,NA,7.092,504.577,-807.244,0,0,32.754,0,0,1185 -Fe,iron,Fe,cr3,RH95,CHNOSZ,05.Aug.07,1348.8,1843.8,8.1352,NA,7.092,5.1938,2.3381,1.5019,0,0,0,0,1667 -Fe,iron,Fe,cr4,RH95,CHNOSZ,05.Aug.07,3190.2,4835.6,11.994,NA,7.092,-4.033,8.0055,9.5584,0,0,0,0,1809 +Fe,iron,Fe,cr1,RH95.1,CHNOSZ.2,05.Aug.07,0,0,6.475,5.994,7.092,7.162,-6.9682,0,0,1.2294,0,0,1043 +Fe,iron,Fe,cr2,RH95.1,CHNOSZ.2,05.Aug.07,-32284.5,-87223.4,-177.791,NA,7.092,504.577,-807.244,0,0,32.754,0,0,1185 +Fe,iron,Fe,cr3,RH95.1,CHNOSZ.2,05.Aug.07,1348.8,1843.8,8.1352,NA,7.092,5.1938,2.3381,1.5019,0,0,0,0,1667 +Fe,iron,Fe,cr4,RH95.1,CHNOSZ.2,05.Aug.07,3190.2,4835.6,11.994,NA,7.092,-4.033,8.0055,9.5584,0,0,0,0,1809 Modified: pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv =================================================================== --- pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv 2017-02-25 02:08:42 UTC (rev 176) +++ pkg/CHNOSZ/inst/extdata/OBIGT/Dick_aq.csv 2017-02-27 11:09:54 UTC (rev 177) @@ -1,34 +1,5 @@ name,abbrv,formula,state,ref1,ref2,date,G,H,S,Cp,V,a1.a,a2.b,a3.c,a4.d,c1.e,c2.f,omega.lambda,z.T -alanine,Ala,C3H7NO2,aq,AH97b,DLH06,25.Aug.06,-88810,-132500,38.83,33.6,60.4,14.9,1.74,7.16,-3.69,49.5,-7,0.18,0 -arginine,Arg,C6H14N4O2,aq,AH97b,DLH06,25.Aug.06,-57360,-143060,80.06,67.4,123.9,28.83,8.21,7.2,-5.95,94.8,-12.5,0.22,0 -argininium,Arg+,C6H15N4O2+,aq,AH97b,DLH06,25.Aug.06,-69930,-154880,82.57,77.6,122.5,31.72,0.22,5.46,-5.15,103.8,-9.6,0.73,0 -argininate,Arg-,C6H13N4O2-,aq,AH97b,DLH06,25.Aug.06,-40340,-129420,68.72,81.1,143,31.28,13.76,32.12,-9.94,141.9,-19.6,2.3,0 -asparagine,Asn,C4H8N2O3,aq,AH97b,DLH06,25.Aug.06,-125490,-182700,57.88,30.8,77.4,19.83,2.37,3.76,-4.81,56.5,-11.7,0.21,0 -"aspartic acid",Asp,C4H7NO4,aq,AH97b,DLH06,25.Aug.06,-172510,-226340,55.22,32.4,74.7,18.96,3.05,-6.62,-2.23,58.1,-11.9,0.17,0 -aspartate,Asp-,C4H6NO4-,aq,AH97b,DLH06,25.Aug.06,-167170,-224540,43.34,2.7,64.8,16.96,5.77,10.11,-6.37,56.3,-15.3,2.47,0 -cysteine,Cys,C3H7NO2S,aq,AH97b,DLH06,25.Aug.06,-80330,-124070,46.32,47.1,73.5,18.14,2.4,9.31,-4.97,59.8,-5.6,0.15,0 -cysteinate,Cys-,C3H6NO2S-,aq,AH97b,DLH06,25.Aug.06,-68920,-115440,37.01,19.1,60.6,14.43,5.11,12.35,-3.71,61,-9.5,2.48,0 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 177