Skip to content

Commit dd00735

Browse files
Merge pull request #23 from helder-ribeiro/dev
New changes
2 parents 19860f7 + 387df82 commit dd00735

16 files changed

+501
-113
lines changed

kvfinder-web-portal/NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export(check_residues_name)
99
export(check_results)
1010
export(choose_input)
1111
export(choose_run_mode)
12+
export(color_cavity_deepth)
1213
export(create_init_scene)
1314
export(create_work_scene)
1415
export(deal_sele_nonstand)
1516
export(get_coord_box_mode)
1617
export(get_ligand_pdb)
18+
export(interface_cav)
1719
export(kv_about)
1820
export(kv_help)
1921
export(kv_params)

kvfinder-web-portal/R/app_server.R

+160-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ app_server <- function(input, output, session) {
2020
cav_list <- NULL
2121
result_toml <- NULL
2222
protein_rep_list <- c()
23+
cav_rep_list <- c()
2324
pdb_processed <- NULL
2425
pdb_ligand_processed <- NULL
2526
run_mode_list <- c()
@@ -58,17 +59,52 @@ app_server <- function(input, output, session) {
5859
observeEvent(input$input_pdb, {
5960
# run process_upload of mod_server_upload module to create boxes and buttons of run mode
6061
process_upload(input = input, output = output, session = session)
62+
get_nonstand_check_upload <<- report_nonstand(pdb_input =input$input_pdb$datapath)
6163
})
64+
65+
observeEvent(input$show_preview_upload, {
66+
print(input$input_pdb$datapath)
67+
print(pdb_name_click_load)
68+
print(get_nonstand)
69+
showModal(modalDialog(
70+
#title = tags$a('Structure preview', style = "text-align: right;" ),
71+
#NGLVieweROutput("structure_prev", width = "100%", height = "75vh"),
72+
if(!is.null(input$input_pdb)){
73+
#print(get_nonstand_check)
74+
renderNGLVieweR({
75+
# get input protein PDB with output cavities
76+
pdb <- input$input_pdb$datapath
77+
# create initial scene
78+
NGLVieweR(pdb) %>%
79+
# start protein with visible cartoon representation
80+
addRepresentation("cartoon") %>%
81+
addRepresentation("ball+stick", param = list(sele = paste(get_nonstand_check_upload, collapse = " or "))) %>%
82+
# start cavity with points
83+
stageParameters(backgroundColor = "black") %>%
84+
setQuality("high") %>%
85+
setFocus(0)
86+
})
87+
}else{
88+
"No loaded structure to preview"
89+
},
90+
easyClose = TRUE,
91+
footer = NULL,
92+
size = 'l'
93+
))
94+
})
95+
6296
#-----------------------------------------------------
6397

6498
#-----------------------------------------------------
6599
# Fetch PDB section
66100
observeEvent(input$send_pdb_id, {
101+
print(input$pdb_id)
67102
# save number of clicks in load button
68103
pdb_name_click_load <<- input$pdb_id
69104
# check if the PDB code is valid by using get_nonstand
70105
showModal(modalDialog("Loading and checking PDB...", footer = NULL, fade = FALSE))
71-
get_nonstand_check <- report_nonstand(pdb_input = input$pdb_id)
106+
get_nonstand_check <<- report_nonstand(pdb_input = input$pdb_id)
107+
print(get_nonstand_check)
72108
removeModal()
73109
if (length(which(is.na(get_nonstand_check))) != 0) {
74110
shinyWidgets::sendSweetAlert(session = session, title = "Oops!", text = "Please insert a valid PDB ID.", type = "error")
@@ -80,6 +116,35 @@ app_server <- function(input, output, session) {
80116
# process_fetch(input = input, output = output)
81117
})
82118

119+
observeEvent(input$show_preview_fetch, {
120+
print(pdb_name_click_load)
121+
showModal(modalDialog(
122+
#title = tags$a('Structure preview', style = "text-align: right;" ),
123+
#NGLVieweROutput("structure_prev", width = "100%", height = "75vh"),
124+
if(pdb_name_click_load != 'init'){
125+
print(get_nonstand_check)
126+
renderNGLVieweR({
127+
# get input protein PDB with output cavities
128+
pdb <- input$pdb_id
129+
# create initial scene
130+
NGLVieweR(pdb) %>%
131+
# start protein with visible cartoon representation
132+
addRepresentation("cartoon") %>%
133+
addRepresentation("ball+stick", param = list(sele = paste(get_nonstand_check, collapse = " or "))) %>%
134+
# start cavity with points
135+
stageParameters(backgroundColor = "black") %>%
136+
setQuality("high") %>%
137+
setFocus(0)
138+
})
139+
}else{
140+
"No loaded structure to preview"
141+
},
142+
easyClose = TRUE,
143+
footer = NULL,
144+
size = 'l'
145+
))
146+
})
147+
83148
#----------------------------------------------------
84149
#>>>>>>>>>>>>>> Submit Job <<<<<<<<<<<<<<<<<<<<<<<
85150
observeEvent(input$submit_button, {
@@ -170,6 +235,14 @@ app_server <- function(input, output, session) {
170235
id = "fullscreen_title",
171236
time = 0
172237
)
238+
hideElement(
239+
id = "cavity_rep",
240+
time = 0
241+
)
242+
hideElement(
243+
id = "cavity_deep",
244+
time = 0
245+
)
173246
}
174247
})
175248
#----------------------------------------------------
@@ -272,6 +345,14 @@ app_server <- function(input, output, session) {
272345
id = "fullscreen_title_pg2",
273346
time = 0
274347
)
348+
hideElement(
349+
id = "cavity_rep_pg2",
350+
time = 0
351+
)
352+
hideElement(
353+
id = "cavity_deep_pg2",
354+
time = 0
355+
)
275356
})
276357
#----------------------------------------------------
277358

@@ -283,6 +364,7 @@ app_server <- function(input, output, session) {
283364
observeEvent(input$view_str,
284365
{
285366
protein_rep_list <<- c() # always initialize an empty list of protein representations when clicking on view button
367+
cav_rep_list <<- c()
286368
protein_col_scheme_list <<- c() # always initialize an empty list of protein color scheme when clicking on view button
287369
# use "residue index" as the first protein color scheme
288370
protein_col_scheme_list <<- c(protein_col_scheme_list, "Residue index")
@@ -337,6 +419,14 @@ app_server <- function(input, output, session) {
337419
id = "fullscreen_title",
338420
time = 0
339421
)
422+
showElement(
423+
id = "cavity_rep",
424+
time = 0
425+
)
426+
showElement(
427+
id = "cavity_deep",
428+
time = 0
429+
)
340430
# disable view button to avoid user to click on it multiple times
341431
disable("view_str")
342432
},
@@ -352,7 +442,7 @@ app_server <- function(input, output, session) {
352442
# fed the protein list of representations
353443
protein_rep_list <<- c(protein_rep_list, current_rep)
354444
# Create the work scene
355-
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)
445+
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 = 'prot', cav_rep_list='')
356446
# clean protein color selector
357447
updateSelectInput(session, "input_protein_color", # This update is made to clean the protein color selector
358448
selected = ""
@@ -361,11 +451,38 @@ app_server <- function(input, output, session) {
361451
ignoreNULL = TRUE,
362452
ignoreInit = TRUE
363453
)
454+
455+
# Create a work scene every time users click on cavity representation selector and change biomolecular structure representation
456+
observeEvent(input$input_cavity_rep,
457+
{
458+
# save the current representation
459+
current_rep_cav <- input$input_cavity_rep
460+
# fed the protein list of representations
461+
cav_rep_list <<- c(cav_rep_list, current_rep_cav)
462+
print(cav_rep_list)
463+
# Create the work scene
464+
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)
465+
# clean protein color selector
466+
# updateSelectInput(session, "input_protein_color", # This update is made to clean the protein color selector
467+
# selected = ""
468+
# )
469+
},
470+
ignoreNULL = TRUE,
471+
ignoreInit = TRUE
472+
)
473+
364474

365475
# Select cavity to be visualized from clicking on cavity selector button
366476
observeEvent(input$select_cavity, {
477+
print('exeuting select')
367478
select_cav(input = input, output = output, result_pdb_list = result_pdb, is_pg2 = FALSE)
368479
})
480+
481+
observeEvent(input$interface_res, {
482+
print('exeuting select')
483+
interface_cav(input = input, output = output, result_pdb_list = result_pdb, is_pg2 = FALSE)
484+
})
485+
369486

370487
# change biomolecular structure color
371488
observeEvent(input$input_protein_color, {
@@ -385,7 +502,7 @@ app_server <- function(input, output, session) {
385502

386503
# change cavity color
387504
observeEvent(input$input_cavity_color, {
388-
change_cav_color(input = input, output = output, is_pg2 = FALSE)
505+
change_cav_color(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list)
389506
})
390507

391508
# change background color
@@ -397,6 +514,10 @@ app_server <- function(input, output, session) {
397514
observeEvent(input$input_snapshot, {
398515
take_snapshot(input = input, output = output, is_pg2 = FALSE)
399516
})
517+
518+
observeEvent(input$input_cavity_deep, {
519+
color_cavity_deepth(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
520+
})
400521

401522

402523
##### View in Get latest results page (pg2)
@@ -463,6 +584,14 @@ app_server <- function(input, output, session) {
463584
id = "fullscreen_title_pg2",
464585
time = 0
465586
)
587+
showElement(
588+
id = "cavity_rep_pg2",
589+
time = 0
590+
)
591+
showElement(
592+
id = "cavity_deep_pg2",
593+
time = 0
594+
)
466595
disable("view_str_pg2")
467596
})
468597

@@ -476,7 +605,7 @@ app_server <- function(input, output, session) {
476605
# create a list of representations
477606
protein_rep_list <<- c(protein_rep_list, current_rep)
478607
# Create work scene
479-
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)
608+
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 = 'prot', cav_rep_list='')
480609

481610
# clean protein color selector
482611
updateSelectInput(session, "input_protein_color_pg2", # This updation is made to clean the protein color selector
@@ -486,6 +615,28 @@ app_server <- function(input, output, session) {
486615
ignoreNULL = TRUE,
487616
ignoreInit = FALSE
488617
)
618+
619+
620+
# Create a work scene every time users click on cavity representation selector and change biomolecular structure representation
621+
observeEvent(input$input_cavity_rep_pg2,
622+
{
623+
print('Inside cav rep pg2')
624+
# save the current representation
625+
current_rep_cav <- input$input_cavity_rep_pg2
626+
# fed the protein list of representations
627+
cav_rep_list <<- c(cav_rep_list, current_rep_cav)
628+
#print(cav_rep_list)
629+
# Create the work scene
630+
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)
631+
# clean protein color selector
632+
# updateSelectInput(session, "input_protein_color", # This update is made to clean the protein color selector
633+
# selected = ""
634+
# )
635+
},
636+
ignoreNULL = TRUE,
637+
ignoreInit = TRUE
638+
)
639+
489640

490641
# Select cavity to be visualized from clicking on cavity selector button
491642
observeEvent(input$select_cavity_pg2, {
@@ -508,7 +659,7 @@ app_server <- function(input, output, session) {
508659
})
509660
# change cavity color
510661
observeEvent(input$input_cavity_color_pg2, {
511-
change_cav_color(input = input, output = output, is_pg2 = TRUE)
662+
change_cav_color(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list)
512663
})
513664
# change background color
514665
observeEvent(input$input_bg_color_pg2, {
@@ -518,6 +669,10 @@ app_server <- function(input, output, session) {
518669
observeEvent(input$input_snapshot_pg2, {
519670
take_snapshot(input = input, output = output, is_pg2 = TRUE)
520671
})
672+
673+
observeEvent(input$input_cavity_deep_pg2, {
674+
color_cavity_deepth(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
675+
})
521676

522677
#----------------------------------------------------
523678
}

kvfinder-web-portal/R/app_ui.R

+22-16
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,22 @@ app_ui <- function(request) {
155155
)
156156
),
157157
fluidRow(
158-
column(3, uiOutput("selection_pdb")),
159-
column(3, uiOutput("cavity_color")),
160-
column(3, uiOutput("protein_rep")),
161-
column(3, uiOutput("protein_color_scheme"))
158+
column(2, uiOutput("selection_pdb")),
159+
column(2, uiOutput("cavity_rep")),
160+
column(2, uiOutput("cavity_color")),
161+
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep"))),
162+
column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface"))),
162163
),
163164
fluidRow(
164-
column(3, uiOutput("show_interface")),
165+
column(2, uiOutput("protein_rep")),
165166
column(2, uiOutput("protein_color")),
166-
column(3, uiOutput("bg_color")),
167+
column(3, uiOutput("protein_color_scheme")),
168+
column(2, uiOutput("bg_color")),
167169
column(2, align = "center", uiOutput("snapshot_title"), uiOutput("snapshot")),
168-
column(2, align = "center", uiOutput("fullscreen_title"), uiOutput("fullscreen"))
169-
)
170+
column(1, align = "center", uiOutput("fullscreen_title"), uiOutput("fullscreen"))
171+
#column(2, align = "center", uiOutput("snapshot_title"), uiOutput("snapshot")),
172+
#column(2, align = "center", uiOutput("fullscreen_title"), uiOutput("fullscreen"))
173+
),
170174
), click_id = "fullscreen")
171175
)
172176
)
@@ -187,7 +191,7 @@ app_ui <- function(request) {
187191
solidHeader = TRUE,
188192
elevation = 2,
189193
headerBorder = TRUE,
190-
width = 11,
194+
width = 12,
191195
textInput(
192196
inputId = "insert_ID",
193197
label = "Insert the job ID to get results",
@@ -235,17 +239,19 @@ app_ui <- function(request) {
235239
NGLVieweROutput("structure_pg2", width = "100%", height = "600px")
236240
),
237241
fluidRow(
238-
column(3, uiOutput("selection_pdb_pg2")),
239-
column(3, uiOutput("cavity_color_pg2")),
240-
column(3, uiOutput("protein_rep_pg2")),
241-
column(3, uiOutput("protein_color_scheme_pg2")),
242+
column(2, uiOutput("selection_pdb_pg2")),
243+
column(2, uiOutput("cavity_rep_pg2")),
244+
column(2, uiOutput("cavity_color_pg2")),
245+
column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep_pg2"))),
246+
column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface_pg2"))),
242247
),
243248
fluidRow(
244-
column(3, uiOutput("show_interface_pg2")),
249+
column(2, uiOutput("protein_rep_pg2")),
245250
column(2, uiOutput("protein_color_pg2")),
246-
column(3, uiOutput("bg_color_pg2")),
251+
column(3, uiOutput("protein_color_scheme_pg2")),
252+
column(2, uiOutput("bg_color_pg2")),
247253
column(2, align = "center", uiOutput("snapshot_title_pg2"), uiOutput("snapshot_pg2")),
248-
column(2, align = "center", uiOutput("fullscreen_title_pg2"), uiOutput("fullscreen_pg2"))
254+
column(1, align = "center", uiOutput("fullscreen_title_pg2"), uiOutput("fullscreen_pg2"))
249255
)
250256
), click_id = "fullscreen_pg2")
251257
)

0 commit comments

Comments
 (0)