[CHNOSZ-commits] r750 - in pkg/CHNOSZ: . R inst inst/tinytest

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 15 13:09:52 CEST 2022


Author: jedick
Date: 2022-10-15 13:09:52 +0200 (Sat, 15 Oct 2022)
New Revision: 750

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/add.protein.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/inst/tinytest/test-add.protein.R
Log:
Allow an empty sequence in seq2aa()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2022-09-29 12:06:21 UTC (rev 749)
+++ pkg/CHNOSZ/DESCRIPTION	2022-10-15 11:09:52 UTC (rev 750)
@@ -1,6 +1,6 @@
-Date: 2022-09-29
+Date: 2022-10-15
 Package: CHNOSZ
-Version: 1.9.9-41
+Version: 1.9.9-42
 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/add.protein.R
===================================================================
--- pkg/CHNOSZ/R/add.protein.R	2022-09-29 12:06:21 UTC (rev 749)
+++ pkg/CHNOSZ/R/add.protein.R	2022-10-15 11:09:52 UTC (rev 750)
@@ -4,18 +4,18 @@
 
 # Calculate amino acid counts from a sequence
 seq2aa <- function(protein, sequence) {
-  # remove newlines and whitespace
+  # $emove newlines and whitespace
   sequence <- gsub("\\s", "", gsub("[\r\n]", "", sequence))
-  # make a data frame from counting the amino acids in the 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 <- pinfo(protein)
-  # now make the data frame
+  # 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)
+  aa <- data.frame(protein = po[1], organism = po[2], ref = NA, abbrv = NA, stringsAsFactors = FALSE)
+  # chains = 1 for any sequence, chains = 0 for no sequence
+  chains <- sum(nchar(sequence) > 0)
+  aa <- cbind(aa, chains = chains, caa)
   return(aa)
 }
 

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2022-09-29 12:06:21 UTC (rev 749)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2022-10-15 11:09:52 UTC (rev 750)
@@ -12,7 +12,7 @@
 % links to vignettes 20220723
 \newcommand{\viglink}{\ifelse{html}{\out{<a href="../CHNOSZ/doc/#1.html"><strong>#1.Rmd</strong></a>}}{\bold{#1.Rmd}}}
 
-\section{Changes in CHNOSZ version 1.9.9-41 (2022-09-29)}{
+\section{Changes in CHNOSZ version 1.9.9-42 (2022-10-15)}{
 
   \subsection{MAJOR USER-VISIBLE CHANGES}{
     \itemize{
@@ -119,6 +119,9 @@
       \item In \code{affinity()}, print a message to indicate whether
       ionization calculations for proteins are being done.
 
+      \item \code{seq2aa()} allows an empty sequence (zero counts of amino
+      acids), useful for intializing a data frame of amino acid composition.
+
     }
   }
 
@@ -186,7 +189,7 @@
       \item Add tests \file{stack_mosaic.R} and \file{stack_solubility.R}
       (these create PDF files for visual inspection of results).
 
-      \item \code{axis.label()} now produces labels with units delimited by
+      \item \code{axis.label()} produces labels with units delimited by
       parentheses instead of a comma.
 
     }

Modified: pkg/CHNOSZ/inst/tinytest/test-add.protein.R
===================================================================
--- pkg/CHNOSZ/inst/tinytest/test-add.protein.R	2022-09-29 12:06:21 UTC (rev 749)
+++ pkg/CHNOSZ/inst/tinytest/test-add.protein.R	2022-10-15 11:09:52 UTC (rev 750)
@@ -12,7 +12,6 @@
 expect_equal(ip1, ip2, info = info)
 
 info <- "Errors and messages occur in some circumstances"
-expect_error(seq2aa("LYS_CHICK", "XXX"), "no characters match an amino acid", info = info)
 expect_error(add.protein(count.aa("AAA")), "does not have the same columns as thermo\\(\\)\\$protein", info = info)
 expect_message(add.protein(pinfo(pinfo("CYC_BOVIN"))), "replaced 1 existing protein\\(s\\)", info = info)
 



More information about the CHNOSZ-commits mailing list