From 6702bef0d9e006ca07a3b269c22af305278c8f6e Mon Sep 17 00:00:00 2001 From: Jeffrey Dick Date: Wed, 28 Feb 2024 03:06:28 +0000 Subject: [PATCH] Move aasum() to canprot and adjust GH actions git-svn-id: svn://scm.r-forge.r-project.org/svnroot/chnosz/pkg/CHNOSZ@829 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- .github/workflows/R-CMD-check.yaml | 11 +++++++++++ DESCRIPTION | 2 +- NAMESPACE | 2 +- R/add.protein.R | 31 ------------------------------ inst/NEWS.Rd | 4 ++-- man/add.protein.Rd | 15 --------------- 6 files changed, 15 insertions(+), 50 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 3a28b3d..cdb594f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,4 +28,15 @@ jobs: extra-packages: any::rcmdcheck needs: check + # Install remotes and development version of canprot 20240228 + # https://stackoverflow.com/questions/76642914/use-a-github-package-for-a-r-github-action + + - name: Install remotes + run: | + Rscript -e "install.packages('remotes', repos='https://ftp.belnet.be/mirror/CRAN')" + + - name: Install development version of canprot + run: | + Rscript -e "remotes::install_github('jedick/canprot')" + - uses: r-lib/actions/check-r-package@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 840d124..7aa10f2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Date: 2024-02-28 Package: CHNOSZ -Version: 2.1.0-1 +Version: 2.1.0-2 Title: Thermodynamic Calculations and Diagrams for Geochemistry Authors@R: c( person("Jeffrey", "Dick", , "j3ffdick@gmail.com", role = c("aut", "cre"), diff --git a/NAMESPACE b/NAMESPACE index d8c5d4f..c2b5d64 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,7 +24,7 @@ export( "getrank", "parent", "sciname", "allparents", "getnodes", "getnames", "protein.OBIGT", "which.pmax", "equil.boltzmann", "equil.reaction", "find.tp", - "ionize.aa", "MP90.cp", "aasum", + "ionize.aa", "MP90.cp", "ratlab", "EOSregress", "EOScoeffs", "EOSplot", "EOSvar", # demos diff --git a/R/add.protein.R b/R/add.protein.R index d9d74a8..db94a24 100644 --- a/R/add.protein.R +++ b/R/add.protein.R @@ -36,34 +36,3 @@ add.protein <- function(aa, as.residue = FALSE) { return(ip) } -# Combine amino acid counts (sum, average, or weighted sum by abundance) -aasum <- function(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) { - # Returns the sum of the amino acid counts in aa, - # multiplied by the abundances of the proteins - abundance <- rep(abundance, length.out = nrow(aa)) - # Drop any NA rows or abundances - ina.aa <- is.na(aa$chains) - ina.ab <- is.na(abundance) - ina <- ina.aa | ina.ab - if(any(ina)) { - aa <- aa[!ina, ] - abundance <- abundance[!ina] - message("aasum: dropped ", sum(ina), " proteins with NA composition and/or abundance") - } - # Multiply - aa[, 6:25] <- aa[, 6:25] * abundance - # Sum - out <- aa[1, ] - out[, 5:25] <- colSums(aa[, 5:25]) - # Average if told to do so - if(average) { - # Polypeptide chains by number of proteins, residues by frequency - out[, 5] <- out[, 5]/nrow(aa) - out[, 6:25] <- out[, 6:25]/sum(abundance) - } - # Add protein and organism names if given - if(!is.null(protein)) out$protein <- protein - if(!is.null(organism)) out$organism <- organism - return(out) -} - diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index e885426..b47d132 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -15,10 +15,10 @@ \newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{CP}}{Cp}}} \newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{ΔG°}}{ΔG°}}} -\section{Changes in CHNOSZ version 2.1.0-1 (2024-02-28)}{ +\section{Changes in CHNOSZ version 2.1.0-2 (2024-02-28)}{ \itemize{ - \item Move \code{read.fasta()} and \code{count.aa()} to canprot package. + \item Move \code{read.fasta()}, \code{count.aa()}, and \code{aasum()} to canprot package. \item Remove \code{seq2aa()}. } diff --git a/man/add.protein.Rd b/man/add.protein.Rd index 8aa77ac..4721e8b 100644 --- a/man/add.protein.Rd +++ b/man/add.protein.Rd @@ -1,7 +1,6 @@ \encoding{UTF-8} \name{add.protein} \alias{add.protein} -\alias{aasum} \title{Amino Acid Compositions of Proteins} \description{ Functions to get amino acid compositions and add them to protein list for use by other functions. @@ -9,16 +8,11 @@ \usage{ add.protein(aa, as.residue = FALSE) - aasum(aa, abundance = 1, average = FALSE, protein = NULL, organism = NULL) } \arguments{ \item{aa}{data frame, amino acid composition in the format of \code{thermo()$protein}} \item{as.residue}{logical, normalize by protein length?} - \item{protein}{character, name of protein; numeric, indices of proteins (rownumbers of \code{\link{thermo}()$protein})} - \item{abundance}{numeric, abundances of proteins} - \item{average}{logical, return the weighted average of amino acid counts?} - \item{organism}{character, name of organism} } \details{ @@ -31,16 +25,10 @@ From the amino acid compositions, the thermodynamic properties of the proteins c Given a data frame of amino acid compositions in the format of \code{thermo()$protein}, \code{add.protein} adds them to \code{thermo()$protein} for use by other functions in CHNOSZ. The amino acid compositions of proteins in \code{aa} with the same name as one in \code{thermo()$protein} are replaced. Set \code{as.residue} to TRUE to normalize by protein length; each input amino acid composition is divided by the corresponding number of residues, with the result that the sum of amino acid frequencies for each protein is 1. - -\code{aasum} returns a data frame representing the sum of amino acid compositions in the rows of the input \code{aa} data frame. -The amino acid compositions are multiplied by the indicated \code{abundance}; that argument is recycled to match the number of rows of \code{aa}. -If \code{average} is TRUE the final sum is divided by the number of input compositions. -The name used in the output is taken from the first row of \code{aa} or from \code{protein} and \code{organism} if they are specified. } \value{ For \code{add.protein}, the rownumbers of \code{thermo()$protein} that are added and/or replaced. -For \code{aasum}, a one-row data frame of amino acid composition and identifying information. } \examples{ @@ -54,9 +42,6 @@ iprotein <- add.protein(aa) # Calculate length and elemental formula protein.length(iprotein) protein.formula(iprotein) - -# Sum the amino acid compositions and assign a new protein name -aasum(aa, protein = "POLG_sum") } \seealso{