addStructure: Add structure

View source: R/NGLVieweR.R

addStructureR Documentation

Add structure

Description

Add a structure to the NGLVieweR object, either from a PDB entry code, a file, or directly from the R environment.

Usage

addStructure(NGLVieweR, data, format = NULL)

Arguments

NGLVieweR

A NGLVieweR object.

data

Structure data to be added, in the same forms as in NGLVieweR(): a PDB entry code (e.g. "7CID"), a file path (also compressed with gzip, bzip2 or xz), or the file contents as a single string or a vector of lines.

format

Format of the structure, as in NGLVieweR() (e.g. "pdb", "cif"). Needed for file contents and when the format cannot be inferred from the file name. For a PDB entry code it picks the file downloaded from RCSB, as in NGLVieweR().

Details

This function allows you to add a structure to the NGLVieweR widget. You can add the structure using a PDB entry code, by specifying a local file, or by providing the structure data directly. If the format is not clear from the input, you may need to specify it using the format parameter.

Value

An updated NGLVieweR object with the added structure.

Examples

NGLVieweR("1CRN") %>%
  addRepresentation("cartoon", param = list(color = "blue")) %>%
  addStructure("1CRN") %>%
  addRepresentation("cartoon", param = list(color = "orange")) %>%
  setPosition(x = 20, y = 0, z = 0) %>%
  setRotation(x = 2, y = 0, z = 0, degrees = FALSE) %>% 
  setScale(0.5)

# Note: The first "1CRN" structure is represented in blue, while the second 
# "1CRN" structure is represented in orange. Transformations such as 
# setPosition, setRotation, and setScale apply to the second 
# (most recently added) structure.


NGLVieweR documentation built on Oct. 20, 2026, 1:07 a.m.