Skip to contents

Display an image of the molecular structure computed using OpenBabel.

Usage

openbabel_structure(
  smiles_column = "smiles",
  row_index = 1,
  image_size = 300,
  hydrogens = "implicit",
  carbons = "terminal",
  double_bonds = "asymmetric",
  colour_atoms = TRUE,
  scale_to_fit = TRUE,
  view_port = 300,
  title_column = NULL,
  subtitle_column = NULL,
  ...
)

Arguments

smiles_column

(character) The name of the annotation_source column with compound identifiers of the type specified in the search_by param. The default is "smiles".

row_index

(integer, numeric) The row index of the annotation_source to request an image of the molecular structure of. The default is 1.

image_size

(numeric, integer) The size of the image to return in pixels. Images will be square. The default is 300.

hydrogens

(character) Hydrogen atoms. Allowed values are limited to the following:

  • "implicit": Hydrogen atoms are not displayed.

  • "explicit": All hydrogen atoms are displayed.

The default is "implicit".

carbons

(character) Carbon atoms. Allowed values are limited to the following:

  • "none": Carbon atoms are not labelled.

  • "terminal": Terminal carbons and hydrogens are labelled.

  • "all": All carbon atoms will be labelled.

The default is "terminal".

double_bonds

(character) The display style of double carbon bonds. The default is "asymmetric".

colour_atoms

(logical) Display some atoms in colour. The default is TRUE.

scale_to_fit

(logical) Normalise coordinates. Allowed values are limited to the following:

  • "TRUE": Molecules will be scaled to fit inside the bounding box of the image.

  • "FALSE": Molecules will not be scaled to fit inside the bounding box of the image.

The default is TRUE.

view_port

(numeric, integer) Scales the image insde the viewport. Can be used to ensure a set of images have the same bond lengths and font sizes. Has no effect if scale_to_fit = TRUE. The molecule might be clipped if the viewport is too small. The default is 300.

title_column

(NULL, character) The column containing text to use as the title for the image. If NULL then no title is included. The default is NULL.

subtitle_column

(NULL, character) The column containing text to use as the subtitle for the image. If NULL then no subtitle is included. The default is NULL.

...

Additional slots and values passed to struct_class.

Value

A openbabel_structure object. This object has no output slots. See chart_plot in the struct package to plot this chart object.

Details

This object makes use of functionality from the following packages:

  • ChemmineOB

  • cowplot

  • rsvg

Inheritance

A openbabel_structure object inherits the following struct classes:

[openbabel_structure] -> [chart] -> [struct_class]

References

Horan K, Girke T (2023). ChemmineOB: R interface to a subset of OpenBabel functionalities. doi:10.18129/B9.bioc.ChemmineOB https://doi.org/10.18129/B9.bioc.ChemmineOB, R package version 1.40.0, https://bioconductor.org/packages/ChemmineOB.

Wilke C (2024). cowplot: Streamlined Plot Theme and Plot Annotations for 'ggplot2'. R package version 1.1.3, https://CRAN.R-project.org/package=cowplot.

Ooms J (2023). rsvg: Render SVG Images into PDF, PNG, (Encapsulated) PostScript, or Bitmap Arrays. R package version 2.6.0, https://CRAN.R-project.org/package=rsvg.

Examples

M <- openbabel_structure(
        smiles_column = "V1",
        image_size = 300,
        hydrogens = "implicit",
        carbons = "terminal",
        double_bonds = "symmetric",
        colour_atoms = FALSE,
        scale_to_fit = FALSE,
        row_index = 1,
        view_port = 300,
        title_column = NULL,
        subtitle_column = NULL)