m_add_cylinder: Add Cylinder Between Points

Description Usage Arguments Examples

View source: R/add.R

Description

Add cynliders between the given points. Will match starting point/s with ending point/s to create a line between each point. Styling options can be supplied as one option, or a vector of length equal to the number of lines.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
m_add_cylinder(
  id,
  start,
  end,
  radius = 0.1,
  fromCap = 1,
  toCap = 1,
  dashed = FALSE,
  color = "black",
  alpha = FALSE,
  wireframe = FALSE,
  hidden = FALSE,
  spec = m_shape_spec()
)

Arguments

id

R3dmol id or a r3dmol object (the output from r3dmol()).

start

Starting position (or list() of positions) of line. Can be a single position or list() of positions. Format either m_sel() or m_vector3().

end

Ending position (or list() of positions) of line. Can be a single position or list() of positions. Format either m_sel() or m_vector3().

radius

Radius of cylinder.

fromCap

Cap at start of cylinder. 0 for none, 1 for flat, 2 for rounded.

toCap

Cap at end of cylinder. 0 for none, 1 for flat, 2 for rounded.

dashed

Boolean, dashed style cylinder instead of solid.

color

Color value for cylinders. Either 1 or vector of colors equal in length to start.

alpha

Alpha value for transparency.

wireframe

Logical, display as wireframe.

hidden

Logical, whether or not to hide the cylinder.

spec

Additional shape specifications defined with m_shape_spec().

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
## Add a cylinder between residue 1 & 2 of Chain "A"
r3dmol() %>%
  m_add_model(pdb_6zsl) %>%
  m_zoom_to(sel = m_sel(resi = 1)) %>%
  m_add_cylinder(
    start = m_sel(resi = 1, chain = "A"),
    end = m_sel(resi = 2, chain = "A"),
    dashed = TRUE,
    radius = 0.1
  )

# Add two cylinders.
# Blue cylinder is between residues 1 & 2
# Green cylinder is between residues 3 & 4
r3dmol() %>%
  m_add_model(pdb_6zsl) %>%
  m_zoom_to(sel = m_sel(resi = 1:4, chain = "A")) %>%
  m_add_cylinder(
    start = list(
      m_sel(resi = 1, chain = "A"),
      m_sel(resi = 3, chain = "A")
    ),
    end = list(
      m_sel(resi = 2, chain = "A"),
      m_sel(resi = 4, chain = "A")
    ),
    dashed = TRUE,
    radius = 0.1,
    color = c("blue", "green")
  ) %>%
  m_add_res_labels(m_sel(resi = 1:4, chain = "A"))

# The same scene achieved with m_multi_resi_sel()
r3dmol() %>%
  m_add_model(pdb_6zsl) %>%
  m_zoom_to(sel = m_sel(resi = 1:4, chain = "A")) %>%
  m_add_cylinder(
    start = m_multi_resi_sel(resi = c(1, 3), chain = "A"),
    end = list(
      m_sel(resi = 2, chain = "A"),
      m_sel(resi = 4, chain = "A")
    ),
    dashed = TRUE,
    radius = 0.1,
    color = c("blue", "green")
  ) %>%
  m_add_res_labels(m_sel(resi = 1:4, chain = "A"))

r3dmol documentation built on March 14, 2021, 5:08 p.m.