From b61470b43b0b88221d3b07e1099597d0d3698371 Mon Sep 17 00:00:00 2001 From: Ramiro Magno Date: Tue, 30 Jul 2024 19:02:17 +0100 Subject: [PATCH] Updating code style --- DESCRIPTION | 2 +- R/amino_acid_pairs.R | 48 +++++------ R/amino_acids.R | 6 +- R/as_one_letter.R | 10 +-- R/as_three_letter.R | 10 +-- R/grantham_distance.R | 96 ++++++++++----------- R/sltm_k.R | 7 +- README.Rmd | 6 +- README.md | 6 +- _pkgdown.yml | 5 +- data-raw/data.R | 114 ++++++++++++------------- man/amino_acid_pairs.Rd | 3 +- man/as_one_letter.Rd | 8 +- man/as_three_letter.Rd | 8 +- man/grantham_distance.Rd | 6 +- man/grantham_distance_exact.Rd | 2 +- tests/spelling.R | 9 +- tests/testthat/test-amino_acid_pairs.R | 3 - tests/testthat/test-amino_acids.R | 1 - 19 files changed, 172 insertions(+), 178 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 60984be..fe3d583 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,5 +42,5 @@ Suggests: spelling, testthat (>= 3.0.0) Language: en-US -Config/Needs/website: patterninstitute/chic Config/testthat/edition: 3 +Roxygen: list(markdown = TRUE) diff --git a/R/amino_acid_pairs.R b/R/amino_acid_pairs.R index 131ae63..13e06d6 100644 --- a/R/amino_acid_pairs.R +++ b/R/amino_acid_pairs.R @@ -22,8 +22,8 @@ #' amino_acid_pairs(keep_self = FALSE) #' #' # Generate specific combinations of Ser against Ala and Trp. -#' amino_acid_pairs(x = 'Ser', y = c('Ala', 'Trp')) -#' @md +#' amino_acid_pairs(x = "Ser", y = c("Ala", "Trp")) +#' #' @importFrom dplyr .data #' @export amino_acid_pairs <- @@ -32,15 +32,15 @@ amino_acid_pairs <- keep_self = TRUE, keep_duplicates = TRUE, keep_reverses = TRUE) { + if (!all_amino_acids(x)) { + stop("`x` must be a vector of three-letter code amino acids") + } - if(!all_amino_acids(x)) - stop('`x` must be a vector of three-letter code amino acids') - - if (!all_amino_acids(y)) - stop('`y` must be a vector of three-letter code amino acids' - ) + if (!all_amino_acids(y)) { + stop("`y` must be a vector of three-letter code amino acids") + } - # tbl <- tidyr::expand_grid(x = x, y = y) + # tbl <- tidyr::expand_grid(x = x, y = y) tbl <- expand.grid( y = y, x = x, @@ -50,20 +50,20 @@ amino_acid_pairs <- tibble::as_tibble() |> dplyr::relocate("x", "y") - tbl <- `if`(keep_self, tbl, dplyr::filter(tbl, x != y)) - tbl <- `if`(keep_duplicates, tbl, dplyr::distinct(tbl)) + tbl <- `if`(keep_self, tbl, dplyr::filter(tbl, x != y)) + tbl <- `if`(keep_duplicates, tbl, dplyr::distinct(tbl)) - tbl <- - if (keep_reverses) { - tbl # do nothing - } else { - tbl |> - dplyr::rowwise() |> - dplyr::mutate(key = paste(sort(c(x, y)), collapse = '-')) |> - dplyr::ungroup() |> - dplyr::distinct(.data$key, .keep_all = TRUE) |> - dplyr::select(-'key') - } + tbl <- + if (keep_reverses) { + tbl # do nothing + } else { + tbl |> + dplyr::rowwise() |> + dplyr::mutate(key = paste(sort(c(x, y)), collapse = "-")) |> + dplyr::ungroup() |> + dplyr::distinct(.data$key, .keep_all = TRUE) |> + dplyr::select(-"key") + } - return(tbl) -} + return(tbl) + } diff --git a/R/amino_acids.R b/R/amino_acids.R index 5ca2122..0d37631 100644 --- a/R/amino_acids.R +++ b/R/amino_acids.R @@ -10,7 +10,9 @@ #' #' @export amino_acids <- function() { - c("Ser", "Arg", "Leu", "Pro", "Thr", "Ala", "Val", "Gly", "Ile", + c( + "Ser", "Arg", "Leu", "Pro", "Thr", "Ala", "Val", "Gly", "Ile", "Phe", "Tyr", "Cys", "His", "Gln", "Asn", "Lys", "Asp", "Glu", - "Met", "Trp") + "Met", "Trp" + ) } diff --git a/R/as_one_letter.R b/R/as_one_letter.R index 104e0b4..13c590d 100644 --- a/R/as_one_letter.R +++ b/R/as_one_letter.R @@ -11,14 +11,13 @@ #' @return A character vector of one-letter amino acid codes, e.g. `"S"`, `"R"`, #' `"L"`, or `"B"`. #' -#' @md #' @examples #' # Convert Ser to S, Arg to R and Pro to P. -#' as_one_letter(c('Ser', 'Arg', 'Pro')) +#' as_one_letter(c("Ser", "Arg", "Pro")) #' #' # The function `as_one_letter()` is case insensitive on the input but will #' # always return the one-letter codes in uppercase. -#' as_one_letter(c('ser', 'ArG', 'PRO')) +#' as_one_letter(c("ser", "ArG", "PRO")) #' #' # Convert the codes of the 20 standard amino acids. Note that the function #' # `amino_acids()` returns the three-letter codes of the 20 standard amino @@ -27,16 +26,15 @@ #' #' # Convert also special case codes Asx (Asparagine or Aspartic acid) and Glx #' # (Glutamine or Glutamic acid) -#' as_one_letter(c('Asx', 'Glx')) +#' as_one_letter(c("Asx", "Glx")) #' #' # Invalid codes in the input are converted to NA. #' # "Ser" is correctly mapped to "S" but "Serine" is not as it is not a #' # three-letter amino acid code (the same applies to "Glucose"). -#' as_one_letter(c('Ser', 'Serine', 'Glucose')) +#' as_one_letter(c("Ser", "Serine", "Glucose")) #' #' @export as_one_letter <- function(x) { - three_to_one_letter_codes <- stats::setNames(one_letter_codes, nm = three_letter_codes) unname(three_to_one_letter_codes[tools::toTitleCase(x)]) } diff --git a/R/as_three_letter.R b/R/as_three_letter.R index 21b6ce5..8784acd 100644 --- a/R/as_three_letter.R +++ b/R/as_three_letter.R @@ -11,27 +11,25 @@ #' @return A character vector of three-letter amino acid codes, e.g. `"Ser"`, #' `"Arg"`, `"Leu"`, or `"Pro"`. #' -#' @md #' @examples #' # Convert S to Ser, R to Arg and P to Pro. -#' as_three_letter(c('S', 'R', 'P')) +#' as_three_letter(c("S", "R", "P")) #' #' # The function `as_three_letter()` is case insensitive on the input but will #' # always return the three-letter codes with the first letter in uppercase. -#' as_three_letter(c('S', 's', 'p', 'P')) +#' as_three_letter(c("S", "s", "p", "P")) #' #' # Convert also special case codes B (Asparagine or Aspartic acid) and Z #' # (Glutamine or Glutamic acid) -#' as_three_letter(c('B', 'Z')) +#' as_three_letter(c("B", "Z")) #' #' # Invalid codes in the input are converted to NA. #' # "S" is correctly mapped to "Ser" but "Ser" and "Serine" are not #' # one-letter amino acid codes and are therefore converted to NA. -#' as_three_letter(c('S', 's', 'Ser', 'Serine')) +#' as_three_letter(c("S", "s", "Ser", "Serine")) #' #' @export as_three_letter <- function(x) { - one_to_three_letter_codes <- stats::setNames(three_letter_codes, nm = one_letter_codes) unname(one_to_three_letter_codes[toupper(x)]) } diff --git a/R/grantham_distance.R b/R/grantham_distance.R index 3512e5c..9893d1c 100644 --- a/R/grantham_distance.R +++ b/R/grantham_distance.R @@ -58,7 +58,6 @@ #' values that can be used with this formula. This data set is from Table 1, #' Science (1974). 185(4154): 862--4 by R. Grantham. #' -#' @md #' @export grantham_equation <- function(c_i, @@ -71,11 +70,10 @@ grantham_equation <- beta = 0.1018, gamma = 0.000399, rho = 50.723) { - d_ij <- rho * - (alpha * (c_i - c_j) ^ 2 + - beta * (p_i - p_j) ^ 2 + - gamma * (v_i - v_j) ^ 2) ^ 0.5 + (alpha * (c_i - c_j)^2 + + beta * (p_i - p_j)^2 + + gamma * (v_i - v_j)^2)^0.5 return(d_ij) } @@ -126,21 +124,19 @@ grantham_equation <- #' @return A [tibble][tibble::tibble-package] of Grantham's distances for each #' amino acid pair. #' -#' @md -#' #' @source \doi{10.1126/science.185.4154.862}. #' #' @examples #' # Grantham's distance between Serine (Ser) and Glutamate (Glu) -#' grantham_distance('Ser', 'Glu') +#' grantham_distance("Ser", "Glu") #' #' # Grantham's distance between Serine (Ser) and Glutamate (Glu) #' # with the "exact" method -#' grantham_distance('Ser', 'Glu', method = 'exact') +#' grantham_distance("Ser", "Glu", method = "exact") #' #' # `grantham_distance()` is vectorised #' # amino acids are paired element-wise between `x` and `y` -#' grantham_distance(x = c('Pro', 'Gly'), y = c('Glu', 'Arg')) +#' grantham_distance(x = c("Pro", "Gly"), y = c("Glu", "Arg")) #' #' # Use `amino_acid_pairs()` to generate pairs (by default generates all pairs) #' aa_pairs <- amino_acid_pairs() @@ -150,39 +146,43 @@ grantham_equation <- grantham_distance <- function(x, y, - method = c('original', 'exact'), + method = c("original", "exact"), alpha = 1.833, beta = 0.1018, gamma = 0.000399, rho = 50.723) { + if (!all_amino_acids(x)) { + stop("`x` should contain only amino acid three-letter codes.") + } - if(!all_amino_acids(x)) - stop('`x` should contain only amino acid three-letter codes.') + if (!all_amino_acids(y)) { + stop("`y` should contain only amino acid three-letter codes.") + } - if(!all_amino_acids(y)) - stop('`y` should contain only amino acid three-letter codes.') + # `rec`: recycled vectors `x` and `y`: + rec <- vctrs::vec_recycle_common(x = x, y = y) - # `rec`: recycled vectors `x` and `y`: - rec <- vctrs::vec_recycle_common(x = x, y = y) + # Check that `method` is either 'original' or 'exact'. + method <- match.arg(method) - # Check that `method` is either 'original' or 'exact'. - method <- match.arg(method) - - if(identical(method, 'original')) - return(grantham_distance_original(x = rec$x, - y = rec$y)) - else - return( - grantham_distance_exact( + if (identical(method, "original")) { + return(grantham_distance_original( x = rec$x, - y = rec$y, - alpha = alpha, - beta = beta, - gamma = gamma, - rho = rho + y = rec$y + )) + } else { + return( + grantham_distance_exact( + x = rec$x, + y = rec$y, + alpha = alpha, + beta = beta, + gamma = gamma, + rho = rho + ) ) - ) -} + } + } #' Grantham's distance (original) #' @@ -196,12 +196,10 @@ grantham_distance <- #' @return A [tibble][tibble::tibble-package] of Grantham's distances for each #' amino acid pair. #' -#' @md #' @source \doi{10.1126/science.185.4154.862}. #' @keywords internal #' @export grantham_distance_original <- function(x, y) { - amino_acid_pairs <- matrix(c(aa_idx(x), aa_idx(y)), ncol = 2) tbl <- tibble::tibble(x = x, y = y, d = grantham_distances_matrix[amino_acid_pairs]) @@ -210,8 +208,6 @@ grantham_distance_original <- function(x, y) { #' Grantham's distance (exact) #' -#' @md -#' #' @description #' This function calculates the Grantham's distance for pairs of amino acids. It #' uses the values for the amino acid properties as published in Table 1 of @@ -246,7 +242,7 @@ grantham_distance_original <- function(x, y) { #' @seealso [grantham_equation()] #' #' @examples -#' grantham_distance_exact(c('Ser', 'Ser'), c('Pro', 'Trp')) +#' grantham_distance_exact(c("Ser", "Ser"), c("Pro", "Trp")) #' #' @keywords internal #' @export @@ -256,24 +252,24 @@ grantham_distance_exact <- function(x, beta = 0.1018, gamma = 0.000399, rho = 50.723) { - # Filter the properties table for the queried amino acids x_tbl <- amino_acids_properties[aa_idx(x), ] y_tbl <- amino_acids_properties[aa_idx(y), ] # Grantham's distance computed from the amino acids' properties as provided in # Table 1 of Grantham (1974). - d <- grantham_equation(c_i = x_tbl$c, - c_j = y_tbl$c, - p_i = x_tbl$p, - p_j = y_tbl$p, - v_i = x_tbl$v, - v_j = y_tbl$v, - alpha = alpha, - beta = beta, - gamma = gamma, - rho = rho - ) + d <- grantham_equation( + c_i = x_tbl$c, + c_j = y_tbl$c, + p_i = x_tbl$p, + p_j = y_tbl$p, + v_i = x_tbl$v, + v_j = y_tbl$v, + alpha = alpha, + beta = beta, + gamma = gamma, + rho = rho + ) tbl <- tibble::tibble(x = x, y = y, d = d) diff --git a/R/sltm_k.R b/R/sltm_k.R index 3917e26..3b7d6a9 100644 --- a/R/sltm_k.R +++ b/R/sltm_k.R @@ -6,7 +6,6 @@ #' @param n Dimension of a `n` by `n` square matrix. #' #' @return An integer vector of linear positions in column-major order. -#' @md #' #' @examples #' sltm_k(3) @@ -14,7 +13,9 @@ #' @noRd #' @keywords internal sltm_k <- function(n) { - if(!(n > 1)) stop('`n` must be greater than 1') + if (!(n > 1)) stop("`n` must be greater than 1") - utils::combn(seq_len(n), 2, function(ij) {ij2k(i = ij[2], j = ij[1], n)}) + utils::combn(seq_len(n), 2, function(ij) { + ij2k(i = ij[2], j = ij[1], n) + }) } diff --git a/README.Rmd b/README.Rmd index 592dd12..6dcdd0c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -43,13 +43,13 @@ Grantham distance between two amino acids: ```{r} library(grantham) -grantham_distance(x = 'Ser', y = 'Phe') +grantham_distance(x = "Ser", y = "Phe") ``` The function `grantham_distance()` is vectorised with amino acids being matched element-wise to form pairs for comparison: ```{r} -grantham_distance(x = c('Ser', 'Arg'), y = c('Phe', 'Leu')) +grantham_distance(x = c("Ser", "Arg"), y = c("Phe", "Leu")) ``` The two vectors of amino acids must have compatible sizes in the sense of @@ -59,7 +59,7 @@ one of them is of length one, and it is recycled up to the length of the other. ```{r} # `'Ser'` is recycled to match the length of the second vector, i.e. 3. -grantham_distance(x = 'Ser', y = c('Phe', 'Leu', 'Arg')) +grantham_distance(x = "Ser", y = c("Phe", "Leu", "Arg")) ``` Use the function `amino_acid_pairs()` to generate all 20 x 20 amino acid pairs: diff --git a/README.md b/README.md index 45672d9..02bc39d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Grantham distance between two amino acids: ``` r library(grantham) -grantham_distance(x = 'Ser', y = 'Phe') +grantham_distance(x = "Ser", y = "Phe") #> # A tibble: 1 × 3 #> x y d #> @@ -45,7 +45,7 @@ The function `grantham_distance()` is vectorised with amino acids being matched element-wise to form pairs for comparison: ``` r -grantham_distance(x = c('Ser', 'Arg'), y = c('Phe', 'Leu')) +grantham_distance(x = c("Ser", "Arg"), y = c("Phe", "Leu")) #> # A tibble: 2 × 3 #> x y d #> @@ -61,7 +61,7 @@ to the length of the other. ``` r # `'Ser'` is recycled to match the length of the second vector, i.e. 3. -grantham_distance(x = 'Ser', y = c('Phe', 'Leu', 'Arg')) +grantham_distance(x = "Ser", y = c("Phe", "Leu", "Arg")) #> # A tibble: 3 × 3 #> x y d #> diff --git a/_pkgdown.yml b/_pkgdown.yml index 80eb663..43d7055 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,7 +1,6 @@ url: https://www.pattern.institute/grantham template: - package: chic bootstrap: 5 authors: @@ -13,7 +12,7 @@ authors: href: https://www.linkedin.com/in/ana-teresa-maia-2a1a866/ CINTESIS: href: "https://cintesis.eu/" - html: "" + html: "CINTESIS logo" Pattern Institute: href: https://www.pattern.institute - html: + html: Pattern Institute logo diff --git a/data-raw/data.R b/data-raw/data.R index fb460f9..953dfa9 100644 --- a/data-raw/data.R +++ b/data-raw/data.R @@ -5,8 +5,8 @@ library(grantham) # Grantham distances' matrix grantham_distances_matrix <- readr::read_csv( - file = here::here('data-raw', 'grantham_distance_matrix.csv'), - col_types = 'ciiiiiiiiiiiiiiiiiii', + file = here::here("data-raw", "grantham_distance_matrix.csv"), + col_types = "ciiiiiiiiiiiiiiiiiii", col_select = -1 ) |> as.matrix() @@ -23,21 +23,22 @@ grantham_distances_matrix <- # directly obtained from Table 1 of Grantham (1974). amino_acids_properties <- readr::read_csv( - file = here::here('data-raw', 'amino_acids_properties.csv'), - col_types = 'cdd' + file = here::here("data-raw", "amino_acids_properties.csv"), + col_types = "cdd" ) |> # Next line is just ensure that the order comes out the same as in `amino_acids()`. - dplyr::left_join(x = tibble::tibble(amino_acid = amino_acids()), y = _, by = 'amino_acid') + dplyr::left_join(x = tibble::tibble(amino_acid = amino_acids()), y = _, by = "amino_acid") # The 20 amino acids. n_amino_acids <- length(amino_acids()) mean_chemical_distance <- - with(amino_acids_properties, - c( - 'c' = mean(outer(c, c, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]), - 'p' = mean(outer(p, p, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]), - 'v' = mean(outer(v, v, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]) - ) + with( + amino_acids_properties, + c( + "c" = mean(outer(c, c, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]), + "p" = mean(outer(p, p, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]), + "v" = mean(outer(v, v, function(x, y) abs(x - y))[grantham:::sltm_k(n_amino_acids)]) + ) ) |> signif(digits = 4) |> round(digits = 3) @@ -49,56 +50,56 @@ mean_chemical_distance <- # value is 1.831.) # As the difference is relatively minor, we stick with the values reported in # the original paper to avoid confusion. -mean_weighting_factors <- c('alpha' = 1.833, 'beta' = 0.1018, 'gamma' = 0.000399) +mean_weighting_factors <- c("alpha" = 1.833, "beta" = 0.1018, "gamma" = 0.000399) one_letter_codes <- c( - 'A', # Alanine - 'R', # Arginine - 'N', # Asparagine - 'D', # Aspartic acid - 'B', # Asparagine or aspartic acid - 'C', # Cysteine - 'E', # Glutamic acid - 'Q', # Glutamine - 'Z', # Glutamine or glutamic acid - 'G', # Glycine - 'H', # Histidine - 'I', # Isoleucine - 'L', # Leucine - 'K', # Lysine - 'M', # Methionine - 'F', # Phenylalanine - 'P', # Proline - 'S', # Serine - 'T', # Threonine - 'W', # Tryptophan - 'Y', # Tyrosine - 'V' # Valine + "A", # Alanine + "R", # Arginine + "N", # Asparagine + "D", # Aspartic acid + "B", # Asparagine or aspartic acid + "C", # Cysteine + "E", # Glutamic acid + "Q", # Glutamine + "Z", # Glutamine or glutamic acid + "G", # Glycine + "H", # Histidine + "I", # Isoleucine + "L", # Leucine + "K", # Lysine + "M", # Methionine + "F", # Phenylalanine + "P", # Proline + "S", # Serine + "T", # Threonine + "W", # Tryptophan + "Y", # Tyrosine + "V" # Valine ) three_letter_codes <- c( - 'Ala', # Alanine - 'Arg', # Arginine - 'Asn', # Asparagine - 'Asp', # Aspartic acid - 'Asx', # Asparagine or aspartic acid - 'Cys', # Cysteine - 'Glu', # Glutamic acid - 'Gln', # Glutamine - 'Glx', # Glutamine or glutamic acid - 'Gly', # Glycine - 'His', # Histidine - 'Ile', # Isoleucine - 'Leu', # Leucine - 'Lys', # Lysine - 'Met', # Methionine - 'Phe', # Phenylalanine - 'Pro', # Proline - 'Ser', # Serine - 'Thr', # Threonine - 'Trp', # Tryptophan - 'Tyr', # Tyrosine - 'Val' # Valine + "Ala", # Alanine + "Arg", # Arginine + "Asn", # Asparagine + "Asp", # Aspartic acid + "Asx", # Asparagine or aspartic acid + "Cys", # Cysteine + "Glu", # Glutamic acid + "Gln", # Glutamine + "Glx", # Glutamine or glutamic acid + "Gly", # Glycine + "His", # Histidine + "Ile", # Isoleucine + "Leu", # Leucine + "Lys", # Lysine + "Met", # Methionine + "Phe", # Phenylalanine + "Pro", # Proline + "Ser", # Serine + "Thr", # Threonine + "Trp", # Tryptophan + "Tyr", # Tyrosine + "Val" # Valine ) # These variables end up in R/sysdata.rda @@ -116,4 +117,3 @@ usethis::use_data( # These end up in data/*.rda usethis::use_data(amino_acids_properties, overwrite = TRUE) usethis::use_data(grantham_distances_matrix, overwrite = TRUE) - diff --git a/man/amino_acid_pairs.Rd b/man/amino_acid_pairs.Rd index 74aa4a2..b60b328 100644 --- a/man/amino_acid_pairs.Rd +++ b/man/amino_acid_pairs.Rd @@ -41,5 +41,6 @@ amino_acid_pairs() amino_acid_pairs(keep_self = FALSE) # Generate specific combinations of Ser against Ala and Trp. -amino_acid_pairs(x = 'Ser', y = c('Ala', 'Trp')) +amino_acid_pairs(x = "Ser", y = c("Ala", "Trp")) + } diff --git a/man/as_one_letter.Rd b/man/as_one_letter.Rd index 1496b0d..98388e8 100644 --- a/man/as_one_letter.Rd +++ b/man/as_one_letter.Rd @@ -22,11 +22,11 @@ to B, and Glx (Glutamine or Glutamic acid) converted to Z. } \examples{ # Convert Ser to S, Arg to R and Pro to P. -as_one_letter(c('Ser', 'Arg', 'Pro')) +as_one_letter(c("Ser", "Arg", "Pro")) # The function `as_one_letter()` is case insensitive on the input but will # always return the one-letter codes in uppercase. -as_one_letter(c('ser', 'ArG', 'PRO')) +as_one_letter(c("ser", "ArG", "PRO")) # Convert the codes of the 20 standard amino acids. Note that the function # `amino_acids()` returns the three-letter codes of the 20 standard amino @@ -35,11 +35,11 @@ as_one_letter(amino_acids()) # Convert also special case codes Asx (Asparagine or Aspartic acid) and Glx # (Glutamine or Glutamic acid) -as_one_letter(c('Asx', 'Glx')) +as_one_letter(c("Asx", "Glx")) # Invalid codes in the input are converted to NA. # "Ser" is correctly mapped to "S" but "Serine" is not as it is not a # three-letter amino acid code (the same applies to "Glucose"). -as_one_letter(c('Ser', 'Serine', 'Glucose')) +as_one_letter(c("Ser", "Serine", "Glucose")) } diff --git a/man/as_three_letter.Rd b/man/as_three_letter.Rd index fc9b83a..65c1288 100644 --- a/man/as_three_letter.Rd +++ b/man/as_three_letter.Rd @@ -22,19 +22,19 @@ to Asx, and Z (Glutamine or Glutamic acid) converted to Glx. } \examples{ # Convert S to Ser, R to Arg and P to Pro. -as_three_letter(c('S', 'R', 'P')) +as_three_letter(c("S", "R", "P")) # The function `as_three_letter()` is case insensitive on the input but will # always return the three-letter codes with the first letter in uppercase. -as_three_letter(c('S', 's', 'p', 'P')) +as_three_letter(c("S", "s", "p", "P")) # Convert also special case codes B (Asparagine or Aspartic acid) and Z # (Glutamine or Glutamic acid) -as_three_letter(c('B', 'Z')) +as_three_letter(c("B", "Z")) # Invalid codes in the input are converted to NA. # "S" is correctly mapped to "Ser" but "Ser" and "Serine" are not # one-letter amino acid codes and are therefore converted to NA. -as_three_letter(c('S', 's', 'Ser', 'Serine')) +as_three_letter(c("S", "s", "Ser", "Serine")) } diff --git a/man/grantham_distance.Rd b/man/grantham_distance.Rd index 8c295ab..41f0855 100644 --- a/man/grantham_distance.Rd +++ b/man/grantham_distance.Rd @@ -71,15 +71,15 @@ amino acid properties explicitly, then use \code{\link[=grantham_equation]{grant } \examples{ # Grantham's distance between Serine (Ser) and Glutamate (Glu) -grantham_distance('Ser', 'Glu') +grantham_distance("Ser", "Glu") # Grantham's distance between Serine (Ser) and Glutamate (Glu) # with the "exact" method -grantham_distance('Ser', 'Glu', method = 'exact') +grantham_distance("Ser", "Glu", method = "exact") # `grantham_distance()` is vectorised # amino acids are paired element-wise between `x` and `y` -grantham_distance(x = c('Pro', 'Gly'), y = c('Glu', 'Arg')) +grantham_distance(x = c("Pro", "Gly"), y = c("Glu", "Arg")) # Use `amino_acid_pairs()` to generate pairs (by default generates all pairs) aa_pairs <- amino_acid_pairs() diff --git a/man/grantham_distance_exact.Rd b/man/grantham_distance_exact.Rd index c191f51..9ad48b6 100644 --- a/man/grantham_distance_exact.Rd +++ b/man/grantham_distance_exact.Rd @@ -54,7 +54,7 @@ amino acid properties (composition, polarity and molecular volume). No rounding to nearest integer is performed. } \examples{ -grantham_distance_exact(c('Ser', 'Ser'), c('Pro', 'Trp')) +grantham_distance_exact(c("Ser", "Ser"), c("Pro", "Trp")) } \seealso{ diff --git a/tests/spelling.R b/tests/spelling.R index 6713838..13f77d9 100644 --- a/tests/spelling.R +++ b/tests/spelling.R @@ -1,3 +1,6 @@ -if(requireNamespace('spelling', quietly = TRUE)) - spelling::spell_check_test(vignettes = TRUE, error = FALSE, - skip_on_cran = TRUE) +if (requireNamespace("spelling", quietly = TRUE)) { + spelling::spell_check_test( + vignettes = TRUE, error = FALSE, + skip_on_cran = TRUE + ) +} diff --git a/tests/testthat/test-amino_acid_pairs.R b/tests/testthat/test-amino_acid_pairs.R index c4cf6bb..5cf8c32 100644 --- a/tests/testthat/test-amino_acid_pairs.R +++ b/tests/testthat/test-amino_acid_pairs.R @@ -10,7 +10,6 @@ test_that("amino_acid_pairs() validates amino acids (three letter codes)", { }) test_that("amino_acid_pairs() removes self-self amino acid combinations", { - with_self <- amino_acid_pairs(x = "Arg", y = c("Arg", "Leu")) without_self <- amino_acid_pairs(x = "Arg", y = c("Arg", "Leu"), keep_self = FALSE) @@ -22,7 +21,6 @@ test_that("amino_acid_pairs() removes self-self amino acid combinations", { }) test_that("amino_acid_pairs() removes duplicate amino acid combinations", { - with_duplicates <- amino_acid_pairs(x = c("Arg", "Arg"), y = c("Arg", "Leu")) without_duplicates <- amino_acid_pairs(x = c("Arg", "Arg"), y = c("Arg", "Leu"), keep_duplicates = FALSE) @@ -34,7 +32,6 @@ test_that("amino_acid_pairs() removes duplicate amino acid combinations", { }) test_that("amino_acid_pairs() removes reversed amino acid combinations", { - with_reverses <- amino_acid_pairs(x = c("Arg", "Leu"), y = c("Leu", "Arg")) without_reverses <- amino_acid_pairs(x = c("Arg", "Leu"), y = c("Leu", "Arg"), keep_reverses = FALSE) diff --git a/tests/testthat/test-amino_acids.R b/tests/testthat/test-amino_acids.R index e327ab6..df7d627 100644 --- a/tests/testthat/test-amino_acids.R +++ b/tests/testthat/test-amino_acids.R @@ -24,5 +24,4 @@ test_that("amino_acids() returns 20 amino acids", { ) expect_identical(amino_acids(), the_twenty) - })