Skip to content

Commit

Permalink
Add extra residue_type column
Browse files Browse the repository at this point in the history
Either eplet or reactivity pattern
  • Loading branch information
lcreteig committed Feb 5, 2024
1 parent 8ad2aa8 commit 16a4bbb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions R/eplet_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ scrape_eplet_registry <- function(file_path) {
) |>
purrr::map(tidyr::as_tibble) |> # make a dataframe out of each scraped db
purrr::list_rbind() |> # combine into one dataframe
dplyr::mutate(residue_type = dplyr::case_when(
stringr::str_detect(.data$name, "\\+") ~ "reactivity pattern",
.default = "eplet"
), .after = "name") |>
# get full description from info if it exists
dplyr::mutate(description = dplyr::coalesce(
.data$descr_info,
Expand Down
21 changes: 19 additions & 2 deletions tests/testthat/test-eplet_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@ test_that("load_eplet_registry prints message when print_version = TRUE", {
expect_message(load_eplet_registry(print_version = TRUE))
})

test_that("table has 8 columns", {
expect_equal(length(df_eplets), 8)
test_that("table has 9 columns", {
expect_equal(length(df_eplets), 9)
})

test_that("column names and types are correct", {
eplet_registry_info <- c(
id = "character",
name = "character",
residue_type = "character",
description = "character",
exposition = "character",
confirmation = "character",
Expand All @@ -208,6 +209,12 @@ test_that("low cardinality character columns contain expected values", {
c("Very Low", "Low", "Intermediate", "High", NA)
)

# residue type
expect_setequal(
unique(df_eplets$residue_type),
c("eplet", "reactivity pattern")
)

# database
expect_setequal(
unique(df_eplets$locus_group),
Expand Down Expand Up @@ -236,6 +243,16 @@ test_that("table has no duplicate eplets", {
})

test_that("a few randomly selected cells have same value as on the website", {
expect_equal(
dplyr::pull(df_eplets[df_eplets$name == "3P", ], "residue_type")[1],
"eplet"
)

expect_equal(
dplyr::pull(df_eplets[df_eplets$name == "77N+85VG", ], "residue_type")[1],
"reactivity pattern"
)

expect_equal(
dplyr::pull(df_eplets[df_eplets$name == "37Y", ], "exposition")[1],
"High"
Expand Down

0 comments on commit 16a4bbb

Please sign in to comment.