## What is in a selection

Selections in r3dmol are provided via the m_sel() function. These selections are then interpreted by by 3Dmol.js that is the underlying molecular library.

When dealing with styles, 3Dmol.js works on every atom inside the m_sel(). When creating new objects such as lines, spheres or cylinders and 3Dmol.js interprets these selections by finding the middle-most-point of the selection.

If we look at the code below, the styles are being applied to the residue number 2. Each atom of the selection m_sel(resi = 2, chain = "A") has the specified styles applied to it.

library(r3dmol)

model <- r3dmol() %>%
m_set_style(m_style_stick(hidden = TRUE)) %>%
style = c(
m_style_stick(),
m_style_sphere(scale = 0.3)
),
sel = m_sel(resi = 2, chain = "A")
) %>%
m_zoom_to(m_sel(resi = 2, chain = "A"))

model %>%
m_add_res_labels(m_sel(resi = 2, chain = "A"),
style = m_style_label(inFront = FALSE)
) %>%
m_spin()

What if we add a shape to this scene, using the same selection m_sel(resi = 2, chain = "A")?

model %>%
center = m_sel(resi = 2, chain = "A"),
spec = m_shape_spec(
wireframe = TRUE,
color = "BLUE"
)
) %>%
m_spin()