Skip to content

Commit

Permalink
Update KVFinder-web to v1.1.1 (#46)
Browse files Browse the repository at this point in the history
* Update KVFinder-web to v1.1.1 (#45)

* Update CITATION.cff

* Update CITATION.cff

* Change background color to LNBio colorscheme, add LNBio/CNPEM logo to footer, conditionalPanel for Run Cavity Analysis tab

* Update layout of jumbotron in main page

* Remove emojis from jumbotron title

* Update layout of choose_input card in main page

* Update laytout of choose_run_mode card in main page

* Separate functions into individual files

* Separate functions into individual files

* conditionalPanel for Submit, Check Results and View buttons in Run Cavity Analysis tab and conditionalPanel for Get Results and View buttons in Retrieve Results page

* Fix typos and code formatting

* Update Get latest results color in card

* Update Tutorial tab and remove debug prints

* Add partial solution to Get Results bugs and remove debug prints

* Fix bugs in tab 2 (Get latest results) - hide job status and ngl viewer, and show error for empty job ID and alphanumeric job ID

* var_status was not defined when receiving a http error code, now it is set to error

* Update layout and information in Help tab - missing TOML results file description

* Update tutorial layout

* Update Help tab layout and add description of TOML-formatted results file

* Update DESCRIPTION

* Remove .Rproj from repository

* Update layout of about tab

* Fix typo

* Update app_server.R

* Update README.md

* Update app_ui.R
  • Loading branch information
jvsguerra authored Oct 10, 2023
1 parent 6107bc5 commit 08b4e53
Show file tree
Hide file tree
Showing 75 changed files with 2,970 additions and 1,677 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# RStudio files
.Rproj.user/
.Rproj

# produced vignettes
vignettes/*.html
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,33 @@ To run locally the KVFinder-web portal in Linux distributions, it is necessary t
sudo apt install docker-compose
```

After the docker-compose installation and clone of this repository. First, you have to build our KVFinder-web interface:
Before using the KVFinder-web portal, you need to configure the URL address for the KVFinder-web service. Open the [app_server.R](kvfinder-web-portal/R/app_server.R#L14-L24) file and define the URL address:

If KVFinder-web service is running on your local machine, use the first configuration:

```r
url_address <- "http://localhost:8081/"
```

If KVFinder-web service is on a different containers in the same network, replace <ip> in the second configuration with the actual IP address of that machine.

```r
url_address <- "http://<ip>:8081/"
```

If KVFinder-web service and portal are in the same container, use the third configuration (http://kv-server:8081/).

```r
url_address <- "http://kv-server:8081/"
```

Afterwards, you have to build our KVFinder-web portal:

```bash
docker build -t kvfinder-web-portal .
```

To start KVFinder-web interface:
To start KVFinder-web portal:

```bash
docker run -p 3838:3838 kvfinder-web-portal
Expand Down
4 changes: 2 additions & 2 deletions kvfinder-web-portal/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: KVFinderWebPortal
Title: KVFinder-web portal
Version: 1.1.0
Version: 1.1.1
Authors@R:
c(
person(
Expand All @@ -12,7 +12,7 @@ Authors@R:
person(
given = "João",
family = "Guerra",
role = c("ctb"),
role = c("aut", "cre"),
),
person(
given = "José",
Expand Down
18 changes: 0 additions & 18 deletions kvfinder-web-portal/KVserver.Rproj

This file was deleted.

2 changes: 2 additions & 0 deletions kvfinder-web-portal/R/app_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ app_sys <- function(...) {
#' @param use_parent Logical, scan the parent directory for config file.
#'
#' @noRd
#'

get_golem_config <- function(value,
config = Sys.getenv(
"GOLEM_CONFIG_ACTIVE",
Expand Down
131 changes: 112 additions & 19 deletions kvfinder-web-portal/R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
#'
#' @param input,output,session Internal parameters for {shiny}.
#' DO NOT REMOVE.
#'
#' @import shiny
#' @import shinyjs
#' @import ggplot2
#'
#'
#' @noRd
#'

app_server <- function(input, output, session) {
# url address to connection. This is used in submition and check results functions.
# URL address for KVFinder-web service
# Use this if KVFinder-web service is on the same machine
url_address <- "http://localhost:8081/"

# KVFinder-web portal outside KVFinder-web service container
# Uncomment and replace <ip> with the actual IP address if service is on a different container
# url_address <- "http://<ip>:8081/"

# KVFinder-web portal inside the same container of KVFinder-web service
# Uncomment and use this if service and portal are in the same container
# url_address <- "http://kv-server:8081/"

#-----------------------------------------------
Expand Down Expand Up @@ -75,11 +78,9 @@ app_server <- function(input, output, session) {
# title = tags$a('Structure preview', style = "text-align: right;" ),
# NGLVieweROutput("structure_prev", width = "100%", height = "75vh"),
if (!is.null(input$input_pdb)) {
# print(get_nonstand_check)
renderNGLVieweR({
# get input protein PDB with output cavities
pdb <- input$input_pdb$datapath
print(paste("/", as.numeric(input$model_number), sep = ""))
# create initial scene
NGLVieweR(pdb) %>%
# start protein with visible cartoon representation
Expand All @@ -104,7 +105,6 @@ app_server <- function(input, output, session) {
#-----------------------------------------------------
# Fetch PDB section
observeEvent(input$send_pdb_id, {
print(input$pdb_id)
# save number of clicks in load button
pdb_name_click_load <<- input$pdb_id
# check if the PDB code is valid by using get_nonstand
Expand All @@ -114,20 +114,17 @@ app_server <- function(input, output, session) {
if (length(which(is.na(get_nonstand_check))) != 0) {
shinyWidgets::sendSweetAlert(session = session, title = "Oops!", text = "Please insert a valid PDB ID.", type = "error")
} else {
print("PDB ID ok")
process_fetch(input = input, output = output)
}
# run process_fetch of mod_server_fetch module to create boxes and buttons of run mode
# process_fetch(input = input, output = output)
})

observeEvent(input$show_preview_fetch, {
print(pdb_name_click_load)
showModal(modalDialog(
# title = tags$a('Structure preview', style = "text-align: right;" ),
# NGLVieweROutput("structure_prev", width = "100%", height = "75vh"),
if (pdb_name_click_load != "init") {
print(get_nonstand_check)
renderNGLVieweR({
# get input protein PDB with output cavities
pdb <- input$pdb_id
Expand Down Expand Up @@ -291,7 +288,6 @@ app_server <- function(input, output, session) {
observe({
result_pdb <<- check_results(input = input, output = output, run_id = current_run_id, is_pg2 = FALSE, url_address = url_address, session = session)
if (length(result_pdb) == 1) { # if results_pdb corresponds to output status and not kvfinder results
print(result_pdb)
if (result_pdb %in% c("queued", "running")) {
invalidateLater(5000) # means 5 seconds
}
Expand All @@ -317,10 +313,47 @@ app_server <- function(input, output, session) {

# Check results in the secondary page ("get latest results" page)
observeEvent(input$check_loc_pg2, {
result_pdb <<- check_results(input = input, output = output, run_id = trimws(input$insert_ID), is_pg2 = TRUE, url_address = url_address, session = session)
# When check results button in page 2 is clicked, the structure visualization and all buttons related to NGL viewer will be hidden
# to allow an update if the check button is used multiple times
output[["structure_pg2"]] <- renderNGLVieweR({})

# When Get results button in tab 2 is clicked, the job information and the results table will be hidden
# Hide elements
hideElement(
id = "output_status_pg2",
time = 0
)
hideElement(
id = "download_pg2",
time = 0
)
hideElement(
id = "download2_pg2",
time = 0
)
hideElement(
id = "download_results_pg2",
time = 0
)
hideElement(
id = "download_results2_pg2",
time = 0
)
hideElement(
id = "results_table_pg2",
time = 0
)
hideElement(
id = "table_out_pg2",
time = 0
)
hideElement(
id = "view_output_pg2",
time = 0
)
hideElement(
id = "view_str_pg2",
time = 0
)

# When View button in tab 2 is clicked, the structure visualization and all buttons related to NGL viewer will be hidden
hideElement(
id = "structure_pg2",
time = 0
Expand Down Expand Up @@ -389,6 +422,70 @@ app_server <- function(input, output, session) {
id = "scale_plot",
time = 0
)

# Remove whitespaces from input$insert_ID
id <- trimws(input$insert_ID)

# Check if run_id is empty or an alphanumeric string
if ((nchar(id) == 0) || (is.na(as.numeric(id)))) {
shinyWidgets::sendSweetAlert(
session = session,
title = "Oops!",
text = "An error occurred when retrieving your job! \
Please insert a valid Job ID!",
type = "error"
)

return(NULL)
}

# Check results of a Job ID
result_pdb <<- check_results(input = input, output = output, run_id = id, is_pg2 = TRUE, url_address = url_address, session = session)

# Sucessfully got results, so show elements
showElement(
id = "output_status_pg2",
time = 0
)
if ("result_toml" %in% names(result_pdb)) {

showElement(
id = "download_pg2",
time = 0
)
showElement(
id = "download2_pg2",
time = 0
)
showElement(
id = "download_results_pg2",
time = 0
)
showElement(
id = "download_results2_pg2",
time = 0
)
showElement(
id = "results_table_pg2",
time = 0
)
showElement(
id = "table_out_pg2",
time = 0
)
showElement(
id = "view_output_pg2",
time = 0
)
showElement(
id = "view_str_pg2",
time = 0
)
}

# Show NGL viewer and buttons
output[["structure_pg2"]] <- renderNGLVieweR({})

})
#----------------------------------------------------

Expand Down Expand Up @@ -508,7 +605,6 @@ app_server <- function(input, output, session) {
current_rep_cav <- input$input_cavity_rep
# fed the protein list of representations
cav_rep_list <<- c(cav_rep_list, current_rep_cav)
print(cav_rep_list)
# Create the work scene
create_work_scene(input = input, output = output, protein_rep_list = protein_rep_list, protein_col_list = protein_col_list, protein_col_scheme_list = protein_col_scheme_list, result_pdb_list = result_pdb, is_pg2 = FALSE, scheme_color_list = scheme_color_list, prot_or_cav = "cav", cav_rep_list = cav_rep_list)
# clean protein color selector
Expand Down Expand Up @@ -567,7 +663,7 @@ app_server <- function(input, output, session) {
updateCheckboxInput(session, "input_cavity_hyd", value = FALSE)
}

color_cavity_deepth(input = input, output = output, is_pg2 = FALSE, cav_rep_list = cav_rep_list, result_pdb_list = result_pdb)
color_cavity_depth(input = input, output = output, is_pg2 = FALSE, cav_rep_list = cav_rep_list, result_pdb_list = result_pdb)

output$scale_plot_deep <- renderPlot(
{
Expand Down Expand Up @@ -609,7 +705,6 @@ app_server <- function(input, output, session) {

# Click view in the secondary page to initialize the result visualization with the NGL engine
observeEvent(input$view_str_pg2, {
print(protein_rep_list)
protein_rep_list <<- c() # always initialize an empty list of protein representations when clicking on view button
cav_rep_list <<- c()
cav_rep_list <<- c(cav_rep_list, 'point') # add initial rep for the cavities to avoid NULL when running a second job
Expand Down Expand Up @@ -719,12 +814,10 @@ app_server <- function(input, output, session) {
# Create a work scene every time users click on cavity representation selector and change biomolecular structure representation
observeEvent(input$input_cavity_rep_pg2,
{
print("Inside cav rep pg2")
# save the current representation
current_rep_cav <- input$input_cavity_rep_pg2
# fed the protein list of representations
cav_rep_list <<- c(cav_rep_list, current_rep_cav)
# print(cav_rep_list)
# Create the work scene
create_work_scene(input = input, output = output, protein_rep_list = protein_rep_list, protein_col_list = protein_col_list, protein_col_scheme_list = protein_col_scheme_list, result_pdb_list = result_pdb, is_pg2 = TRUE, scheme_color_list = scheme_color_list, prot_or_cav = "cav", cav_rep_list = cav_rep_list)
# clean protein color selector
Expand Down Expand Up @@ -778,7 +871,7 @@ app_server <- function(input, output, session) {
updateCheckboxInput(session, "input_cavity_hyd_pg2", value = FALSE)
}

color_cavity_deepth(input = input, output = output, is_pg2 = TRUE, cav_rep_list = cav_rep_list, result_pdb_list = result_pdb)
color_cavity_depth(input = input, output = output, is_pg2 = TRUE, cav_rep_list = cav_rep_list, result_pdb_list = result_pdb)

output$scale_plot_deep_pg2 <- renderPlot(
{
Expand Down
Loading

0 comments on commit 08b4e53

Please sign in to comment.