removeSelection {NGLVieweR}R Documentation

Remove a selection

Description

Remove an existing NGLVieweR selection in Shinymode.

Usage

removeSelection(NGLVieweR_proxy, name)

Arguments

NGLVieweR_proxy

A NGLVieweR object.

name

Name of selection to be removed.

Value

API call containing NGLVieweR id and list of message parameters.

See Also

Other selections: addSelection(), updateSelection()

Examples

## Not run: 
NGLVieweR_proxy("structure") %>%
     removeSelection("sel1")

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

[Package NGLVieweR version 1.3.1 Index]