File size: 3,216 Bytes
977cc7d
e55e859
977cc7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e55e859
 
 
 
 
 
 
 
 
 
 
 
 
 
977cc7d
 
 
 
 
e55e859
977cc7d
 
17e03a6
 
 
 
977cc7d
 
 
 
 
 
 
17e03a6
 
 
 
 
977cc7d
 
17e03a6
977cc7d
 
 
17e03a6
 
 
 
 
977cc7d
 
 
 
e55e859
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# globals.R
# ::rtemisseq::
# EDG rtemis.org

# Themes ----
# {bg_dark, bg_light} also used by plot.bg
bg_dark <- "#191919"
bg_light <- "#ffffff"
primary_dark <- "#72CDF4"
primary_light <- "#1295D8"
seconday_dark <- "#808080"
secondary_light <- "#808080"
info_dark <- "#FEB2E0"
info_light <- "#E44C9A"
success_dark <- "#B4DC55"
success_light <- "#84C234"

bslib_dark <- bslib::bs_theme(
  bg = bg_dark,
  fg = "#fff",
  primary = primary_dark,
  secondary = seconday_dark,
  success = success_dark,
  info = info_dark,
  `tooltip-bg` = "#bbbbbb",
  `tooltip-color` = info_dark,
  `tooltip-opacity` = .95
) |>
  bslib::bs_add_rules(sass::sass_file("www/rtemislive.scss"))

bslib_light <- bslib::bs_theme(
  bg = bg_light,
  fg = "#000",
  primary = primary_light,
  secondary = secondary_light,
  success = success_light,
  info = info_light,
  `tooltip-bg` = "#303030",
  `tooltip-color` = info_light,
  `tooltip-opacity` = .95
) |>
  bslib::bs_add_rules(sass::sass_file("www/rtemislive.scss"))

# from rtemislive
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
  )
} # rtemislive::rthelp

rthelp_inline <- function(..., title = NULL, class = "rthelp-inline") {
  rthelp(..., title = title, class = class)
} # rtemislive::rthelp_inline

#' Create bulleted list
#' 
#' @return div
rthelplist <- function(x, bullet = bsicons::bs_icon("arrow-right-short"), class = "rthelplist") {
  div(
    htmltools::HTML(
      paste0(
        bullet, "<i>", x, "</i>", "<br>"
      )
    ),
    class = class
  )
} # rtemisseq::rthelplist

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 object in HTML
#'
#' @param x a3 object
#'
#' @return HTML string
#' @author EDG
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")
    )
  )
} # rtemisseq::summarize_a3