Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #24

Merged
merged 5 commits into from
Feb 28, 2023
Merged

Dev #24

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kvfinder-web-portal/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(check_results)
export(choose_input)
export(choose_run_mode)
export(color_cavity_deepth)
export(color_cavity_hyd)
export(create_init_scene)
export(create_work_scene)
export(deal_sele_nonstand)
Expand Down
47 changes: 46 additions & 1 deletion kvfinder-web-portal/R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ app_server <- function(input, output, session) {
id = "cavity_deep",
time = 0
)
hideElement(
id = "cavity_hyd",
time = 0
)
}
})
#----------------------------------------------------
Expand Down Expand Up @@ -353,6 +357,10 @@ app_server <- function(input, output, session) {
id = "cavity_deep_pg2",
time = 0
)
hideElement(
id = "cavity_hyd_pg2",
time = 0
)
})
#----------------------------------------------------

Expand Down Expand Up @@ -427,6 +435,10 @@ app_server <- function(input, output, session) {
id = "cavity_deep",
time = 0
)
showElement(
id = "cavity_hyd",
time = 0
)
# disable view button to avoid user to click on it multiple times
disable("view_str")
},
Expand Down Expand Up @@ -519,7 +531,32 @@ app_server <- function(input, output, session) {
color_cavity_deepth(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
})


observeEvent(input$input_cavity_hyd, {
color_cavity_hyd(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
output$scale_plot <- renderPlot({
EisenbergWeiss_scale = c(-0.64, 2.6,0.8,0.92,-0.3,0.87,0.76,
-0.49,0.41,-1.42,-1.09,1.54,-0.66,-1.22,
-0.12,0.18,0.05, -0.83, -0.27, -1.11)
df <- data.frame(x = seq(1,length(EisenbergWeiss_scale)), y = EisenbergWeiss_scale)
p <- ggplot(data = df, aes(x = x, y = y, colour = y)) +
geom_point() +
scale_colour_gradient2(name = "Hydropathy", low = "yellow", mid = "white", high = "blue", midpoint = 0.59,breaks = seq(-1,2.5,0.5))+
theme(plot.title = element_text(hjust = 0.5),
legend.position = "bottom",
legend.key.width= unit(0.2, 'npc'),
#legend.spacing = unit(0.25,"cm"),
legend.title = element_text(hjust = 0.5),
legend.justification = "center") +
guides(colour = guide_colourbar(title.position="top", title.hjust = 0.5),
size = guide_legend(title.position="top", title.hjust = 0.5))

# ggpubr does this for you
leg <- get_legend(p)
as_ggplot(leg)

}) #, height =50, width = '100%'
})

##### View in Get latest results page (pg2)

# Click view in the secondary page to initialize the result visualization with the NGL engine
Expand Down Expand Up @@ -592,6 +629,10 @@ app_server <- function(input, output, session) {
id = "cavity_deep_pg2",
time = 0
)
showElement(
id = "cavity_hyd_pg2",
time = 0
)
disable("view_str_pg2")
})

Expand Down Expand Up @@ -673,6 +714,10 @@ app_server <- function(input, output, session) {
observeEvent(input$input_cavity_deep_pg2, {
color_cavity_deepth(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
})

observeEvent(input$input_cavity_hyd_pg2, {
color_cavity_hyd(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
})

#----------------------------------------------------
}
14 changes: 12 additions & 2 deletions kvfinder-web-portal/R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ app_ui <- function(request) {
tags$br(),
uiOutput("results_table"),
tags$br(),
htmlOutput("table_footer")
),
column(
7,
Expand All @@ -154,12 +155,20 @@ app_ui <- function(request) {
NGLVieweROutput("structure", width = "100%", height = "75vh")
)
),
conditionalPanel(
condition="input.input_cavity_hyd==1",
fluidRow(
column(12, align='center',
plotOutput("scale_plot", height = '50', width = '50%'))
)
),
fluidRow(
column(2, uiOutput("selection_pdb")),
column(2, uiOutput("cavity_rep")),
column(2, uiOutput("cavity_color")),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep"))),
column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface"))),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_hyd"))),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface"))),
),
fluidRow(
column(2, uiOutput("protein_rep")),
Expand Down Expand Up @@ -243,7 +252,8 @@ app_ui <- function(request) {
column(2, uiOutput("cavity_rep_pg2")),
column(2, uiOutput("cavity_color_pg2")),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep_pg2"))),
column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface_pg2"))),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_hyd_pg2"))),
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface_pg2"))),
),
fluidRow(
column(2, uiOutput("protein_rep_pg2")),
Expand Down
16 changes: 11 additions & 5 deletions kvfinder-web-portal/R/mod_server_checkResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,19 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) {
})
output[[table_out]] <- DT::renderDataTable(
data.table(
`Cavity ID` = names(result_toml$AREA),
`ID` = names(result_toml$AREA),
`Area (A²)` = unlist(result_toml$AREA),
`Volume (A³)` = unlist(result_toml$VOLUME),
`Avg Depth (A)` = unlist(result_toml$AVG_DEPTH)
`Vol. (A³)` = unlist(result_toml$VOLUME),
`Dep. (A)` = unlist(result_toml$AVG_DEPTH),
`Hyd.` = unlist(result_toml$AVG_HYDROPATHY)
),
filter = c("none"),
style = "auto",
options = list(dom = "lBfrtip",
buttons = c("excel", "pdf"),
autoWidth = TRUE,
scrollX = TRUE,
columnDefs = list(list(targets=c(4), visible=TRUE, width='75'))
columnDefs = list(list(targets=c(5), visible=TRUE, width='60'))
),
extensions = "Buttons"
)
Expand Down Expand Up @@ -130,11 +131,16 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) {
write_toml(param_list, output = filename)
}
)

# create visualization button
output[[view_output]] <- renderUI({
actionButton(inputId = view_str, label = "View", icon = icon("eye"), style = "color: #fff; background-color: #6c757d; border-color: #6c757d")
})

output$table_footer <- renderText({
paste(
p("ID: Cavity ID, Area: Cavity area, Vol: Cavity volume, Dep: Cavity average depth, Hyd: Cavity average hydropathy.")
)
})
# create list to store results
result_list <- list(
retrieve_input_pdb = retrieve_input_pdb,
Expand Down
51 changes: 51 additions & 0 deletions kvfinder-web-portal/R/mod_server_colorCAVhyd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#' Function that change background color in NGL viewer
#'
#' @param input shiny input
#' @param output shiny output
#' @param is_pg2 logical TRUE/FALSE. If TRUE, we calling to create result in page 2 (get latest results page).
#' @param cav_rep_list
#' @param result_pdb_list
#'
#'
#' @import shiny
#' @import NGLVieweR
#'
#' @export
#'

color_cavity_hyd <- function(input, output, is_pg2, cav_rep_list, result_pdb_list) {
if (is_pg2 == TRUE) {
input_cavity_hyd <- "input_cavity_hyd_pg2"
structure <- "structure_pg2"
} else {
input_cavity_hyd <- "input_cavity_hyd"
structure <- "structure"
}
#print(result_pdb_list$result_toml$MAX_DEPTH)
#print(max(unlist(result_pdb_list$result_toml$MAX_DEPTH)))
#NGLVieweR_proxy(structure) %>%
# removeSelection(name = tail(cav_rep_list, n = 2)[1])
# After the initial structure is invisible, we can add a new representation to the current scene

if(input[[input_cavity_hyd]] == TRUE){
NGLVieweR_proxy(structure) %>%
addSelection("point",
param =
list(
name = "hyd", # now the created selection is named "sel3"
sele = paste(result_pdb_list$result_cav_names, collapse = " or "),
colorScheme = 'occupancy',
colorScale = c('blue', 'white', 'yellow'),
colorReverse = TRUE,
colorDomain = c(-1.42, 2.6)
#colorScheme = scheme_color_list[[tail(protein_col_scheme_list, n = 1)]]
)
)
} else{
NGLVieweR_proxy(structure) %>%
removeSelection(name = "hyd")
}

# NGLVieweR_proxy(structure) %>%
# updateColor(tail(cav_rep_list,n=1),color= "resname")
}
13 changes: 11 additions & 2 deletions kvfinder-web-portal/R/mod_server_createINITscene.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col
fullscreen_title <- "fullscreen_title_pg2"
cavity_rep <- "cavity_rep_pg2"
cavity_deep <- "cavity_deep_pg2"
cavity_hyd <- "cavity_hyd_pg2"
# if in the main page
} else {
structure <- "structure"
Expand All @@ -50,6 +51,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col
fullscreen_title <- "fullscreen_title"
cavity_rep <- "cavity_rep"
cavity_deep <- "cavity_deep"
cavity_hyd <- "cavity_hyd"
}

#-------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -87,7 +89,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col
output[[show_interface]] <- renderUI({
div(
style = "font-size:12px;",
checkboxInput(inputId = interface_res, label = div(style = "font-size:12px;display:inline-block", "Show interface residues"))
checkboxInput(inputId = interface_res, label = div(style = "font-size:12px;display:inline-block", "Interface AA"))
)
})
# protein color scheme selector
Expand Down Expand Up @@ -184,7 +186,14 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col
output[[cavity_deep]] <- renderUI({
div(
style = "font-size:12px;",
checkboxInput(inputId = paste("input_", cavity_deep, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Cavity depth"))
checkboxInput(inputId = paste("input_", cavity_deep, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Depth"))
)
})

output[[cavity_hyd]] <- renderUI({
div(
style = "font-size:12px;",
checkboxInput(inputId = paste("input_", cavity_hyd, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Hydropathy"))
)
})
#----------------------------------------------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions kvfinder-web-portal/man/color_cavity_hyd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.