Skip to content

Commit

Permalink
Move aasum() to canprot and adjust GH actions
Browse files Browse the repository at this point in the history
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/chnosz/pkg/CHNOSZ@829 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
jedick committed Feb 28, 2024
1 parent 071bd73 commit 6702bef
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 50 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"),
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions R/add.protein.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

4 changes: 2 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
\newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{&Delta;<I>G</I>&deg;}}{Δ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()}.
}

Expand Down
15 changes: 0 additions & 15 deletions man/add.protein.Rd
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
\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.
}

\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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit 6702bef

Please sign in to comment.