Add a new selection to a NGLVieweR object in Shinymode.
addSelection(
NGLVieweR_proxy,
type,
param = list(),
structureIndex = NULL,
structure = NULL
)A NGLVieweR object.
Type of representation. Most common options are "cartoon", "ball+stick", "surface", "ribbon" and "label".
Options for the different types of representations. Most common
options are name, opacity, colorScheme, sele,
colorValue and visibility. For a full list of options, see the
general "RepresentationParameters" method and type specific Label-,
Structure- and Surface- RepresentationParameters in the official
NGL.js manual.
Deprecated; use structure. The same, but
counting from 0.
(optional) Number of the structure to add the selection to,
counting from 1 in the order the structures were added (see
addStructure()). In Shiny, input$<outputId>_selectionStructure
gives the number of the last clicked structure. If not specified, the
selection is added to all loaded structures.
API call containing NGLVieweR id and list of message
parameters.
updateRepresentation() Update an existing NGLVieweR representation.
NGLVieweR_example() See example "addSelection".
Other selections:
removeSelection(),
updateSelection()
if (FALSE) { # \dontrun{
NGLVieweR_proxy("7CID") %>%
addSelection("ball+stick", param = list(name="sel1",
sele="1-20",
colorValue="yellow",
colorScheme="element"
))
} # }
if (interactive()) {
library(shiny)
ui <- fluidPage(
titlePanel("Viewer with API inputs"),
sidebarLayout(
sidebarPanel(
textInput("selection", "Selection", "1-20"),
selectInput("type", "Type", c("ball+stick", "cartoon", "backbone")),
selectInput("color", "Color", c("orange", "grey", "white")),
actionButton("add", "Add"),
actionButton("remove", "Remove")
),
mainPanel(
NGLVieweROutput("structure")
)
)
)
server <- function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", colorScheme = "residueindex")
)
})
observeEvent(input$add, {
NGLVieweR_proxy("structure") %>%
addSelection(isolate(input$type),
param =
list(
name = "sel1",
sele = isolate(input$selection),
colorValue = isolate(input$color)
)
)
})
observeEvent(input$remove, {
NGLVieweR_proxy("structure") %>%
removeSelection("sel1")
})
}
shinyApp(ui, server)
}