addSelection: Add a selection

Description Usage Arguments Value See Also Examples

View source: R/api.R

Description

Add a new selection to a NGLVieweR object in Shinymode.

Usage

1

Arguments

NGLVieweR_proxy

A NGLVieweR object.

type

Type of representation. Most common options are "cartoon", "ball+stick", "surface", "ribbon" and "label".

param

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.

Value

API call containing NGLVieweR id and list of message parameters.

See Also

Other selections: removeSelection(), updateSelection()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## Not run: 
NGLVieweR_proxy("7CID") %>%
 addSelection("ball+stick", param = list(name="sel1",
                                         sele="1-20",
                                         colorValue="yellow",
                                         colorScheme="element"
                                         ))

## End(Not run)

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)
}

NGLVieweR documentation built on June 1, 2021, 9:08 a.m.