From noreply at r-forge.r-project.org Sun Mar 1 18:01:55 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Mar 2015 18:01:55 +0100 (CET) Subject: [CHNOSZ-commits] r76 - in pkg/CHNOSZ: . R data inst man Message-ID: <20150301170155.E7BC9187560@r-forge.r-project.org> Author: jedick Date: 2015-03-01 18:01:52 +0100 (Sun, 01 Mar 2015) New Revision: 76 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/data/opt.csv pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/subcrt.Rd Log: add thermo$opt$varP to use variable-pressure standard state for gases Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/DESCRIPTION 2015-03-01 17:01:52 UTC (rev 76) @@ -1,12 +1,12 @@ -Date: 2015-02-15 +Date: 2015-03-01 Package: CHNOSZ -Version: 1.0.3-13 +Version: 1.0.3-14 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Depends: R (>= 2.12.0) Suggests: limSolve, parallel, testthat, knitr -Description: This package includes functions and data sets to support chemical thermodynamic +Description: A set of 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 biomolecules; a database of thermodynamic properties of aqueous, crystalline Modified: pkg/CHNOSZ/R/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/R/subcrt.R 2015-03-01 17:01:52 UTC (rev 76) @@ -360,6 +360,12 @@ out <- c(out,rep(p.H2O,length(which(isH2O==TRUE)))) } + # use variable-pressure standard Gibbs energy for gases + isgas <- reaction$state %in% "gas" + if(TRUE %in% isgas & "g" %in% eprop & thermo$opt$varP) { + for(i in which(isgas)) out[[i]]$G <- out[[i]]$G - convert(log10(P), "G", T=T) + } + # logK if('logk' %in% prop) { for(i in 1:length(out)) { Modified: pkg/CHNOSZ/data/opt.csv =================================================================== --- pkg/CHNOSZ/data/opt.csv 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/data/opt.csv 2015-03-01 17:01:52 UTC (rev 76) @@ -1,2 +1,2 @@ -Tr,Pr,Theta,Psi,R,cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol -298.15,1,228,2600,1.9872,1e-10,cal,C,bar,aq,SUPCRT92,100,1,1 +Tr,Pr,Theta,Psi,R,cutoff,E.units,T.units,P.units,state,water,G.tol,Cp.tol,V.tol,varP +298.15,1,228,2600,1.9872,1e-10,cal,C,bar,aq,SUPCRT92,100,1,1,FALSE Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/inst/NEWS 2015-03-01 17:01:52 UTC (rev 76) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.3-13 (2015-02-15) +CHANGES IN CHNOSZ 1.0.3-14 (2015-03-01) --------------------------------------- - Add files with average amino acid compositions of proteins from Bison @@ -45,6 +45,11 @@ - In test-diagram.R, test that same diagrams are produced using 'as.residue' in equilibrate() or diagram(). +- Add 'tplot' argument to diagram(). + +- Add thermo$opt$varP option as a flag for subcrt() to calculate Gibbs + energies of gases using a variable-pressure standard state. + CHANGES IN CHNOSZ 1.0.3 (2014-01-12) ------------------------------------ Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/man/data.Rd 2015-03-01 17:01:52 UTC (rev 76) @@ -54,6 +54,7 @@ \code{G.tol} \tab numeric \tab Absolute difference between tabulated and calculated value of G above which \code{\link{checkGHS}} produces a message (cal mol\eqn{^{-1}}{^-1}).\cr \code{Cp.tol} \tab numeric \tab Absolute difference between tabulated and calculated value of Cp above which \code{\link{checkEOS}} produces a message (cal K\eqn{^{-1}}{-1} mol\eqn{^{-1}}{^-1}).\cr \code{V.tol} \tab numeric \tab Absolute difference between tabulated and calculated value of V above which \code{\link{checkEOS}} produces a message (cm\eqn{^{3}}{3} mol\eqn{^{-1}}{^-1}).\cr + \code{varP} \tab logical \tab Use variable-pressure standard state for gases (default \code{FALSE})? See \code{\link{subcrt}}.\cr } \item \code{thermo$element} Modified: pkg/CHNOSZ/man/subcrt.Rd =================================================================== --- pkg/CHNOSZ/man/subcrt.Rd 2015-02-15 06:42:50 UTC (rev 75) +++ pkg/CHNOSZ/man/subcrt.Rd 2015-03-01 17:01:52 UTC (rev 76) @@ -72,9 +72,11 @@ However, \code{NA}s may be produced in the output of \code{subcrt} if the requisite thermodynamic or electrostatic properties of water can not be calculated at given conditions. Specifically, \code{NA}s are produced for calculations at \samp{Psat} when the temperature exceeds the critical temperature of H2O. - For calculations below 273.16 K, the pressure should be set to 1, as Psat is not defined in these conditions. +If \code{thermo$opt$varP} is \code{TRUE}, standard Gibbs energies of gases will be converted from a standard state at 1 bar (as used in SUPCRT) to a variable pressure standard state (see chapter 12 in Anderson and Crerar, 1993). +This is useful for constructing e.g. boiling curves for organic compounds. + } \section{Warning}{ @@ -269,6 +271,8 @@ } \references{ + Anderson, G. M. and Crerar, D. A. (1993) \emph{Thermodynamics in Geochemistry: The Equilibrium Model}, Oxford University Press. \url{http://www.worldcat.org/oclc/803272549} + Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) 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\eqn{^{\circ}}{?}C. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{http://dx.doi.org/10.1016/0098-3004(92)90029-Q} LaRowe, D. E. and Helgeson, H. C. (2007) Quantifying the energetics of metabolic reactions in diverse biogeochemical systems: electron flow and ATP synthesis. \emph{Geobiology} \bold{5}, 153--168. \url{http://dx.doi.org/10.1111/j.1472-4669.2007.00099.x} From noreply at r-forge.r-project.org Fri Mar 6 02:54:24 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 6 Mar 2015 02:54:24 +0100 (CET) Subject: [CHNOSZ-commits] r77 - in pkg/CHNOSZ: . inst man Message-ID: <20150306015424.4A0921878D6@r-forge.r-project.org> Author: jedick Date: 2015-03-06 02:54:23 +0100 (Fri, 06 Mar 2015) New Revision: 77 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/data.Rd pkg/CHNOSZ/man/diagram.Rd pkg/CHNOSZ/man/extdata.Rd pkg/CHNOSZ/man/water.Rd Log: fix some URLs in Rd files Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/DESCRIPTION 2015-03-06 01:54:23 UTC (rev 77) @@ -1,19 +1,19 @@ -Date: 2015-03-01 +Date: 2015-03-06 Package: CHNOSZ -Version: 1.0.3-14 +Version: 1.0.3-15 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Depends: R (>= 2.12.0) Suggests: limSolve, parallel, testthat, knitr -Description: A set of 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 biomolecules; a database of thermodynamic properties of aqueous, crystalline - and gaseous species; amino acid group additivity for the standard molal thermodynamic - properties of neutral and ionized proteins; use of the revised Helgeson-Kirkham-Flowers - equations of state for aqueous species; construction of equilibrium activity diagrams as a - function of temperature, pressure, and chemical activities or fugacities of basis species. +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 + biomolecules; a database of thermodynamic properties of aqueous, crystalline and gaseous + species; amino acid group additivity for the standard molal thermodynamic properties of + neutral and ionized proteins; use of the revised Helgeson-Kirkham-Flowers equations of state + for aqueous species; construction of equilibrium activity diagrams as a function of + temperature, pressure, and chemical activities or fugacities of basis species. License: GPL (>= 2) BuildResaveData: no ZipData: no Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/inst/NEWS 2015-03-06 01:54:23 UTC (rev 77) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.3-14 (2015-03-01) +CHANGES IN CHNOSZ 1.0.3-15 (2015-03-06) --------------------------------------- - Add files with average amino acid compositions of proteins from Bison Modified: pkg/CHNOSZ/man/data.Rd =================================================================== --- pkg/CHNOSZ/man/data.Rd 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/man/data.Rd 2015-03-06 01:54:23 UTC (rev 77) @@ -241,7 +241,7 @@ 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}. - 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{http://www.nist.gov/srd/PDFfiles/jpcrdS2Vol11.pdf} + 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{http://www.nist.gov/data/PDFfiles/jpcrdS2Vol11.pdf} } Modified: pkg/CHNOSZ/man/diagram.Rd =================================================================== --- pkg/CHNOSZ/man/diagram.Rd 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/man/diagram.Rd 2015-03-06 01:54:23 UTC (rev 77) @@ -316,7 +316,7 @@ 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} - Seewald, J. S. (1997) Mineral redox buffers and the stability of organic compounds under hydrothermal conditions. \emph{Mat. Res. Soc. Symp. Proc.} \bold{432}, 317--331. \url{http://lucy.mrs.org/meetings/spring96/Program/S.S96.html} + Seewald, J. S. (1997) Mineral redox buffers and the stability of organic compounds under hydrothermal conditions. \emph{Mat. Res. Soc. Symp. Proc.} \bold{432}, 317--331. \url{http://dx.doi.org/10.1557/PROC-432-317} Seewald, J. S. (2001) Aqueous geochemistry of low molecular weight hydrocarbons at elevated temperatures and pressures: Constraints from mineral buffered laboratory experiments \emph{Geochim. Cosmochim. Acta} \bold{65}, 1641--1664. \url{http://dx.doi.org/10.1016/S0016-7037(01)00544-0} Modified: pkg/CHNOSZ/man/extdata.Rd =================================================================== --- pkg/CHNOSZ/man/extdata.Rd 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/man/extdata.Rd 2015-03-06 01:54:23 UTC (rev 77) @@ -53,7 +53,7 @@ \item \code{Eco.csv.xz} Amino acid compositions of 4407 proteins in \emph{Escherichia coli} strain K12. Format is the one used \code{\link{thermo}$protein}, with columns \samp{protein} holding the gene name, \samp{organism} set to \samp{ECOLI}, and \code{abbrv} holding the UniProt ID. - The source of data is the file \samp{ECOLI.fas} downloaded from the HAMAP (High-quality Automated and Manual Annotation of microbial Proteomes system) FTP site (Gattiker et al., 2003) (\url{ftp://ftp.expasy.org/databases/hamap/complete_proteomes/fasta/bacteria}) on 2010-09-25. + The source of data is the file \samp{ECOLI.fas} downloaded from the HAMAP (High-quality Automated and Manual Annotation of microbial Proteomes system) FTP site (Gattiker et al., 2003) on 2010-09-25 (old URL: \code{ftp://ftp.expasy.org/databases/hamap/complete_proteomes/fasta/bacteria}) . } @@ -109,11 +109,11 @@ Gattiker, A., Michoud, K., Rivoire, C., Auchincloss, A. H., Coudert, E., Lima, T., Kersey, P., Pagni, M., Sigrist, C. J. A., Lachaize, C., Veuthey, A.-L., Gasteiger, E. and Bairoch, A. (2003) Automatic annotation of microbial proteomes in Swiss-Prot. \emph{Comput. Biol. Chem.} \bold{27}, 49--58. \url{http://dx.doi.org/10.1016/S1476-9271(02)00094-4} - Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \url{http://dx.doi.org/10.1038/nature01977} + Gaucher, E. A., Thomson, J. M., Burgan, M. F. and Benner, S. A (2003) Inferring the palaeoenvironment of ancient bacteria on the basis of resurrected proteins. \emph{Nature} \bold{425}(6955), 285--288. \code{http://dx.doi.org/10.1038/nature01977} - Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \url{http://dx.doi.org/10.1038/nature02046} + Ghaemmaghami, S., Huh, W., Bower, K., Howson, R. W., Belle, A., Dephoure, N., O'Shea, E. K. and Weissman, J. S. (2003) Global analysis of protein expression in yeast. \emph{Nature} \bold{425}(6959), 737--741. \code{http://dx.doi.org/10.1038/nature02046} - Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \url{http://dx.doi.org/10.1038/nature02026} + Huh, W. K., Falvo, J. V., Gerke, L. C., Carroll, A. S., Howson, R. W., Weissman, J. S. and O'Shea, E. K. (2003) Global analysis of protein localization in budding yeast. \emph{Nature} \bold{425}(6959), 686--691. \code{http://dx.doi.org/10.1038/nature02026} HAMAP system. HAMAP FTP directory, \url{ftp://ftp.expasy.org/databases/hamap/} Modified: pkg/CHNOSZ/man/water.Rd =================================================================== --- pkg/CHNOSZ/man/water.Rd 2015-03-01 17:01:52 UTC (rev 76) +++ pkg/CHNOSZ/man/water.Rd 2015-03-06 01:54:23 UTC (rev 77) @@ -159,7 +159,7 @@ \references{ - Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-Huckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{http://www.nist.gov/srd/PDFfiles/jpcrd383.pdf} + Archer, D. G. and Wang, P. M. (1990) The dielectric constant of water and Debye-Huckel limiting law slopes. \emph{J. Phys. Chem. Ref. Data} \bold{19}, 371--411. \url{http://www.nist.gov/data/PDFfiles/jpcrd383.pdf} Haar, L., Gallagher, J. S. and Kell, G. S. (1984) \emph{NBS/NRC Steam Tables}. Hemisphere, Washington, D. C., 320 p. \url{http://www.worldcat.org/oclc/301304139} @@ -169,7 +169,7 @@ Johnson, J. W., Oelkers, E. H. and Helgeson, H. C. (1992) 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\eqn{^{\circ}}{?}C. \emph{Comp. Geosci.} \bold{18}, 899--947. \url{http://dx.doi.org/10.1016/0098-3004(92)90029-Q} - Levelt-Sengers, J. M. H., Kamgarparsi, B., Balfour, F. W. and Sengers, J. V. (1983) Thermodynamic properties of steam in the critical region. \emph{J. Phys. Chem. Ref. Data} \bold{12}, 1--28. \url{http://www.nist.gov/srd/PDFfiles/jpcrd214.pdf} + Levelt-Sengers, J. M. H., Kamgarparsi, B., Balfour, F. W. and Sengers, J. V. (1983) Thermodynamic properties of steam in the critical region. \emph{J. Phys. Chem. Ref. Data} \bold{12}, 1--28. \url{http://www.nist.gov/data/PDFfiles/jpcrd214.pdf} Wagner, W. and Pruss, 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} From noreply at r-forge.r-project.org Fri Mar 6 07:52:51 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 6 Mar 2015 07:52:51 +0100 (CET) Subject: [CHNOSZ-commits] r78 - in pkg/CHNOSZ: . R inst inst/tests Message-ID: <20150306065251.F41EA183EDE@r-forge.r-project.org> Author: jedick Date: 2015-03-06 07:52:51 +0100 (Fri, 06 Mar 2015) New Revision: 78 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/util.misc.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/inst/tests/test-IAPWS95.R pkg/CHNOSZ/inst/tests/test-affinity.R pkg/CHNOSZ/inst/tests/test-findit.R pkg/CHNOSZ/inst/tests/test-ionize.aa.R pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R pkg/CHNOSZ/inst/tests/test-revisit.R pkg/CHNOSZ/inst/tests/test-subcrt.R pkg/CHNOSZ/inst/tests/test-water.R pkg/CHNOSZ/inst/tests/test-wjd.R Log: use named 'tolerance' argument in expect_equal() tests Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/DESCRIPTION 2015-03-06 06:52:51 UTC (rev 78) @@ -1,6 +1,6 @@ Date: 2015-03-06 Package: CHNOSZ -Version: 1.0.3-15 +Version: 1.0.3-16 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/util.misc.R =================================================================== --- pkg/CHNOSZ/R/util.misc.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/R/util.misc.R 2015-03-06 06:52:51 UTC (rev 78) @@ -84,7 +84,7 @@ proptable[[i]] <- myprops if(didit) ndid <- ndid + 1 } - if(ndid > 0) cat(paste('nonideal:',ndid,'species were nonideal\n')) + if(ndid > 0) msgout(paste('nonideal:',ndid,'species were nonideal\n')) return(proptable) } Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/NEWS 2015-03-06 06:52:51 UTC (rev 78) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.3-15 (2015-03-06) +CHANGES IN CHNOSZ 1.0.3-16 (2015-03-06) --------------------------------------- - Add files with average amino acid compositions of proteins from Bison Modified: pkg/CHNOSZ/inst/tests/test-IAPWS95.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-IAPWS95.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-IAPWS95.R 2015-03-06 06:52:51 UTC (rev 78) @@ -31,7 +31,7 @@ expect_equal(residual.calc.1, residual.ref.1, check.attributes=FALSE) expect_equal(idealgas.calc.2, idealgas.ref.2, check.attributes=FALSE) # ... however an offset is apparent in the value of the residual phi.delta.delta for case 2 - expect_equal(residual.calc.2, residual.ref.2, check.attributes=FALSE, tol=1e-5) + expect_equal(residual.calc.2, residual.ref.2, check.attributes=FALSE, tolerance=1e-5) }) test_that("calculations of thermodynamic properties are consistent with reference values", { @@ -58,21 +58,21 @@ vapor.calc <- IAPWS95(p, T, rho.vapor) ## the tests # take P to 5 significant digits but not more than 6 decimals - expect_equal(round(signif(liquid.calc$p, 5), 6), P.ref, tol=1e-3) - expect_equal(round(signif(vapor.calc$p, 5), 6), P.ref, tol=1e-4) + expect_equal(round(signif(liquid.calc$p, 5), 6), P.ref, tolerance=1e-3) + expect_equal(round(signif(vapor.calc$p, 5), 6), P.ref, tolerance=1e-4) # take H to 6 significant digits but not more than 3 decimals - expect_equal(round(signif(liquid.calc$h, 6), 3), H.liquid.ref, tol=1e-5) + expect_equal(round(signif(liquid.calc$h, 6), 3), H.liquid.ref, tolerance=1e-5) expect_that(round(signif(vapor.calc$h, 6), 3), equals(H.vapor.ref)) # spot on! # round S to 4 decimals expect_that(round(liquid.calc$s, 4), equals(S.liquid.ref)) # spot on! - expect_equal(round(vapor.calc$s, 4), S.vapor.ref, tol=1e-4) + expect_equal(round(vapor.calc$s, 4), S.vapor.ref, tolerance=1e-4) # round cv to 4 decimals - expect_equal(round(liquid.calc$cv, 4), cv.liquid.ref, tol=1e-4) - expect_equal(round(vapor.calc$cv, 4), cv.vapor.ref, tol=1e-4) + expect_equal(round(liquid.calc$cv, 4), cv.liquid.ref, tolerance=1e-4) + expect_equal(round(vapor.calc$cv, 4), cv.vapor.ref, tolerance=1e-4) # take cp to 5 significant digits but not more than 4 decimals # note high tolerance setting: the highest temperature is the challenge - expect_equal(round(signif(liquid.calc$cp, 5), 4), cp.liquid.ref, tol=1e0) - expect_equal(round(signif(vapor.calc$cp, 5), 4), cp.vapor.ref, tol=1e-1) + expect_equal(round(signif(liquid.calc$cp, 5), 4), cp.liquid.ref, tolerance=1e0) + expect_equal(round(signif(vapor.calc$cp, 5), 4), cp.vapor.ref, tolerance=1e-1) }) test_that("calculations are possible at low temperatures", { Modified: pkg/CHNOSZ/inst/tests/test-affinity.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-affinity.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-affinity.R 2015-03-06 06:52:51 UTC (rev 78) @@ -110,7 +110,7 @@ A.2303RT_max <- apply(A.2303RT, 2, max) # we're off a bit in the second decimal ... # maybe becuase of rounding of the aa composition? - expect_equal(A.2303RT_max, A.2303RT_ref, 1e-3) + expect_equal(A.2303RT_max, A.2303RT_ref, tolerance=1e-3) # todo: add comparison with results from loading proteins via species() }) @@ -125,15 +125,15 @@ basis("CHNOS") # try it with iprotein ip <- iprotein("CSG_HALJP") - expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.nonionized, 1e-6) + expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.nonionized, tolerance=1e-6) # then with the protein loaded as a species species("CSG_HALJP") - expect_equal(affinity()$values[[1]][1], A.2303RT.nonionized, 1e-6) + expect_equal(affinity()$values[[1]][1], A.2303RT.nonionized, tolerance=1e-6) # now for ionized protein basis("CHNOS+") - expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.ionized, 1e-6) + expect_equal(affinity(iprotein=ip)$values[[1]][1], A.2303RT.ionized, tolerance=1e-6) species("CSG_HALJP") - expect_equal(affinity()$values[[1]][1], A.2303RT.ionized, 1e-6) + expect_equal(affinity()$values[[1]][1], A.2303RT.ionized, tolerance=1e-6) }) test_that("affinity() for proteins keeps track of pH on 2-D calculations", { Modified: pkg/CHNOSZ/inst/tests/test-findit.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-findit.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-findit.R 2015-03-06 06:52:51 UTC (rev 78) @@ -33,9 +33,9 @@ # sanity check: the output values are all the same length expect_equal(length(unique(sapply(f$value, length))), 1) # -pi, -e and -sqrt(2) were approximately retrieved! - expect_equal(tail(f$value[[1]],1), -pi, tol=1e-2) - expect_equal(tail(f$value[[2]],1), -exp(1), tol=1e-2) - expect_equal(tail(f$value[[3]],1), -sqrt(2), tol=1e-1) + expect_equal(tail(f$value[[1]],1), -pi, tolerance=1e-2) + expect_equal(tail(f$value[[2]],1), -exp(1), tolerance=1e-2) + expect_equal(tail(f$value[[3]],1), -sqrt(2), tolerance=1e-1) # we could decrease the tolerance by increasing the resolution and/or iterations in findit() }) Modified: pkg/CHNOSZ/inst/tests/test-ionize.aa.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-ionize.aa.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-ionize.aa.R 2015-03-06 06:52:51 UTC (rev 78) @@ -40,10 +40,10 @@ pH <- c(4, 6, 8, 10, 12, 14) # the literature values are significantly different at this tolerance (the following is not TRUE) # expect_equal(Z.LYSC_CHICK.25, Z.LYSC_CHICK.100, 1e-1) - expect_equal(ionize.aa(aa, pH=pH, T=25)[, 1], Z.LYSC_CHICK.25, 1e-1, check.attributes=FALSE) - expect_equal(ionize.aa(aa, pH=pH, T=100)[, 1], Z.LYSC_CHICK.100, 1e-1, check.attributes=FALSE) - expect_equal(ionize.aa(aa, pH=pH, T=150)[, 1], Z.LYSC_CHICK.150, 1e-1, check.attributes=FALSE) - expect_equal(ionize.aa(aa, pH=pH, T=25, suppress.Cys=TRUE)[, 1], Z.LYSC_CHICK.25_oxid, 1e-2, check.attributes=FALSE) + expect_equal(ionize.aa(aa, pH=pH, T=25)[, 1], Z.LYSC_CHICK.25, tolerance=1e-1, check.attributes=FALSE) + expect_equal(ionize.aa(aa, pH=pH, T=100)[, 1], Z.LYSC_CHICK.100, tolerance=1e-1, check.attributes=FALSE) + expect_equal(ionize.aa(aa, pH=pH, T=150)[, 1], Z.LYSC_CHICK.150, tolerance=1e-1, check.attributes=FALSE) + expect_equal(ionize.aa(aa, pH=pH, T=25, suppress.Cys=TRUE)[, 1], Z.LYSC_CHICK.25_oxid, tolerance=1e-2, check.attributes=FALSE) }) test_that("heat capacity and Gibbs energy of ionization are consistent with literature", { @@ -58,8 +58,8 @@ Cp.ionization.pH12 <- ionize.aa(aa, "Cp", T=c(60, 80, 100, 120, 140), pH=12) # the literature values are significantly different at this tolerance (the following is not TRUE) # expect_equal(Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion, Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion, 1e-2) - expect_equal(Cp.ionization.pH6[,1], (Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion)*1000, 1e-2, check.attributes=FALSE) - expect_equal(Cp.ionization.pH12[,1], (Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion)*1000, 1e-2, check.attributes=FALSE) + expect_equal(Cp.ionization.pH6[,1], (Cp.AMYA_PYRFU.pH6 - Cp.AMYA_PYRFU.nonion)*1000, tolerance=1e-2, check.attributes=FALSE) + expect_equal(Cp.ionization.pH12[,1], (Cp.AMYA_PYRFU.pH12 - Cp.AMYA_PYRFU.nonion)*1000, tolerance=1e-2, check.attributes=FALSE) # Gibbs energy (Mcal mol-1) of AMY_BACSU at pH 0, 2, 4, 6, 8, 10, 12, 14 at 25 and 100 degrees # digitized from Fig. 12 of Dick et al., 2006 G.AMY_BACSU.25 <- c(-24.9, -24.9, -24.7, -24.5, -24.4, -23.9, -23.5, -23.2) @@ -70,8 +70,8 @@ aa <- ip2aa(iprotein("AMY_BACSU")) G.ionization.25 <- ionize.aa(aa, "G", T=25, pH=seq(0, 14, 2))[,1] G.ionization.100 <- ionize.aa(aa, "G", T=100, pH=seq(0, 14, 2))[,1] - expect_equal(G.nonionized[1] + G.ionization.25, G.AMY_BACSU.25 * 1e6, 1e-3, check.attributes=FALSE) - expect_equal(G.nonionized[2] + G.ionization.100, G.AMY_BACSU.100 * 1e6, 1e-3, check.attributes=FALSE) + expect_equal(G.nonionized[1] + G.ionization.25, G.AMY_BACSU.25 * 1e6, tolerance=1e-3, check.attributes=FALSE) + expect_equal(G.nonionized[2] + G.ionization.100, G.AMY_BACSU.100 * 1e6, tolerance=1e-3, check.attributes=FALSE) # restore thermo$obigt to original state data(thermo) }) Modified: pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-ionize.aa_pK.R 2015-03-06 06:52:51 UTC (rev 78) @@ -13,15 +13,15 @@ `[AABB-]`= c(10.16,7.85, 6.51, 6.28)) this.pK <- ionize.aa(T=c(0, 100, 200, 300), ret.val="pK") # ionization of [Cys] and [His] is off more than the others - expect_equal(this.pK[, 1], DLH06.pK$`[Cys-]`, 1e-1, check.attributes=FALSE) - expect_equal(this.pK[, 2], DLH06.pK$`[Asp-]`, 1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 3], DLH06.pK$`[Glu-]`, 1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 4], DLH06.pK$`[His+]`, 1e-1, check.attributes=FALSE) - expect_equal(this.pK[, 5], DLH06.pK$`[Lys+]`, 1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 6], DLH06.pK$`[Arg+]`, 1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 7], DLH06.pK$`[Tyr-]`, 1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 8], DLH06.pK$`[AABB+]`,1e-2, check.attributes=FALSE) - expect_equal(this.pK[, 9], DLH06.pK$`[AABB-]`,1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 1], DLH06.pK$`[Cys-]`, tolerance=1e-1, check.attributes=FALSE) + expect_equal(this.pK[, 2], DLH06.pK$`[Asp-]`, tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 3], DLH06.pK$`[Glu-]`, tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 4], DLH06.pK$`[His+]`, tolerance=1e-1, check.attributes=FALSE) + expect_equal(this.pK[, 5], DLH06.pK$`[Lys+]`, tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 6], DLH06.pK$`[Arg+]`, tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 7], DLH06.pK$`[Tyr-]`, tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 8], DLH06.pK$`[AABB+]`,tolerance=1e-2, check.attributes=FALSE) + expect_equal(this.pK[, 9], DLH06.pK$`[AABB-]`,tolerance=1e-2, check.attributes=FALSE) }) test_that("there is one pK value for each ionizable group at each temperature", { Modified: pkg/CHNOSZ/inst/tests/test-revisit.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-revisit.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-revisit.R 2015-03-06 06:52:51 UTC (rev 78) @@ -50,10 +50,10 @@ r1.qqr <- revisit(e1, "qqr", plot.it=FALSE) # the tests will alert us to significant numerical changes # but so far haven't been independently verified - expect_equal(r1.cv$optimum, 0.30576, tol=1e-5) - expect_equal(r1.sd$optimum, 0.000284694, tol=1e-5) - expect_equal(r1.shannon$optimum, 1.066651, tol=1e-5) - expect_equal(r1.qqr$optimum, 0.999783, tol=1e-5) + expect_equal(r1.cv$optimum, 0.30576, tolerance=1e-5) + expect_equal(r1.sd$optimum, 0.000284694, tolerance=1e-5) + expect_equal(r1.shannon$optimum, 1.066651, tolerance=1e-5) + expect_equal(r1.qqr$optimum, 0.999783, tolerance=1e-5) }) test_that("referenced objectives give expected results", { Modified: pkg/CHNOSZ/inst/tests/test-subcrt.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-subcrt.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-subcrt.R 2015-03-06 06:52:51 UTC (rev 78) @@ -61,14 +61,14 @@ # 4(2-)propanol(aq) + 3CO2(aq) + 2H2O(l) = 3CH4(aq) + 4lactic acid(aq) sout.E12 <- subcrt(c("2-propanol", "CO2", "H2O", "CH4", "lactic acid"), c(-4, -3, -2, 3, 4), T=T)$out # now the tests, tolerances set to lowest order of magnitute to pass - expect_equal(sout.H2O$G/1000, DG0.H2O, 1e-4) - expect_equal(sout.A1$G/1000, DG0.A1, 1e-4) + expect_equal(sout.H2O$G/1000, DG0.H2O, tolerance=1e-4) + expect_equal(sout.A1$G/1000, DG0.A1, tolerance=1e-4) # greater tolerance, our values for NO(aq) differ slightly from AS01 - expect_equal(sout.NO$G/1000, DG0.NO.aq - DG0.NO.g, 1e-2) - expect_equal(sout.B10$G/1000, DG0.B10, 1e-3) + expect_equal(sout.NO$G/1000, DG0.NO.aq - DG0.NO.g, tolerance=1e-2) + expect_equal(sout.B10$G/1000, DG0.B10, tolerance=1e-3) # we can check that sulfur has expected phase transitions expect_equal(s.C7$state$sulfur, c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3)) - expect_equal(sout.C7$G/1000, DG0.C7, 1e-4) + expect_equal(sout.C7$G/1000, DG0.C7, tolerance=1e-4) # this one is on hold until the HKF parameters of 2-propanol can be located #expect_equal(sout.E12$G/1000, DG0.E12, 1e-4) # also todo: COS(g) in Amend and Helgeson, 2001 Table 7.2? Modified: pkg/CHNOSZ/inst/tests/test-water.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-water.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-water.R 2015-03-06 06:52:51 UTC (rev 78) @@ -12,8 +12,8 @@ # now compare with some real data from Tables V and VI of Fine and Millero, 1973 T <- convert(c(25, 100), "K") P <- c(100, 1000) - expect_equal(water.SUPCRT92("beta", T, P)[, 1] * 1e6, c(44.100, 37.002), tol=1e-2) - expect_equal(water.SUPCRT92("alpha", T, P)[, 1] * 1e6, c(268.06, 625.55), tol=1e-2) + expect_equal(water.SUPCRT92("beta", T, P)[, 1] * 1e6, c(44.100, 37.002), tolerance=1e-2) + expect_equal(water.SUPCRT92("alpha", T, P)[, 1] * 1e6, c(268.06, 625.55), tolerance=1e-2) }) # reference Modified: pkg/CHNOSZ/inst/tests/test-wjd.R =================================================================== --- pkg/CHNOSZ/inst/tests/test-wjd.R 2015-03-06 01:54:23 UTC (rev 77) +++ pkg/CHNOSZ/inst/tests/test-wjd.R 2015-03-06 06:52:51 UTC (rev 78) @@ -4,7 +4,7 @@ # the values from last column of Table III in the paper X <- c(0.040668, 0.147730, 0.783153, 0.001414, 0.485247, 0.000693, 0.027399, 0.017947, 0.037314, 0.096872) w <- wjd() - expect_equal(X, w$X, tol=1e-4) + expect_equal(X, w$X, tolerance=1e-4) }) test_that("guess() operates on intermediate compositions but fails with endmembers", { @@ -56,7 +56,7 @@ e <- equilibrate(a, loga.balance=log10(sum(Y))) X.open <- 10^unlist(e$loga.equil) # the test: abundances calculated both ways are equal - expect_equal(X.closed, X.open, tol=0.019) + expect_equal(X.closed, X.open, tolerance=0.019) # seems that we could do better than that 1.9% mean difference! }) From noreply at r-forge.r-project.org Fri Mar 6 12:12:22 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 6 Mar 2015 12:12:22 +0100 (CET) Subject: [CHNOSZ-commits] r79 - in pkg/CHNOSZ: . R demo inst man Message-ID: <20150306111223.035A418768C@r-forge.r-project.org> Author: jedick Date: 2015-03-06 12:12:22 +0100 (Fri, 06 Mar 2015) New Revision: 79 Added: pkg/CHNOSZ/demo/solubility.R Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/examples.R pkg/CHNOSZ/R/util.expression.R pkg/CHNOSZ/demo/00Index pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/examples.Rd Log: new demo: solubility.R Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/DESCRIPTION 2015-03-06 11:12:22 UTC (rev 79) @@ -1,6 +1,6 @@ Date: 2015-03-06 Package: CHNOSZ -Version: 1.0.3-16 +Version: 1.0.3-17 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/examples.R =================================================================== --- pkg/CHNOSZ/R/examples.R 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/R/examples.R 2015-03-06 11:12:22 UTC (rev 79) @@ -31,7 +31,7 @@ demos <- function(which=c("sources", "NaCl", "cordierite", "phosphate", "nucleobase", "orp", - "findit", "CO2Ac", "nonideal", "TPX", "mosaic")) { + "findit", "CO2Ac", "nonideal", "TPX", "mosaic", "solubility")) { # 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 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/R/util.expression.R 2015-03-06 11:12:22 UTC (rev 79) @@ -36,7 +36,7 @@ # write a designation of physical state # use the state given in log if it's a gas or neutral aqueous species if(log %in% c("g", "gas")) state <- "g" - else if(!"Z" %in% names(elements)) state <- log + else if(!"Z" %in% names(elements) & !missing(log)) state <- log if(state != "") { # subscript it if we're not in a log expression if(log != "") expr <- substitute(a*group('(',italic(b),')'),list(a=expr, b=state)) Modified: pkg/CHNOSZ/demo/00Index =================================================================== --- pkg/CHNOSZ/demo/00Index 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/demo/00Index 2015-03-06 11:12:22 UTC (rev 79) @@ -9,3 +9,4 @@ nonideal activity coefficient of charged species, using the IS argument of subcrt TPX metastablilities of selected ionized bacterial thiol peroxidases as a chemical activity buffer mosaic Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species +solubility solubility of calicite or CO2(gas) as a function of pH Added: pkg/CHNOSZ/demo/solubility.R =================================================================== --- pkg/CHNOSZ/demo/solubility.R (rev 0) +++ pkg/CHNOSZ/demo/solubility.R 2015-03-06 11:12:22 UTC (rev 79) @@ -0,0 +1,83 @@ +# demo showing how to calculate CO2(gas) or calcite solubility and aqueous carbonate speciation +# the affinity() ... equilibrate() sequence in CHNOSZ gives *metastable equilibrium activities* +# (activities for a total activity of the balanced component given in loga.balance) ... +# here we are interested in finding the value of loga.balance itself +# (the total activity of [CO2, HCO3-, CO3-2] species in the aqueous phase). +# this total activity is the solubility of CO2(gas) or calcite if the affinities of the +# aqueous species as formed from CO2(gas) or calcite are all equal to zero. +# note that the affinities for species in metastable equilibrium are all equal. +# Afun() calculates the metastable equilibrium affinities for a given loga.balance +# and uniroot() finds the loga.balance where they are zero +# additionally, if we are reacting calcite, the activity of Ca+2 should be set equal to loga.balance + +# for comparison with published calcite solubility plot, see Fig. 4A in +# Manning et al., 2013, Reviews in Mineralogy & Geochemistry, v. 75, pp. 109-148 +# (doi: 10.2138/rmg.2013.75.5) + +# for comparison with published CO2 solubility plot, see Fig. 4.5 in +# Stumm and Morgan, 1996, Aquatic Chemistry: Chemical Equilibria and Rates in Natural Waters +# (New York: John Wiley & Sons), 3rd edition + +# set this to CO2 or calcite +#what <- "CO2" +what <- "calcite" + +# function to return the affinity of the metastable equilibrium species +Afun <- function(loga.balance=-3, T=25) { + if(what=="calcite") basis("Ca+2", loga.balance) + a <- affinity(T=T) + e <- equilibrate(a, loga.balance=loga.balance) + # set metastable activities and re-calculate the affinity + species(1:3, unlist(e$loga.equil)) + a <- affinity(T=T) + # check they're actually equal + stopifnot(all(abs(unlist(a$values) - a$values[[1]]) < 1e-10)) + return(a$values[[1]]) +} + +# set up system +if(what=="CO2") { + basis("CHNOS+") + basis("CO2", "gas") + # ca. atmospheric PCO2 + basis("CO2", -3.5) +} else if(what=="calcite") { + basis(c("calcite", "Ca+2", "H2O", "O2", "H+")) +} +species(c("CO2", "HCO3-", "CO3-2")) +T <- 25 +# decrease this for higher resolution +pHstep <- 1 + +# where we'll store the results +loga.tot <- numeric() +loga.CO2 <- loga.HCO3 <- loga.CO3 <- numeric() + +# loop over pH range +pHs <- seq(0, 14, pHstep) +for(pH in pHs) { + print(paste("pH =", pH)) + basis("pH", pH) + # this is for the solubility + loga.balance <- suppressMessages(uniroot(Afun, c(-10, 10), T=T)$root) + loga.tot <- c(loga.tot, loga.balance) + # this is for the speciation + if(what=="calcite") basis("Ca+2", loga.balance) + a <- affinity(T=T) + e <- equilibrate(a, loga.balance=loga.balance) + loga <- unlist(e$loga.equil) + loga.CO2 <- c(loga.CO2, loga[1]) + loga.HCO3 <- c(loga.HCO3, loga[2]) + loga.CO3 <- c(loga.CO3, loga[3]) +} + +# make plot +ylim <- c(-10, 4) +thermo.plot.new(xlim=range(pHs), ylim=ylim, xlab="pH", ylab="log a") +lines(pHs, loga.tot, lwd=3) +lines(pHs, loga.CO2, lwd=2) +lines(pHs, loga.HCO3, lty=2, lwd=2) +lines(pHs, loga.CO3, lty=3, lwd=2) +legend(ifelse(what=="calcite", "topright", "topleft"), lty=c(1, 1:3), lwd=c(3, 2, 2, 2), + 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))) Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/inst/NEWS 2015-03-06 11:12:22 UTC (rev 79) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.3-16 (2015-03-06) +CHANGES IN CHNOSZ 1.0.3-17 (2015-03-06) --------------------------------------- - Add files with average amino acid compositions of proteins from Bison @@ -50,6 +50,8 @@ - Add thermo$opt$varP option as a flag for subcrt() to calculate Gibbs energies of gases using a variable-pressure standard state. +- Add 'solubility.R' demo. + CHANGES IN CHNOSZ 1.0.3 (2014-01-12) ------------------------------------ Modified: pkg/CHNOSZ/man/examples.Rd =================================================================== --- pkg/CHNOSZ/man/examples.Rd 2015-03-06 06:52:51 UTC (rev 78) +++ pkg/CHNOSZ/man/examples.Rd 2015-03-06 11:12:22 UTC (rev 79) @@ -15,7 +15,7 @@ examples(do.png = FALSE) demos(which = c("sources", "NaCl", "cordierite", "phosphate", "nucleobase", "orp", "findit", - "CO2Ac", "nonideal", "TPX", "mosaic")) + "CO2Ac", "nonideal", "TPX", "mosaic", "solubility")) } \details{ @@ -41,6 +41,7 @@ \code{nonideal} \tab activity coefficient of charged species (Alberty, 2003), using the \code{IS} argument of \code{subcrt} \cr \code{TPX} \tab metastablilities of selected ionized bacterial thiol peroxidases as a chemical activity buffer \cr \code{mosaic} \tab Eh-pH diagram for iron oxides, sulfides and carbonate with two sets of changing basis species (Garrels and Christ, 1965) \cr + \code{solubility} \tab solubility of calcite (cf. Manning et al., 2013 Fig. 4A) or CO2(gas) (cf. Stumm and Morgan, 1996 Fig 4.5) as a function of pH \cr } } @@ -50,7 +51,11 @@ Garrels, R. M. and Christ, C. L. (1965) \emph{Solutions, Minerals, and Equilibria}, Harper & Row, New York, 450 p. \url{http://www.worldcat.org/oclc/517586} + 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} + 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} } From noreply at r-forge.r-project.org Tue Mar 10 17:00:18 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 10 Mar 2015 17:00:18 +0100 (CET) Subject: [CHNOSZ-commits] r80 - in pkg/CHNOSZ: . R inst man vignettes Message-ID: <20150310160018.9A9DB1878EF@r-forge.r-project.org> Author: jedick Date: 2015-03-10 17:00:18 +0100 (Tue, 10 Mar 2015) New Revision: 80 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/equilibrate.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/man/equilibrate.Rd pkg/CHNOSZ/man/protein.info.Rd pkg/CHNOSZ/man/util.fasta.Rd pkg/CHNOSZ/vignettes/anintro.Rnw pkg/CHNOSZ/vignettes/anintro.lyx Log: update anintro.Rnw vignette Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/DESCRIPTION 2015-03-10 16:00:18 UTC (rev 80) @@ -1,6 +1,6 @@ -Date: 2015-03-06 +Date: 2015-03-10 Package: CHNOSZ -Version: 1.0.3-17 +Version: 1.0.3-18 Title: Chemical Thermodynamics and Activity Diagrams Author: Jeffrey Dick Maintainer: Jeffrey Dick Modified: pkg/CHNOSZ/R/equilibrate.R =================================================================== --- pkg/CHNOSZ/R/equilibrate.R 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/R/equilibrate.R 2015-03-10 16:00:18 UTC (rev 80) @@ -233,7 +233,8 @@ # "length" - balanced on sequence length of proteins # (default if balance is missing and all species are proteins) # 1 - balanced on one mole of species - # numeric vector - uesr-defined n.balance + # numeric vector - user-defined n.balance + # "volume" - standard-state volume listed in thermo$obigt # the index of the basis species that might be balanced ibalance <- numeric() # deal with proteins @@ -259,6 +260,10 @@ n.balance <- protein.length(aout$species$name) balance.description <- "protein length" msgout(paste("balance: coefficients are", balance.description, "\n")) + } else if(identical(balance, "volume")) { + n.balance <- info(aout$species$ispecies, check.it=FALSE)$V + balance.description <- "volume" + msgout(paste("balance: coefficients are", balance.description, "\n")) } else { # is the balance the name of a basis species? if(length(ibalance)==0) { Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/inst/NEWS 2015-03-10 16:00:18 UTC (rev 80) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.0.3-17 (2015-03-06) +CHANGES IN CHNOSZ 1.0.3-18 (2015-03-10) --------------------------------------- - Add files with average amino acid compositions of proteins from Bison @@ -50,7 +50,7 @@ - Add thermo$opt$varP option as a flag for subcrt() to calculate Gibbs energies of gases using a variable-pressure standard state. -- Add 'solubility.R' demo. +- Add 'solubility.R' demo and calcite solubility plot to anintro.Rnw. CHANGES IN CHNOSZ 1.0.3 (2014-01-12) ------------------------------------ Modified: pkg/CHNOSZ/man/equilibrate.Rd =================================================================== --- pkg/CHNOSZ/man/equilibrate.Rd 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/man/equilibrate.Rd 2015-03-10 16:00:18 UTC (rev 80) @@ -58,7 +58,7 @@ \code{ispecies} can be supplied to identify a subset of the species to include in the calculation. -\code{equil.boltzmann} is used to calculation the equilibrium activities if \code{balance} is \samp{1} (including the normalized result when \code{normalize} is TRUE), otherwise \code{equil.reaction} is called. +\code{equil.boltzmann} is used to calculate the equilibrium activities if \code{balance} is \samp{1} (including the normalized result when \code{normalize} is TRUE), otherwise \code{equil.reaction} is called. } Modified: pkg/CHNOSZ/man/protein.info.Rd =================================================================== --- pkg/CHNOSZ/man/protein.info.Rd 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/man/protein.info.Rd 2015-03-10 16:00:18 UTC (rev 80) @@ -122,13 +122,14 @@ \donttest{## using protein.formula: average oxidation state of ## carbon of proteins from different organisms +# after Dick, 2014 (see Supporting Information to make plot with more groups) # 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)) # only use those organisms with a certain # number of sequenced bases -ip <- ip[as.numeric(thermo$protein$abbrv[ip]) > 100000] +ip <- ip[as.numeric(thermo$protein$abbrv[ip]) > 50000] pf <- protein.formula(thermo$protein[ip, ]) zc <- ZC(pf) # the organism names we search for @@ -153,6 +154,8 @@ } \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} + 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} 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} Modified: pkg/CHNOSZ/man/util.fasta.Rd =================================================================== --- pkg/CHNOSZ/man/util.fasta.Rd 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/man/util.fasta.Rd 2015-03-10 16:00:18 UTC (rev 80) @@ -75,6 +75,7 @@ } \seealso{ +\code{\link{seq2aa}}, like \code{count.aa}, counts amino acids in a user-input sequence, but returns a data frame in the format of \code{thermo$protein}. \code{\link{nucleic.formula}} for an example of counting nucleobases in a DNA sequence. When computing relative abundances of many proteins that might be found with \code{grep.file} and \code{read.fasta}, consider using the \code{iprotein} arugment of \code{\link{affinity}} to speed things up; for an example see the help page for \code{\link{revisit}}. } Modified: pkg/CHNOSZ/vignettes/anintro.Rnw =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rnw 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/vignettes/anintro.Rnw 2015-03-10 16:00:18 UTC (rev 80) @@ -1,12 +1,12 @@ -%% LyX 2.0.5 created this file. For more info, see http://www.lyx.org/. +%% LyX 2.1.3 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are doing. -\documentclass[noae,round]{article} +\documentclass[english,noae,round]{article} \usepackage{mathpazo} \usepackage[T1]{fontenc} -\usepackage[latin9]{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} @@ -102,10 +102,8 @@ the species of interest for relative stability calculations, calculate the affinities of formation reactions of the species of interest under reference (non-equilibrium) conditions, calculate the equilibrium -chemical activities, and finally plot the results;% -\footnote{\texttt{equilibrate()} appeared in version 0.9-9 of CHNOSZ. In previous -versions, the equilibrium calculations were invoked by calls to \texttt{diagram()}.% -} +chemical activities, and finally plot the results;\footnote{\texttt{equilibrate()} appeared in version 0.9-9 of CHNOSZ. In previous +versions, the equilibrium calculations were invoked by calls to \texttt{diagram()}.} \item using \texttt{revisit()} to calculate/plot statistics of the chemical activities of the species of interest and \texttt{findit()} to search for combinations of activities of basis species, temperature and/or @@ -135,7 +133,6 @@ install.packages("CHNOSZ") @ - Then load the CHNOSZ package to make its functions available in your working session. @@ -143,7 +140,6 @@ library(CHNOSZ) @ - Then load the \texttt{thermo} object, which contains the thermodynamic database and is also where your system settings will be stored. @@ -151,7 +147,6 @@ data(thermo) @ - The rest of this document assumes that the CHNOSZ package and data are loaded. @@ -171,7 +166,6 @@ info("ethylene") @ - There are two species named ``ethylene'' in the database. Normally, \texttt{info()} gives preference to aqueous species if they exist, so in this case we find that aqueous ethylene is species number 88 @@ -182,7 +176,6 @@ info(88) @ - If you were instead interested in the properties of the gas, you could run: @@ -190,7 +183,6 @@ info("ethylene","gas") @ - \texttt{info()} itself is used by other functions in the package. It prints output to the screen, but also returns a numeric value if it finds a species matching the search term. So, we can retrieve the @@ -203,7 +195,6 @@ @ - \subsection{\texttt{thermo\$refs}} The thermodynamic data and other parameters used by the functions, @@ -214,7 +205,6 @@ summary(thermo) @ - Within this list, the thermodynamic database is contained in a data frame (an R object that is like a matrix with named columns), \texttt{thermo\$obigt}, and the references to the original sources of thermodynamic data in @@ -230,7 +220,6 @@ browse.refs(88) @ - \texttt{browse.refs: opening URL for SH90 (E. L. Shock and H. C. Helgeson, \citeyear{SH90})} @@ -243,7 +232,6 @@ info("acid") @ - Here, \texttt{info()} couldn't find an exact match to a name, so it performed a fuzzy search. That's why ``uracil'' and ``metacinnabar'' show up above. If you really just want species whose names include @@ -256,7 +244,6 @@ info(" acid") @ - The names of species other than proteins use (almost) exclusively lowercase letters. \texttt{info()} can also be used to search the text of the chemical formulas as they are entered in the database; @@ -269,7 +256,6 @@ @ - \section{Proteins} @@ -287,7 +273,6 @@ aa2eos(aa) @ - What happened there? Well, the first line found the row number (6) of \texttt{thermo\$protein} that contains the amino acid composition of LYSC\_CHICK. The second line extracted as a data frame. The third @@ -302,7 +287,6 @@ @ - \subsection{\texttt{info()}} Most of the time you probably won't be using the \texttt{iprotein()} @@ -316,7 +300,6 @@ info(si) @ - When CHNOSZ is first loaded, the thermodynamic properties and parameters of the proteins are not present in \texttt{thermo\$obigt}. Therefore, the first call to\texttt{ info()} just above had a side effect of @@ -343,7 +326,6 @@ subcrt("water") @ - The columns in the output are temperature ($^{\circ}$C), pressure (bar), density of water (g cm$^{-3}$), logarithm of the equilibrium constant (only meaningful for reactions; see below), and standard @@ -368,7 +350,6 @@ subcrt(c("C2H5OH","O2","CO2","H2O"),c(-1,-3,2,3),T=37) @ - For historical reasons (i.e., the prevalence of the use of oxygen fugacity in geochemical modeling; \citealp{And05}), $\mathrm{O_{2}}$ breaks the general rule in CHNOSZ that species whose states are not @@ -382,22 +363,18 @@ subcrt(c("C2H5OH","O2","CO2","H2O"),c(-1,-3,2,3),c("aq","aq","aq","liq"),T=37) @ - A useful feature of \texttt{subcrt()} is that it emits a warning if the reaction is not balanced. Let's say you forgot to account for -oxygen on the left-hand side of the reaction% -\footnote{This example is motivated by the unbalanced reaction found at the +oxygen on the left-hand side of the reaction\footnote{This example is motivated by the unbalanced reaction found at the \href{http://en.wikipedia.org/wiki/Ethanol_metabolism}{Wikipedia entry on ethanol metabolism} on 2010-09-23 and still present as of 2011-08-15: ``Complete Reaction: C$_{2}$H$_{6}$O(Ethanol)$\rightarrow$C$_{2}$H$_{4}$O(Acetaldehyde)$\rightarrow$C$_{2}$H$_{4}$O$_{2}$(acetic -Acid) $\rightarrow$Acetyl-CoA$\rightarrow$3H$_{2}$O+2CO$_{2}$''.% -}. +Acid) $\rightarrow$Acetyl-CoA$\rightarrow$3H$_{2}$O+2CO$_{2}$''.}. <>= subcrt(c("C2H5OH","CO2","H2O"),c(-1,2,3),T=37) @ - The function still reports the results of the calculations, but use them very cautiously (only if you have a specific reason for writing an unbalanced reaction). In the next section we'll see how to use @@ -424,7 +401,6 @@ <>= basis(c("CO2","H2O","NH3","H2S","H+")) @ - \begin{lyxcode} Error~in~put.basis(basis,~mystates)~:~ @@ -446,7 +422,6 @@ basis(c("CO2","H2O","NH3","O2","H2S","H+")) @ - First basis definition! Note the column names, which give CHNOSZ its name. These represent the elements in the commonly-occurring amino acids, together with charge, denoted by ``Z''. @@ -461,7 +436,6 @@ subcrt(c("C2H5OH","CO2","H2O"),c(-1,2,3),T=37) @ - Here, \texttt{subcrt()} detected an unbalanced reaction, but since the missing element was among the elements of the basis species, it added the appropriate amount of $\mathrm{O_{2}}_{\left(gas\right)}$ @@ -473,7 +447,6 @@ subcrt(c("C2H5OH"),c(-1),T=37) @ - What if you were interested in the thermodynamic properties of the reaction of ethanol to acetaldehyde, but didn't want to balance the reaction yourself (and you also didn't know how the formulas of the @@ -483,7 +456,6 @@ subcrt(c("ethanol","acetaldehyde"),c(-1,1),T=37) @ - Notice how 2 H's needed to be added to the right-hand side of the reaction; in our definition of basis species this comes out to $\mathrm{H_{2}O}-0.5\mathrm{O_{2}}$. With a different choice of basis species, but the same elements, the @@ -498,7 +470,6 @@ subcrt(c("ethanol","acetaldehyde"),c(-1,1),T=37) @ - In this case, the function finds that 2 H's are the compositional equivalent of $0.5\mathrm{C_{6}H_{13}NO_{2}}-0.125\mathrm{C_{6}H_{14}N_{2}O_{2}}-0.250\mathrm{C_{9}H_{11}NO_{3}}$. It's pretty easy for the computer to figure that out using matrix @@ -523,7 +494,6 @@ subcrt("LYSC_CHICK",1,T=25) @ - Note that using the keyword argument in \texttt{basis()} also set the logarithms of activities (or fugacity in the case of $\mathrm{O_{2}}_{\left(g\right)}$) to nominal values. While these settings do not affect the results @@ -531,64 +501,17 @@ the standard molal properties of the reaction), they are essential for calculating the relative stabilities of the species of interest. -If the protein is not found in CHNOSZ's own database, the amino acid -composition of the protein can be retrieved from the UniProt Knowledge -Base using the Swiss-Prot name (if the computer is connected to the -Internet). This is the only time a function in CHNOSZ asks for confirmation -from a user, in order to give fair warning that an online activity -is about to be performed. +If the protein is not available in CHNOSZ's own database, the amino +acid composition of the protein can be retrieved from the UniProtKB +(if the computer is connected to the Internet). -<>= +<>= +aa <- uniprot.aa("ALAT1_HUMAN") +add.protein(aa) subcrt("ALAT1_HUMAN",1,T=25) @ -\begin{lyxcode} -Shall~I~try~an~online~search~for~~ALAT1\_HUMAN~\_~SWISS~?~y -protein:~trying~http://www.uniprot.org/uniprot/ALAT1\_HUMAN~...~got~it! - -protein:~found~P24298~...~~Alanine~aminotransferase~1~~(length~496). - -protein:~found~ALAT1\_HUMAN~(C2429H3866N684O705S22,~496~residues) - -subcrt:~1~species~at~298.15~K~and~1~bar~(wet)~ - -subcrt:~reaction~is~not~balanced;~it~is~missing~this~composition: - -~~~~~C~~~~~H~~~~N~~~~O~~~S - -~-2429~-3866~-684~-705~-22 - -subcrt:~adding~missing~composition~from~basis~definition~and~restarting... - -subcrt:~6~species~at~298.15~K~and~1~bar~(wet)~ - -\$reaction - -~~~~~coeff~~~~~~~~name~~~~~~~~~~~~~~~formula~state~ispecies - -2926~~~~~1~ALAT1\_HUMAN~C2429H3866N684O705S22~~~~aq~~~~~2926 - -69~~~-2429~~~~~~~~~CO2~~~~~~~~~~~~~~~~~~~CO2~~~~aq~~~~~~~69 - -1~~~~~-885~~~~~~~water~~~~~~~~~~~~~~~~~~~H2O~~~liq~~~~~~~~1 - -68~~~~-684~~~~~~~~~NH3~~~~~~~~~~~~~~~~~~~NH3~~~~aq~~~~~~~68 - -70~~~~~-22~~~~~~~~~H2S~~~~~~~~~~~~~~~~~~~H2S~~~~aq~~~~~~~70 - -2691~~2519~~~~~~oxygen~~~~~~~~~~~~~~~~~~~~O2~~~gas~~~~~2691 - -\$out - -~~~T~P~~~~~~logK~~~~~~~~~G~~~~~~~~~H~~~~~~~~S~~~~~~V~~~~~~~~Cp - -1~25~1~-191972.3~261897066~273248830~38245.59~-73411~-107650.2 - -\end{lyxcode} - - - \section{Activity diagrams} @@ -608,6 +531,7 @@ of temperature (I do!) \setkeys{Gin}{width=0.6\textwidth} + <>= basis("CHNOS+") species(c("CO2", "HCO3-", "CO3-2")) @@ -618,10 +542,28 @@ e <- equilibrate(a) diagram(e, add=TRUE, col="red") @ + \setkeys{Gin}{width=1.0\textwidth} +This just shows the speciation (relative abundances) of the aqueous +carbonate species. Calculating the solubility of a carbonate mineral, +or of $\mathrm{CO_{2}}$ gas, is possible, but more involved; try +the following: +\setkeys{Gin}{width=0.6\textwidth} +\selectlanguage{english}% +<>= +demo("solubility", ask=FALSE) +@ + +\setkeys{Gin}{width=1.0\textwidth} + +See the code of the demo (look for \texttt{demo/solubility.R} in the +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 @@ -641,7 +583,6 @@ species(c("SLAP_ACEKI", "CSG_METJA", "CSG_METVO", "CSG_HALJP")) @ - Note the output: the matrix denotes the coefficients of each of the basis species in the formation reaction for one mole of each of the species of interest. The \textbf{formation reaction} is the chemical @@ -669,7 +610,6 @@ a <- affinity(O2=c(-90,-70)) @ - Now we can use \texttt{equilibrate()} to calculate the equilibrium activities of the proteins and \texttt{diagram()} to plot them. \texttt{normalize=TRUE} invokes the normalization of the chemical formulas of the proteins @@ -678,13 +618,15 @@ where the legend should be placed on the plot. \setkeys{Gin}{width=0.6\textwidth} + +\selectlanguage{english}% <>= e <- equilibrate(a, normalize=TRUE) diagram(e, legend.x="bottomleft", ylim=c(-6, -2)) @ + \setkeys{Gin}{width=1.0\textwidth} - Notably, the protein from the organism found at the highest temperatures is relatively stable at more reduced conditions. @@ -700,15 +642,17 @@ but the resulting predominance diagram would be identical. \setkeys{Gin}{width=0.6\textwidth} + +\selectlanguage{english}% <>= species(c("SLAP_ACEKI", "SLAP_GEOSE", "SLAP_BACLI", "SLAP_AERSA")) basis(c("NH3", "H2S"), c(-1, -10)) a <- affinity(O2=c(-85, -70), H2O=c(-5, 0)) diagram(a, normalize=TRUE) @ + \setkeys{Gin}{width=1.0\textwidth} - Equilibrium predominances for proteins as a function of two chemical activities! If you don't like the colors in the plot, don't worry... the colors can be changed by using the \texttt{col} argument of \texttt{diagram()}. @@ -733,7 +677,6 @@ @ - \subsection{A mineral example} This example is modeled after a figure on p. 246 of \citet{BJH84} @@ -741,6 +684,8 @@ 1000 bar. \setkeys{Gin}{width=0.6\textwidth} + +\selectlanguage{english}% <>= basis(c("HCl","H2O","Ca+2","CO2","Mg+2","SiO2","O2","H+"), c(999,0,999,999,999,999,999,-7)) @@ -749,9 +694,9 @@ a <- affinity("Mg+2"=c(-12,-4),"Ca+2"=c(-8,0),T=300,P=1000) diagram(a) @ + \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 the calculation. This is so because 1) $\mathrm{HCl}$, $\mathrm{CO_{2}}$ @@ -795,7 +740,6 @@ example(diagram) @ - 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 @@ -805,7 +749,6 @@ examples() @ - There are even more examples that can be accessed by \texttt{demo()} (or \texttt{demos()} to run all of them): @@ -813,7 +756,6 @@ demo("findit") @ - If you want to add to or modify the thermodynamic database, read the instructions at the top of the help page for \texttt{thermo}: @@ -821,7 +763,6 @@ help(thermo) @ - Have fun! @@ -860,6 +801,8 @@ $T$, and degree sign in the units). \setkeys{Gin}{width=0.5\textwidth} + +\selectlanguage{english}% <>= basis("CHNOSe") basis(c("NH3", "H2S"), c(-6, -3)) @@ -879,9 +822,9 @@ ltext <- c("soils [BKM60]", "yellowstone [SWMP05]", "iceland [SA02]") legend("bottomleft", legend=ltext, pch=c(20, 3, 17)) @ + \setkeys{Gin}{width=1.0\textwidth} - \clearpage @@ -898,6 +841,8 @@ current version of CHNOSZ. \setkeys{Gin}{width=0.7\textwidth} + +\selectlanguage{english}% <>= locations <- yeastgfp() gfp <- yeastgfp(locations) @@ -917,9 +862,9 @@ db <- describe.basis(ibasis=(1:6)[-5]) legend("topright", legend=c(dp, db), bty="n") @ + \setkeys{Gin}{width=1.0\textwidth} - 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 @@ -949,6 +894,7 @@ \begin{small} \setkeys{Gin}{width=1.0\textwidth} + <>= layout(matrix(1:2, nrow=1), widths=c(2, 1)) b.species <- c("Fe", "CO2", "H2O", "N2", "H2", "H2S", "SiO2") @@ -978,10 +924,10 @@ legend("topleft", legend = c(describe.property("P", 300), describe.basis(ibasis=c(2,4)), "minerals", "HCN", "formaldehyde"), lty=c(NA, NA, NA, 1, 2, 3), bg="white") @ + \setkeys{Gin}{width=1.0\textwidth} \end{small} - \clearpage @@ -996,6 +942,7 @@ \begin{small} \setkeys{Gin}{width=0.35\textwidth} + <>= basis("CHNOS") species(c("isoleucine", "tyrosine", "glutamic acid", "methionine", "aspartic acid")) @@ -1004,10 +951,10 @@ r <- revisit(e) title(main=paste("CV minimum =", round(r$optimum, 2))) @ + \setkeys{Gin}{width=1.0\textwidth} \end{small} - The \texttt{balance=1} in \texttt{equilibrate()} means the relative stabilities are calculated using the formation reactions written per mole of amino acid (not conserving e.g. $\mathrm{CO_{2}}$ which would @@ -1018,6 +965,8 @@ \begin{small} \setkeys{Gin}{width=0.6\textwidth} + +\selectlanguage{english}% <>= basis(c("CO2", "O2"), c(r$x, r$y)) a <- affinity() @@ -1027,10 +976,10 @@ plot.new() legend("topleft", describe.basis(basis()), bg="white") @ + \setkeys{Gin}{width=1.0\textwidth} \end{small} - This hypothetical metastably equilibrated mixture has very little methionine and aspartic acid. Can we find where the relative abundances of the amino acids have a more even distribution? @@ -1053,16 +1002,18 @@ \begin{small} \setkeys{Gin}{width=0.4\textwidth} + +\selectlanguage{english}% <>= basis("CHNOS") species(c("isoleucine", "tyrosine", "glutamic acid", "methionine", "aspartic acid")) f <- findit(list(CO2=c(-5, 5), O2=c(-85, -65), H2S=c(-10, 5), H2O=c(-10, 0)), niter=5, res=10, balance=1) @ + \setkeys{Gin}{width=1.0\textwidth} \end{small} - After 5 iterations, what are the fractional equilibrium abundances of the amino acids? Note that, during its operation, \texttt{findit()} updates the activities of the basis species so we don't have to set @@ -1070,6 +1021,8 @@ \begin{small} \setkeys{Gin}{width=0.6\textwidth} + +\selectlanguage{english}% <>= a <- affinity() par(mfrow=c(1, 2)) @@ -1078,10 +1031,10 @@ plot.new() legend("topleft", describe.basis(basis()), bg="white") @ + \setkeys{Gin}{width=1.0\textwidth} \end{small} - We found a combination of chemical activities of basis species that lowered the variation of the equilibrium activities of the amino acids. Woohoo! @@ -1111,7 +1064,6 @@ sessionInfo() @ - \bibliographystyle{plainnat} \bibliography{vig} Modified: pkg/CHNOSZ/vignettes/anintro.lyx =================================================================== --- pkg/CHNOSZ/vignettes/anintro.lyx 2015-03-06 11:12:22 UTC (rev 79) +++ pkg/CHNOSZ/vignettes/anintro.lyx 2015-03-10 16:00:18 UTC (rev 80) @@ -1,5 +1,5 @@ -#LyX 2.0 created this file. For more info see http://www.lyx.org/ -\lyxformat 413 +#LyX 2.1 created this file. For more info see http://www.lyx.org/ +\lyxformat 474 \begin_document \begin_header \textclass article @@ -17,18 +17,18 @@ \maintain_unincluded_children false \language english \language_package default -\inputencoding auto +\inputencoding default \fontencoding global \font_roman palatino \font_sans default \font_typewriter default +\font_math auto \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 - \graphics default \default_output_format default \output_sync 0 @@ -51,15 +51,24 @@ \pdf_quoted_options "citecolor=blue" \papersize letterpaper \use_geometry true -\use_amsmath 1 -\use_esint 1 -\use_mhchem 1 -\use_mathdots 1 -\cite_engine natbib_authoryear +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine natbib +\cite_engine_type authoryear +\biblio_style plainnat \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false +\justification true \use_refstyle 0 \branch load \selected 1 @@ -110,16 +119,27 @@ Dick \end_layout -\begin_layout Chunk -<>= +\begin_layout Standard +\begin_inset Flex Chunk +status open + +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +echo=FALSE \end_layout -\begin_layout Chunk +\end_inset + options(width=90) \end_layout -\begin_layout Chunk -@ +\end_inset + + \end_layout \begin_layout Section @@ -254,7 +274,7 @@ under reference (non-equilibrium) conditions, calculate the equilibrium chemical activities, and finally plot the results; \begin_inset Foot -status collapsed +status open \begin_layout Plain Layout @@ -336,19 +356,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +install_CHNOSZ,eval=FALSE \end_layout -\begin_layout Chunk +\end_inset install.packages("CHNOSZ") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -363,21 +391,29 @@ \begin_layout Standard \begin_inset Branch stuff -status collapsed +status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +library_CHNOSZ \end_layout -\begin_layout Chunk +\end_inset library(CHNOSZ) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -398,19 +434,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +data_thermo \end_layout -\begin_layout Chunk +\end_inset data(thermo) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -458,19 +502,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_ethylene \end_layout -\begin_layout Chunk +\end_inset info("ethylene") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -501,19 +553,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_88 \end_layout -\begin_layout Chunk +\end_inset info(88) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -529,19 +589,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_ethylene_gas \end_layout -\begin_layout Chunk +\end_inset info("ethylene","gas") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -565,24 +633,32 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_acetic \end_layout -\begin_layout Chunk +\end_inset aadata <- info(info("acetic acid")) \end_layout -\begin_layout Chunk +\begin_layout Plain Layout print(aadata) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -619,19 +695,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +summary_thermo \end_layout -\begin_layout Chunk +\end_inset summary(thermo) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -667,19 +751,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +browse.refs,eval=F \end_layout -\begin_layout Chunk +\end_inset browse.refs(88) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -729,19 +821,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_acid \end_layout -\begin_layout Chunk +\end_inset info("acid") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -797,19 +897,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_spaceacid \end_layout -\begin_layout Chunk +\end_inset info(" acid") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -835,19 +943,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_OH \end_layout -\begin_layout Chunk +\end_inset info("(OH)") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -889,29 +1005,37 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +protein_LYSC \end_layout -\begin_layout Chunk +\end_inset ip <- iprotein("LYSC_CHICK") \end_layout -\begin_layout Chunk +\begin_layout Plain Layout aa <- ip2aa(ip) \end_layout -\begin_layout Chunk +\begin_layout Plain Layout aa2eos(aa) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -943,24 +1067,32 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +formula_LYSC \end_layout -\begin_layout Chunk +\end_inset pf <- protein.formula(aa) \end_layout -\begin_layout Chunk +\begin_layout Plain Layout as.chemical.formula(pf) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -1011,24 +1143,32 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +info_LYSC \end_layout -\begin_layout Chunk +\end_inset si <- info("LYSC_CHICK") \end_layout -\begin_layout Chunk +\begin_layout Plain Layout info(si) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -1107,19 +1247,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +subcrt_water \end_layout -\begin_layout Chunk +\end_inset subcrt("water") \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -1204,19 +1352,27 @@ \begin_inset Branch stuff status open -\begin_layout Chunk +\begin_layout Standard +\begin_inset Flex Chunk +status open -<>= +\begin_layout Plain Layout + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +subcrt_C2H5OH \end_layout -\begin_layout Chunk +\end_inset subcrt(c("C2H5OH","O2","CO2","H2O"),c(-1,-3,2,3),T=37) \end_layout -\begin_layout Chunk +\end_inset -@ + \end_layout \end_inset @@ -1254,19 +1410,27 @@ \begin_inset Branch stuff [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/chnosz -r 80