Skip to content

Commit 86ad5e6

Browse files
Merge pull request #11 from LBC-LNBio/dev
Dev
2 parents dd92a93 + 30ea849 commit 86ad5e6

14 files changed

+87
-66
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y \
66
libssl-dev \
77
libxml2-dev
88

9-
RUN install2.r shiny pkgload remotes devtools bio3d bs4Dash config data.table DT golem NGLVieweR RcppTOML readr rjson shinyalert shinyjs blogdown colourpicker shinyfullscreen shinycssloaders
9+
RUN install2.r shiny pkgload remotes devtools bio3d bs4Dash config data.table DT golem NGLVieweR RcppTOML readr rjson shinyjs blogdown colourpicker shinyfullscreen shinycssloaders
1010
#RUN R -e 'devtools::install_github("https://github.com/LBC-LNBio/KVshiny-docker")'
1111

1212
# copy the app directory into the image

KVshiny/DESCRIPTION

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ Imports:
2525
rjson,
2626
rlang,
2727
shiny (>= 1.7.1),
28-
shinyalert,
2928
shinycssloaders,
30-
shinyjs
29+
shinyfullscreen,
30+
shinyjs,
31+
shinyWidgets
3132
Encoding: UTF-8
3233
LazyData: true
3334
RoxygenNote: 7.1.2

KVshiny/NAMESPACE

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export(kv_help)
1919
export(kv_params)
2020
export(pdb_process)
2121
export(process_fetch)
22-
export(process_fetch_ligmode)
2322
export(process_upload)
24-
export(process_upload_ligmode)
2523
export(report_nonstand)
2624
export(run_app)
2725
export(select_cav)
@@ -43,7 +41,7 @@ import(readr)
4341
import(rjson)
4442
import(rlang)
4543
import(shiny)
46-
import(shinyalert)
44+
import(shinyWidgets)
4745
import(shinycssloaders)
4846
import(shinyfullscreen)
4947
import(shinyjs)

KVshiny/R/app_server.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ app_server <- function( input, output, session ) {
6969
get_nonstand_check <- report_nonstand(pdb_input = input$pdb_id)
7070
removeModal()
7171
if (is.na(get_nonstand_check)){
72-
shinyWidgets::sendSweetAlert(title = "Oops!", text = "Please insert a valid PDB ID.", type = "error")
73-
#shinyalert("Oops!", "Please insert a valid PDB ID.", type = "error")
72+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please insert a valid PDB ID.", type = "error")
7473
} else{
7574
print("PDB ID ok")
75+
process_fetch(input = input, output = output)
7676
}
7777
#run process_fetch of mod_server_fetch module to create boxes and buttons of run mode
78-
process_fetch(input = input, output = output)
78+
#process_fetch(input = input, output = output)
7979
})
8080

8181
#----------------------------------------------------
@@ -91,7 +91,8 @@ app_server <- function( input, output, session ) {
9191
current_run_id <<- submit_job(input = input,
9292
output = output,
9393
pdb_name_click_load = pdb_name_click_load,
94-
url_address = url_address)
94+
url_address = url_address,
95+
session = session)
9596
removeModal()
9697
# If result_pdb object is not null, i.e. the Check button was clicked previously,
9798
# all the buttons generated by Check results (next block of code), will be hidden every time we click on submit button.
@@ -175,7 +176,7 @@ app_server <- function( input, output, session ) {
175176
#Check results in the main Run KVFinder page
176177
observeEvent(input$go_to_check_results, {
177178
# Get and output the results
178-
result_pdb <<- check_results(input = input, output = output, run_id = current_run_id, is_pg2 = FALSE, url_address = url_address)
179+
result_pdb <<- check_results(input = input, output = output, run_id = current_run_id, is_pg2 = FALSE, url_address = url_address, session = session)
179180
# If result_pdb object is not null, i.e. the Check button was clicked in another previous run,
180181
# the function showElement below is executed to show the output status that was hidden by the submission button.
181182
if(!is.null(result_pdb)){
@@ -190,7 +191,7 @@ app_server <- function( input, output, session ) {
190191
}
191192
# Create a 'observe' to monitor the results by checking and automatically updating the status each 5s when in queued or running
192193
observe({
193-
result_pdb <<- check_results(input = input, output = output, run_id = current_run_id, is_pg2 = FALSE, url_address = url_address)
194+
result_pdb <<- check_results(input = input, output = output, run_id = current_run_id, is_pg2 = FALSE, url_address = url_address, session = session)
194195
if(result_pdb %in% c("queued", "running")){
195196
invalidateLater(5000) #means 5 seconds
196197
} else{ #in case of status completed or error, the check_results will not be updated each 5s
@@ -212,7 +213,7 @@ app_server <- function( input, output, session ) {
212213
#Check results in the secondary page ("get latest results" page)
213214
observeEvent(input$check_loc_pg2, {
214215
#output[["structure_p2"]] <<- NULL
215-
result_pdb <<- check_results(input = input, output = output, run_id = input$insert_ID, is_pg2 = TRUE, url_address = url_address)
216+
result_pdb <<- check_results(input = input, output = output, run_id = input$insert_ID, is_pg2 = TRUE, url_address = url_address, session = session)
216217
# When check results button in page 2 is clicked, the structure visualization and all buttons related to NGL viewer will be hidden
217218
# to allow an update if the check button is used multiple times
218219
output[["structure_pg2"]] <- renderNGLVieweR({})

KVshiny/R/mod_server_checkResults.R

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
#' @param output shiny output
55
#' @param run_id current run id
66
#' @param is_pg2 logical TRUE/FALSE. If TRUE, we calling to create result in page 2 (get latest results page).
7-
#' @url_address url address to conexion
7+
#' @param url_address url address to conexion
8+
#' @param session
89
#'
910
#' @import shiny
1011
#' @import RcppTOML
1112
#' @import data.table
1213
#' @import DT
1314
#' @import blogdown
15+
#' @import shinyWidgets
1416
#' @export
1517
#'
1618

17-
check_results <- function(input, output, run_id, is_pg2, url_address){
19+
check_results <- function(input, output, run_id, is_pg2, url_address, session){
1820
#check which page to output the results (main page or get latest results page - pg2)
1921
#this block was created to allow the use of this function in the main or secondary page
2022
if(is_pg2 == TRUE){ #get latest results page
@@ -74,7 +76,7 @@ check_results <- function(input, output, run_id, is_pg2, url_address){
7476
result_toml <- parseTOML(input = content_get_output$output$report,fromFile = FALSE,escape = TRUE)$RESULTS
7577
#check if the at least one cavity was found
7678
if(length(result_toml$AREA) == 0){
77-
shinyalert("Oops!", "No cavity found. Please check the input parameters and try again.", type = "warning")
79+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "No cavity found. Please check the input parameters and try again.", type = "warning")
7880
} else{ #if cavities were found
7981
#create result table
8082
output[[results_table]] <- renderUI({

KVshiny/R/mod_server_fetch.R

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#' @param output shiny output
55
#'
66
#' @import shiny
7-
#' @import shinyalert
87
#'
98
#' @export
109
#'

KVshiny/R/mod_server_pdbProcess.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
#' @param output shiny output
55
#' @param get_nonstand vector of non-standard residues from the input PDB
66
#' @param mode select between "upload" or "fetch" modes
7+
#' @param session
78
#'
89
#' @import shiny
9-
#' @import shinyalert
10+
#' @import shinyWidgets
1011
#'
1112
#' @export
1213
#'
13-
pdb_process <- function(input, output, get_nonstand, mode){
14+
pdb_process <- function(input, output, get_nonstand, mode, session){
1415
#if the PDB was uploaded
1516
if(mode == "upload"){
1617
#path of the pdb input
@@ -25,19 +26,19 @@ pdb_process <- function(input, output, get_nonstand, mode){
2526
}
2627
#create a processed PDB for each run mode: default, customized, ligand or box mode
2728
if(input$run_mode == "mode_def"){
28-
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list)
29+
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list, session = session)
2930
pdb_processed <- list(pdb_processed = pdb_processed)
3031
} else if(input$run_mode == "mode_cust"){
31-
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list)
32+
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list, session = session)
3233
pdb_processed <- list(pdb_processed = pdb_processed)
3334
} else if(input$run_mode == "box_mode"){
3435
#in the case of running the box mode, we have to check if the target residues are correctly in the PDB input
3536
check_residues = check_residues_name(pdb_input = pdb_input, target_residues = input$box_residues)
3637
if(check_residues == FALSE){
37-
shinyalert("Oops!", "Please insert a valid list of residues for box mode run.", type = "error")
38+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please insert a valid list of residues for box mode run.", type = "error")
3839
pdb_processed <- "wrong_target_res"
3940
} else{
40-
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list)
41+
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = get_nonstand, include_list = include_list, session = session)
4142
pdb_processed <- list(pdb_processed = pdb_processed)
4243
}
4344
} else { #enter in the ligand mode
@@ -46,7 +47,7 @@ pdb_process <- function(input, output, get_nonstand, mode){
4647
#update nonstandard residues list to exclude the ligand
4748
get_nonstand_noLig <- setdiff(get_nonstand,input$lig_name) #get all non-standand but the ligand
4849
#by default remove all non standards residues and the ligand
49-
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = c(get_nonstand,input$lig_name), include_list = include_list)
50+
pdb_processed <- deal_sele_nonstand(pdb_input = pdb_input,nonstand_list = c(get_nonstand,input$lig_name), include_list = include_list, session = session)
5051
pdb_processed <- list(pdb_processed = pdb_processed, pdb_lig_processed = pdb_ligand_processed)
5152
}
5253
return(pdb_processed)

KVshiny/R/mod_server_submitJob.R

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
#' @param input shiny input
44
#' @param output shiny output
55
#' @param pdb_name_click_load variable of the number of clicks on load button
6-
#' @url_address url address to conexion
6+
#' @param url_address url address to conexion
7+
#' @param session
78
#'
89
#' @import shiny
910
#' @import rjson
1011
#' @import jsonlite
1112
#' @import rlang
1213
#' @import httr
14+
#' @import shinyWidgets
1315
#'
1416
#' @export
1517
#'
1618

17-
submit_job <- function(input, output, pdb_name_click_load, url_address){
19+
submit_job <- function(input, output, pdb_name_click_load, url_address, session){
1820
#-------------------------------------------------------------------
1921
#Get KVFinder parameters from the user interface
2022
probein_input <- input[[paste(input$run_mode, "Pin_input", sep = "_")]]
@@ -28,24 +30,24 @@ submit_job <- function(input, output, pdb_name_click_load, url_address){
2830

2931
#check if probe in is smaller than probe out
3032
if(probein_input > probeout_input){
31-
shinyalert("Oops!", "Probe In must be smaller than Probe Out.", type = "error")
33+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Probe In must be smaller than Probe Out.", type = "error")
3234
# check if user uploaded a PDB or fetched a PDB ID before to submit
3335
} else if(is.null(input$input_pdb) & input$pdb_id == ""){
34-
shinyalert("Oops!", "Please load from PDB or upload a PDB file before to submit.", type = "error")
36+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please load from PDB or upload a PDB file before to submit.", type = "error")
3537
#Check if the user that is using the fetch mode clicked on the Load button before to submit
3638
} else if(pdb_name_click_load != "init" & pdb_name_click_load != input$pdb_id){ #
37-
shinyalert("Oops!", "Please after input PDB ID in Choose input section, be sure you loaded the PDB by clicking on the Load button.", type = "error")
39+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please after input PDB ID in Choose input section, be sure you loaded the PDB by clicking on the Load button.", type = "error")
3840
# Just another check if user uploaded a PDB or fetched a PDB ID before to submit
3941
} else if(length(input$pdb_id) > 0 & input$send_pdb_id == 0){
40-
shinyalert("Oops!", "Please load from PDB or upload a PDB file before to submit.", type = "error")
42+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please load from PDB or upload a PDB file before to submit.", type = "error")
4143
} else {
4244
#if pass through the above checks...
4345
#get pdb_processed from upload mode
4446
if(input$input_type == 'pdb_from_file'){
45-
pdb_processed <- pdb_process(input = input, output = output, get_nonstand = get_nonstand, mode = "upload")
47+
pdb_processed <- pdb_process(input = input, output = output, get_nonstand = get_nonstand, mode = "upload", session = session)
4648
#get pdb_processed from fetch mode
4749
} else{
48-
pdb_processed <- pdb_process(input = input, output = output, get_nonstand = get_nonstand, mode = "fetch")
50+
pdb_processed <- pdb_process(input = input, output = output, get_nonstand = get_nonstand, mode = "fetch", session = session)
4951
}
5052
#check if the list of residues in "target residues" field is appropriated. The function pdb_process (in mod_server_pdbProcess.R) returns "wrong_target_res" if the input is not in the required format
5153
if(pdb_processed != "wrong_target_res"){
@@ -57,7 +59,7 @@ submit_job <- function(input, output, pdb_name_click_load, url_address){
5759
}
5860
#check if user inserted a valid PDB before do submit
5961
if(length(pdb_path) == 0){
60-
shinyalert("Oops!", "Please insert a valid PDB before to submit.", type = "error")
62+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text ="Please insert a valid PDB before to submit.", type = "error")
6163
} else {
6264
#Create a KVFinder input file based on the specific target mode to be submitted to the server using submit_prepare function
6365
#Whole protein (default parameters)
@@ -93,7 +95,7 @@ submit_job <- function(input, output, pdb_name_click_load, url_address){
9395
#return the job id
9496
return(get_run_id)
9597
} else{ # if the submission status is other than 200
96-
shinyalert("Oops!", "An error occurred when submitting your job. Perhaps the input file is larger than what our server allows or the input parameters are outside the allowed limits. Please read our Help page and if the problem persist please contact us", type = "error")
98+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text ="An error occurred when submitting your job. Perhaps the input file is larger than what our server allows or the input parameters are outside the allowed limits. Please read our Help page and if the problem persist please contact us.", type = "error")
9799
}
98100
}
99101
}

KVshiny/R/mod_server_upload.R

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#' @param output shiny output
55
#'
66
#' @import shiny
7-
#' @import shinyalert
87
#'
98
#' @export
109
#'

KVshiny/R/utils_pdbProcess_.R

+33-27
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
#' @export
1313

1414
report_nonstand <- function(pdb_input) {
15-
15+
1616
pdb <- tryCatch({read.pdb(pdb_input)},
1717
error = function(err) {
1818
return(NA)
1919
})
20-
20+
2121
if(!is.na(pdb)) {
2222
#get protein
2323
indx_p <- atom.select(pdb, string = "protein", inverse= TRUE)
@@ -43,40 +43,46 @@ report_nonstand <- function(pdb_input) {
4343
#' @param pdb_input Pdb path
4444
#' @param nonstand_list List of non-standard residues
4545
#' @param include_list List of non-standard residues that must be maintained in the PDB
46+
#' @param session
4647
#'
4748
#' @import bio3d
49+
#' @import shinyWidgets
4850
#'
4951
#' @examples
5052
#'
5153
#' @export
5254
#'
5355

54-
deal_sele_nonstand <- function(pdb_input, nonstand_list, include_list){
55-
pdb <- read.pdb(pdb_input)
56-
57-
if(is.null(include_list)){
58-
#get nonstandard selected
59-
indx_s <- atom.select(pdb, resid = nonstand_list, inverse = TRUE)
60-
#subset pdb
61-
clean_pdb <- trim.pdb(pdb, indx_s)
62-
#create random number to name file
63-
rand <- sample(x = 1:100000,size = 1)
64-
outfile = file.path(tempdir(), paste(rand,".pdb",sep = ""))
65-
#write tmp
66-
write.pdb(pdb = clean_pdb, file = outfile)
67-
return(outfile)
68-
} else {
69-
indx_s <- atom.select(pdb, resid = nonstand_list, inverse = TRUE)
70-
indx_i <- atom.select(pdb, resid = include_list)
71-
indx <- combine.select(indx_s, indx_i, operator= "OR")
72-
clean_pdb <- trim.pdb(pdb, indx)
73-
#create random number to name file
74-
rand <- sample(x = 1:100000,size = 1)
75-
outfile = file.path(tempdir(), paste(rand,".pdb",sep = ""))
76-
#write tmp
77-
write.pdb(pdb = clean_pdb, file = outfile)
78-
return(outfile)
56+
deal_sele_nonstand <- function(pdb_input, nonstand_list, include_list, session = session){
57+
tryCatch({ #test if the pdb_input is an appropriated PDB ID and if the read,pdb function can download successfully this pdb
58+
pdb <- read.pdb(pdb_input)
59+
if(is.null(include_list)){
60+
#get nonstandard selected
61+
indx_s <- atom.select(pdb, resid = nonstand_list, inverse = TRUE)
62+
#subset pdb
63+
clean_pdb <- trim.pdb(pdb, indx_s)
64+
#create random number to name file
65+
rand <- sample(x = 1:100000,size = 1)
66+
outfile = file.path(tempdir(), paste(rand,".pdb",sep = ""))
67+
#write tmp
68+
write.pdb(pdb = clean_pdb, file = outfile)
69+
return(outfile)
70+
} else {
71+
indx_s <- atom.select(pdb, resid = nonstand_list, inverse = TRUE)
72+
indx_i <- atom.select(pdb, resid = include_list)
73+
indx <- combine.select(indx_s, indx_i, operator= "OR")
74+
clean_pdb <- trim.pdb(pdb, indx)
75+
#create random number to name file
76+
rand <- sample(x = 1:100000,size = 1)
77+
outfile = file.path(tempdir(), paste(rand,".pdb",sep = ""))
78+
#write tmp
79+
write.pdb(pdb = clean_pdb, file = outfile)
80+
return(outfile)
81+
}
82+
}, error = function(e){
83+
shinyWidgets::sendSweetAlert(session = session,title = "Oops!", text = "Please insert a valid PDB ID.", type = "error")
7984
}
85+
)
8086
}
8187

8288

KVshiny/man/check_results.Rd

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

KVshiny/man/deal_sele_nonstand.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)