[CHNOSZ-commits] r420 - in pkg/CHNOSZ: . R inst inst/extdata/thermo man tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 3 07:54:51 CET 2019


Author: jedick
Date: 2019-03-03 07:54:49 +0100 (Sun, 03 Mar 2019)
New Revision: 420

Added:
   pkg/CHNOSZ/inst/extdata/thermo/stoich.csv.xz
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/thermo.R
   pkg/CHNOSZ/inst/CHECKLIST
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/retrieve.Rd
   pkg/CHNOSZ/man/thermo.Rd
   pkg/CHNOSZ/tests/testthat/test-retrieve.R
Log:
add precalculated stoichiometric matrix to speed up retrieve()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/DESCRIPTION	2019-03-03 06:54:49 UTC (rev 420)
@@ -1,6 +1,6 @@
-Date: 2019-03-02
+Date: 2019-03-03
 Package: CHNOSZ
-Version: 1.3.1
+Version: 1.3.1-1
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/R/thermo.R
===================================================================
--- pkg/CHNOSZ/R/thermo.R	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/R/thermo.R	2019-03-03 06:54:49 UTC (rev 420)
@@ -17,10 +17,15 @@
     buffers = read.csv(file.path(thermodir, "buffer.csv"), as.is=1:3),
     protein = read.csv(file.path(thermodir, "protein.csv"), as.is=1:4),
     groups = read.csv(file.path(thermodir, "groups.csv"), row.names=1, check.names=FALSE),
+    stoich = read.csv(file.path(thermodir, "stoich.csv.xz"), as.is=TRUE),
     basis = NULL,
     species = NULL,
     opar = NULL
   )
+  # store stoich as matrix (with non-unique row names), not data frame
+  formula <- thermo$stoich[, 1]
+  thermo$stoich <- as.matrix(thermo$stoich[, 2:ncol(thermo$stoich)])
+  rownames(thermo$stoich) <- formula
   # give a summary of what we are doing
   if(!"thermo" %in% ls(CHNOSZ)) message("reset: creating \"thermo\" object")
   else message("reset: resetting \"thermo\" object")

Modified: pkg/CHNOSZ/inst/CHECKLIST
===================================================================
--- pkg/CHNOSZ/inst/CHECKLIST	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/inst/CHECKLIST	2019-03-03 06:54:49 UTC (rev 420)
@@ -10,6 +10,9 @@
   co <- check.obigt()
   write.csv(co, "obigt_check.csv", row.names=FALSE, na="")
 
+- recreate extdata/thermo/stoich.csv.xz after all data updates
+  (see testthat/test-retrieve.R for instructions)
+
 - check that uniprot.aa() works with current UniProt web pages
 
 - run R_PAPERSIZE=letter R CMD Rd2pdf chnosz/
@@ -18,31 +21,26 @@
 - run R CMD check using R compiled without long doubles (emulating Solaris checks on CRAN)
   (CFLAGS=-ffloat-store ./configure --disable-long-double)
 
-- build the package on the source directory;
-  try both qpdf and ghostscript to compact vignettes:
+- size reduction of vignettes: after installing/upgrading rmarkdown, replace files in
+  rmarkdown/rmd/h/bootstrap/fonts/ with empty files
+
+- build the package using both qpdf and ghostscript to compact vignettes:
   R CMD build --compact-vignettes=both chnosz/
 
-- check reverse dependencies on CRAN: LipidMS, canprot, ecipex, iemisc as of 2019-02-09
-
 - vignettes/obigt.bib: check correct year for CHNOSZ reference
 
 - documentation links: after installation, run doc/mklinks.sh
   and insert the modified anintro.html in the package
 
-- reduce size of vignettes: after upgrading rmarkdown, replace files in
-  rmarkdown/rmd/h/bootstrap/fonts/ with empty files
-
 - backwards compatibility: build and check the package with the
   *minimum* R version (from the DESCRIPTION file)
 
-OTHER THINGS TO CHECK:
+- check reverse dependencies on CRAN: LipidMS, canprot, ecipex, iemisc as of 2019-02-09
 
-- remove all "<<-" from sources (leftover from debugging)
+OTHER THINGS TO WORK ON:
 
 - update list of documentation topics in examples() with any new ones
 
-- check for stale URLs in Rd files
-
 - clean up all TODO, XXX, etc. in Rd files (and hopefully R files too)
 
 - update .Rinstignore with any new/deleted files

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/inst/NEWS	2019-03-03 06:54:49 UTC (rev 420)
@@ -1,3 +1,10 @@
+CHANGES IN CHNOSZ 1.3.1-1 (2019-03-03)
+--------------------------------------
+
+- Add thermo/stoich.csv.xz (stored as thermo()$stoich), containing a
+  precalculated stochiometric matrix for the default database, to speed
+  up retrieve().
+
 CHANGES IN CHNOSZ 1.3.1 (2019-03-02)
 ------------------------------------
 

Added: pkg/CHNOSZ/inst/extdata/thermo/stoich.csv.xz
===================================================================
(Binary files differ)


Property changes on: pkg/CHNOSZ/inst/extdata/thermo/stoich.csv.xz
___________________________________________________________________
Added: svn:mime-type
   + application/x-xz

Modified: pkg/CHNOSZ/man/retrieve.Rd
===================================================================
--- pkg/CHNOSZ/man/retrieve.Rd	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/man/retrieve.Rd	2019-03-03 06:54:49 UTC (rev 420)
@@ -36,8 +36,8 @@
 If the argument list is empty, then the function returns an empty (length 0) numeric value.
 A special argument value \samp{all} can be used to retrieve all species in the thermodynamic database, including filtering on state and hiding of the groups.
 
-The first time the function is run, it uses \code{\link{i2A}} to build the stoichiometric matrix for the current database.
-Following runs use the previously calculated stoichiometric matrix, unless a change to the database is detected, which triggers a recalculation.
+To speed up operation, the function uses a precalculated stoichiometric matrix for the default database, which is loaded with the package (see \code{\link{thermo}}).
+If the function detects a change to any chemical formulas in database, it triggers a recalculation using \code{\link{i2A}}.
 }
 
 \seealso{

Modified: pkg/CHNOSZ/man/thermo.Rd
===================================================================
--- pkg/CHNOSZ/man/thermo.Rd	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/man/thermo.Rd	2019-03-03 06:54:49 UTC (rev 420)
@@ -226,6 +226,14 @@
        \code{name} \tab character \tab Name of species\cr
     }
 
+    \item \code{thermo$stoich}
+    A precalculated stoichiometric matrix for the default database. This is a matrix, not a data frame, and as such can accept duplicated row names, corresponding to chemical formulas of the species. See \code{\link{retrieve}}, and the first test in \code{testthat/test-retrieve.R} for how to update this.
+    \tabular{lll}{
+       \code{rownames} \tab character \tab Chemical formulas from \code{thermo$obigt}\cr
+       \code{...} \tab numeric \tab Stoichiometry, one column for each element present in any species
+    }
+
+
   }  % end of itemize with long descriptions
 
 } % end of format

Modified: pkg/CHNOSZ/tests/testthat/test-retrieve.R
===================================================================
--- pkg/CHNOSZ/tests/testthat/test-retrieve.R	2019-03-02 15:12:02 UTC (rev 419)
+++ pkg/CHNOSZ/tests/testthat/test-retrieve.R	2019-03-03 06:54:49 UTC (rev 420)
@@ -1,5 +1,16 @@
 context("retrieve")
 
+test_that("packaged stoichiometric matrix matches the default database", {
+  expect_identical(rownames(thermo()$stoich), thermo()$obigt$formula)
+  # test added 20190303
+  # if this test fails, update extdata/thermo/stoich.csv.xz and rebuild the package:
+  # reset()
+  # formula <- thermo()$obigt$formula
+  # stoich <- i2A(formula)
+  # write.csv(stoich, "stoich.csv")
+  # system("xz stoich.csv")
+})
+
 test_that("errors and recalculations produce expected messages", {
   # this should give an error about one non-element
   expect_error(retrieve(c("A", "B", "C")), '"A" is not an element')



More information about the CHNOSZ-commits mailing list