[CHNOSZ-commits] r962 - in pkg/CHNOSZ: . R inst/tinytest man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 12 12:12:02 CET 2026
Author: jedick
Date: 2026-01-12 12:12:01 +0100 (Mon, 12 Jan 2026)
New Revision: 962
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/protein.info.R
pkg/CHNOSZ/inst/tinytest/test-protein.info.R
pkg/CHNOSZ/man/protein.info.Rd
Log:
Add tests for MP90.cp()
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2026-01-11 01:20:24 UTC (rev 961)
+++ pkg/CHNOSZ/DESCRIPTION 2026-01-12 11:12:01 UTC (rev 962)
@@ -1,6 +1,6 @@
-Date: 2026-01-11
+Date: 2026-01-12
Package: CHNOSZ
-Version: 2.2.0-28
+Version: 2.2.0-29
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/protein.info.R
===================================================================
--- pkg/CHNOSZ/R/protein.info.R 2026-01-11 01:20:24 UTC (rev 961)
+++ pkg/CHNOSZ/R/protein.info.R 2026-01-12 11:12:01 UTC (rev 962)
@@ -7,7 +7,7 @@
# protein.OBIGT: perform group additivity calculations
# protein.basis: coefficients of basis species in formation reactions of [ionized] proteins [residues]
-pinfo <- function(protein, organism = NULL, residue = FALSE, regexp = 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:
@@ -29,19 +29,11 @@
if(residue) out[, 5:25] <- out[, 5:25]/rowSums(out[, 6:25])
} else {
t_p <- get("thermo", CHNOSZ)$protein
- # 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)
- }
+ # 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/inst/tinytest/test-protein.info.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-protein.info.R 2026-01-11 01:20:24 UTC (rev 961)
+++ pkg/CHNOSZ/inst/tinytest/test-protein.info.R 2026-01-12 11:12:01 UTC (rev 962)
@@ -10,3 +10,22 @@
info <- "pinfo() returns NA if no organism is given"
expect_equal(pinfo(c("LYSC_CHICK", "MYGPHYCA")), c(6, NA), info = info)
+# Tests added on 20260112
+
+info <- "protein.basis() works as expected"
+basis("CHNOS+")
+# Formation reaction of unionized protein using species()
+s <- species("LYSC_CHICK")
+# Basis species to form ionized protein at low and high pH
+basis("pH", 0)
+pb0 <- protein.basis("LYSC_CHICK")
+basis("pH", 14)
+pb14 <- protein.basis("LYSC_CHICK")
+# Numbers of CO2, H2O, NH3, and H2S should be equal
+expect_equivalent(as.numeric(s[, 1:5]), pb0[, 1:5], info = info)
+expect_equivalent(as.numeric(s[, 1:5]), pb14[, 1:5], info = info)
+# Protein is more positively charged at low pH
+expect_true(pb0[, "H+"] > pb14[, "H+"], info = info)
+# Divide by protein length to get normalized basis composition
+pb_norm <- protein.basis("LYSC_CHICK", normalize = TRUE)
+expect_equal(pb_norm, pb14/129, info = info)
Modified: pkg/CHNOSZ/man/protein.info.Rd
===================================================================
--- pkg/CHNOSZ/man/protein.info.Rd 2026-01-11 01:20:24 UTC (rev 961)
+++ pkg/CHNOSZ/man/protein.info.Rd 2026-01-12 11:12:01 UTC (rev 962)
@@ -13,7 +13,7 @@
}
\usage{
- pinfo(protein, organism=NULL, residue=FALSE, regexp=FALSE)
+ pinfo(protein, organism=NULL, residue=FALSE)
protein.length(protein, organism = NULL)
protein.formula(protein, organism = NULL, residue = FALSE)
protein.OBIGT(protein, organism = NULL, state=thermo()$opt$state)
@@ -24,7 +24,6 @@
\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 \degC}
@@ -35,9 +34,6 @@
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).
More information about the CHNOSZ-commits
mailing list