|
|
|
|
|
|
|
|
|
|
|
msg2start <- getFromNamespace("msg2start", "rtemis") |
|
msg2done <- getFromNamespace("msg2done", "rtemis") |
|
|
|
|
|
rthelp <- function(..., title = NULL, class = "rthelp") { |
|
div( |
|
div(HTML(paste0(title, " Instructions")), |
|
style = "color: #808080; font-weight: 300; padding-bottom:.5em;" |
|
), |
|
HTML(paste0("<i>", paste(..., sep = "<br>")), "</i>"), |
|
class = class |
|
) |
|
} |
|
|
|
rthelp_inline <- function(..., title = NULL, class = "rthelp-inline") { |
|
rthelp(..., title = title, class = class) |
|
} |
|
|
|
|
|
|
|
|
|
rthelplist <- function(x, bullet = bsicons::bs_icon("arrow-right-short"), class = "rthelplist") { |
|
div( |
|
htmltools::HTML( |
|
paste0( |
|
bullet, "<i>", x, "</i>", "<br>" |
|
) |
|
), |
|
class = class |
|
) |
|
} |
|
|
|
bold <- function(x) { |
|
paste0("<b>", x, "</b>") |
|
} |
|
|
|
hilite <- function(x) { |
|
paste0("<span style='color: var(--bs-primary);font-weight: bold;'>", x, "</span>") |
|
} |
|
|
|
nannot <- function(n) { |
|
ngettext(n, "annotation", "annotations") |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summarize_a3 <- function(x) { |
|
n_site <- length(x$Annotations$Site) |
|
n_region <- length(x$Annotations$Region) |
|
n_ptm <- length(x$Annotations$PTM) |
|
n_cleavage <- length(x$Annotations$Cleavage_site) |
|
n_variant <- length(x$Annotations$Variant) |
|
htmltools::HTML( |
|
paste0( |
|
if (!is.null(x$Description)) paste0("Description: ", hilite(x$Description), "<br>"), |
|
if (!is.null(x$UniprotID)) paste0("Uniprot ID: ", hilite(x$UniprotID), "<br>"), |
|
paste0("Sequence length: ", hilite(length(x$Sequence)), "<br>"), |
|
"<ul>", |
|
if (n_site > 0) paste("<li>", hilite(n_site), "site", nannot(n_site), "<br>"), |
|
if (n_region > 0) paste("<li>", hilite(n_region), "region", nannot(n_region), "<br>"), |
|
if (n_ptm > 0) paste("<li>", hilite(n_ptm), "PTM", nannot(n_ptm), "<br>"), |
|
if (n_cleavage > 0) paste("<li>", hilite(n_cleavage), " cleavage site", nannot(n_cleavage), "<br>"), |
|
if (n_variant > 0) paste("<li>", hilite(n_variant), "variant", nannot(n_variant), "<br>"), |
|
"</ul>", |
|
if (!is.null(x$Reference)) a("Reference", href = x$Reference, target = "_blank") |
|
) |
|
) |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_github_files <- function(repo_owner, repo_name, verbosity = 1) { |
|
if (verbosity > 0) { |
|
msg2start("Getting file information from", paste0(repo_owner, "/", repo_name)) |
|
} |
|
|
|
api_url <- paste0("https://api.github.com/repos/", repo_owner, "/", repo_name, "/contents/data") |
|
|
|
|
|
response <- httr::GET(api_url) |
|
|
|
|
|
if (response[["status_code"]] == 200) { |
|
|
|
files_data <- httr::content(response, as = "text", encoding = "UTF-8") |> jsonlite::fromJSON() |
|
|
|
|
|
files_df <- data.frame( |
|
file_name = files_data[["name"]], |
|
download_url = files_data[["download_url"]] |
|
) |
|
if (verbosity > 0) { |
|
msg2done() |
|
} |
|
return(files_df) |
|
} else { |
|
print("Error: Could not retrieve file information.") |
|
return(NULL) |
|
} |
|
} |
|
|