[CHNOSZ-commits] r5 - in pkg: . R inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 29 15:47:35 CEST 2012


Author: jedick
Date: 2012-08-29 15:47:35 +0200 (Wed, 29 Aug 2012)
New Revision: 5

Modified:
   pkg/DESCRIPTION
   pkg/R/iprotein.R
   pkg/inst/tests/test-iprotein.R
Log:
add.protein(): return correct indices for already existing proteins


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-06-26 14:22:07 UTC (rev 4)
+++ pkg/DESCRIPTION	2012-08-29 13:47:35 UTC (rev 5)
@@ -1,8 +1,8 @@
 Package: CHNOSZ
 Title: Chemical Thermodynamics and Activity Diagrams
 Version: 0.9-7.98
-Date: 2012-06-26
-Author: Jeffrey M. Dick <jmdick at asu.edu>
+Date: 2012-08-29
+Author: Jeffrey M. Dick
 Maintainer: Jeffrey M. Dick <jmdick at asu.edu>
 Depends: R (>= 2.10.0), utils
 Suggests: testthat, parallel

Modified: pkg/R/iprotein.R
===================================================================
--- pkg/R/iprotein.R	2012-06-26 14:22:07 UTC (rev 4)
+++ pkg/R/iprotein.R	2012-08-29 13:47:35 UTC (rev 5)
@@ -218,9 +218,8 @@
   thermo$protein <<- rbind(thermo$protein, aa[!ipdup, ])
   rownames(thermo$protein) <<- NULL
   # return the new rownumbers
-  ntotal <- nrow(thermo$protein)
-  iprotein <- (ntotal-nrow(aa)+1):ntotal
+  ip <- iprotein(po)
   # make some noise
   msgout("add.protein: added ", nrow(aa)-sum(ipdup), " of ", nrow(aa), " proteins\n")
-  return(iprotein)
+  return(ip)
 }

Modified: pkg/inst/tests/test-iprotein.R
===================================================================
--- pkg/inst/tests/test-iprotein.R	2012-06-26 14:22:07 UTC (rev 4)
+++ pkg/inst/tests/test-iprotein.R	2012-08-29 13:47:35 UTC (rev 5)
@@ -41,6 +41,15 @@
   expect_equal(ip1, ip2)
 })
 
+test_that("add.protein returns correct indices for existing names", {
+  file <- system.file("data/protein.csv", package="CHNOSZ")
+  aa <- read.aa(file)
+  aa$protein[1] <- "TEST"
+  # only the first one is added, because the others already exist
+  expect_message(ip <- add.protein(aa), "added 1 of")
+  expect_equal(thermo$protein$protein[ip], aa$protein)
+})
+
 # for the future... make info() faster!
 # (especially the loading of ionizable groups for proteins)
 #test_that("calculations for ionized proteins meet performance expectations", {



More information about the CHNOSZ-commits mailing list